/* LangMate PWA styles — mobile first, one column, no framework (docs/ARCHITECTURE.md §8). */

:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #eceff3;
  --text: #10141a;
  --text-dim: #5b6572;
  --accent: #1d4ed8;
  --accent-text: #ffffff;
  --border: #d7dce3;
  --mark-bg: #ffe08a;
  --mark-text: #3a2c00;
  --danger: #b42318;
  --ok: #15803d;
  --tabbar-h: 58px;
  --radius: 14px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f172a;
    --surface: #17203a;
    --surface-2: #1f2a49;
    --text: #eef2ff;
    --text-dim: #a5b0c8;
    --accent: #7dd3fc;
    --accent-text: #06121f;
    --border: #2c3a5e;
    --mark-bg: #7c5a10;
    --mark-text: #fff5d6;
    --danger: #fca5a5;
    --ok: #86efac;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Noto Sans KR", system-ui, sans-serif;
  -webkit-text-size-adjust: 100%;
}

body { overscroll-behavior-y: contain; }

.view {
  padding: calc(env(safe-area-inset-top) + 12px) calc(env(safe-area-inset-right) + 14px)
           calc(env(safe-area-inset-bottom) + var(--tabbar-h) + 24px)
           calc(env(safe-area-inset-left) + 14px);
  max-width: 720px;
  margin: 0 auto;
  min-height: 100vh;
}

h1 { font-size: 22px; margin: 4px 0 14px; }
h2 { font-size: 17px; margin: 20px 0 8px; color: var(--text-dim); font-weight: 600; }
p { margin: 8px 0; }

/* ---------- tab bar ---------- */
.tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  display: flex;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 20;
}
.tab {
  flex: 1;
  height: var(--tabbar-h);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 11px;
  color: var(--text-dim);
  text-decoration: none;
}
.tab .tab-icon { font-size: 17px; line-height: 1; }
.tab[aria-current="page"] { color: var(--accent); font-weight: 700; }

/* ---------- buttons ---------- */
button {
  font: inherit;
  color: inherit;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  min-height: 46px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
button:active { background: var(--surface-2); }
button[disabled] { opacity: 0.5; }
button.primary {
  background: var(--accent);
  color: var(--accent-text);
  border-color: transparent;
  font-weight: 700;
}
button.danger { color: var(--danger); }
button.wide { width: 100%; }
button.big { min-height: 64px; font-size: 19px; }

/* Listen-screen controls must stay comfortably tappable (≥ 56 px). */
.listen-actions button { min-height: 56px; font-size: 16px; }
.listen-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 18px;
}
.listen-actions .span-2 { grid-column: 1 / -1; }

/* ---------- generic surfaces ---------- */
.card, .tile, .row {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.card { padding: 16px; }
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tile { padding: 14px; text-align: left; }
.tile .num { display: block; font-size: 26px; font-weight: 700; }
.tile .lbl { color: var(--text-dim); font-size: 13px; }

.row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  margin-bottom: 8px;
  width: 100%;
  text-align: left;
}
.row .row-main { flex: 1; min-width: 0; }
.row .row-title { font-weight: 600; overflow-wrap: anywhere; }
.row .row-sub { color: var(--text-dim); font-size: 13px; overflow-wrap: anywhere; }

.badge {
  display: inline-block;
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-dim);
  white-space: nowrap;
}
.badge.me { background: var(--accent); color: var(--accent-text); }

.chips { display: flex; gap: 8px; overflow-x: auto; padding: 4px 0 10px; }
.chip { white-space: nowrap; padding: 8px 12px; min-height: 40px; border-radius: 999px; font-size: 14px; }
.chip[aria-pressed="true"] { background: var(--accent); color: var(--accent-text); border-color: transparent; }

input[type="text"], input[type="search"], input[type="password"], select {
  font: inherit;
  color: inherit;
  width: 100%;
  padding: 12px;
  min-height: 46px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
input[type="range"] { width: 100%; }
label { display: block; margin: 14px 0 6px; color: var(--text-dim); font-size: 14px; }

.muted { color: var(--text-dim); font-size: 14px; }
.error { color: var(--danger); }
.ok { color: var(--ok); }
.stack > * + * { margin-top: 10px; }

/* ---------- listen card ---------- */
.expression { font-size: 28px; font-weight: 700; line-height: 1.3; margin: 10px 0; overflow-wrap: anywhere; }
.context { font-size: 17px; color: var(--text-dim); overflow-wrap: anywhere; }
mark { background: var(--mark-bg); color: var(--mark-text); border-radius: 4px; padding: 0 3px; }
.strike { text-decoration: line-through; opacity: 0.7; }
.reveal { margin-top: 16px; }
.reveal dl { margin: 0; }
.reveal dt { color: var(--text-dim); font-size: 13px; margin-top: 12px; }
.reveal dd { margin: 2px 0 0; overflow-wrap: anywhere; }
.progress { color: var(--text-dim); font-size: 13px; }
.state-line { font-size: 13px; color: var(--text-dim); min-height: 18px; margin-top: 8px; }

/* ---------- sheet ---------- */
.sheet {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: flex-end;
  z-index: 30;
}
.sheet-body {
  background: var(--surface);
  width: 100%;
  max-height: 82vh;
  overflow-y: auto;
  border-radius: 18px 18px 0 0;
  padding: 18px 16px calc(env(safe-area-inset-bottom) + 18px);
}
.sheet-body h2 { margin-top: 0; }

/* ---------- toast ---------- */
.toast {
  position: fixed;
  left: 12px; right: 12px;
  bottom: calc(env(safe-area-inset-bottom) + var(--tabbar-h) + 12px);
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  font-size: 14px;
  text-align: center;
  z-index: 40;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.25);
}

[hidden] { display: none !important; }
