/* ============================================================
   Lockstep Mini App -- Stage 2: shared design-kit applied
   Replaces the earlier terminal aesthetic (dark brass/ink) with the
   white/silver canvas + trustworthy blue + teal secondary system from
   /Users/bob/Projects/lockstep-design-kit/index.html. Tokens, component
   patterns (cards, buttons, data rows, elevation) are lifted directly
   from that kit -- this file adapts them to a single-column mobile app
   shell rather than the kit's own wide desktop-sidebar layout.
   ============================================================ */

@font-face {
  font-family: "Plex Sans";
  font-weight: 400 800;
  font-style: normal;
  font-display: swap;
  src: url("fonts/plex-sans-var.woff2") format("woff2");
}
@font-face {
  font-family: "Plex Mono";
  font-weight: 400;
  font-style: normal;
  font-display: swap;
  src: url("fonts/plex-mono-400.woff2") format("woff2");
}
@font-face {
  font-family: "Plex Mono";
  font-weight: 500;
  font-style: normal;
  font-display: swap;
  src: url("fonts/plex-mono-500.woff2") format("woff2");
}
@font-face {
  font-family: "Plex Mono";
  font-weight: 600;
  font-style: normal;
  font-display: swap;
  src: url("fonts/plex-mono-600.woff2") format("woff2");
}

:root {
  /* Canvas & elevation -- identical values to the shared kit. White base,
     elevation carried by border + soft shadow rather than a background
     jump, so a card floating on the app's own white background still
     reads as raised. */
  --canvas: #ffffff;
  --surface-1: #f6f7f9;
  --surface-2: #eef0f3;
  --surface-3: #e4e7ec;
  --border-subtle: #ebedf1;
  --border-default: #d8dce3;
  --border-strong: #b7bec9;

  --text-primary: #14171f;
  --text-secondary: #565d6d;
  --text-tertiary: #8a92a3;
  --text-on-brand: #ffffff;

  /* Brand -- same corrected blue as the kit (h~224, not the earlier
     indigo/violet drift). */
  --brand: #2a458f;
  --brand-strong: #182a5b;
  --brand-tint: #f0f3fc;
  --brand-tint-strong: #d7dff4;

  /* Secondary accent -- teal, same value as the kit. */
  --accent-teal: #137386;
  --accent-teal-tint: #ebf7f9;

  /* Semantic grade ramp -- deliberately never blue or teal. Same five
     values as the kit, Coinbase's own shipped red/green as the anchor. A
     risky grade must read as alarming regardless of how trustworthy the
     rest of the UI feels -- this is the one rule that never changes
     across any round of this rebuild. */
  --grade-f: #cf202f;
  --grade-d: #c74a18;
  --grade-c: #a8650a;
  --grade-b: #5c7a1e;
  --grade-a: #098351;
  --positive: #098351;
  --negative: #cf202f;

  --shadow-sm: 0 1px 2px rgba(20,23,31,0.05), 0 1px 1px rgba(20,23,31,0.03);
  --shadow-md: 0 3px 10px rgba(20,23,31,0.07), 0 1px 2px rgba(20,23,31,0.04);
  --shadow-lg: 0 12px 32px rgba(20,23,31,0.11), 0 2px 6px rgba(20,23,31,0.05);

  --space-1: 4px;  --space-2: 8px;  --space-3: 12px; --space-4: 16px;
  --space-5: 24px; --space-6: 32px;

  --duration-fast: 120ms;
  --duration-base: 200ms;
  --ease-standard: cubic-bezier(0.2, 0.7, 0.3, 1);
}

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  background: var(--canvas);
  color: var(--text-primary);
  font-family: "Plex Sans", -apple-system, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

a { color: var(--accent-teal); }
.num { font-variant-numeric: tabular-nums; }
code, .mono { font-family: "Plex Mono", ui-monospace, monospace; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 4px; }

/* ---------- App shell ---------- */
.term-window {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  min-width: 0;
}

/* Header -- replaces the old titlebar-with-dots. Shows the real logo
   lockup (the negative-space L, hand-cut, from the design kit's Logo
   mark section) plus the devnet safety badge, which stays -- it's a
   real, load-bearing signal, not decoration. */
