/* One theme: frosted glass panels over a dark, misty warehouse floor. */
:root {
  --text: #ffffff;
  --muted: rgba(255, 255, 255, .62);
  --border: rgba(255, 255, 255, .12);
  --accent: #8cd7d7; /* teal */
  --accent-soft: rgba(140, 215, 215, .14);
  --accent-strong: rgba(140, 215, 215, .30);
  --accent-text: #0b1520;
  --glass: rgba(16, 24, 40, .38);
  --glass-border: rgba(255, 255, 255, .10);
  --glass-shadow: 0 22px 60px rgba(0, 0, 0, .28), inset 0 1px 0 rgba(255, 255, 255, .06);
  --bg: rgba(255, 255, 255, .07); /* fields, code blocks */
  --bg-focus: rgba(255, 255, 255, .11);
  --warn-bg: rgba(255, 196, 0, .14);
  --warn-text: #ffd98a;
  --error-bg: rgba(255, 90, 90, .14);
  --error-text: #ffb3b3;
  --radius: 22px;
  --radius-sm: 13px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background: #070b0e;
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
/* Fixed layer (not background-attachment: fixed, which iOS ignores). */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    linear-gradient(rgba(10, 16, 28, .15), rgba(10, 16, 28, .15)),
    /* Narrow screens crop the sides: favour the left, where the light is.
       Ultrawide screens crop top and bottom: favour the wet floor. */
    url("/img/bg-warehouse.webp") 25% 65% / cover no-repeat;
}
[hidden] { display: none !important; }
h1 { font-size: 1.6rem; font-weight: 500; letter-spacing: -.02em; margin: 0 0 1rem; }
h2 { font-size: 1.15rem; margin: 0 0 .75rem; }
h3 { font-size: 1rem; margin: 0 0 .5rem; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: .875rem; }

/* ---- glass ---- */
.panel, .topbar, .update-banner, dialog.confirm {
  background: var(--glass);
  -webkit-backdrop-filter: blur(22px);
  backdrop-filter: blur(22px);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
}

/* ---- chrome ---- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .75rem 16px; position: sticky; top: 0; z-index: 10;
  border-width: 0 0 1px; box-shadow: none;
}
.brand { font-weight: 700; text-decoration: none; color: var(--text); white-space: nowrap; }
nav { display: flex; gap: .25rem; }
nav a { padding: .35rem .85rem; border-radius: 999px; text-decoration: none; color: var(--muted); border: 1px solid transparent; }
nav a:hover { color: var(--text); }
nav a[aria-current="page"] { background: var(--accent-soft); border-color: var(--accent-strong); color: var(--text); }

main { max-width: 1100px; margin: 0 auto; padding: 24px 16px; }
.layout-2 { display: grid; gap: 20px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 860px) { .layout-2 { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); align-items: start; } }
/* A page with one visible panel (the reader before a result) centres it. */
.layout-2:has(> .result[hidden]) { grid-template-columns: minmax(0, 1fr); max-width: 560px; }
.panel { border-radius: var(--radius); padding: 24px; min-width: 0; }
@media (max-width: 480px) { .panel { padding: 18px; border-radius: 18px; } }

/* ---- home ---- */
.home { width: calc(100% - 32px); max-width: 560px; margin: 6vh auto; }
.home h1 { text-align: center; }
.lead { font-size: 1.05rem; color: var(--muted); text-align: center; margin: 0; }
.home-cards { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); margin: 1.5rem 0; }
.card-link {
  display: flex; flex-direction: column; gap: .3rem; padding: 16px; text-decoration: none; color: var(--muted);
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm);
  transition: background .15s ease, border-color .15s ease;
}
.card-link strong { color: var(--accent); font-size: 1.1rem; font-weight: 600; }
.card-link:hover { background: var(--bg-focus); border-color: var(--accent-strong); }
.home-qr { margin: 1.5rem 0 0; text-align: center; }
.home-qr img { display: block; width: min(220px, 60vw); height: auto; margin: 0 auto .5rem; border-radius: var(--radius-sm); }
.home-qr figcaption { color: var(--muted); font-size: .9rem; }

