/* App: a ruled terminal. Panels share hairlines (grid gap on a hair background). */

body.app { min-height: 100svh; }

.appbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 20px;
  height: 60px; padding: 0 18px;
  background: rgba(11,10,9,.9); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--hair);
}
.appbar .brand { text-decoration: none; font-size: 28px; padding: 6px 0; margin-right: 6px; }
.mkts { display: flex; gap: 2px; }
.mkts button {
  display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 12px;
  border: 1px solid transparent; border-radius: var(--r); background: transparent; cursor: pointer;
  color: var(--ink2); transition: background-color .18s var(--ease), color .18s var(--ease), border-color .18s var(--ease);
}
.mkts button .sym { font-weight: 640; font-size: 14.5px; }
.mkts button .px { font-size: 13px; color: var(--ink3); }
.mkts button:hover { color: var(--ink); background: rgba(239,233,223,.04); }
.mkts button[aria-pressed='true'] { color: var(--ink); border-color: var(--hair); background: var(--panel); }
.mkts button[aria-pressed='true'] .px { color: var(--ink2); }
.appnav { display: flex; gap: 2px; }
.appnav a { color: var(--ink2); text-decoration: none; font-size: 14.5px; padding: 10px 10px; border-radius: var(--r); }
.appnav a:hover { color: var(--ink); }
.acct { margin-left: auto; display: flex; align-items: center; gap: 14px; position: relative; }
.bal { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.2; }
.bal .label { font-size: 10px; }
.bal .mono { font-size: 14px; }

.demo-note {
  margin: 0; display: flex; align-items: center; justify-content: center; gap: 14px; flex-wrap: wrap;
  padding: 8px 18px; border-bottom: 1px dashed rgba(239,233,223,.2);
  font-family: var(--mono); font-size: 12px; color: var(--ink2); text-align: center;
}
.linkbtn { background: none; border: 0; padding: 0 6px; min-height: 40px; margin: -8px 0; color: var(--ink); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; font: inherit; }