.term-titlebar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  background: var(--canvas);
  border-bottom: 1px solid var(--border-subtle);
  position: sticky;
  top: 0;
  z-index: 10;
  min-width: 0;
}
.term-dots { display: none; } /* terminal-era window dots, no longer part of the mark */
.app-logo {
  display: flex;
  align-items: baseline;
  gap: 0;
  font-family: "Plex Sans", sans-serif;
  font-weight: 800;
  font-size: 17px;
  letter-spacing: -0.03em;
  color: var(--brand);
  line-height: 1;
}
.app-logo .logo-l { display: inline-block; width: 11px; height: 19px; vertical-align: -4px; margin-right: 1px; }
.app-logo .logo-l svg { display: block; overflow: visible; }
.term-title {
  flex: 1;
  font-size: 12px;
  color: var(--text-tertiary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.term-title b { display: none; } /* wordmark now carries the brand name, no duplicate text needed */
.term-badge {
  font-size: 10.5px;
  font-family: "Plex Mono", monospace;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #a05a06;
  background: #fdf3e4;
  border: 1px solid #f2ddb8;
  border-radius: 6px;
  padding: 3px 8px;
  flex-shrink: 0;
}

.term-body {
  flex: 1;
  min-width: 0;
  padding: var(--space-5) var(--space-4) 100px;
  max-width: 560px;
  width: 100%;
  margin: 0 auto;
  background: var(--surface-1);
}

.screen { display: none; }
.screen.active { display: block; animation: fadein 0.18s var(--ease-standard); }
@keyframes fadein { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  .screen.active { animation: none; }
}

/* Section label -- replaces the fake terminal prompt-line. A plain
   small-caps eyebrow, same convention as the kit's .kit-eyebrow. */
.prompt-line {
  font-family: "Plex Mono", monospace;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--brand);
  margin-bottom: var(--space-3);
  display: flex;
  align-items: center;
  gap: 2px;
}
.prompt-line .prompt-user, .prompt-line .prompt-path { display: none; } /* fake shell path, no longer shown */
.cursor { display: none; } /* blinking terminal cursor, dropped with the rest of the shell conceit */

/* ---------- Panels: real cards now (border + soft shadow, white on the
   app's light-gray canvas), not a bracket-cut terminal fieldset. Still a
   <fieldset>/<legend> underneath for the free semantic grouping, just
   restyled as a normal card with an inline title. ---------- */
.term-panel {
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  padding: var(--space-4);
  margin: 0 0 var(--space-4);
  background: var(--canvas);
  box-shadow: var(--shadow-sm);
  min-width: 0;
}
.term-panel > legend {
  padding: 0 0 var(--space-2);
  margin: 0 0 var(--space-3);
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border-subtle);
  width: 100%;
}

.muted { color: var(--text-secondary); }
.faint { color: var(--text-tertiary); }
.small { font-size: 13px; }
.hidden { display: none !important; }
.error-line { color: var(--negative); font-size: 13.5px; margin: 10px 0 0; display: flex; align-items: center; gap: 6px; }
.error-line::before { content: "\26A0"; font-size: 12px; } /* small warning glyph, not a terminal "x" */
.ok-line { color: var(--positive); font-size: 13.5px; margin: 10px 0 0; display: flex; align-items: center; gap: 6px; }
.ok-line::before { content: "\2713"; font-size: 12px; }

/* ---------- Buttons -- kit's real button system (gradient sheen on
   primary, proper shadow-lift, no bracket decoration). Active/pressed
   states matter more than hover here since this is a touch surface. ---------- */
.term-btn {
  font-family: "Plex Sans", sans-serif;
  font-size: 14.5px;
  font-weight: 600;
  background: var(--canvas);
  border: 1px solid var(--border-default);
  color: var(--text-primary);
  border-radius: 10px;
  padding: 13px 16px;
  width: 100%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: var(--shadow-sm);
  transition: background var(--duration-fast) var(--ease-standard), box-shadow var(--duration-fast) var(--ease-standard), transform var(--duration-fast) var(--ease-standard), border-color var(--duration-fast) var(--ease-standard);
}
.term-btn::before, .term-btn::after { content: none; } /* terminal bracket decoration, dropped */
.term-btn:active { transform: translateY(1px); box-shadow: var(--shadow-sm); }
.term-btn:disabled { opacity: 0.5; cursor: default; box-shadow: none; }
.term-btn.primary {
  background: linear-gradient(180deg, rgba(255,255,255,0.22) 0%, rgba(255,255,255,0) 55%), var(--brand);
  color: #fff;
  border-color: transparent;
  box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255,255,255,0.28);
}
.term-btn.primary:active { background: linear-gradient(180deg, rgba(255,255,255,0.22) 0%, rgba(255,255,255,0) 55%), var(--brand-strong); }
.term-btn.danger { border-color: #f0c6cb; color: var(--negative); }
.term-btn.danger:active { background: #fdf1f2; }
.term-btn + .term-btn { margin-top: var(--space-2); }

/* ---------- Wallet screen ---------- */
.addr-row {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface-1); border: 1px solid var(--border-subtle); border-radius: 10px;
  padding: 11px 12px; margin-bottom: var(--space-4);
}
.addr-row code { flex: 1; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-primary); }
.icon-btn { border: none; background: none; color: var(--text-secondary); font-size: 13px; cursor: pointer; padding: 4px 6px; font-family: "Plex Mono", monospace; border-radius: 6px; }
.icon-btn:active { color: var(--brand); background: var(--brand-tint); }

