/* Reckon — "paper meets terminal". Warm ledger aesthetic, one calm accent,
   ruled baseline, monospace numbers that line up. Light + dark themes. */

:root {
  --accent: #0f766e;      /* teal — results */
  --accent-2: #b45309;    /* amber — highlights/pro */
  --pos: #15803d;
  --neg: #b91c1c;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", monospace;
  --ui: "Figtree", -apple-system, "Segoe UI", sans-serif;
  --disp: "Fraunces", Georgia, serif;
  --line-h: 30px;
  --pad-x: 26px;
}

/* ── Dark (default) ── */
[data-theme="dark"] {
  --bg: #111318;
  --paper: #15171d;
  --ink: #e7e5df;
  --ink-dim: #9a988f;
  --ink-faint: #63615b;
  --rule: rgba(255,255,255,0.045);
  --seam: rgba(255,255,255,0.08);
  --chip: #1d2027;
  --accent-ink: #5eead4;
  --result: #5eead4;
}
/* ── Light (paper) ── */
[data-theme="light"] {
  --bg: #eae6dc;
  --paper: #faf7f0;
  --ink: #232019;
  --ink-dim: #6b6658;
  --ink-faint: #a9a394;
  --rule: rgba(0,0,0,0.05);
  --seam: rgba(0,0,0,0.10);
  --chip: #efe9dc;
  --accent-ink: #0f766e;
  --result: #0f766e;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--ui);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* ── Top bar ── */
.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 0 16px; height: 54px; flex-shrink: 0;
  background: var(--bg);
  border-bottom: 1px solid var(--seam);
}
.brand { display: flex; align-items: baseline; gap: 9px; }
.brand-mark {
  font-family: var(--disp); font-size: 22px; color: var(--paper);
  background: var(--accent); width: 30px; height: 30px; border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
  align-self: center; font-weight: 600;
}
.brand-name { font-family: var(--disp); font-size: 23px; font-weight: 600; letter-spacing: -.01em; }
.brand-tag { font-size: 12px; color: var(--ink-faint); font-style: italic; font-family: var(--disp); }

.tabs { display: flex; gap: 4px; flex: 1; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  display: inline-flex; align-items: center; gap: 7px; white-space: nowrap;
  padding: 6px 11px; border-radius: 8px; cursor: pointer; border: 1px solid transparent;
  color: var(--ink-dim); font-weight: 500; font-size: 13px; background: none;
  max-width: 180px;
}
.tab:hover { background: var(--chip); }
.tab.active { background: var(--chip); color: var(--ink); border-color: var(--seam); }
.tab-name { overflow: hidden; text-overflow: ellipsis; }
.tab-close { opacity: .5; font-size: 14px; line-height: 1; }
.tab-close:hover { opacity: 1; color: var(--neg); }

.topbar-actions { display: flex; align-items: center; gap: 6px; }
.icon-btn {
  width: 34px; height: 34px; border-radius: 8px; border: 1px solid var(--seam);
  background: var(--paper); color: var(--ink-dim); cursor: pointer; font-size: 16px;
  display: inline-flex; align-items: center; justify-content: center;
}
.icon-btn:hover { color: var(--ink); border-color: var(--ink-faint); }
.btn {
  font-family: var(--ui); font-weight: 600; font-size: 13px; cursor: pointer;
  border-radius: 8px; padding: 8px 14px; border: 1px solid var(--seam);
  background: var(--chip); color: var(--ink);
}
.btn.ghost { background: none; }
.btn:hover { border-color: var(--ink-faint); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.wide { width: 100%; }
.pro-badge {
  font-family: var(--mono); font-size: 10px; letter-spacing: .2em; color: #fff;
  background: var(--accent); border-radius: 5px; padding: 4px 7px;
}

/* ── Workspace / notepad ── */
.workspace { flex: 1; overflow: hidden; display: flex; padding: 18px; }
.pad {
  flex: 1; display: grid;
  grid-template-columns: 42px 1fr minmax(150px, 300px);
  background: var(--paper);
  border: 1px solid var(--seam);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 20px 50px rgba(0,0,0,.18);
  position: relative;
}
/* shared vertical scroll: all three columns scroll together via JS + overflow */
.gutter, .input, .results {
  padding-top: 18px; padding-bottom: 40vh;
  line-height: var(--line-h);
  font-family: var(--mono);
  font-size: 15px;
  overflow: hidden;
}
.gutter {
  text-align: right; padding-right: 10px; color: var(--ink-faint);
  user-select: none; font-size: 12px; border-right: 1px solid var(--rule);
  background: linear-gradient(to right, transparent, var(--rule) 100%);
  white-space: pre;                 /* one line number per row, no wrapping */
}
.input {
  border: 0; resize: none; outline: none; background: transparent; color: var(--ink);
  padding-left: var(--pad-x); padding-right: 20px;
  white-space: pre; overflow-x: auto; overflow-y: scroll;
  caret-color: var(--accent);
  scrollbar-width: thin;
}
.input::-webkit-scrollbar { height: 8px; width: 8px; }
.input::-webkit-scrollbar-thumb { background: var(--seam); border-radius: 4px; }
.results {
  padding-right: var(--pad-x); padding-left: 14px;
  border-left: 1px solid var(--rule);
  overflow: hidden; text-align: right;
  background: linear-gradient(to left, transparent, var(--rule) 140%);
}
.res-line { height: var(--line-h); line-height: var(--line-h); white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; }
.res-line.result, .res-line.assign { color: var(--result); cursor: pointer; }
.res-line.result:hover, .res-line.assign:hover { text-decoration: underline; }
.res-line.assign { opacity: .82; }
.res-line.error { color: var(--neg); opacity: .7; font-family: var(--ui); font-size: 12px; font-style: italic; }
.res-line.copied { color: var(--accent-2); }

/* ── Status bar ── */
.statusbar {
  flex-shrink: 0; height: 34px; display: flex; align-items: center; gap: 10px;
  padding: 0 18px; font-size: 12px; color: var(--ink-faint);
  border-top: 1px solid var(--seam); background: var(--bg);
}
.stat-sep { opacity: .5; }
.stat-grow { flex: 1; }
#stat-total { color: var(--result); font-family: var(--mono); }
.stat-hint kbd {
  font-family: var(--mono); font-size: 10px; background: var(--chip);
  border: 1px solid var(--seam); border-radius: 4px; padding: 1px 5px;
}
.stat-privacy { color: var(--ink-faint); }
@media (max-width: 820px) { .stat-hint { display: none; } }

/* ── Modals ── */
.modal {
  border: 1px solid var(--seam); border-radius: 16px; padding: 0;
  background: var(--paper); color: var(--ink);
  width: min(560px, calc(100vw - 32px));
  box-shadow: 0 40px 120px rgba(0,0,0,.5);
}
.modal::backdrop { background: rgba(0,0,0,.5); backdrop-filter: blur(3px); }
.modal-body { padding: 28px 26px; position: relative; }
.modal-close {
  position: absolute; top: 14px; right: 14px; background: none; border: 0;
  color: var(--ink-faint); font-size: 15px; cursor: pointer;
}
.modal-title { font-family: var(--disp); font-weight: 600; font-size: 26px; margin: 0 0 18px; }
.cheat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 22px; }
.cheat-row { display: flex; justify-content: space-between; gap: 10px; padding: 5px 0; border-bottom: 1px solid var(--rule); }
.cheat-in { font-family: var(--mono); font-size: 12.5px; color: var(--ink); }
.cheat-out { font-family: var(--mono); font-size: 12.5px; color: var(--result); white-space: nowrap; }
.cheat-foot { margin: 18px 0 0; font-size: 12.5px; color: var(--ink-faint); }
@media (max-width: 560px) { .cheat-grid { grid-template-columns: 1fr; } }