/* grid */
.grid {
  display: grid; grid-template-columns: minmax(0, 1fr) 340px 330px;
  gap: 1px; background: var(--hair); border-bottom: 1px solid var(--hair);
}
.col { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.panel { background: var(--bg); padding: 16px 18px 18px; min-width: 0; }
.col > .panel:last-child { flex: 1; }
.phead { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; min-height: 40px; }
.ptitle { margin: 0; font-size: 15px; font-weight: 640; letter-spacing: -0.005em; }
.psub { margin: 2px 0 0; font-size: 13px; color: var(--ink3); }

.seg { display: inline-flex; border: 1px solid var(--hair); border-radius: var(--r); padding: 2px; gap: 2px; }
.seg button { height: 38px; min-width: 40px; padding: 0 12px; border: 0; border-radius: 4px; background: transparent; color: var(--ink2); cursor: pointer; font-size: 13.5px; font-weight: 520; transition: background-color .15s var(--ease), color .15s var(--ease); }
.seg button:hover { color: var(--ink); }
.seg button[aria-pressed='true'] { background: var(--raised2); color: var(--ink); }
.seg button .mono { font-size: 12px; color: var(--ink3); margin-left: 4px; }

/* chart */
.chart-panel { padding-bottom: 10px; }
.quote { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.qsym { font-weight: 700; font-size: 18px; }
.qpx { font-size: 24px; letter-spacing: -0.02em; transition: color .3s var(--ease); }
.qchg { font-size: 13px; }
.qgap { flex-basis: 100%; font-size: 11.5px; color: var(--ink3); margin-top: -4px; }
.qgap.warn { color: var(--ink2); }
.chart-wrap { position: relative; height: clamp(320px, 46vh, 470px); }
.chart-wrap canvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: pan-y; }
.ohlc { position: absolute; left: 8px; top: 4px; font-size: 11px; color: var(--ink3); pointer-events: none; display: flex; gap: 10px; }

/* order */
.sides { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 18px; }
.side { height: 46px; border-radius: var(--r); border: 1px solid var(--hair); background: transparent; cursor: pointer; font-size: 15.5px; font-weight: 640; color: var(--ink2); transition: background-color .18s var(--ease), color .18s var(--ease), border-color .18s var(--ease), transform .12s var(--ease); }
.side:active { transform: scale(.97); }
.side.long[aria-pressed='true'] { background: var(--gain-dim); color: var(--gain); border-color: rgba(82,192,142,.45); }
.side.short[aria-pressed='true'] { background: var(--loss-dim); color: var(--loss); border-color: rgba(240,97,75,.45); }
.field { margin-bottom: 16px; }
.frow { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.inbox { display: flex; align-items: center; gap: 8px; height: 48px; padding: 0 12px; border: 1px solid var(--hair); border-radius: var(--r); background: var(--panel); transition: border-color .18s var(--ease); }
.inbox:focus-within { border-color: rgba(239,233,223,.45); }
.inbox input { flex: 1; min-width: 0; height: 100%; border: 0; background: transparent; color: var(--ink); font-size: 17px; outline: none; }
.inbox input::placeholder { color: var(--ink3); }
.inbox .pre { color: var(--ink3); }
.inbox.small { height: 44px; }
.inbox.small input { font-size: 16px; }
.chips { display: flex; gap: 4px; margin-top: 8px; flex-wrap: wrap; }
.chips button { flex: 1; height: 40px; min-width: 44px; border: 1px solid var(--hair2); border-radius: 4px; background: transparent; color: var(--ink2); cursor: pointer; font-family: var(--mono); font-size: 12px; transition: color .15s var(--ease), border-color .15s var(--ease), background-color .15s var(--ease); }
.chips button:hover { color: var(--ink); border-color: var(--hair); }
.chips button[aria-pressed='true'] { color: var(--ink); border-color: rgba(239,233,223,.4); background: var(--raised); }
.hint { margin: 6px 0 0; font-size: 12.5px; color: var(--ink3); }
.hint.err { color: var(--loss); }
.levval { font-size: 22px; letter-spacing: -0.02em; }

input[type='range'] { -webkit-appearance: none; appearance: none; width: 100%; height: 32px; background: transparent; cursor: pointer; margin: 0; }
input[type='range']::-webkit-slider-runnable-track { height: 3px; border-radius: 3px; background: linear-gradient(90deg, var(--ink) var(--fill, 50%), rgba(239,233,223,.14) var(--fill, 50%)); }
input[type='range']::-webkit-slider-thumb { -webkit-appearance: none; width: 20px; height: 20px; margin-top: -8.5px; border-radius: 50%; background: var(--ink); border: 4px solid var(--bg); box-shadow: 0 0 0 1px var(--ink); transition: transform .15s var(--ease); }
input[type='range']:active::-webkit-slider-thumb { transform: scale(1.12); }
input[type='range']::-moz-range-track { height: 3px; border-radius: 3px; background: rgba(239,233,223,.14); }
input[type='range']::-moz-range-progress { height: 3px; border-radius: 3px; background: var(--ink); }
input[type='range']::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: var(--ink); border: 3px solid var(--bg); }
input[type='range']:focus-visible { outline: none; }
input[type='range']:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 1px var(--ink), 0 0 0 5px rgba(239,233,223,.18); }

.disclose { display: flex; justify-content: space-between; align-items: center; width: 100%; height: 40px; padding: 0; border: 0; background: none; color: var(--ink2); cursor: pointer; font-size: 14px; }
.disclose:hover { color: var(--ink); }
.disclose[aria-expanded='true'] .mono { transform: rotate(45deg); }
.disclose .mono { transition: transform .2s var(--ease); font-size: 16px; }
.two { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 6px; margin-top: 4px; }
.two .inbox, .two input { min-width: 0; }

.summary { margin: 4px 0 16px; border-top: 1px solid var(--hair2); }
.summary div, .ep-rows div { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px solid var(--hair2); font-size: 13.5px; }
.summary dt, .ep-rows dt { color: var(--ink2); white-space: nowrap; }
.summary dd, .ep-rows dd { margin: 0; text-align: right; white-space: nowrap; }
.summary .strong dt, .ep-rows .strong dt { color: var(--ink); }
.go { width: 100%; --h: 52px; font-size: 16px; }
.fine { margin: 10px 0 0; font-size: 12.5px; color: var(--ink3); line-height: 1.5; }