/* ---- forms ---- */
.field { display: flex; flex-direction: column; gap: .3rem; margin: 0 0 1rem; min-width: 0; }
.field .label { font-weight: 500; font-size: .9rem; color: var(--muted); }
.field small { color: var(--muted); font-size: .8rem; padding: 0 4px; }
.check { display: flex; align-items: center; gap: .5rem; margin: 0 0 .7rem; color: var(--muted); }
.check input { accent-color: var(--accent); }
input, select, textarea, button { font: inherit; color: inherit; }
input[type="text"], input[type="url"], input[type="email"], input[type="tel"], input[type="password"], input:not([type]), select, textarea {
  width: 100%; padding: 13px 14px; color: var(--text);
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm);
  transition: border-color .15s ease, background .15s ease, box-shadow .15s ease;
}
input::placeholder, textarea::placeholder { color: rgba(255, 255, 255, .4); }
select option { background: #16202f; color: var(--text); }
textarea { resize: vertical; }
input[type="text"]:focus, input[type="url"]:focus, input[type="email"]:focus, input[type="tel"]:focus, input[type="password"]:focus, input:not([type]):focus, select:focus, textarea:focus {
  outline: none; border-color: rgba(255, 255, 255, .28); background: var(--bg-focus); box-shadow: 0 0 0 3px rgba(255, 255, 255, .06);
}
.check input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.grid-2 { display: grid; gap: 0 12px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 560px) { .grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .span-2 { grid-column: span 2; } }

/* Floating label: rests inside the empty field, moves up on focus or once filled.
   Markup: <label class="field floating"><input placeholder=" "><span class="label">…</span>[<small>hint</small>]</label> */
.floating { position: relative; }
.floating > input, .floating > textarea, .floating > select { padding: 26px 14px 9px; }
.floating > .label {
  position: absolute; left: 15px; top: 18px;
  color: rgba(255, 255, 255, .55); font-size: .95rem; font-weight: 500;
  pointer-events: none; transform-origin: left top;
  transition: top .16s ease, font-size .16s ease, color .16s ease;
}
.floating > :focus + .label,
.floating > :not(:placeholder-shown) + .label,
.floating > select + .label {
  top: 7px; font-size: .75rem; color: rgba(140, 215, 215, .85);
}

button {
  padding: 11px 16px; border-radius: var(--radius-sm); cursor: pointer; font-weight: 600;
  background: var(--accent-soft); border: 1px solid var(--accent-strong); color: var(--text);
  transition: background .15s ease, border-color .15s ease;
}
button:hover:not(:disabled) { background: var(--accent-strong); }
button.secondary { background: transparent; border-color: var(--border); }
button.secondary:hover:not(:disabled) { background: var(--bg); border-color: var(--accent-strong); }
button.small { padding: .3rem .7rem; font-size: .85rem; border-radius: 10px; }
button.danger { background: transparent; color: var(--error-text); border-color: var(--border); }
button:disabled { opacity: .45; cursor: not-allowed; }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; margin: .75rem 0; }

