:root {
  color-scheme: dark;
  --bg: #080809;
  --surface: #111113;
  --surface-2: #18181b;
  --line: #2e2e33;
  --text: #ebebef;
  --muted: #7a7a85;
  --danger: #c45c5c;
  --ok: #6a9a72;
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", "Segoe UI Mono", monospace;
  --pad: clamp(1rem, 3vw, 1.75rem);
  --radius: 2px;
}

*, *::before, *::after { box-sizing: border-box; }

html { background: var(--bg); }

body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.45;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
}

a { color: inherit; text-decoration: none; }

button, input {
  font: inherit;
  color: inherit;
}

.gate-page {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--pad);
}

.gate-page h1 {
  margin: 0 0 1.75rem;
  font-size: clamp(1.5rem, 4.5vw, 2.25rem);
  font-weight: 500;
  letter-spacing: -0.03em;
  text-align: center;
}

.pass-box {
  display: flex;
  width: min(100%, 22rem);
  border: 1px solid var(--line);
  background: var(--surface);
}

.pass-box input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  padding: 0.85rem 1rem;
  outline: none;
}

.pass-box input::placeholder { color: var(--muted); }

.pass-box button {
  flex-shrink: 0;
  width: 3rem;
  border: 0;
  border-left: 1px solid var(--line);
  background: var(--surface-2);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background 0.12s;
}

.pass-box button:hover { background: #222226; }
.pass-box button:active { background: #1a1a1d; }

.pass-box button svg {
  width: 1.1rem;
  height: 1.1rem;
  stroke: var(--text);
  fill: none;
  stroke-width: 2;
}

.gate-msg {
  margin-top: 0.75rem;
  min-height: 1.25rem;
  font-size: 0.875rem;
  color: var(--danger);
  text-align: center;
}

.top-bar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem var(--pad);
  background: rgba(8, 8, 9, 0.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(8px);
}

.top-bar .brand {
  font-size: 0.95rem;
  letter-spacing: -0.02em;
  color: var(--muted);
}

.top-bar .brand strong { color: var(--text); font-weight: 500; }

.admin-pill {
  font-size: 0.8rem;
  text-transform: lowercase;
  padding: 0.35rem 0.65rem;
  border: 1px solid var(--line);
  background: var(--surface);
  cursor: pointer;
}

.admin-pill:hover { border-color: #44444c; }

.page-main {
  padding: var(--pad);
  padding-bottom: calc(var(--pad) + 2rem);
  max-width: 72rem;
  margin: 0 auto;
}

.add-bar {
  display: none;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}

body.is-admin .add-bar { display: flex; }

.btn-small {
  padding: 0.35rem 0.5rem;
  font-size: 0.75rem;
  min-height: 2rem;
  min-width: 2rem;
}

.shop-section {
  margin-bottom: clamp(1.75rem, 4vw, 2.5rem);
}

.shop-section:last-child {
  margin-bottom: 0;
}

.section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem 1rem;
  margin-bottom: 0.85rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--line);
}

.section-label {
  margin: 0;
  font-size: clamp(0.95rem, 2.5vw, 1.1rem);
  font-weight: 500;
  letter-spacing: 0.02em;
  text-transform: lowercase;
  color: var(--text);
}

.section-tools {
  display: none;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
}

body.is-admin .section-tools { display: flex; }

.section-empty {
  grid-column: 1 / -1;
  margin: 0;
  padding: 1.25rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
  border: 1px dashed var(--line);
  background: var(--surface);
}

.shop-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 9.5rem), 1fr));
  gap: clamp(0.75rem, 2vw, 1.25rem);
}

@media (min-width: 640px) {
  .shop-grid {
    grid-template-columns: repeat(auto-fill, minmax(10.5rem, 1fr));
  }
}

.item-card {
  position: relative;
  border: 1px solid var(--line);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  cursor: pointer;
  transition: border-color 0.12s;
}

