/* Paper theme: cream stock, ink colours, ruled lines, a newspaper/ledger feel. */
:root {
  color-scheme: light;
  --desk: #e9dfc8; /* page background behind the sheets */
  --paper: #fbf7ec; /* card sheets */
  --paper-2: #f3ecdb; /* inset strips, hover */
  --paper-3: #ece2cb;
  --line: #e4d8bf; /* ruled lines */
  --line-2: #cdbd9b; /* firmer borders */
  --ink: #2a2118;
  --muted: #6e5f4a;
  --faint: #9a8a70;
  --green: #2e7a4c;
  --green-bg: rgba(46, 122, 76, 0.1);
  --red: #b0372b;
  --red-bg: rgba(176, 55, 43, 0.09);
  --accent: #7a5a2e; /* papertrade brown */
  --accent-ink: #fbf5e6;
  --accent-bg: rgba(122, 90, 46, 0.1);
  --blue: #2f5596; /* ballpoint blue: the AI's own handwriting */
  --blue-bg: rgba(47, 85, 150, 0.08);
  --margin-red: #e2a79c;
  --radius: 4px;
  --shadow: 0 1px 0 rgba(255, 255, 255, 0.7) inset, 0 1px 2px rgba(70, 48, 16, 0.08), 0 10px 24px -14px rgba(70, 48, 16, 0.28);
  --serif: 'Newsreader', 'Iowan Old Style', Georgia, serif;
  --mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  --sans: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  /* fine paper grain */
  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.35 0 0 0 0 0.25 0 0 0 0 0.1 0 0 0 0.09 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

* { box-sizing: border-box; }
html, body { margin: 0; color: var(--ink); font-family: var(--sans); font-size: 14px; }
html { background: var(--desk); }
body {
  min-height: 100vh;
  background-color: var(--desk);
  background-image: var(--grain), radial-gradient(ellipse at 50% -10%, rgba(255, 250, 235, 0.75), transparent 60%);
}
a { color: var(--accent); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--ink); }
button { font: inherit; }
::selection { background: rgba(122, 90, 46, 0.22); }

/* ---------- top bar: a newspaper masthead ---------- */
.topbar {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 12px 20px 11px;
  background-color: rgba(251, 247, 236, 0.94); background-image: var(--grain);
  border-bottom: 3px double var(--line-2);
  backdrop-filter: blur(6px);
  position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: baseline; gap: 10px; }