/* positions */
.ptable { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.ptable th { text-align: left; font-family: var(--mono); font-weight: 400; font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--ink3); padding: 0 8px 8px 0; border-bottom: 1px solid var(--hair2); white-space: nowrap; }
.ptable td { padding: 10px 8px 10px 0; border-bottom: 1px solid var(--hair2); white-space: nowrap; vertical-align: middle; }
.ptable td.r, .ptable th.r { text-align: right; }
.ptable .mono { font-size: 13px; }
.mk { display: flex; flex-direction: column; line-height: 1.25; }
.mk b { font-weight: 640; }
.mk small { font-family: var(--mono); font-size: 11.5px; }
.state { font-family: var(--mono); font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--ink3); }
.pill { display: inline-block; font-family: var(--mono); font-size: 10.5px; letter-spacing: .06em; text-transform: uppercase; padding: 2px 6px; border-radius: 3px; border: 1px solid var(--hair); color: var(--ink2); }
.pill.liq { border-color: rgba(240,97,75,.5); color: var(--loss); }
.acts { display: flex; gap: 6px; justify-content: flex-end; }
.acts .btn { --h: 40px; padding: 0 12px; font-size: 13px; }
.empty { padding: 26px 0 18px; color: var(--ink2); font-size: 14px; }
.empty b { color: var(--ink); font-weight: 600; }
.pos-cards { display: none; }

/* tilt */
.tiltpx { font-size: 15px; }
.tiltp { display: flex; flex-direction: column; }
.tilt-wrap { position: relative; height: 210px; flex: 1; min-height: 210px; }
.tilt-wrap canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.tilt-info { margin: 10px 0 0; font-size: 13.5px; color: var(--ink2); line-height: 1.55; min-height: 3.1em; }
.tilt-info b { color: var(--ink); font-weight: 600; }

/* cope */
.sub-h { display: flex; justify-content: space-between; align-items: baseline; margin: 4px 0 8px; }
.rows { list-style: none; margin: 0 0 18px; padding: 0; border-top: 1px solid var(--hair2); }
.rows li { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--hair2); font-size: 13.5px; }
.rows li .meta { display: flex; flex-direction: column; line-height: 1.3; min-width: 0; }
.rows li .meta small { color: var(--ink3); font-size: 12px; }
.rows li .btn { --h: 40px; padding: 0 12px; font-size: 13px; }
.stake-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--hair2); border: 1px solid var(--hair2); border-radius: var(--r); overflow: hidden; margin-bottom: 12px; }
.stake-grid > div { background: var(--bg); padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; }
.stake-grid .mono { font-size: 15px; }
.stake-acts { display: flex; gap: 6px; flex-wrap: wrap; }
.stake-acts .btn { --h: 40px; padding: 0 12px; font-size: 13px; flex: 1; }

