/* Shared design tokens and layout chrome (nav rail, mobile tab bar) for
   the Directory, ECA Detail, and Gallery pages. Ported from the Claude
   Design redesign handoff - see /docs (not shipped) for the original
   spec. Colors are authored in oklch() per the handoff for perceptual
   consistency; this app already targets modern Safari/Chrome (iPad/Mac),
   which both support oklch().

   One deliberate deviation from the handoff: group headers use a plain
   hyphen ("North - Floor 2") instead of an em dash, per house style. */

:root {
  --navy: #05154d;
  --navy-hover: oklch(0.3 0.09 265);
  --accent: oklch(0.68 0.14 250);
  --accent-hover: oklch(0.74 0.13 250);
  --page-bg: oklch(0.982 0.004 255);
  --header-bg: oklch(0.995 0.002 255);
  --surface: #fff;
  --border: oklch(0.93 0.006 262);
  --border-strong: oklch(0.9 0.006 262);
  --border-hover: oklch(0.8 0.03 255);
  --rule: oklch(0.92 0.006 262);
  --rule-inset: oklch(0.94 0.005 262);
  --dashed: oklch(0.87 0.006 262);
  --dashed-light: oklch(0.88 0.006 262);
  --ink: oklch(0.24 0.02 262);
  --ink-stat: oklch(0.28 0.02 262);
  --ink-note: oklch(0.32 0.015 262);
  --ink-prose: oklch(0.38 0.015 262);
  --ink-muted: oklch(0.42 0.015 262);
  --ink-meta: oklch(0.48 0.015 262);
  --ink-mono: oklch(0.615 0.015 262);
  --placeholder: oklch(0.68 0.012 260);
  --avatar-fill: oklch(0.94 0.02 255);
  --avatar-ink: oklch(0.42 0.06 258);
  --focus-ring: oklch(0.9 0.05 250);
  --focus-border: oklch(0.68 0.12 250);
  --green: oklch(0.7 0.14 152);
  --amber: oklch(0.8 0.13 85);
  --amber-bg: oklch(0.95 0.04 85);
  --amber-ink: oklch(0.44 0.1 70);
  --red: oklch(0.61 0.17 25);
  --red-bg: oklch(0.955 0.035 25);
  --red-ink: oklch(0.48 0.14 25);
  --none-dot: oklch(0.86 0.008 262);
  --none-bg: oklch(0.96 0.004 262);
  --none-ink: oklch(0.52 0.015 262);
  --pad: 30px;
}

@media (max-width: 1079px) {
  :root { --pad: 22px; }
}
@media (max-width: 699px) {
  :root { --pad: 16px; }
}

* { box-sizing: border-box; }

body.app-body {
  margin: 0;
  background: var(--page-bg);
  color: var(--ink);
  font-family: 'Instrument Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
  letter-spacing: -0.005em;
  -webkit-font-smoothing: antialiased;
}

.mono {
  font-family: 'DM Mono', ui-monospace, 'SF Mono', monospace;
}

a { color: oklch(0.55 0.14 255); text-decoration: none; }
a:hover { color: oklch(0.45 0.14 255); }
input, select, button, textarea { font: inherit; }
::placeholder { color: var(--placeholder); }
.noscroll::-webkit-scrollbar { display: none; }
.noscroll { scrollbar-width: none; -webkit-overflow-scrolling: touch; }

.app-shell {
  display: flex;
  min-height: 100vh;
}

/* ---------- Nav rail (desktop) ---------- */

.rail {
  width: 224px;
  flex: 0 0 224px;
  background: var(--navy);
  height: 100vh;
  position: sticky;
  top: 0;
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  gap: 28px;
  overflow: hidden;
}

.rail-logo-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 6px;
}

.rail-mark {
  width: 26px;
  height: 26px;
  flex: 0 0 26px;
  border-radius: 8px;
  background: var(--accent);
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--navy);
}

.rail-wordmark {
  font-weight: 600;
  font-size: 15px;
  white-space: nowrap;
  color: #fff;
}

.rail-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.rail-item {
  display: flex;
  align-items: center;
  padding: 9px 10px;
  border-radius: 10px;
  font-size: 13px;
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.72);
  font-weight: 400;
  cursor: pointer;
  text-decoration: none;
  width: 100%;
  text-align: left;
}

.rail-item:hover {
  background: rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.72);
}

.rail-item.active {
  background: rgba(255, 255, 255, 0.13);
  color: #fff;
  font-weight: 600;
}

.rail-item .glyph {
  width: 16px;
  flex: 0 0 16px;
  text-align: center;
  opacity: 0.75;
  font-family: 'DM Mono', monospace;
}

.rail-item.active .glyph { opacity: 1; }

.rail-item .label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-left: 4px;
}

.rail-item .count {
  font-family: 'DM Mono', monospace;
  font-size: 12px;
  opacity: 0.7;
}

.rail-footer {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.rail-cta {
  width: 100%;
  padding: 11px;
  border-radius: 10px;
  border: none;
  background: var(--accent);
  color: var(--navy);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  display: block;
}

.rail-cta:hover { background: var(--accent-hover); color: var(--navy); }

.rail-user-row {
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  padding: 8px 6px 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.rail-avatar {
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 600;
  color: #fff;
}

.rail-user-text { min-width: 0; }

.rail-user-name {
  font-size: 12.5px;
  font-weight: 500;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rail-user-role {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.55);
}

.rail-logout {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.55);
  font-size: 11px;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
}

/* ---------- Main column ---------- */

.app-main {
  flex: 1;
  min-width: 0;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--header-bg);
  border-bottom: 1px solid var(--rule);
  padding: 26px var(--pad) 16px;
}