.balance-row { margin-bottom: var(--space-4); }
.balance-label { font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-tertiary); margin-bottom: 4px; font-weight: 600; }
.balance { font-size: 32px; font-weight: 700; font-family: "Plex Mono", monospace; letter-spacing: -0.01em; }
.balance span { font-size: 14px; color: var(--text-tertiary); font-weight: 500; margin-left: 6px; font-family: "Plex Sans", sans-serif; }

/* ---------- Watchlist / token rows -- same data-row pattern as the
   kit's data table (light dividers, hover/press highlight), collapsed
   to a single-column card list for phone width. ---------- */
.token-list { display: flex; flex-direction: column; border-top: 1px solid var(--border-subtle); }
.token-row {
  background: var(--canvas);
  padding: var(--space-3) 2px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px;
  cursor: pointer;
  border: none;
  border-bottom: 1px solid var(--border-subtle);
  width: 100%;
  font-family: inherit;
  color: inherit;
  text-align: left;
  transition: background var(--duration-fast) var(--ease-standard);
}
.token-row:active { background: var(--brand-tint); }
.token-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.token-symbol { font-weight: 700; font-size: 14.5px; }
.token-meta { font-size: 12px; color: var(--text-tertiary); }
.token-right { text-align: right; flex-shrink: 0; }
.token-right .grade { font-size: 13.5px; font-weight: 700; font-family: "Plex Mono", monospace; }
.token-right .pct { font-size: 12px; font-family: "Plex Mono", monospace; }
.grade-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.grade-dot.grade-A { background: var(--grade-a); }
.grade-dot.grade-B { background: var(--grade-b); }
.grade-dot.grade-C { background: var(--grade-c); }
.grade-dot.grade-D { background: var(--grade-d); }
.grade-dot.grade-F { background: var(--grade-f); }
.pct-up { color: var(--positive); }
.pct-down { color: var(--negative); }
.chevron { color: var(--text-tertiary); font-size: 12px; }

/* ---------- Audit screen ---------- */
.audit-input-row {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-1);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 2px 2px 2px 14px;
  margin-bottom: var(--space-3);
}
.audit-input-row .prefix { display: none; } /* fake shell prompt char, dropped */
.audit-input-row input {
  flex: 1;
  min-width: 0;
  background: none;
  border: none;
  color: var(--text-primary);
  font-family: "Plex Sans", sans-serif;
  font-size: 14.5px;
  padding: 12px 0;
  outline: none;
}
.audit-input-row input::placeholder { color: var(--text-tertiary); }
.audit-input-row button {
  flex-shrink: 0;
  background: var(--brand);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 10px 16px;
  font-family: "Plex Sans", sans-serif;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.audit-input-row button:disabled { opacity: 0.5; }
.audit-input-row button:active { background: var(--brand-strong); }

.grade-plate { display: flex; align-items: center; gap: var(--space-3); margin-bottom: 4px; }
.grade-letter {
  font-family: "Plex Mono", monospace;
  font-size: 26px; font-weight: 700; line-height: 1;
  width: 54px; height: 54px; border-radius: 12px;
  display: grid; place-items: center;
  color: #fff;
  flex-shrink: 0;
}
.grade-info .name { font-size: 15px; font-weight: 700; color: var(--text-primary); }
.grade-info .score { font-size: 12.5px; color: var(--text-tertiary); font-family: "Plex Mono", monospace; margin-top: 2px; }

.signal-row { padding: var(--space-2) 0; border-bottom: 1px solid var(--border-subtle); }
.signal-row:last-child { border-bottom: none; }
.signal-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-size: 13px; }
.signal-top .signal-name { color: var(--text-primary); font-weight: 500; }
.signal-top .signal-weight { color: var(--text-tertiary); font-size: 11.5px; font-family: "Plex Mono", monospace; }
.signal-detail { font-size: 12px; color: var(--text-secondary); margin-top: 3px; }

