/* Market Watch — styles. System fonts only (no outside font services). */
:root {
  --bg: #f4f5f2; --card: #ffffff; --ink: #1b1f1c; --muted: #5f6862; --faint: #8b938d;
  --line: #e3e6e1; --accent: #1f7a55; --accent-ink: #ffffff; --accent-soft: #e3f1ea;
  --warn: #a35a00; --warn-soft: #fff3e0; --bad: #b3261e; --chip: #eef0ec;
  --buy: #1f7a55; --sell: #a3401e; --news: #2f5d9b; --read: #7a4a9b; --hold: #5b6b2f;
  --radius: 14px; --tabh: 58px;
  --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121412; --card: #1c1f1d; --ink: #ecefeb; --muted: #a9b1ab; --faint: #7d857f;
    --line: #2c312d; --accent: #4cc38a; --accent-ink: #0d1a13; --accent-soft: #1d3329;
    --warn: #f0b35a; --warn-soft: #33281a; --bad: #ff8a80; --chip: #262a27;
    --buy: #4cc38a; --sell: #ff9a73; --news: #8fb6ff; --read: #d0a6ff; --hold: #c5d47e;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body {
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-text-size-adjust: 100%; overscroll-behavior-y: none;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }
[hidden] { display: none !important; }

#top {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between;
  padding: calc(var(--safe-t) + 10px) 18px 8px; background: color-mix(in srgb, var(--bg) 92%, transparent);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
}
#top h1 { font-size: 28px; line-height: 1.15; margin: 0; letter-spacing: -0.02em; }
.icon-btn { border: 0; background: transparent; color: var(--muted); padding: 8px; margin-right: -8px; border-radius: 10px; }
.back { border: 0; background: none; color: var(--accent); padding: 4px 0; font-size: 16px; margin-bottom: 4px; }

#view { padding: 4px 16px calc(var(--tabh) + var(--safe-b) + 24px); outline: none; max-width: 680px; margin: 0 auto; }

#tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; display: flex; justify-content: space-around;
  padding: 6px 4px calc(var(--safe-b) + 4px); background: color-mix(in srgb, var(--card) 94%, transparent);
  border-top: 1px solid var(--line); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
}
#tabs button {
  flex: 1; border: 0; background: none; color: var(--faint); display: flex; flex-direction: column; align-items: center;
  gap: 2px; font-size: 11px; padding: 4px 0;
}
#tabs svg { width: 25px; height: 25px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
#tabs button.on { color: var(--accent); }

.status { color: var(--muted); font-size: 14px; margin: 0 2px 12px; display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; }
.status .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); display: inline-block; margin-right: 4px; }
.status .dot.old { background: var(--warn); }
.sub { font-size: 15px; color: var(--muted); margin: -2px 2px 10px; }

.banner { background: var(--warn-soft); color: var(--warn); border-radius: 12px; padding: 10px 12px; font-size: 14px; margin-bottom: 12px; border: 0; width: 100%; text-align: left; }
.btn {
  border: 0; border-radius: 12px; padding: 11px 16px; background: var(--accent); color: var(--accent-ink); font-weight: 600;
}
.btn.ghost { background: var(--chip); color: var(--ink); font-weight: 500; }
.btn.small { padding: 7px 12px; font-size: 14px; border-radius: 10px; }
.btn.danger { background: transparent; color: var(--bad); border: 1px solid var(--line); }
.btn:disabled { opacity: .55; }
.row-btns { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0; }

h2.sec { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--faint); margin: 22px 4px 8px; font-weight: 600; }

.card { background: var(--card); border-radius: var(--radius); padding: 14px 14px 12px; margin-bottom: 10px; box-shadow: 0 1px 0 var(--line); }
.card .chips { display: flex; gap: 6px; margin-bottom: 6px; flex-wrap: wrap; }
.chip { font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--chip); color: var(--muted); }
.chip.buy { color: var(--buy); } .chip.sell { color: var(--sell); } .chip.news { color: var(--news); }
.chip.read { color: var(--read); } .chip.hold { color: var(--hold); } .chip.start { background: var(--accent-soft); color: var(--accent); }
.card h3 { font-size: 17px; line-height: 1.3; margin: 0 0 4px; font-weight: 600; }
.card .body { margin: 6px 0 0; white-space: pre-line; color: var(--ink); font-size: 15px; }
.card .why { margin: 8px 0 0; color: var(--muted); font-size: 14px; }
.card .why b { color: var(--ink); font-weight: 600; }
.card .meta { margin-top: 8px; font-size: 12.5px; color: var(--faint); display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: center; }
.card .more { border: 0; background: none; color: var(--accent); padding: 0; font-size: 14px; }
.card .lines { margin: 8px 0 0; padding: 10px 12px; background: var(--bg); border-radius: 10px; font-size: 14px; }
.card .lines div { padding: 2px 0; }
.card .lines a { display: block; padding: 4px 0; }
.card a.open { font-size: 14px; text-decoration: none; font-weight: 500; }

.term { border: 0; background: none; padding: 0; color: inherit; font: inherit; text-decoration: underline dotted var(--faint); text-underline-offset: 3px; }
.term .i { display: inline-flex; align-items: center; justify-content: center; width: 15px; height: 15px; margin-left: 2px;
  border-radius: 50%; border: 1.3px solid var(--accent); color: var(--accent); font-size: 10px; font-weight: 700; font-style: normal;
  vertical-align: 2px; text-decoration: none; font-family: Georgia, serif; }

.empty { text-align: center; color: var(--muted); padding: 28px 16px 8px; }
.empty .big { font-size: 19px; color: var(--ink); font-weight: 600; margin-bottom: 4px; }