/* epoch */
.bell { display: flex; align-items: baseline; gap: 12px; margin: 2px 0 14px; }
.clock { font-size: 46px; letter-spacing: -0.04em; line-height: 1; }
.ep-rows { margin: 0 0 14px; border-top: 1px solid var(--hair2); }
.king { border: 1px solid var(--hair); border-radius: var(--r); padding: 12px 14px; display: grid; grid-template-columns: 34px 1fr auto; gap: 4px 12px; align-items: center; margin-bottom: 10px; }
.king svg { grid-row: span 2; width: 30px; height: 30px; }
.king .who { font-weight: 640; font-size: 15px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.king .amt { font-size: 15px; }
.king small { grid-column: 2 / 4; color: var(--ink3); font-size: 12.5px; }
.king.you { border-color: rgba(239,233,223,.55); background: var(--raised); }
.king.emptyk { grid-template-columns: 34px 1fr; }
.king.emptyk small { grid-column: 2; }
.you { font-size: 13.5px; color: var(--ink2); line-height: 1.5; }
.you b { color: var(--ink); font-weight: 600; }

/* feed */
.feed { display: flex; flex-direction: column; min-height: 320px; }
.feed-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; max-height: 640px; border-top: 1px solid var(--hair2); }
.feed-list li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 1px 10px; padding: 9px 2px; border-bottom: 1px solid var(--hair2); font-size: 13px; }
.feed-list li.new { animation: feedIn .5s var(--ease) both; }
.feed-list li.me { background: rgba(239,233,223,.04); }
.feed-list .who { font-family: var(--mono); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feed-list .what { grid-column: 1; color: var(--ink3); font-size: 12px; }
.feed-list .amt { text-align: right; font-family: var(--mono); color: var(--loss); }
.feed-list .t { text-align: right; color: var(--ink3); font-family: var(--mono); font-size: 11.5px; }
@keyframes feedIn { from { opacity: 0; transform: translateY(-6px); background: var(--loss-dim); } }

/* queue */
.queue-total { font-size: 13.5px; color: var(--ink2); margin: 0 0 12px; line-height: 1.5; }

/* menu placement */
.acct .menu { right: 0; top: 50px; }
.menu .note { padding: 6px 12px 10px; font-size: 12.5px; color: var(--ink3); max-width: 260px; line-height: 1.45; }

/* rekt dialog */
.rekt { border: 1px solid var(--hair); border-radius: 14px; background: var(--panel); color: var(--ink); padding: 0; width: min(760px, calc(100vw - 24px)); max-height: calc(100svh - 24px); overflow: auto; }
.rekt::backdrop { background: rgba(5,4,3,.72); backdrop-filter: blur(6px); }
.rekt[open] { animation: rektIn .42s var(--spring) both; }
.rekt-inner { padding: 18px 20px 20px; }
.rekt header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.rekt h2:focus { outline: none; }
.rekt h2 { margin: 0; font-size: 30px; font-weight: 700; font-stretch: 75%; letter-spacing: -0.01em; }
.rekt .x { width: 40px; height: 40px; border-radius: var(--r); border: 1px solid var(--hair); background: transparent; color: var(--ink2); font-size: 22px; cursor: pointer; }
.rekt .x:hover { color: var(--ink); }
.rekt canvas { width: 100%; height: auto; border-radius: 8px; border: 1px solid var(--hair2); }
.rekt-line { margin: 12px 0 14px; color: var(--ink2); font-size: 14px; line-height: 1.5; }
.rekt-actions { display: flex; gap: 8px; flex-wrap: wrap; position: sticky; bottom: 0; background: var(--panel); padding: 10px 0 2px; margin-bottom: -2px; }
.rekt-actions .btn { flex: 1; }
.rekt-actions #revenge { flex: 1.4; }
@keyframes rektIn { from { opacity: 0; transform: translateY(14px) scale(.97); } }

/* ---------- responsive ---------- */
@media (max-width: 1280px) {
  .grid { grid-template-columns: minmax(0, 1fr) 330px; }
  .col-c { grid-column: 1 / -1; flex-direction: row; }
  .col-c > .panel { flex: 1; }
  .feed-list { max-height: 420px; }
}
@media (max-width: 1000px) {
  .appnav { display: none; }
  .mkts button .px { display: none; }
}
@media (max-width: 900px) {
  .grid { display: flex; flex-direction: column; }
  .col { display: contents; }
  .chart-panel { order: 1; }
  .order { order: 2; }
  .epoch { order: 3; }
  .positions { order: 4; }
  .cope { order: 5; }
  .queue { order: 6; }
  .feed { order: 7; }
  .tiltp { order: 8; }
  .chart-wrap { height: 300px; }
  .feed-list { max-height: 380px; }
  .ptable { display: none; }
  .pos-cards { display: block; }
}
@media (max-width: 640px) {
  .appbar { gap: 8px; padding: 0 10px; height: 56px; }
  .appbar .brand { font-size: 24px; margin-right: 0; }
  .mkts button { padding: 0 8px; height: 40px; }
  .demo-flag { display: none !important; }
  .bal .label { display: none; }
  .bal .mono { font-size: 13px; }
  .panel { padding: 14px 14px 16px; }
  .clock { font-size: 40px; }
  .demo-note { font-size: 11px; padding: 6px 10px; gap: 4px 10px; }
  .rekt-inner { padding: 14px; }
  .rekt canvas { max-width: 340px; margin: 0 auto; }
  .rekt-actions .btn { flex: 1 1 100%; }
}
@media (max-width: 360px) {
  .mkts button { padding: 0 6px; }
  .mkts button .sym { font-size: 13px; }
  .acct { gap: 6px; }
  .acct .btn { padding: 0 10px; }
  .appbar .brand { font-size: 22px; }
  .demo-flag { display: none !important; }
  .bal { display: none; }
}

/* position cards (mobile) */
.pcard { border-bottom: 1px solid var(--hair2); padding: 12px 0; display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; font-size: 13.5px; }
.pcard .kv { display: flex; gap: 14px; flex-wrap: wrap; grid-column: 1 / -1; color: var(--ink2); font-size: 12.5px; }
.pcard .kv .mono { color: var(--ink); }
.pcard .acts { grid-column: 1 / -1; justify-content: stretch; }
.pcard .acts .btn { flex: 1; }

@media (max-height: 620px) and (max-width: 640px) {
  .rekt canvas { max-width: 200px; }
  .rekt h2 { font-size: 24px; }
  .rekt header { margin-bottom: 8px; }
  .rekt-line { font-size: 13px; margin: 8px 0 6px; }
  .rekt-actions .btn { --h: 42px; }
}