.item-card:hover { border-color: #3d3d44; }

.item-card .thumb {
  position: relative;
  aspect-ratio: 1;
  background: var(--surface-2);
  overflow: hidden;
}

.item-card .thumb-media,
.product-hero .thumb-media {
  width: 100%;
  height: 100%;
}

.item-card .thumb img,
.product-hero .thumb-media img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  display: block;
}

.item-card.is-oos .thumb-media img,
.product-hero.is-oos .thumb-media img {
  filter: blur(2px) brightness(0.5);
}

.oos-badge {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0, 0, 0, 0.82);
  color: var(--text);
  font-size: clamp(0.65rem, 2.5vw, 0.75rem);
  letter-spacing: 0.06em;
  text-transform: lowercase;
  padding: 0.45rem 0.65rem;
  border: 1px solid rgba(255, 255, 255, 0.12);
  white-space: nowrap;
  pointer-events: none;
  z-index: 2;
}

.field-check { margin-bottom: 0.85rem; }

.check-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  cursor: pointer;
}

.check-label input {
  width: 1rem;
  height: 1rem;
  accent-color: var(--text);
}

.admin-hint {
  margin: -0.35rem 0 0.75rem;
  font-size: 0.75rem;
  color: var(--muted);
}

.item-card .thumb .empty {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 0.75rem;
}

.item-card .meta {
  padding: 0.65rem 0.7rem 0.75rem;
  border-top: 1px solid var(--line);
}

.item-card .name {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 500;
  line-height: 1.25;
}

.item-card .price {
  margin: 0.35rem 0 0;
  font-family: var(--mono);
  font-size: 0.82rem;
  color: var(--muted);
}

.item-card .admin-actions {
  display: none;
  position: absolute;
  top: 0.25rem;
  right: 0.25rem;
  left: 0.25rem;
  flex-wrap: wrap;
  gap: 0.2rem;
  justify-content: flex-end;
}

body.is-admin .item-card .admin-actions { display: flex; }

body.is-admin .item-card { cursor: default; }

.item-card .admin-actions button {
  font-size: 0.65rem;
  padding: 0.35rem 0.45rem;
  min-height: 1.75rem;
  min-width: 1.75rem;
  border: 1px solid var(--line);
  background: rgba(8, 8, 9, 0.9);
  cursor: pointer;
  touch-action: manipulation;
}

.item-card .admin-actions button.del { color: var(--danger); }

.btn {
  border: 1px solid var(--line);
  background: var(--surface-2);
  padding: 0.55rem 0.9rem;
  cursor: pointer;
  font-size: 0.875rem;
}

.btn:hover { border-color: #44444c; }

.btn-primary {
  background: var(--text);
  color: var(--bg);
  border-color: var(--text);
}

.modal-back {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0, 0, 0, 0.72);
  display: none;
  align-items: center;
  justify-content: center;
  padding: var(--pad);
}

.modal-back.open { display: flex; }

.modal {
  width: min(100%, 24rem);
  max-height: 90dvh;
  overflow: auto;
  border: 1px solid var(--line);
  background: var(--surface);
  padding: 1.25rem;
}

.modal h2 {
  margin: 0 0 1rem;
  font-size: 1rem;
  font-weight: 500;
}

.field { margin-bottom: 0.85rem; }

.field label {
  display: block;
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 0.35rem;
  text-transform: lowercase;
}

.field input, .field textarea, .field select {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--bg);
  padding: 0.55rem 0.65rem;
  outline: none;
}

.field select { cursor: pointer; }

.field input:focus, .field textarea:focus { border-color: #55555e; }

.modal-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  margin-top: 1rem;
}

.product-page {
  padding-left: max(var(--pad), env(safe-area-inset-left, 0px));
  padding-right: max(var(--pad), env(safe-area-inset-right, 0px));
  padding-bottom: max(calc(var(--pad) + 2.5rem), env(safe-area-inset-bottom, 0px));
}

.product-back {
  display: inline-block;
  margin-bottom: 1rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.product-back:hover { color: var(--text); }

.product-layout {
  display: flex;
  flex-direction: column;
  gap: 1.15rem;
  width: 100%;
  min-width: 0;
}

.product-info {
  min-width: 0;
  width: 100%;
}

@media (min-width: 720px) {
  .product-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 1.75rem;
    align-items: start;
  }
}