.app-body {
  padding: 26px var(--pad) 60px;
}

/* ---------- Buttons / chips shared everywhere ---------- */

.btn {
  padding: 8px 14px;
  border-radius: 10px;
  font-size: 13.5px;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--ink);
  text-decoration: none;
  display: inline-block;
}

.btn:hover { background: var(--none-bg); }

.btn-primary {
  background: var(--navy);
  color: #fff;
  border: none;
}

.btn-primary:hover { background: var(--navy-hover); color: #fff; }

.rag-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex: 0 0 9px;
  display: inline-block;
}

.rag-dot.green { background: var(--green); }
.rag-dot.yellow, .rag-dot.amber { background: var(--amber); }
.rag-dot.red { background: var(--red); }
.rag-dot.none { background: var(--none-dot); }

.pill-followup {
  font-size: 11px;
  font-weight: 500;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--amber-bg);
  color: var(--amber-ink);
  white-space: nowrap;
}

/* ---------- Avatar stack ---------- */

.avatar-stack {
  display: flex;
  flex: 0 0 auto;
}

.avatar-stack .avatar {
  width: 30px;
  height: 30px;
  flex: 0 0 30px;
  border-radius: 999px;
  overflow: hidden;
  background: var(--avatar-fill);
  box-shadow: 0 0 0 2px #fff;
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 600;
  color: var(--avatar-ink);
  font-family: 'Instrument Sans', sans-serif;
}

.avatar-stack .avatar:not(:first-child) {
  margin-left: -10px;
}

.avatar-stack .avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar-sm {
  width: 26px;
  height: 26px;
  border-radius: 999px;
  background: var(--avatar-fill);
  display: grid;
  place-items: center;
  font-size: 10.5px;
  font-weight: 600;
  color: var(--avatar-ink);
  flex: 0 0 26px;
  overflow: hidden;
}

.avatar-sm img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ---------- Panels ---------- */

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px 20px;
}

.panel-label {
  font-family: 'DM Mono', monospace;
  font-size: 11.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-mono);
  margin-bottom: 10px;
}

/* ---------- Mobile bottom tab bar ---------- */

.tab-bar {
  display: none;
}

@media (max-width: 699px) {
  .rail { display: none; }

  .tab-bar {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: 1fr;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 20;
    background: var(--navy);
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
  }

  .tab-bar a, .tab-bar button {
    background: none;
    border: none;
    height: 56px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    text-decoration: none;
  }

  .tab-bar .tab-indicator {
    width: 20px;
    height: 3px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.22);
  }

  .tab-bar .tab-label {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.55);
    font-weight: 500;
  }

  .tab-bar a.active .tab-indicator, .tab-bar button.active .tab-indicator {
    background: var(--accent);
  }

  .tab-bar a.active .tab-label, .tab-bar button.active .tab-label {
    color: #fff;
    font-weight: 600;
  }

  .page-with-tabbar {
    padding-bottom: calc(72px + env(safe-area-inset-bottom));
  }

  .fab-add-eca {
    position: fixed;
    right: 16px;
    bottom: calc(84px + env(safe-area-inset-bottom));
    z-index: 20;
    height: 52px;
    padding: 0 20px;
    border-radius: 999px;
    background: var(--navy);
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    border: none;
    box-shadow: 0 10px 26px -10px oklch(0.2 0.08 265 / 0.6);
    display: flex;
    align-items: center;
    text-decoration: none;
  }

  /* More menu sheet */
  .more-sheet {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    z-index: 30;
    display: none;
  }
  .more-sheet.open { display: block; }
  .more-sheet-panel {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--surface);
    border-radius: 16px 16px 0 0;
    padding: 10px 10px calc(20px + env(safe-area-inset-bottom));
  }
  .more-sheet-panel a, .more-sheet-panel button {
    display: block;
    width: 100%;
    text-align: left;
    padding: 14px 16px;
    font-size: 15px;
    color: var(--ink);
    background: none;
    border: none;
    border-bottom: 1px solid var(--rule-inset);
    cursor: pointer;
    text-decoration: none;
  }
  .more-sheet-panel a:last-child, .more-sheet-panel button:last-child {
    border-bottom: none;
  }
}

@media (min-width: 700px) {
  .more-sheet { display: none !important; }
}

/* ---------- Tablet: icon-only rail ---------- */

@media (min-width: 700px) and (max-width: 899px) {
  .rail {
    width: 68px;
    flex: 0 0 68px;
    padding: 20px 12px;
    gap: 26px;
  }
  .rail-logo-row { justify-content: center; padding: 0; }
  .rail-wordmark, .rail-item .label, .rail-item .count,
  .rail-user-text { display: none; }
  .rail-item {
    justify-content: center;
    height: 44px;
    padding: 0;
  }
  .rail-cta {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    padding: 0;
    font-size: 20px;
    margin: 0 auto;
  }
  .rail-user-row { justify-content: center; }
}

@media (min-width: 700px) and (max-width: 1079px) {
  .btn, .rail-item { min-height: 44px; }
}
