/* ==========================================================================
   One design system for every screen. See DESIGN.md.
   Warm incubator dark, agar-amber accent, one legible family.
   The dish rim (a circle whose colour is the status) is the only loud element.
   ========================================================================== */

:root {
  color-scheme: dark;
  --bg: #14120e;          /* incubator */
  --surface: #1d1a14;     /* bench */
  --surface-2: #27231b;   /* tray */
  --surface-3: #312c22;
  --border: #39332a;      /* rule */
  --border-strong: #4d4537;
  --text: #f1eadb;        /* label paper */
  --muted: #a89f8c;       /* pencil */
  --faint: #7d7566;
  --accent: #e8a93a;      /* agar amber */
  --accent-hover: #f2bc59;
  --accent-soft: #3a2c12;
  --accent-ink: #1a1206;
  --ok: #8fcb7e;          /* colony green */
  --ok-soft: #1e2d1a;
  --ok-ink: #0f1d0b;
  --warn: #f08a4b;
  --warn-soft: #3a2414;
  --bad: #ec7a6e;         /* stain red */
  --bad-soft: #3b1e1b;

  --font: "Atkinson Hyperlegible Next", "Atkinson Hyperlegible", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  --fs-xs: 12px;
  --fs-sm: 13.5px;
  --fs-md: 15px;
  --fs-lg: 18px;
  --fs-xl: 23px;
  --fs-2xl: 30px;

  --radius-lg: 16px;      /* page panels */
  --radius: 12px;         /* cards inside panels */
  --radius-sm: 10px;      /* controls */
  --shadow: none;
  --shadow-pop: 0 18px 40px rgba(0, 0, 0, .5), 0 0 0 1px rgba(241, 234, 219, .04);
  --ease: cubic-bezier(.3, .7, .4, 1);
  --nav-h: 60px;
  --tabbar-h: 64px;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 400 var(--fs-md)/1.5 var(--font);
  font-variant-numeric: tabular-nums;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { margin: 0; font-weight: 700; line-height: 1.2; letter-spacing: -.01em; }
h1 { font-size: var(--fs-xl); }
h2 { font-size: var(--fs-lg); }
p { margin: 0; }
a { color: var(--accent); text-underline-offset: 3px; }
img { display: block; max-width: 100%; }
::selection { background: var(--accent-soft); color: var(--text); }
:focus-visible { scroll-margin: 90px; }

/* ---------- buttons ---------- */
.btn, button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 0 16px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface-2); color: var(--text);
  font: inherit; font-size: var(--fs-sm); font-weight: 600; line-height: 1.1;
  white-space: nowrap; text-decoration: none;
  cursor: pointer; user-select: none; -webkit-tap-highlight-color: transparent;
  transition: background-color .15s var(--ease), border-color .15s var(--ease), color .15s var(--ease), transform .1s var(--ease);
}
.btn:hover, button:hover { background: var(--surface-3); border-color: var(--faint); }
.btn:active, button:active { transform: scale(.97); }
.btn:focus-visible, button:focus-visible, a:focus-visible, select:focus-visible, input:focus-visible, summary:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
.btn:disabled, button:disabled { opacity: .4; cursor: default; transform: none; }
.btn svg, button svg { flex: none; }

.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--surface-2); border-color: transparent; color: var(--text); }
.btn-danger { color: var(--bad); }
.btn-danger:hover { background: var(--bad-soft); border-color: var(--bad); color: var(--bad); }
.btn-sm { min-height: 34px; padding: 0 12px; font-size: var(--fs-xs); border-radius: 9px; }
.btn-lg { min-height: 50px; padding: 0 22px; font-size: var(--fs-md); }
.btn-block { width: 100%; }
.btn-icon { width: 40px; padding: 0; }
.btn-icon.btn-sm { width: 34px; }