.note-block {
  font-size: 12.5px; color: var(--text-secondary);
  background: var(--surface-1);
  border-radius: 8px;
  padding: var(--space-3);
  margin-top: var(--space-4);
}

/* ---------- Bottom tab bar -- underline-on-active per the kit's nav
   convention, with real icons instead of bracket key hints. Keyboard
   shortcuts (1-4) still work via app.js's keydown handler; the visible
   [1]-style hint is dropped since it doesn't fit a touch-first app. ---------- */
.term-tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 20;
  display: flex;
  background: var(--canvas);
  border-top: 1px solid var(--border-subtle);
  padding-bottom: env(safe-area-inset-bottom, 0);
  box-shadow: 0 -2px 12px rgba(20,23,31,0.04);
}
.tab-btn {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-tertiary);
  font-family: "Plex Sans", sans-serif;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.01em;
  padding: 10px 4px 8px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.tab-btn .key { display: none; } /* bracket key-hint chip, dropped with the terminal styling */
.tab-btn svg { width: 21px; height: 21px; stroke: currentColor; }
.tab-btn.active { color: var(--brand); }

/* ---------- Add-to-watchlist (Audit result) ---------- */
.add-watchlist-row { margin-top: var(--space-4); padding-top: var(--space-4); border-top: 1px solid var(--border-subtle); }

/* ---------- My List screen ---------- */
.mylist-row {
  background: var(--canvas);
  border-bottom: 1px solid var(--border-subtle);
}
.mylist-row:last-child { border-bottom: none; }
.mylist-main {
  padding: var(--space-3) 2px;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.mylist-main.muted-entry { opacity: 0.55; }
.mylist-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.mute-btn, .expand-btn {
  border: 1px solid var(--border-default);
  background: var(--canvas);
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 13px;
  border-radius: 8px;
  padding: 7px 9px;
  cursor: pointer;
  line-height: 1;
}
.mute-btn.is-muted { color: var(--brand); border-color: var(--brand-tint-strong); background: var(--brand-tint); }
.mute-btn:active, .expand-btn:active { background: var(--surface-1); }
.expand-btn.is-open { color: var(--brand); border-color: var(--brand-tint-strong); }

.alert-config {
  padding: var(--space-1) 2px var(--space-4);
  border-top: 1px dashed var(--border-default);
  margin-top: var(--space-2);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.alert-config .alert-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
  color: var(--text-secondary);
  padding-top: var(--space-2);
}
.alert-config .alert-row label { flex: 1; }
.alert-config input[type="checkbox"] {
  accent-color: var(--brand);
  width: 18px; height: 18px;
  flex-shrink: 0;
  cursor: pointer;
}
.alert-config input[type="number"] {
  width: 68px;
  background: var(--surface-1);
  border: 1px solid var(--border-default);
  border-radius: 8px;
  color: var(--text-primary);
  font-family: "Plex Mono", monospace;
  font-size: 13px;
  padding: 7px 8px;
  text-align: right;
  flex-shrink: 0;
}
.alert-config input[type="number"]:disabled { opacity: 0.4; }
.alert-config-actions { display: flex; gap: 8px; margin-top: 4px; }
.alert-config-actions .term-btn { margin-top: 0; padding: 10px 12px; font-size: 13px; }
.alert-status { font-size: 12px; min-height: 14px; }

/* ---------- Activity feed (Audit screen) ---------- */
.activity-list { display: flex; flex-direction: column; border-top: 1px solid var(--border-subtle); }
.activity-row {
  background: var(--canvas);
  padding: 10px 2px;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  font-size: 12.5px;
  border-bottom: 1px solid var(--border-subtle);
}
.activity-row:last-child { border-bottom: none; }
.activity-row .sym { font-weight: 600; display: flex; align-items: center; gap: 8px; min-width: 0; }
.activity-row .sym-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.activity-row .grade { font-size: 12px; color: var(--text-tertiary); flex-shrink: 0; font-family: "Plex Mono", monospace; }
.activity-poll-note { font-size: 11px; color: var(--text-tertiary); margin-top: var(--space-3); text-align: center; }