.recap { background: var(--accent-soft); }
.recap h3 { color: var(--accent); }
.recap .grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; margin: 8px 0; font-size: 14px; }
.recap .grid b { font-size: 18px; margin-right: 6px; color: var(--ink); }
.recap ul { margin: 6px 0 0; padding-left: 18px; font-size: 14px; }

.list { background: var(--card); border-radius: var(--radius); overflow: hidden; margin-bottom: 10px; }
.list .li { display: flex; align-items: center; gap: 10px; width: 100%; padding: 12px 14px; border: 0; background: none; text-align: left; border-bottom: 1px solid var(--line); }
.list .li:last-child { border-bottom: 0; }
.list .li .grow { flex: 1; min-width: 0; }
.list .li .t { font-weight: 600; }
.list .li .s { font-size: 13.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.list .li .sym { font-size: 12px; font-weight: 700; color: var(--muted); background: var(--chip); padding: 2px 7px; border-radius: 6px; }
.list .li .chev { color: var(--faint); font-size: 20px; }
.list .li .warn { color: var(--warn); font-size: 13px; }

.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table td { padding: 6px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
.table td.r { text-align: right; white-space: nowrap; color: var(--muted); padding-left: 10px; }

input.search, textarea, input.field {
  width: 100%; border: 1px solid var(--line); background: var(--card); border-radius: 12px; padding: 11px 12px; font-size: 16px; outline: none;
}
input.search:focus, textarea:focus, input.field:focus { border-color: var(--accent); }
textarea { min-height: 90px; resize: vertical; }

.seg { display: flex; background: var(--chip); border-radius: 11px; padding: 3px; margin: 4px 0 12px; }
.seg button { flex: 1; border: 0; background: none; padding: 7px 4px; border-radius: 9px; font-size: 13.5px; color: var(--muted); }
.seg button.on { background: var(--card); color: var(--ink); font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,.08); }

.note { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.note:last-child { border-bottom: 0; }
.note .check { flex: none; width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--faint); background: none; margin-top: 1px; display: flex; align-items: center; justify-content: center; color: var(--accent-ink); font-size: 14px; padding: 0; }
.note .check.on { background: var(--accent); border-color: var(--accent); }
.note .txt { flex: 1; white-space: pre-wrap; word-break: break-word; }
.note.done .txt { color: var(--faint); text-decoration: line-through; }
.note .when { font-size: 12px; color: var(--faint); margin-top: 2px; }
.note .del { border: 0; background: none; color: var(--faint); font-size: 20px; padding: 0 2px; line-height: 1; }

.learn-item { border-bottom: 1px solid var(--line); }
.learn-item:last-child { border-bottom: 0; }
.learn-item button { width: 100%; text-align: left; border: 0; background: none; padding: 12px 14px; font-weight: 600; display: flex; justify-content: space-between; }
.learn-item .def { padding: 0 14px 12px; font-size: 15px; }
.learn-item .def p { margin: 0 0 6px; }
.learn-item .def .w { color: var(--muted); }

/* PIN screen */
.pin { display: flex; flex-direction: column; align-items: center; padding-top: 6vh; text-align: center; }
.pin .logo { width: 72px; height: 72px; border-radius: 18px; margin-bottom: 14px; }
.pin h2 { margin: 0 0 4px; font-size: 22px; }
.pin p { margin: 0 0 18px; color: var(--muted); min-height: 1.4em; }
.pin p.err { color: var(--bad); }
.dots { display: flex; gap: 16px; margin-bottom: 26px; }
.dots i { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--muted); }
.dots i.on { background: var(--ink); border-color: var(--ink); }
.pad { display: grid; grid-template-columns: repeat(3, 76px); gap: 14px 22px; }
.pad button { width: 76px; height: 76px; border-radius: 50%; border: 0; background: var(--card); font-size: 30px; font-weight: 400; box-shadow: 0 1px 0 var(--line); }
.pad button:active { background: var(--chip); }
.pad button.blank { visibility: hidden; }
.pad button.del { background: none; box-shadow: none; font-size: 17px; color: var(--muted); }
.shake { animation: shake .35s; }
@keyframes shake { 20%, 60% { transform: translateX(-9px); } 40%, 80% { transform: translateX(9px); } }

/* Bottom sheet */
#sheet-wrap { position: fixed; inset: 0; z-index: 20; }
#sheet-bg { position: absolute; inset: 0; background: rgba(0,0,0,.35); }
#sheet {
  position: absolute; left: 0; right: 0; bottom: 0; max-height: 88vh; overflow: auto; background: var(--bg);
  border-radius: 20px 20px 0 0; padding: 10px 18px calc(var(--safe-b) + 20px); max-width: 680px; margin: 0 auto;
  animation: up .22s ease-out;
}
@keyframes up { from { transform: translateY(40px); opacity: .6; } to { transform: none; opacity: 1; } }
#sheet .grab { width: 38px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 12px; }
#sheet h2 { margin: 0 0 8px; font-size: 21px; }
#sheet .x { float: right; border: 0; background: var(--chip); color: var(--muted); width: 30px; height: 30px; border-radius: 50%; font-size: 17px; line-height: 1; }
#sheet .lbl, .lbl { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--faint); margin: 14px 0 4px; }

#toast { position: fixed; left: 50%; bottom: calc(var(--tabh) + var(--safe-b) + 18px); transform: translateX(-50%) translateY(20px); opacity: 0;
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-size: 14px; transition: .2s; pointer-events: none; z-index: 30; max-width: 90vw; text-align: center; }
#toast.on { opacity: 1; transform: translateX(-50%); }

.spin { display: inline-block; width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: r .8s linear infinite; vertical-align: -2px; }
@keyframes r { to { transform: rotate(360deg); } }
.loading { text-align: center; color: var(--faint); padding: 40px 0; }
.small:not(.btn) { font-size: 13px; color: var(--faint); }
