/* Zoza web shell (lane A). Colours, radii and sizes come from
   /design-system/zoza-tokens.css; nothing here invents a palette. */

:root {
  --shell-font: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, Roboto, "Noto Sans", sans-serif;
  --shell-tab-h: 56px;
  --shell-rail-w: 84px;
  --shell-top-h: 44px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--shell-font);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

[hidden] { display: none !important; }

.app {
  height: 100dvh;
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  grid-template-areas: "top" "notice" "stage" "tabs";
}

/* ── top bar (only shown when there is something to put in it) ───────── */
.topbar {
  grid-area: top;
  height: var(--shell-top-h);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 var(--inset);
  border-bottom: 1px solid var(--border-hairline);
  background: var(--bg-elevated);
}
.topbar-back {
  border: 0;
  background: none;
  color: var(--accent-primary);
  font: inherit;
  font-weight: 600;
  padding: 8px 8px 8px 0;
  min-height: var(--tap-min);
  cursor: pointer;
}
.topbar-title {
  flex: 1;
  min-width: 0;
  margin: 0;
  font-size: var(--title-size);
  font-weight: var(--title-weight);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.topbar-link {
  color: var(--accent-primary);
  font-size: var(--meta-size);
  text-decoration: none;
  white-space: nowrap;
}
.topbar-link:hover { text-decoration: underline; }

/* ── notice line ─────────────────────────────────────────────────────── */
.notice {
  grid-area: notice;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px var(--inset);
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border-hairline);
  font-size: var(--meta-size);
}
.notice-text { flex: 1; margin: 0; color: var(--text-secondary); }
.notice-action, .notice-close {
  border: 0;
  background: none;
  font: inherit;
  cursor: pointer;
  padding: 6px 0;
}
.notice-action { color: var(--accent-primary); font-weight: 600; }
.notice-close { color: var(--text-muted); }

/* ── page stage ──────────────────────────────────────────────────────── */
.stage {
  grid-area: stage;
  position: relative;
  min-height: 0;
  overflow: hidden;
}
.frame {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  background: var(--bg-primary);
}

.panel {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--inset);
  background: var(--bg-primary);
  overflow: auto;
}

/* ── cards and buttons (app-only screen, first-run gate) ─────────────── */
.card {
  width: 100%;
  max-width: 420px;
  padding: 24px var(--inset);
  border: 1px solid var(--border-hairline);
  border-radius: var(--radius-lg);
  background: var(--bg-elevated);
}
.card-title { margin: 0 0 8px; font-size: 22px; font-weight: 700; line-height: 1.25; }
.card-text { margin: 0 0 20px; color: var(--text-secondary); }
.card-fine { margin: 20px 0 0; font-size: var(--meta-size); color: var(--text-muted); }
.card-error { margin: 12px 0 0; font-size: var(--meta-size); color: var(--mkt-down-text); }
.card-actions { display: flex; flex-wrap: wrap; gap: 12px; }
.card-actions-stack { flex-direction: column; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap-min);
  padding: 0 18px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-primary);
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}
.btn:hover { background: var(--bg-hover); }
.btn-primary {
  border-color: var(--accent-primary);
  background: var(--accent-primary);
  color: var(--text-on-accent);
}
.btn-primary:hover { background: var(--accent-primary); filter: brightness(1.08); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn:focus-visible, .tab:focus-visible, .topbar-back:focus-visible, .notice-action:focus-visible {
  outline: 2px solid var(--accent-primary);
  outline-offset: 2px;
}

/* ── first-run / unlock gate ─────────────────────────────────────────── */
.gate {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--inset);
  background: var(--bg-primary);
}

/* ── tab bar: bottom on phones, left rail on wide screens ────────────── */
.tabbar {
  grid-area: tabs;
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  height: calc(var(--shell-tab-h) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  border-top: 1px solid var(--border-hairline);
  background: var(--bg-elevated);
}
.tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-width: 0;
  border: 0;
  background: none;
  color: var(--text-secondary);
  font: inherit;
  font-size: var(--micro-size);
  font-weight: var(--micro-weight);
  cursor: pointer;
}
.tab svg { width: 22px; height: 22px; flex: none; }
.tab span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tab[aria-current="page"] { color: var(--accent-primary); }
.tab:hover { color: var(--text-primary); }
.tab[aria-current="page"]:hover { color: var(--accent-primary); }

@media (min-width: 900px) {
  .app {
    grid-template-columns: var(--shell-rail-w) 1fr;
    grid-template-rows: auto auto 1fr;
    grid-template-areas: "tabs top" "tabs notice" "tabs stage";
  }
  .tabbar {
    grid-template-columns: none;
    grid-auto-rows: 64px;
    align-content: start;
    height: auto;
    padding: 12px 0 0;
    border-top: 0;
    border-right: 1px solid var(--border-hairline);
  }
  .tab { font-size: 12px; }
}

/* ── key-origin frame: full screen, shown only while it needs the user.
   Inline style.display (set by the shell or keys-client.js) switches it. ── */
#zoza-keys-frame {
  display: none;
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  border: 0;
  z-index: 100;
  background: transparent;
}

@media (prefers-reduced-motion: no-preference) {
  .tab, .btn { transition: color var(--dur-fast) var(--ease-standard), background-color var(--dur-fast) var(--ease-standard); }
}
