:root {
  color-scheme: dark;
  --bg: #0b1220;
  --panel: #131b2e;
  --border: #263149;
  --text: #e7ecf5;
  --muted: #8b96ab;
  --accent: #3d8bff;
  --danger: #ff5a5a;
  --ok: #35c46a;
  font-size: 17px; /* comfortable minimum touch/legibility size in the field */
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

body {
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
}

#app { max-width: 640px; margin: 0 auto; padding: 1rem; }

.screen.hidden { display: none; }
/* The quick-search form is hidden until a case is active (app.js updateActiveCaseIndicator);
   .quick-search sets display: grid at equal specificity and appears later in this file, so the
   toggle needs its own rule. Found in a real browser 2026-09-16: the form rendered with no
   active case and a search produced only a toast. */
.quick-search.hidden { display: none; }

h1 { font-size: 1.4rem; margin: 0.2rem 0 0.6rem; }
.subtitle { color: var(--muted); margin-top: -0.4rem; }

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}
header h1 { margin: 0; }

label {
  display: block;
  margin-bottom: 0.9rem;
  font-size: 0.9rem;
  color: var(--muted);
}

input, select {
  display: block;
  width: 100%;
  margin-top: 0.3rem;
  padding: 0.75rem 0.8rem;
  font-size: 1rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
}
input:focus, select:focus { outline: 2px solid var(--accent); }

button {
  display: block;
  width: 100%;
  padding: 0.85rem;
  font-size: 1rem;
  font-weight: 600;
  border: none;
  border-radius: 10px;
  background: var(--accent);
  color: white;
  cursor: pointer;
}
button:active { opacity: 0.8; }
button.ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  width: auto;
  padding: 0.6rem 0.9rem;
  font-weight: 500;
}

.error { color: var(--danger); min-height: 1.2em; font-size: 0.9rem; }

.quick-search {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.5rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.9rem;
  margin-bottom: 0.5rem;
}
.hint { color: var(--muted); font-size: 0.85rem; margin: 0.4rem 0 1rem; }

.case-actions { display: flex; gap: 0.5rem; margin-bottom: 0.9rem; }
.case-actions button { width: auto; flex: 1; }

.case-list, .entry-list { list-style: none; margin: 0; padding: 0; }

.case-list li, .entry-list li {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.8rem 0.9rem;
  margin-bottom: 0.6rem;
}
.case-list li { display: flex; flex-direction: column; gap: 0.2rem; cursor: pointer; }
.case-title { font-weight: 600; }
.case-sub { color: var(--muted); font-size: 0.85rem; }

.badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--muted);
}
.badge.routine { color: var(--muted); }
.badge.sensitive { color: var(--accent); border-color: var(--accent); }
.badge.restricted { color: #ffb020; border-color: #ffb020; }
.badge.critical { color: var(--danger); border-color: var(--danger); }

.meta { color: var(--muted); font-size: 0.85rem; margin-top: -0.3rem; }

.entry-list pre {
  white-space: pre-wrap;
  word-break: break-word;
  background: #0a0f1c;
  border-radius: 8px;
  padding: 0.6rem;
  font-size: 0.8rem;
  max-height: 220px;
  overflow: auto;
}
.entry-head { display: flex; justify-content: space-between; gap: 0.5rem; margin-bottom: 0.4rem; }
.entry-target { font-weight: 600; }
.entry-time { color: var(--muted); font-size: 0.8rem; }

.toast {
  position: fixed;
  left: 1rem; right: 1rem; bottom: calc(1rem + env(safe-area-inset-bottom));
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.75rem 1rem;
  text-align: center;
}
.toast.hidden { display: none; }
.toast.error { border-color: var(--danger); color: var(--danger); }
.toast.ok { border-color: var(--ok); color: var(--ok); }

/* ---- Desktop: sidebar case list + detail pane, side by side ----
   Pure CSS on top of the unchanged mobile layout/JS above — app.js still toggles the same
   .hidden classes via showScreen(); on mobile that's still one screen at a time (untouched
   behavior). At this width we override display on the cases/case screens specifically so both
   stay visible together, laid out as a two-column grid, once login is done. The `:has()` gate
   keeps the login screen a normal centered form instead of splitting into an empty grid before
   there's any case data to show. Not run in a real browser this session — verify on first use. */
@media (min-width: 900px) {
  body:has(#screen-login:not(.hidden)) #app {
    max-width: 420px;
    margin: 4rem auto;
  }

  body:has(#screen-login.hidden) #app {
    max-width: 1100px;
    display: grid;
    grid-template-columns: 380px 1fr;
    align-items: start;
    gap: 1.5rem;
    padding: 1.5rem;
  }

  body:has(#screen-login.hidden) #screen-cases,
  body:has(#screen-login.hidden) #screen-case {
    display: block !important; /* override the mobile .hidden toggle: both panes stay visible */
  }

  #screen-case { position: sticky; top: 1.5rem; }
  #back-btn { display: none; } /* both panes already visible side by side, nothing to go "back" from */
}
.toast.error { border-color: var(--danger); color: var(--danger); }
.toast.ok { border-color: var(--ok); color: var(--ok); }