/* decisions */
.btn-accept { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-accept:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-reject { color: var(--bad); }
.btn-reject:hover { border-color: var(--bad); background: var(--bad-soft); }
.btn-unsure { color: var(--warn); }
.btn-unsure:hover { border-color: var(--warn); background: var(--warn-soft); }

/* a chosen tool or option */
.is-on, .btn.on, button.on {
  background: var(--accent) !important; border-color: var(--accent) !important; color: var(--accent-ink) !important;
}

/* ---------- fields ---------- */
select, input[type=text], input[type=password], input[type=search], input:not([type]) {
  min-height: 42px; padding: 0 12px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--bg); color: var(--text); font: inherit; font-size: var(--fs-md);
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
input::placeholder { color: var(--faint); }
select:hover, input:hover { border-color: var(--faint); }
select:focus, input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input[type=range] { accent-color: var(--accent); }
input[type=checkbox] { accent-color: var(--accent); width: 16px; height: 16px; }
label > span, .label { font-size: var(--fs-xs); font-weight: 600; color: var(--muted); }

/* ---------- segmented control: EN | SL ---------- */
.seg { display: inline-flex; padding: 3px; gap: 2px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); }
.seg button {
  min-height: 28px; padding: 0 11px; border: none; border-radius: 999px; background: transparent;
  color: var(--muted); font-size: var(--fs-xs); font-weight: 700;
}
.seg button:hover { background: var(--surface-2); color: var(--text); border: none; }
.seg button.is-on, .seg button.on { background: var(--surface-3) !important; color: var(--text) !important; }

/* ---------- surfaces ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 18px; }
.eyebrow { font-size: var(--fs-xs); font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.muted { color: var(--muted); }
.small { font-size: var(--fs-xs); }
.empty {
  padding: 40px 24px; text-align: center; color: var(--muted);
  border: 1px dashed var(--border-strong); border-radius: var(--radius-lg);
}

/* badges: status as a dot and words */
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-xs); font-weight: 600; color: var(--muted); }
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge--ok { color: var(--ok); }
.badge--warn { color: var(--accent); }
.badge--bad { color: var(--bad); }

/* chips: filters */
.chip {
  display: inline-flex; align-items: center; gap: 8px; min-height: 36px; padding: 0 14px;
  border-radius: 999px; border: 1px solid var(--border); background: transparent;
  color: var(--muted); text-decoration: none; font-size: var(--fs-sm); font-weight: 600;
}
.chip b { font-weight: 700; color: var(--faint); }
.chip:hover { color: var(--text); border-color: var(--border-strong); }
.chip.on { background: var(--accent-soft); border-color: transparent; color: var(--accent); }
.chip.on b { color: var(--accent); opacity: .75; }

/* progress bar (kept for pages that still use it) */
.progress { height: 6px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.progress > i { display: block; height: 100%; border-radius: inherit; background: var(--accent); transition: width .35s var(--ease); }

/* ---------- motion: answers to actions only ---------- */
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.rise { animation: rise .25s var(--ease); }
.btn.is-saved { background: var(--ok) !important; border-color: var(--ok) !important; color: var(--ok-ink) !important; }

/* ---------- popover next to an outline ---------- */
.popover { position: fixed; z-index: 60; min-width: 240px; padding: 6px; background: var(--surface-2); border: 1px solid var(--border-strong); border-radius: var(--radius); box-shadow: var(--shadow-pop); animation: rise .15s var(--ease); }
.popover__head { padding: 8px 10px 6px; font-size: var(--fs-xs); font-weight: 600; color: var(--muted); }
.popover__item { display: flex; width: 100%; min-height: 40px; justify-content: flex-start; padding: 0 10px; border: none; border-radius: 8px; background: transparent; font-weight: 500; font-size: var(--fs-sm); }
.popover__item:hover { background: var(--surface-3); border: none; color: var(--accent); }
.popover__item:active { transform: none; background: var(--accent-soft); }
.popover__item--danger { color: var(--bad); }
.popover__item--danger:hover { background: var(--bad-soft); color: var(--bad); }
.popover__sep { height: 1px; margin: 5px 4px; background: var(--border); }

/* ---------- modal: a sheet from the bottom on phones ---------- */
.modal-backdrop { position: fixed; inset: 0; z-index: 70; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(8, 7, 5, .66); }
.modal {
  width: min(520px, 100%); max-height: 88vh; overflow: auto; padding: 24px;
  background: var(--surface); color: var(--text); border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-pop); line-height: 1.6; animation: rise .2s var(--ease);
}
.modal h2 { font-size: var(--fs-lg); margin-bottom: 14px; }
.modal ol { padding-left: 20px; margin: 0; }
.modal li { margin-bottom: 8px; }
.modal__foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; flex-wrap: wrap; }
@media (max-width: 560px) {
  .modal-backdrop { align-items: flex-end; padding: 0; }
  .modal { width: 100%; border-radius: var(--radius-lg) var(--radius-lg) 0 0; padding: 22px 18px calc(18px + env(safe-area-inset-bottom)); }
}