/* Segmented strip: one row of equal-width buttons that never wraps. */
.chips {
  display: flex; margin: 0 0 1.25rem;
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden;
}
.chip {
  flex: 1 1 0; min-width: 0; padding: .65rem .25rem; font-weight: 500;
  background: transparent; color: var(--muted);
  border: 0; border-left: 1px solid var(--border); border-radius: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chip:first-child { border-left: 0; }
.chip:hover:not([aria-pressed="true"]) { background: var(--bg); color: var(--text); }
.chip[aria-pressed="true"] { background: var(--accent-strong); color: var(--text); }
.chip:focus-visible { outline: 2px solid var(--accent); outline-offset: -4px; }

.warning, .error, .field-error { border-radius: var(--radius-sm); }
.notice { background: var(--accent-soft); border: 1px solid var(--accent-strong); border-radius: var(--radius-sm); padding: .75rem .9rem; }
.notice p { margin: .35rem 0 0; color: var(--muted); }
.warning { background: var(--warn-bg); color: var(--warn-text); padding: .6rem .75rem; }
.error { background: var(--error-bg); color: var(--error-text); padding: .6rem .75rem; }
.field-error { color: var(--error-text); min-height: 1.5em; margin: .25rem 0; }

/* ---- QR preview (the code itself stays black on white so it scans) ---- */
.qr-frame { display: flex; justify-content: center; background: #fff; border-radius: var(--radius-sm); padding: 12px; }
.qr-canvas { width: 100%; max-width: 320px; height: auto; aspect-ratio: 1; image-rendering: pixelated; }
.qr-canvas.stale { opacity: .15; }
.qr-info { color: var(--muted); font-size: .9rem; margin: .6rem 0; }
.payload-box summary { cursor: pointer; color: var(--muted); font-size: .9rem; }
pre.payload, pre.raw {
  white-space: pre-wrap; word-break: break-all; background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: .6rem .75rem; font-size: .85rem; max-height: 320px; overflow: auto;
}

/* ---- admin ---- */
.codes-grid { display: grid; gap: 16px; margin-top: 16px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }

/* ---- reader ---- */
.viewport { position: relative; margin: 0 0 1rem; border-radius: var(--radius-sm); overflow: hidden; background: #000; }
.viewport video { display: block; width: 100%; max-height: 60vh; object-fit: cover; }
.reticle { position: absolute; inset: 15%; border: 3px solid rgba(255, 255, 255, .85); border-radius: 12px; pointer-events: none; }
.drop-zone {
  display: flex; flex-direction: column; gap: .6rem; padding: 1.1rem; margin: 0 0 1rem; color: var(--muted);
  background: var(--bg); border: 1px dashed rgba(255, 255, 255, .25); border-radius: var(--radius-sm); cursor: pointer;
  transition: border-color .15s ease, background .15s ease;
}
.drop-zone strong { color: var(--text); }
.drop-zone:hover, .drop-zone.over { border-color: var(--accent); background: var(--bg-focus); }
.drop-zone input { max-width: 100%; }
.drop-zone input::file-selector-button {
  margin-right: .75rem; padding: .4rem .8rem; border-radius: 10px; cursor: pointer;
  background: var(--accent-soft); border: 1px solid var(--accent-strong); color: var(--text); font: inherit;
}
#scan-status.error { background: var(--error-bg); color: var(--error-text); padding: .6rem .75rem; border-radius: var(--radius-sm); }
.result:focus { outline: none; }
.result-head { display: flex; justify-content: space-between; align-items: center; gap: .5rem; margin: 0 0 1rem; }
.badge { background: var(--accent-strong); color: var(--text); border-radius: 999px; padding: .2rem .75rem; font-size: .85rem; font-weight: 600; }
dl.details { margin: 0; }
.kv { display: grid; grid-template-columns: 7rem minmax(0, 1fr); gap: .5rem; padding: .45rem 0; border-bottom: 1px solid var(--border); }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
ul.plain { list-style: none; margin: 0; padding: 0; }
.pre-line { white-space: pre-line; }
.secret-row { display: inline-flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
code.secret { font-size: 1rem; overflow-wrap: anywhere; }
.url-host { font-size: 1.25rem; margin: 0 0 .5rem; overflow-wrap: anywhere; }
.url-full { font-family: ui-monospace, Consolas, monospace; overflow-wrap: anywhere; background: var(--bg); padding: .5rem .75rem; border-radius: var(--radius-sm); }
dialog.confirm { max-width: min(520px, calc(100vw - 32px)); border-radius: var(--radius); color: var(--text); padding: 24px; background: rgba(16, 24, 40, .85); }
dialog.confirm::backdrop { background: rgba(0, 0, 0, .55); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
.contact-card h2 { margin-bottom: .25rem; }

/* ---- update prompt ---- */
.update-banner {
  position: fixed; left: 16px; right: 16px; bottom: 16px; z-index: 20; margin: 0 auto; max-width: 480px;
  display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; padding: .75rem 1rem;
  border-radius: var(--radius-sm); border-color: var(--accent-strong);
}
.update-banner span { flex: 1 1 auto; }