/* Pro modal (shared styles reused from Moonshot pattern) */
.pro-head { display:flex; align-items:center; gap:12px; margin-bottom:14px; }
.pro-mark { font-family: var(--disp); font-size: 26px; color: var(--paper); background: var(--accent); width: 40px; height: 40px; border-radius: 10px; display:inline-flex; align-items:center; justify-content:center; }
.pro-title { font-family: var(--disp); font-weight: 600; font-size: 26px; margin: 0; }
.pro-perks { list-style: none; margin: 0 0 18px; padding: 0; font-size: 14px; line-height: 2; color: var(--ink-dim); }
.pro-perks li::before { content: "＝ "; color: var(--accent); }
.pro-divider { display:flex; align-items:center; gap:12px; margin:16px 0 12px; font-family: var(--mono); font-size:10px; letter-spacing:.2em; text-transform:uppercase; color: var(--ink-faint); }
.pro-divider::before, .pro-divider::after { content:""; flex:1; height:1px; background: var(--seam); }
.pay-addr { display:flex; gap:8px; align-items:center; margin-bottom: 12px; }
.pay-addr code { flex:1; font-family: var(--mono); font-size: 10.5px; word-break: break-all; background: var(--chip); border:1px solid var(--seam); border-radius:8px; padding:9px 10px; user-select: all; }
.pay-step { font-size: 12.5px; color: var(--ink-dim); margin: 0 0 8px; }
.pay-step strong { color: var(--accent-ink); }
.pay-row { display:flex; gap:8px; }
.text-input { flex:1; background: var(--paper); color: var(--ink); border:1px solid var(--seam); border-radius:8px; padding:9px 10px; font-family: var(--ui); font-size: 13px; outline:none; }
.text-input:focus { border-color: var(--accent); }
.pay-msg { min-height: 16px; margin: 10px 0 0; font-size: 12px; color: var(--ink-faint); }
.pay-msg.ok { color: var(--pos); } .pay-msg.err { color: var(--neg); }
.card-links { display:flex; gap:8px; }
.wallet-link { margin-bottom: 12px; color: var(--accent-ink); font-size: 13px; }

/* ── Toast ── */
.toast {
  position: fixed; inset: auto; bottom: 46px; left: 50%; margin: 0;
  transform: translate(-50%, 12px); background: var(--chip); color: var(--ink);
  border: 1px solid var(--seam); border-radius: 10px; padding: 10px 16px; font-size: 13px;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 100;
  box-shadow: 0 12px 40px rgba(0,0,0,.4);
}
.toast:popover-open { display: block; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 640px) {
  .brand-tag { display: none; }
  .workspace { padding: 8px; }
  .pad { grid-template-columns: 34px 1fr minmax(110px, 40%); border-radius: 10px; }
  .gutter,.input,.results { font-size: 14px; }
}