.product-hero {
  position: relative;
  border: 1px solid var(--line);
  background: var(--surface);
  width: min(100%, 16.5rem);
  max-width: 100%;
  margin: 0 auto;
  aspect-ratio: 1;
  overflow: hidden;
  flex-shrink: 0;
}

@media (min-width: 720px) {
  .product-hero {
    width: 100%;
    max-width: none;
    margin: 0;
    max-height: min(62vh, 24rem);
    height: auto;
    aspect-ratio: 1;
  }
}

.product-hero .empty {
  height: 100%;
  display: grid;
  place-items: center;
  color: var(--muted);
}

.product-info h1 {
  margin: 0 0 0.4rem;
  font-size: clamp(1.15rem, 4.5vw, 1.65rem);
  font-weight: 500;
  line-height: 1.2;
  word-break: break-word;
}

.product-info .base-price {
  font-family: var(--mono);
  color: var(--muted);
  margin: 0 0 1rem;
  font-size: 0.95rem;
}

.flavor-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border: 1px solid var(--line);
}

.flavor-list li {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.25rem;
  padding: 0.7rem 0.85rem;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

@media (min-width: 420px) {
  .flavor-list li {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
  }
}

.flavor-list li:last-child { border-bottom: 0; }

.flavor-list .fname {
  font-weight: 500;
  font-size: 0.95rem;
  word-break: break-word;
}

.flavor-list .fmeta {
  font-family: var(--mono);
  font-size: 0.82rem;
  color: var(--muted);
}

.flavor-list .fmeta .out { color: var(--danger); }

.admin-flavor-edit {
  display: none;
  width: 100%;
  margin-top: 0.5rem;
  gap: 0.35rem;
}

body.is-admin .flavor-list li.editing .admin-flavor-edit { display: grid; }

body.is-admin .flavor-list li .edit-fl { display: inline-block; }

.flavor-list li .edit-fl {
  display: none;
  font-size: 0.7rem;
  margin-left: 0.5rem;
  color: var(--muted);
  cursor: pointer;
  text-decoration: underline;
}

.btn-add-flavor { margin-top: 0.5rem; }

.product-admin-actions {
  margin-top: 1rem;
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.admin-panel {
  display: none;
  margin-top: 1.25rem;
  padding: 0.85rem;
  border: 1px dashed var(--line);
  background: var(--surface);
  max-width: 100%;
  overflow-x: clip;
}

body.is-admin .admin-panel { display: block; }

.admin-panel h3 {
  margin: 0 0 0.75rem;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--muted);
}

.flavor-rows { display: flex; flex-direction: column; gap: 0.5rem; }

.flavor-row {
  display: grid;
  grid-template-columns: 1fr 4.5rem 4.5rem auto;
  gap: 0.35rem;
  align-items: center;
}

@media (max-width: 520px) {
  .flavor-row {
    grid-template-columns: 1fr;
  }
  .flavor-row input { width: 100%; min-width: 0; }
  .flavor-row button {
    width: 100%;
    justify-self: stretch;
  }
}

.login-page {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--pad);
}

.login-box {
  width: min(100%, 20rem);
  border: 1px solid var(--line);
  background: var(--surface);
  padding: 1.25rem;
}

.login-box h1 {
  margin: 0 0 1rem;
  font-size: 1rem;
  font-weight: 500;
}

.login-box .pass-box { width: 100%; margin-bottom: 0; }

.login-box .gate-msg-inline {
  text-align: left;
  margin-top: 0.5rem;
  min-height: 0;
}

.login-box .gate-msg-inline:not(:empty) {
  min-height: 1.25rem;
}

.back-link {
  display: inline-block;
  margin-top: 1rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.back-link:hover { color: var(--text); }

.empty-shop {
  text-align: center;
  color: var(--muted);
  padding: 3rem 1rem;
  border: 1px solid var(--line);
  background: var(--surface);
}