/* ---------- site navigation: top bar on computers, tab bar at the bottom on phones ---------- */
.sitebar {
  position: sticky; top: 0; z-index: 30; height: var(--nav-h);
  display: flex; align-items: center; gap: 12px; padding: 0 24px;
  background: rgba(20, 18, 14, .92); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.sitebar .tabs { display: flex; align-items: center; gap: 4px; flex: 1; min-width: 0; }
.sitebar .tabs a {
  display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 14px;
  border-radius: var(--radius-sm); color: var(--muted); text-decoration: none; font-size: var(--fs-sm); font-weight: 600;
}
.sitebar .tabs a svg { width: 18px; height: 18px; }
.sitebar .tabs a:hover { color: var(--text); background: var(--surface-2); }
.sitebar .tabs a.on { color: var(--accent); background: var(--accent-soft); }
.sitebar .tabs a.out { margin-left: auto; }
/* secondary places (Deleted, Log out): greyer and smaller, they light up only when open */
.sitebar .tabs a.quiet { color: var(--faint); font-weight: 500; }
.sitebar .tabs a.quiet:hover { color: var(--muted); }
.sitebar .tabs a.quiet.on { color: var(--accent); }
.sitebar #labCtl { display: flex; }

@media (max-width: 720px) {
  /* no backdrop-filter here: it would make the bar the containing block of the fixed tab bar below */
  .sitebar { padding: 0 16px; height: 52px; justify-content: flex-end; background: var(--bg); backdrop-filter: none; -webkit-backdrop-filter: none; }
  .sitebar .tabs {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
    height: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); padding: 6px 8px env(safe-area-inset-bottom);
    gap: 0; background: rgba(29, 26, 20, .97); border-top: 1px solid var(--border);
    backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  }
  .sitebar .tabs a {
    flex: 1; flex-direction: column; justify-content: center; gap: 3px; min-height: 52px; padding: 0 4px;
    font-size: 11px; font-weight: 600; border-radius: var(--radius-sm);
  }
  .sitebar .tabs a svg { width: 22px; height: 22px; }
  .sitebar .tabs a.on { background: transparent; }
  .sitebar .tabs a.on svg { color: var(--accent); }
  .sitebar .tabs a.out { margin-left: 0; }
  body.has-tabbar { padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); }
}

/* ---------- a photo shown large (static/viewer.js) ---------- */
.viewer{position:fixed;inset:0;z-index:200;display:flex;flex-direction:column;background:rgba(8,7,5,.95);animation:rise .15s var(--ease)}
.viewer-bar{display:flex;align-items:center;gap:12px;padding:10px 16px;padding-top:calc(10px + env(safe-area-inset-top))}
.viewer-name{flex:1;min-width:0;font-size:var(--fs-sm);font-weight:600;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.viewer-hint{color:var(--muted);font-size:var(--fs-xs)}
.viewer-stage{flex:1;min-height:0;overflow:auto;display:grid;place-items:center;padding:8px 8px calc(8px + env(safe-area-inset-bottom))}
.viewer-stage img{max-width:100%;max-height:100%;object-fit:contain;border-radius:6px;cursor:zoom-in}
.viewer-stage.zoomed{display:block}
.viewer-stage.zoomed img{max-width:none;max-height:none;cursor:zoom-out}
@media (max-width:560px){ .viewer-hint{display:none} }

.lab-slot { display: inline-flex; align-items: center; gap: 6px; }

* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