.logo { font-family: var(--sans); font-weight: 600; font-size: 19px; letter-spacing: -0.03em; color: var(--ink); }
.cursor { color: var(--red); animation: blink 1.1s steps(1) infinite; }
.brand-sub { font-family: var(--serif); font-style: italic; font-size: 15px; color: var(--muted); }
.topnav { display: flex; align-items: center; gap: 8px; }
/* navigation: [ LABEL ] with the brackets opening up on hover */
.navlink {
  display: inline-flex; align-items: center; gap: 10px; padding: 6px 6px;
  font-family: var(--sans); font-size: 12.5px; font-weight: 500; letter-spacing: 0.22em; text-transform: uppercase;
  color: var(--muted); text-decoration: none; border-radius: var(--radius); transition: color 0.2s, background 0.2s;
}
.navlink::before { content: '['; }
.navlink::after { content: ']'; }
.navlink::before, .navlink::after { font-size: 17px; font-weight: 300; letter-spacing: 0; line-height: 1; color: var(--line-2); transition: transform 0.25s ease, color 0.2s; }
.navlink:hover, .navlink:focus-visible { color: var(--ink); background: rgba(122, 90, 46, 0.06); outline: none; }
.navlink:hover::before, .navlink:focus-visible::before { transform: translateX(-4px); color: var(--accent); }
.navlink:hover::after, .navlink:focus-visible::after { transform: translateX(4px); color: var(--accent); }
.navlink.active { color: var(--ink); }
.navlink.active::before, .navlink.active::after { color: var(--accent); }
.card-head h2 .pill { font-family: var(--mono); font-size: 11px; height: 22px; }
.btn-view { display: inline-flex; align-items: center; gap: 4px; text-decoration: none; color: var(--accent); border-color: var(--accent); font-weight: 600; }
.btn-view:hover { color: var(--accent-ink); background: var(--accent); border-color: var(--accent); }
.btn-view[hidden] { display: none; }
/* the bot's real account on papertrade.xyz, in the nav style */
.navlink-account[hidden] { display: none; }
.navlink-account .live-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 3px rgba(46, 122, 76, 0.16); margin-right: -2px; }
.navlink-addr { font-family: var(--mono); font-size: 12px; letter-spacing: 0.02em; text-transform: none; color: var(--ink); }
.navlink-ext { letter-spacing: 0; transition: transform 0.25s ease; }
.navlink-account:hover .navlink-ext { transform: translate(2px, -2px); color: var(--accent); }
.status { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; flex: 1; }
.pill {
  display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px;
  border: 1px solid var(--line-2); border-radius: 999px; font-size: 12px; color: var(--muted);
  font-family: var(--mono); white-space: nowrap; background: var(--paper);
}
/* SIMULATION as a rubber stamp */
#pill-mode {
  color: var(--red); border: 2px solid var(--red); border-radius: 3px; background: transparent;
  font-weight: 600; letter-spacing: 0.14em; height: 24px; transform: rotate(-2.5deg);
  box-shadow: 0 0 0 1px rgba(176, 55, 43, 0.15) inset; opacity: 0.9;
}
.pill-brain { color: var(--blue); border-color: rgba(47, 85, 150, 0.35); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); display: inline-block; }
.pill.ok .dot, .live-badge .dot { background: var(--green); box-shadow: 0 0 0 3px rgba(46, 122, 76, 0.16); }
.pill.bad .dot { background: var(--red); }
.countdown { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.countdown.busy { color: var(--blue); }
.controls { display: flex; gap: 8px; }
.btn {
  height: 32px; padding: 0 14px; border-radius: var(--radius); border: 1px solid var(--line-2);
  background: var(--paper); color: var(--ink); cursor: pointer; font-size: 13px; font-weight: 500;
  box-shadow: 0 1px 0 rgba(70, 48, 16, 0.08);
}
.btn:hover { border-color: var(--muted); background: #fffaf0; }
.btn:active { transform: translateY(1px); box-shadow: none; }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn-accent { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-accent:hover { background: #6a4d26; border-color: #6a4d26; }
.btn-ghost { background: transparent; color: var(--muted); box-shadow: none; }
.btn-sm { height: 26px; padding: 0 10px; font-size: 12px; }

/* a pinned note */
.notice {
  margin: 14px 20px 0; padding: 10px 14px; border-radius: 2px; font-size: 12.5px; color: var(--muted);
  background: var(--paper); border: 1px solid var(--line); box-shadow: var(--shadow);
}
.notice.warn { color: #6b4a12; background: #fbf0c9; border-color: #e9d590; }
/* Real-money modes: a solid red LIVE pill and banner, an amber LIVE-DRY stamp. */
#pill-mode.pill-live {
  color: #fff; background: var(--red); border-color: var(--red); transform: none; opacity: 1;
  animation: livepulse 1.6s ease-in-out infinite;
}
#pill-mode.pill-dry { color: #8a5a00; border-color: #c98a12; }
.notice.live { color: #fff; background: var(--red); border-color: #8f2a20; font-weight: 600; font-size: 13px; }
.notice.dry { color: #6b4a12; background: #fbf0c9; border-color: #c98a12; }
@keyframes livepulse { 50% { box-shadow: 0 0 0 5px rgba(176, 55, 43, 0.22); } }

/* ---------- KPI: a ledger row ---------- */
.kpis {
  display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 0;
  margin: 14px 20px 0; border: 1px solid var(--line-2); border-radius: var(--radius); overflow: hidden;
  background-color: var(--paper); background-image: var(--grain); box-shadow: var(--shadow);
}
.kpi { box-shadow: inset -1px 0 var(--line), inset 0 -1px var(--line); margin: 0 -1px -1px 0; padding: 12px 14px; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.kpi-label { font-family: var(--serif); font-size: 13px; color: var(--muted); font-style: italic; }
.kpi-value { font-family: var(--mono); font-size: 20px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; letter-spacing: -0.02em; }
.kpi-sub { font-family: var(--mono); font-size: 11.5px; color: var(--faint); min-height: 14px; }

/* ---------- grid ---------- */
.grid {
  display: grid; gap: 14px; padding: 14px 20px 20px;
  grid-template-columns: minmax(0, 1.75fr) minmax(340px, 1fr);
  grid-template-areas:
    'screen feed'
    'positions positions'
    'chart equity'
    'history history';
}
.screen-card { grid-area: screen; }
.chart-card { grid-area: chart; }
.feed-card { grid-area: feed; }
.positions-card { grid-area: positions; }
.equity-card { grid-area: equity; }
.history-card { grid-area: history; }

.card {
  background-color: var(--paper); background-image: var(--grain);
  border: 1px solid var(--line-2); border-radius: var(--radius); box-shadow: var(--shadow);
  display: flex; flex-direction: column; min-width: 0;
}
.card-head { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-bottom: 1px solid var(--line-2); min-height: 48px; flex-wrap: wrap; }
.card-head h2 { margin: 0; font-family: var(--serif); font-size: 18px; font-weight: 600; letter-spacing: -0.01em; display: flex; align-items: center; gap: 8px; }
.muted { color: var(--muted); font-size: 12px; }
.count { font-family: var(--mono); font-size: 11px; color: var(--muted); background: var(--paper-2); border: 1px solid var(--line-2); border-radius: 999px; padding: 1px 8px; }

.tabs { display: flex; gap: 4px; }
.tabs button {
  height: 28px; padding: 0 12px; border-radius: var(--radius); border: 1px solid transparent; background: transparent;
  color: var(--muted); cursor: pointer; font-family: var(--mono); font-size: 13px; font-weight: 600;
}
.tabs button:hover { color: var(--ink); }
.tabs button.active { background: var(--paper-2); border-color: var(--line-2); color: var(--ink); }
.tabs-small button { height: 24px; padding: 0 8px; font-size: 11.5px; font-weight: 500; }
.tabs .tab-pos { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); margin-left: 6px; vertical-align: middle; }
.quote { display: flex; align-items: baseline; gap: 10px; flex: 1; font-family: var(--mono); }
.quote-mid { font-size: 17px; font-weight: 600; transition: color 0.3s; }
.quote-mid.up { color: var(--green); }
.quote-mid.down { color: var(--red); }
.quote-ba { font-size: 11.5px; color: var(--faint); }

.chart { height: 430px; width: 100%; }
.chart-eq { height: 260px; }
.equity-card .chart-eq { flex: 1; height: auto; min-height: 260px; }
.legend { display: flex; gap: 16px; padding: 8px 14px 10px; font-size: 11.5px; color: var(--muted); flex-wrap: wrap; border-top: 1px solid var(--line); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.ln { display: inline-block; width: 18px; height: 0; border-top: 2px dashed; }
.ln-entry { border-color: var(--blue); }
.ln-tp { border-color: var(--green); }
.ln-sl { border-color: var(--red); }
.ln-bust { border-color: #7d1f16; border-top-style: dotted; }

/* ---------- AI feed: a notebook page ---------- */
/* the feed takes exactly the height of its row neighbour and scrolls inside */
.feed-card { height: 0; min-height: 100%; }
.feed {
  overflow-y: auto; padding: 4px 0; flex: 1; min-height: 0;
  scrollbar-width: thin; scrollbar-color: var(--line-2) transparent;
  background-image:
    linear-gradient(90deg, transparent 33px, var(--margin-red) 33px, var(--margin-red) 34px, transparent 34px),
    repeating-linear-gradient(180deg, transparent 0, transparent 23px, rgba(120, 150, 190, 0.16) 23px, rgba(120, 150, 190, 0.16) 24px);
  background-attachment: local;
}
.live-badge { display: inline-flex; align-items: center; gap: 5px; font-family: var(--mono); font-size: 10.5px; color: var(--green); text-transform: uppercase; font-weight: 500; }
.feed-status { font-size: 11px; }
.toggle { margin-left: auto; font-size: 12px; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.toggle input { accent-color: var(--accent); }

.entry { padding: 12px 14px 14px 46px; border-bottom: 1px dashed var(--line-2); }
.fresh { animation: slidein 0.35s ease-out; }
.entry-head { display: flex; align-items: center; gap: 8px; font-family: var(--mono); font-size: 11.5px; color: var(--faint); flex-wrap: wrap; }
.entry-head .cyc { color: var(--blue); font-weight: 600; }
.entry-head .conf { margin-left: auto; }
.conf-bar { display: inline-block; width: 46px; height: 4px; border-radius: 2px; background: var(--line); overflow: hidden; vertical-align: middle; margin-left: 4px; }
.conf-bar i { display: block; height: 100%; background: var(--blue); }
/* reasoning reads like pencil notes in the margin */
.thinking {
  margin: 8px 0 0; padding: 6px 10px; border-left: 2px dotted rgba(47, 85, 150, 0.45); background: var(--blue-bg);
  font-family: var(--serif); font-style: italic; font-size: 13.5px; line-height: 1.5; color: #3d4f78; white-space: pre-wrap; max-height: 180px; overflow-y: auto;
}
.feed.hide-thinking .thinking { display: none; }
.view { margin: 8px 0 0; font-family: var(--serif); font-size: 15.5px; line-height: 1.5; color: var(--ink); }
.actions { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
/* order tickets */
.act { border: 1px dashed var(--line-2); border-left: 3px solid var(--line-2); border-radius: 2px; padding: 7px 10px; background: #fffbf2; }
.act-top { display: flex; align-items: center; gap: 8px; font-family: var(--mono); font-size: 12px; font-weight: 600; flex-wrap: wrap; }
.act-reason { font-size: 12.5px; color: var(--muted); margin-top: 4px; line-height: 1.45; }
.act-note { font-size: 11.5px; color: #8a5a12; margin-top: 4px; font-family: var(--mono); }
.act.long { border-left-color: var(--green); }
.act.short { border-left-color: var(--red); }
.act.rejected, .act.error { opacity: 0.75; }
/* tags look stamped */
.tag { font-family: var(--mono); font-size: 10.5px; font-weight: 600; border-radius: 2px; padding: 1px 5px; text-transform: uppercase; letter-spacing: 0.04em; border: 1px solid currentColor; }
.tag.long { color: var(--green); background: var(--green-bg); }
.tag.short { color: var(--red); background: var(--red-bg); }
.tag.neutral { color: var(--muted); background: transparent; border-color: var(--line-2); }
.tag.warn { color: #8a5a12; background: rgba(200, 140, 30, 0.1); }
.tag.bad { color: var(--red); background: var(--red-bg); }
.tag.good { color: var(--green); background: var(--green-bg); }
.act-meta { color: var(--muted); font-weight: 500; }
.hold { font-family: var(--mono); font-size: 12px; color: var(--faint); margin-top: 8px; }
.err { color: var(--red); font-family: var(--mono); font-size: 12px; margin-top: 8px; }

.event { padding: 7px 14px 7px 46px; border-bottom: 1px dashed var(--line-2); font-family: var(--mono); font-size: 11.5px; color: var(--muted); display: flex; gap: 8px; }
.event time { color: var(--faint); flex: none; }
.event.good { color: var(--green); }
.event.warn { color: #8a5a12; }
.event.error { color: var(--red); font-weight: 600; }

.entry.pending .view { color: var(--blue); font-family: var(--mono); font-size: 12.5px; }
.typing::after { content: '▍'; animation: blink 1s steps(1) infinite; color: var(--blue); }
.dots::after { content: ''; animation: dots 1.4s steps(4) infinite; }
.feed > .empty { padding-left: 46px; text-align: left; font-family: var(--serif); font-style: italic; font-size: 14px; }

/* ---------- tables: a ledger ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.table th { text-align: left; font-weight: 600; color: var(--muted); font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.08em; padding: 8px 10px; border-bottom: 3px double var(--line-2); white-space: nowrap; background: var(--paper-2); }
.table td { padding: 7px 10px; vertical-align: top; border-bottom: 1px dotted var(--line-2); font-family: var(--mono); white-space: nowrap; }
.table tr:last-child td { border-bottom: none; }
.table .r { text-align: right; }
.table tbody tr { transition: background 0.2s; }
.table tbody tr:hover { background: rgba(122, 90, 46, 0.05); }
.table tbody tr.flash { animation: flash 1.4s ease-out; }
.pos { color: var(--green); }
.neg { color: var(--red); }
.sub { display: block; color: var(--faint); font-size: 11px; }
.danger { color: var(--red); font-weight: 600; }
.empty { padding: 22px 14px; color: var(--faint); text-align: center; font-size: 13.5px; font-family: var(--serif); font-style: italic; }
.table:has(tbody tr) + .empty { display: none; }
.history-card .table-wrap { max-height: 360px; overflow-y: auto; }

/* ---------- copy trading (in place of the AI feed) ---------- */
.copy { overflow-y: auto; flex: 1; min-height: 0; }
.copy[hidden], .feed[hidden], .toggle[hidden] { display: none; }
.copy-note { margin: 10px 14px 6px; line-height: 1.45; }
.copy .table td { vertical-align: middle; }
.copy .table td .sub { display: block; color: var(--muted); font-size: 11px; }
.copy .table a { color: inherit; }
.copy-h { margin: 14px 14px 6px; font-family: var(--serif); font-size: 15px; font-weight: 600; }
.copy-log { padding: 0 14px 12px; font-family: var(--mono); font-size: 12px; }
.copy-log .row { display: flex; gap: 8px; align-items: baseline; padding: 4px 0; border-bottom: 1px dotted var(--line-2); flex-wrap: wrap; }
.copy-log .row .t { color: var(--muted); }
.copy-log .row .note { color: var(--muted); flex-basis: 100%; font-size: 11px; }

.footer { padding: 6px 20px 26px; color: var(--muted); font-size: 13px; font-family: var(--serif); font-style: italic; }

@keyframes blink { 50% { opacity: 0; } }
@keyframes slidein { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
@keyframes flash { from { background: rgba(233, 196, 106, 0.35); } to { background: transparent; } }
@keyframes dots { 0% { content: ''; } 25% { content: '.'; } 50% { content: '..'; } 75% { content: '...'; } }

@media (max-width: 1200px) {
  .kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (max-width: 980px) {
  .grid { grid-template-columns: minmax(0, 1fr); grid-template-areas: 'screen' 'feed' 'positions' 'chart' 'equity' 'history'; }
  .feed-card { height: 560px; min-height: 0; }
}
@media (max-width: 640px) {
  .topbar { padding: 10px 16px; gap: 10px; position: static; }
  .controls { width: 100%; }
  .controls .btn { flex: 1; padding: 0 8px; white-space: nowrap; }
  .chart-card .card-head { gap: 8px; }
  .quote { order: -1; flex-basis: 100%; }
  .quote-ba { display: none; }
  #interval-tabs { margin-left: auto; }
  .notice, .kpis { margin-left: 16px; margin-right: 16px; }
  .grid { padding: 12px 16px 16px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .chart { height: 320px; }
  .footer { padding: 4px 16px 20px; }
  .entry, .event { padding-left: 40px; }
  .feed { background-image:
    linear-gradient(90deg, transparent 27px, var(--margin-red) 27px, var(--margin-red) 28px, transparent 28px),
    repeating-linear-gradient(180deg, transparent 0, transparent 23px, rgba(120, 150, 190, 0.16) 23px, rgba(120, 150, 190, 0.16) 24px); }
}

/* ---------- AI screen ---------- */
.mono { font-family: var(--mono); }
.rec { display: inline-flex; align-items: center; gap: 5px; font-family: var(--mono); font-size: 10.5px; font-weight: 600; color: var(--faint); letter-spacing: 0.06em; }
.rec i { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); display: inline-block; }
.screen-card.is-live .rec { color: var(--red); }
.screen-card.is-live .rec i { background: var(--red); animation: pulse 1.6s ease-in-out infinite; }
#screen-fullscreen { margin-left: auto; font-size: 14px; }
/* the browser window sits on the sheet like a pasted-in photo */
.browser { margin: 12px; border: 1px solid var(--line-2); border-radius: 6px; overflow: hidden; background: #f3ead6; display: flex; flex-direction: column; box-shadow: 0 2px 4px rgba(70, 48, 16, 0.1), 0 14px 30px -18px rgba(70, 48, 16, 0.45); }
.browser:fullscreen { margin: 0; border: 0; border-radius: 0; justify-content: center; background: var(--desk); }
.browser:fullscreen .viewport { max-height: calc(100vh - 34px); margin: 0 auto; width: auto; height: calc(100vh - 34px); }
.browser-bar { display: flex; align-items: center; gap: 10px; height: 34px; padding: 0 10px; background: var(--paper-3); border-bottom: 1px solid var(--line-2); }
.lights { display: flex; gap: 6px; }
.lights i { width: 10px; height: 10px; border-radius: 50%; display: block; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12); }
.lights i:nth-child(1) { background: #e8685c; } .lights i:nth-child(2) { background: #e5b44a; } .lights i:nth-child(3) { background: #6fae5a; }
.urlbar { flex: 1; min-width: 0; height: 22px; display: flex; align-items: center; gap: 6px; padding: 0 10px; border-radius: 4px; background: var(--paper); border: 1px solid var(--line); font-family: var(--mono); font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.urlbar b { color: var(--ink); font-weight: 500; }
.lock { font-size: 10px; }
.agent-chip { font-family: var(--mono); font-size: 10.5px; color: var(--accent); border: 1px solid rgba(122, 90, 46, 0.45); background: var(--accent-bg); border-radius: 999px; padding: 2px 8px; white-space: nowrap; }
.viewport { position: relative; width: 100%; aspect-ratio: 1280 / 800; background: #f3ead6; overflow: hidden; cursor: default; }
.viewport img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; display: block; user-select: none; -webkit-user-drag: none; }
.viewport img:not([src]) { visibility: hidden; }
.screen-placeholder { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-family: var(--serif); font-style: italic; font-size: 15px; text-align: center; padding: 20px; }
.screen-placeholder[hidden] { display: none; }

.ai-cursor { position: absolute; left: 50%; top: 45%; width: 0; height: 0; pointer-events: none; z-index: 3; transition: left 45ms linear, top 45ms linear; }
.ai-cursor svg { position: absolute; left: -3px; top: -2px; filter: drop-shadow(0 2px 2px rgba(60, 40, 10, 0.35)); transform-origin: 3px 2px; }
.ai-cursor.pressing svg { animation: press 0.25s ease-out; }
.ai-cursor-label { position: absolute; left: 16px; top: 18px; font-family: var(--mono); font-size: 10.5px; font-weight: 600; color: var(--accent-ink); background: var(--blue); border-radius: 3px; padding: 1px 6px; white-space: nowrap; box-shadow: 0 2px 5px rgba(40, 30, 10, 0.3); }
.ripple { position: absolute; width: 0; height: 0; pointer-events: none; z-index: 2; }
.ripple::before { content: ''; position: absolute; left: -22px; top: -22px; width: 44px; height: 44px; border-radius: 50%; border: 2px solid var(--accent); animation: ripple 0.9s ease-out forwards; }
.ripple.sim::before { border-style: dashed; border-color: var(--blue); animation-duration: 1.3s; }
.ripple.sim::after { content: attr(data-label); position: absolute; left: 14px; top: -30px; font-family: var(--mono); font-size: 10px; font-weight: 700; color: var(--accent-ink); background: var(--blue); border-radius: 2px; padding: 1px 5px; animation: fadeout 1.3s ease-out forwards; }
.ripple.live::before { border-color: var(--red); border-width: 3px; animation-duration: 1.3s; }
.ripple.live::after, .ripple.dry::after { content: attr(data-label); position: absolute; left: 14px; top: -30px; font-family: var(--mono); font-size: 10px; font-weight: 700; color: #fff; background: var(--red); border-radius: 2px; padding: 1px 5px; animation: fadeout 1.3s ease-out forwards; }
.ripple.dry::before { border-style: dashed; border-color: #c98a12; animation-duration: 1.3s; }
.ripple.dry::after { background: #c98a12; }

/* captions are little paper labels pinned to the screen */
.caption { position: absolute; left: 12px; bottom: 12px; max-width: calc(100% - 24px); z-index: 4; display: flex; align-items: center; gap: 8px; padding: 7px 12px 7px 8px; border-radius: 3px; background: var(--paper); border: 1px solid var(--line-2); font-size: 13px; color: var(--ink); box-shadow: 0 2px 3px rgba(70, 48, 16, 0.12), 0 10px 22px -10px rgba(70, 48, 16, 0.4); }
.caption[hidden] { display: none; }
.caption.pop { animation: slidein 0.25s ease-out; }
.caption-icon { flex: none; width: 20px; height: 20px; border-radius: 3px; display: grid; place-items: center; font-family: var(--mono); font-size: 11px; font-weight: 700; background: var(--paper-2); color: var(--muted); border: 1px solid var(--line-2); }
.caption.action .caption-icon { background: var(--blue); border-color: var(--blue); color: var(--accent-ink); }
.caption.done .caption-icon { background: var(--green); border-color: var(--green); color: var(--accent-ink); }
.caption.warn .caption-icon { background: var(--red); border-color: var(--red); color: var(--accent-ink); }
.caption.thinking .caption-icon { color: var(--blue); animation: spin 1.6s linear infinite; }

@keyframes pulse { 50% { opacity: 0.35; } }
@keyframes press { 40% { transform: scale(0.82); } }
@keyframes ripple { from { transform: scale(0.3); opacity: 1; } to { transform: scale(1.5); opacity: 0; } }
@keyframes fadeout { 0%, 70% { opacity: 1; } 100% { opacity: 0; } }
@keyframes spin { to { transform: rotate(360deg); } }
@media (max-width: 640px) {
  .browser { margin: 8px; }
  .agent-chip { display: none; }
  .caption { left: 6px; bottom: 6px; font-size: 11.5px; padding: 5px 8px 5px 6px; }
  .ai-cursor-label { display: none; }
}

/* ---------- on-screen keyboard over the AI screen ---------- */
.screen-card #screen-fullscreen { margin-left: 0; }
.viewport { container-type: inline-size; }
.kb {
  position: absolute; left: 50%; bottom: 0; width: 74%; z-index: 5; transform: translate(-50%, 0);
  padding: 1cqw 1.2cqw 1.2cqw; border: 1px solid var(--line-2); border-bottom: 0; border-radius: 1cqw 1cqw 0 0;
  background-color: rgba(251, 247, 236, 0.97); background-image: var(--grain);
  box-shadow: 0 -10px 28px -12px rgba(70, 48, 16, 0.45);
  animation: kb-in 0.3s ease-out;
}
.kb[hidden] { display: none; }
.viewport:not(.kb-open) .kb { animation: kb-out 0.28s ease-in forwards; }
.kb-compose {
  margin-bottom: 0.9cqw; padding: 0.7cqw 1cqw; border: 1px solid var(--line-2); border-radius: 0.6cqw;
  background: #fffdf6; box-shadow: inset 0 1px 2px rgba(70, 48, 16, 0.08);
  transition: transform 0.42s cubic-bezier(.5, -0.2, .8, .4), opacity 0.42s ease-in;
}
.kb-compose.sent { transform: translate(60%, -40%) scale(0.6); opacity: 0; }
.kb-to { display: block; font-family: var(--mono); font-size: 1.05cqw; color: var(--blue); margin-bottom: 0.3cqw; }
.kb-text {
  font-family: var(--serif); font-size: 1.55cqw; line-height: 1.35; color: var(--ink);
  height: calc(1.55cqw * 1.35 * 2); overflow: hidden; word-break: break-word;
}
.kb-text::after { content: '▍'; color: var(--blue); animation: blink 1s steps(1) infinite; }
.kb-keys { display: flex; flex-direction: column; gap: 0.45cqw; }
.kb-row { display: flex; gap: 0.45cqw; justify-content: center; }
.kb-key {
  flex: 1 1 0; max-width: 5cqw; height: 3.2cqw; display: grid; place-items: center;
  border: 1px solid var(--line-2); border-radius: 0.5cqw; background: var(--paper);
  font-family: var(--mono); font-size: 1.35cqw; color: var(--ink); text-transform: lowercase;
  box-shadow: 0 0.25cqw 0 var(--line-2); transition: transform 60ms, background 60ms, box-shadow 60ms;
}
.kb-key.down { transform: translateY(0.22cqw); background: var(--accent); color: var(--accent-ink); border-color: var(--accent); box-shadow: 0 0.03cqw 0 var(--accent); }
.kb-shift, .kb-back { max-width: 7.5cqw; flex-grow: 1.5; color: var(--muted); }
.kb-space { max-width: none; flex-grow: 6; }
.kb-send { max-width: 11cqw; flex-grow: 2.2; background: var(--blue-bg); color: var(--blue); font-weight: 600; text-transform: none; }
.kb-send.down { background: var(--blue); border-color: var(--blue); color: var(--accent-ink); box-shadow: 0 0.03cqw 0 var(--blue); }
/* keep the step caption visible above the keyboard */
.viewport.kb-open .caption { bottom: calc(26cqw + 10px); }
@keyframes kb-in { from { transform: translate(-50%, 100%); } to { transform: translate(-50%, 0); } }
@keyframes kb-out { to { transform: translate(-50%, 100%); } }

/* =====================================================================
   Theme 2: "Origami" — grey folded paper, like the P logo (switch in the top bar)
   ===================================================================== */
.brand-logo { display: block; align-self: center; width: 32px; height: 32px; border-radius: 6px; box-shadow: 0 1px 0 rgba(255, 255, 255, 0.6) inset, 0 2px 6px -2px rgba(70, 48, 16, 0.4); }
:root[data-theme="origami"] {
  color-scheme: light;
  --desk: #d5d5d8;
  --paper: #f4f4f5;
  --paper-2: #ececee;
  --paper-3: #e2e2e5;
  --line: #d9d9dc;
  --line-2: #c2c2c7;
  --ink: #141416;
  --muted: #5c5c63;
  --faint: #8a8a92;
  --green: #2a7a4e;
  --green-bg: rgba(42, 122, 78, 0.1);
  --red: #b23b3b;
  --red-bg: rgba(178, 59, 59, 0.09);
  --accent: #141416;
  --accent-ink: #f4f4f5;
  --accent-bg: rgba(20, 20, 22, 0.06);
  --blue: #3a3a42; /* the AI's own notes: graphite */
  --blue-bg: rgba(20, 20, 22, 0.035);
  --margin-red: transparent;
  --radius: 2px;
  --shadow: 0 1px 0 rgba(255, 255, 255, 0.95) inset, 0 1px 2px rgba(0, 0, 0, 0.07), 0 16px 30px -20px rgba(0, 0, 0, 0.42);
  --serif: 'Space Grotesk', 'Inter', system-ui, sans-serif;
  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.25 0 0 0 0 0.25 0 0 0 0 0.27 0 0 0 0.07 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  /* big folded facets behind everything: light faces and faces in shadow, as on the logo */
  --folds: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1200 900' preserveAspectRatio='xMidYMid slice'%3E%3Cpolygon points='0,0 420,0 0,260' fill='%23fff' opacity='.45'/%3E%3Cpolygon points='420,0 760,0 300,330' fill='%23fff' opacity='.22'/%3E%3Cpolygon points='0,260 420,0 300,330' fill='%23000' opacity='.035'/%3E%3Cpolygon points='1200,380 1200,900 820,900' fill='%23000' opacity='.06'/%3E%3Cpolygon points='1200,380 820,900 980,560' fill='%23fff' opacity='.28'/%3E%3Cpolygon points='0,900 0,640 300,900' fill='%23000' opacity='.05'/%3E%3C/svg%3E");
}
:root[data-theme="origami"] body {
  background-color: var(--desk);
  background-image: var(--grain), var(--folds), linear-gradient(160deg, #ebebed 0%, #d6d6d9 52%, #c8c8cc 100%);
  background-attachment: scroll, fixed, fixed;
  background-size: auto, cover, auto;
}
[data-theme="origami"] ::selection { background: rgba(20, 20, 22, 0.16); }
[data-theme="origami"] a { color: var(--ink); }

/* masthead: a sheet with a fold along it */
[data-theme="origami"] .topbar {
  background-color: rgba(240, 240, 242, 0.9);
  background-image: var(--grain), linear-gradient(100deg, rgba(255, 255, 255, 0.7) 0%, rgba(255, 255, 255, 0.15) 58%, rgba(0, 0, 0, 0.03) 58.1%, rgba(0, 0, 0, 0) 100%);
  border-bottom: 1px solid var(--line-2);
}
[data-theme="origami"] .brand { align-items: center; }
[data-theme="origami"] .brand-logo { box-shadow: 0 2px 6px -2px rgba(0, 0, 0, 0.45); }
[data-theme="origami"] .logo { font-family: 'Space Grotesk', var(--sans); letter-spacing: -0.02em; }
[data-theme="origami"] .brand-sub { font-family: var(--mono); font-style: normal; font-size: 11px; text-transform: uppercase; letter-spacing: 0.16em; }
[data-theme="origami"] .pill { background: rgba(255, 255, 255, 0.55); }
[data-theme="origami"] #pill-mode:not(.pill-live):not(.pill-dry) { color: var(--ink); border: 1px solid var(--ink); border-radius: 2px; transform: none; box-shadow: none; opacity: 1; background: transparent; }
[data-theme="origami"] .btn { background: linear-gradient(180deg, #fbfbfb 0%, #e9e9ec 100%); box-shadow: 0 1px 0 rgba(255, 255, 255, 0.9) inset, 0 1px 2px rgba(0, 0, 0, 0.1); }
[data-theme="origami"] .btn:hover { border-color: var(--muted); background: linear-gradient(180deg, #ffffff 0%, #eeeef0 100%); }
[data-theme="origami"] .btn-accent { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); box-shadow: 0 2px 6px -2px rgba(0, 0, 0, 0.5); }
[data-theme="origami"] .btn-accent:hover { background: #2b2b30; border-color: #2b2b30; }
[data-theme="origami"] .btn-ghost { background: transparent; box-shadow: none; }

[data-theme="origami"] .notice { background: var(--paper); }
[data-theme="origami"] .notice.warn, [data-theme="origami"] .notice.dry { color: #5e4a12; background: #efe9d8; border-color: #d2c59b; }

/* folded sheets: a light face and a face in shadow, split by one crease */
[data-theme="origami"] .card {
  background-color: var(--paper);
  background-image: var(--grain), linear-gradient(128deg, #fcfcfd 0%, #f2f2f3 46%, #e4e4e7 46.12%, #efeff1 100%);
  border-color: var(--line-2);
}
[data-theme="origami"] .kpis {
  background-color: var(--paper);
  background-image: var(--grain), linear-gradient(200deg, #fcfcfd 0%, #f2f2f3 40%, #e3e3e6 40.1%, #eeeef0 100%);
  border-color: var(--line-2);
}
[data-theme="origami"] .kpi-label { font-family: var(--sans); font-style: normal; font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.1em; }
[data-theme="origami"] .card-head { border-bottom-color: var(--line-2); }
[data-theme="origami"] .card-head h2 { font-family: 'Space Grotesk', var(--sans); font-size: 16px; font-weight: 600; letter-spacing: -0.01em; }
[data-theme="origami"] .tabs button.active { background: #fbfbfc; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08); }
[data-theme="origami"] .count { background: #fbfbfc; }
[data-theme="origami"] .ln-bust { border-color: #7a2323; }

/* AI feed: clean sheet, no notebook lines */
[data-theme="origami"] .feed { background-image: none; }
[data-theme="origami"] .entry, [data-theme="origami"] .event { padding-left: 14px; border-bottom: 1px solid var(--line); }
[data-theme="origami"] .feed > .empty { padding-left: 14px; }
[data-theme="origami"] .thinking { border-left: 2px solid #a3a3aa; background: rgba(20, 20, 22, 0.035); color: #4f4f56; font-size: 13px; }
[data-theme="origami"] .view { font-family: var(--sans); font-size: 14.5px; line-height: 1.55; }
[data-theme="origami"] .act { background: linear-gradient(180deg, #fdfdfd 0%, #f2f2f4 100%); border: 1px solid var(--line-2); border-left: 3px solid var(--line-2); }
[data-theme="origami"] .act.long { border-left-color: var(--green); }
[data-theme="origami"] .act.short { border-left-color: var(--red); }
[data-theme="origami"] .act-note, [data-theme="origami"] .event.warn { color: #7a5c10; }
[data-theme="origami"] .tag.warn { color: #7a5c10; background: rgba(150, 115, 30, 0.1); }
[data-theme="origami"] .empty, [data-theme="origami"] .footer { font-family: var(--sans); font-style: normal; }

/* ledger */
[data-theme="origami"] .table th { background: linear-gradient(180deg, #f6f6f7 0%, #e9e9ec 100%); border-bottom: 1px solid var(--line-2); }
[data-theme="origami"] .table td { border-bottom: 1px solid var(--line); }
[data-theme="origami"] .table tbody tr:hover { background: rgba(0, 0, 0, 0.025); }
[data-theme="origami"] .table tbody tr.flash { animation: flash-origami 1.4s ease-out; }
@keyframes flash-origami { from { background: rgba(20, 20, 22, 0.09); } to { background: transparent; } }

/* AI screen frame, captions and keyboard */
[data-theme="origami"] .browser { background: #e7e7e9; box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08), 0 22px 40px -24px rgba(0, 0, 0, 0.55); }
[data-theme="origami"] .browser:fullscreen { background: var(--desk); }
[data-theme="origami"] .browser-bar { background: linear-gradient(180deg, #f1f1f3 0%, #e1e1e4 100%); }
[data-theme="origami"] .urlbar { background: #fbfbfc; border-color: var(--line); }
[data-theme="origami"] .viewport { background: #e7e7e9; }
[data-theme="origami"] .agent-chip { color: var(--ink); border-color: rgba(20, 20, 22, 0.3); background: rgba(20, 20, 22, 0.05); }
[data-theme="origami"] .ai-cursor-label { background: var(--ink); color: #fff; }
[data-theme="origami"] .caption { background: #f8f8f9; color: var(--ink); }
[data-theme="origami"] .caption-icon { background: var(--paper-3); }
[data-theme="origami"] .kb {
  background-color: rgba(238, 238, 240, 0.97);
  background-image: linear-gradient(150deg, #fbfbfc 0%, #f0f0f2 50%, #e6e6e9 50.15%, #efeff1 100%);
  box-shadow: 0 -14px 30px -14px rgba(0, 0, 0, 0.45);
}
[data-theme="origami"] .kb-compose { background: #fdfdfd; }
[data-theme="origami"] .kb-to { color: var(--muted); }
[data-theme="origami"] .kb-text::after { color: var(--ink); }
[data-theme="origami"] .kb-key { background: linear-gradient(180deg, #ffffff 0%, #ececef 100%); border-color: #c2c2c7; color: var(--ink); box-shadow: 0 0.25cqw 0 #b4b4ba; }
[data-theme="origami"] .kb-key.down { background: var(--ink); color: #fff; border-color: var(--ink); box-shadow: 0 0.03cqw 0 #000; }
[data-theme="origami"] .kb-send { background: linear-gradient(180deg, #e9e9ec 0%, #dcdce0 100%); color: var(--ink); }
[data-theme="origami"] .kb-send.down { background: var(--ink); color: #fff; }
[data-theme="origami"] .ripple:not(.live):not(.dry)::before { border-color: var(--ink); }
[data-theme="origami"] .ripple.sim::after { background: var(--ink); color: #fff; }

/* real-account button in the header */
.btn-account { display: inline-flex; align-items: center; gap: 6px; text-decoration: none; color: var(--green); border-color: var(--green); background: var(--green-bg); font-weight: 600; }
.btn-account[hidden] { display: none; }
.btn-account:hover { color: var(--green); border-color: var(--green); filter: brightness(0.97); }
.btn-account .mono { font-weight: 500; font-size: 11px; }


/* ---------- site footer (rendered by /site.js on every page) ---------- */
.site-footer { margin-top: 28px; padding: 28px 20px 22px; border-top: 3px double var(--line-2); background-color: rgba(251, 247, 236, 0.7); background-image: var(--grain); color: var(--muted); font-size: 13px; }
.sf-top { max-width: 1180px; margin: 0 auto; display: grid; grid-template-columns: 1.6fr repeat(3, 1fr); gap: 24px; }
.sf-brand .sf-logo { display: flex; align-items: center; gap: 10px; }
.sf-brand .sf-logo img { width: 40px; height: 40px; border-radius: 7px; box-shadow: 0 2px 6px -2px rgba(70, 48, 16, 0.4); }
.sf-brand p { margin: 8px 0 0; max-width: 34ch; line-height: 1.5; font-family: var(--serif); font-style: italic; font-size: 14px; }
.sf-col h4 { margin: 2px 0 10px; font-size: 11px; font-weight: 600; letter-spacing: 0.18em; text-transform: uppercase; color: var(--faint); }
.sf-col ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 7px; }
.sf-col a { color: var(--ink); text-decoration: none; }
.sf-col a:hover { color: var(--accent); text-decoration: underline; }
.sf-soon { color: var(--faint); }
.sf-bottom { max-width: 1180px; margin: 22px auto 0; padding-top: 14px; border-top: 1px solid var(--line); display: flex; gap: 16px; justify-content: space-between; flex-wrap: wrap; font-size: 12px; color: var(--faint); }
@media (max-width: 760px) {
  .sf-top { grid-template-columns: 1fr 1fr; }
  .sf-brand { grid-column: 1 / -1; }
}
[data-theme="origami"] .site-footer { background-color: rgba(250, 250, 251, 0.8); }
[data-theme="origami"] .sf-brand p { font-family: var(--sans); font-style: normal; }
