/* css/app.css: the workspace (/app) and the public record (/record). Night theme on the tokens in css/tokens.css. */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body.app {
  margin: 0;
  background: var(--night);
  color: var(--night-ink);
  font: 400 15px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
img, svg { display: inline-block; vertical-align: middle; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(24px, 3vw, 32px); font-weight: 600; letter-spacing: -0.02em; line-height: 1.15; }
h2 { font-size: 18px; font-weight: 600; letter-spacing: -0.01em; }
h3 { font-size: 16px; font-weight: 600; }
.ic { width: 18px; height: 18px; flex: none; }
.mono { font-family: var(--mono); font-size: 0.92em; letter-spacing: 0; }
.muted { color: var(--night-muted); }
.small { font-size: 13px; }
.brand { color: var(--brand); }
.up { color: var(--up); }
.down { color: var(--down); }
.r { text-align: right; }
.break { word-break: break-all; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.row { display: flex; align-items: center; }
.gap { gap: 10px; }
.wrap { flex-wrap: wrap; }
.pad { padding: 8px 10px; }
.noscript { padding: 80px 24px; text-align: center; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 6px; }

/* ------------------------------------------------------------------ buttons, chips, pills */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 8px 16px; border-radius: 999px;
  border: 1px solid var(--night-line); background: var(--night-3); color: var(--night-ink);
  font-weight: 500; font-size: 14px; cursor: pointer; white-space: nowrap;
  transition: background .15s, border-color .15s, opacity .15s;
}
.btn:hover { background: var(--night-4); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.brand { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.brand:hover { background: #ff5a17; }
.btn.ghost { background: transparent; }
.btn.ghost:hover { background: var(--night-3); }
.btn.danger { color: #ff8a73; border-color: #4a2018; background: transparent; }
.btn.danger:hover { background: #2a120d; }
.btn.small { padding: 6px 12px; font-size: 13px; }
.btn.block { width: 100%; }
.link { background: none; border: 0; padding: 0; color: var(--night-ink); text-decoration: underline; text-decoration-color: var(--night-line); text-underline-offset: 3px; cursor: pointer; display: inline-flex; align-items: center; gap: 4px; }
.link:hover { text-decoration-color: var(--brand); }
a.link.mono { text-decoration-color: rgba(244, 71, 0, .5); }
.chip {
  display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 6px 12px;
  border: 1px solid var(--night-line); border-radius: 999px; background: var(--night-2); color: var(--night-ink);
  font-size: 13px; cursor: pointer; text-align: left;
}
.chip:hover { border-color: var(--brand); }
.chip.tiny { min-height: 0; padding: 2px 8px; font-size: 11px; cursor: default; color: var(--night-muted); }
.pill { display: inline-flex; align-items: center; padding: 2px 9px; border-radius: 999px; border: 1px solid var(--night-line); font-size: 12px; color: var(--night-muted); white-space: nowrap; }
.pill.pill-brand { border-color: rgba(244, 71, 0, .55); color: #ff8a5c; background: rgba(244, 71, 0, .08); }
.pill.tiny { padding: 0 7px; font-size: 11px; margin-left: 6px; }
.badge { display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--brand); color: #fff; font-size: 12px; font-weight: 600; margin-left: auto; }
.badge.zero { background: var(--night-4); color: var(--night-muted); margin-left: 6px; }
.count { margin-left: auto; color: var(--night-muted); font-size: 12px; }
.spin { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--night-line); border-top-color: var(--brand); animation: spin .8s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
.center-load { display: flex; justify-content: center; padding: 64px 0; }

/* ------------------------------------------------------------------ header */

.top {
  position: fixed; inset: 0 0 auto 0; z-index: 40; height: 56px;
  display: flex; align-items: center; gap: 12px; padding: 0 16px;
  background: rgba(5, 5, 6, .92); border-bottom: 1px solid var(--night-line);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.top .brand { display: inline-flex; align-items: center; gap: 9px; color: var(--night-ink); font-weight: 600; font-size: 19px; letter-spacing: -0.02em; }
.icon-btn { display: none; align-items: center; justify-content: center; width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--night-line); background: transparent; cursor: pointer; }
.icon-btn .ic { width: 20px; height: 20px; }
.mode-chip { padding: 2px 10px; border-radius: 999px; font-size: 12px; border: 1px solid rgba(244, 71, 0, .5); color: #ff8a5c; }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.top-link { display: inline-flex; align-items: center; min-height: 40px; padding: 0 10px; color: var(--night-muted); font-size: 14px; }
.top-link:hover { color: var(--night-ink); }
.wallet-chip {
  display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 6px 14px; border-radius: 999px;
  border: 1px solid var(--brand); background: var(--brand); color: #fff; font-size: 14px; font-weight: 500; cursor: pointer; white-space: nowrap;
}
.wallet-chip.on { background: var(--night-3); border-color: var(--night-line); color: var(--night-ink); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--up); flex: none; }
.dot.warn { background: #f5b84a; }

/* ------------------------------------------------------------------ shell */

.shell { display: grid; grid-template-columns: 276px minmax(0, 1fr); padding-top: 56px; height: 100vh; height: 100dvh; }
.side { border-right: 1px solid var(--night-line); background: var(--night-2); overflow-y: auto; overscroll-behavior: contain; }
.side-inner { display: flex; flex-direction: column; gap: 14px; padding: 14px 12px 18px; min-height: 100%; }
.side-empty { padding: 16px 8px; }
.office { display: grid; gap: 2px; padding: 12px 14px; border-radius: var(--radius); border: 1px solid var(--night-line); background: var(--night-3); }
.office:hover, .office.is-on { border-color: rgba(244, 71, 0, .5); }
.office-k { font-size: 12px; color: var(--night-muted); text-transform: uppercase; letter-spacing: .06em; }
.office-w { font-size: 15px; }
.office-v { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--night-muted); }
.office-v .ic { width: 15px; height: 15px; }
.side-nav { display: grid; gap: 2px; }
.nav-i, .side-add { display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 8px 10px; border-radius: 10px; color: var(--night-ink); font-size: 14px; }
.nav-i:hover, .side-add:hover { background: var(--night-3); }
.nav-i.is-on, .side-add.is-on { background: var(--night-4); }
.nav-i .ic, .side-add .ic { color: var(--night-muted); }
.side-sec { display: grid; gap: 4px; }
.side-h { display: flex; justify-content: space-between; align-items: baseline; padding: 4px 10px; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--night-muted); }
.side-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.side-bot { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 44px; padding: 6px 10px; border-radius: 10px; border: 0; background: transparent; cursor: pointer; text-align: left; }
.side-bot:hover { background: var(--night-3); }
.side-bot.is-on { background: var(--night-4); }
.sb-text { display: grid; min-width: 0; }
.sb-name { font-size: 14px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sb-sub { font-size: 12px; color: var(--night-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sb-sub.brand { color: #ff8a5c; }
.side-chat { display: grid; min-height: 40px; padding: 6px 10px; border-radius: 10px; }
.side-chat:hover { background: var(--night-3); }
.side-chat.is-on { background: var(--night-4); }
.sc-title { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sc-sub { font-size: 11px; color: var(--night-muted); }
.side-foot { margin-top: auto; display: flex; justify-content: space-between; align-items: center; padding: 8px 10px 0; border-top: 1px solid var(--night-line); min-height: 40px; }
.avatar { flex: none; border-radius: 50%; }
.tile { flex: none; border-radius: 50%; object-fit: cover; }
.scrim { position: fixed; inset: 56px 0 0 0; background: rgba(0, 0, 0, .55); z-index: 30; }

.main { overflow-y: auto; min-width: 0; position: relative; }
.toast {
  position: fixed; left: 50%; top: 66px; transform: translate(-50%, -12px); z-index: 60; max-width: min(92vw, 520px);
  padding: 10px 16px; border-radius: 12px; background: var(--night-4); border: 1px solid var(--night-line); color: var(--night-ink);
  font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.ok { border-color: rgba(62, 207, 142, .5); }
.toast.warn { border-color: rgba(229, 83, 61, .6); }

/* ------------------------------------------------------------------ gate */

.gate-main { display: flex; align-items: flex-start; justify-content: center; }
.gate { width: min(560px, 100%); padding: clamp(36px, 8vh, 96px) 20px 48px; display: grid; gap: 16px; justify-items: start; }
.gate-mark { border-radius: 50%; }
.lead { color: var(--night-muted); font-size: 17px; }
.steps { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 10px; width: 100%; }
.steps li { display: flex; gap: 14px; align-items: flex-start; padding: 16px; border: 1px solid var(--night-line); border-radius: var(--radius); background: var(--night-2); opacity: .55; }
.steps li.now, .steps li.done { opacity: 1; }
.steps li.now { border-color: rgba(244, 71, 0, .5); }
.steps li > div { display: grid; gap: 4px; min-width: 0; }
.steps .n { flex: none; width: 26px; height: 26px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; background: var(--night-4); font-size: 13px; font-weight: 600; }
.steps li.done .ic { color: var(--up); width: 24px; height: 24px; }
.wallet-list { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.wallet-list img { border-radius: 5px; }
.gate-status, .form-status, .card-status { font-size: 13px; color: var(--night-muted); min-height: 0; }
.gate-status.err, .form-status.err, .card-status.err { color: #ff8a73; }
.form-status.ok { color: var(--up); }
.form-status.warn, .card-status.warn { color: #f5b84a; }
.form-status:empty, .card-status:empty { display: none; }

/* ------------------------------------------------------------------ chat */

.chat-main { display: flex; flex-direction: column; overflow: hidden; }
.chat { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.chat-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 10px clamp(12px, 3vw, 28px); border-bottom: 1px solid var(--night-line); }
.ch-bot { display: flex; align-items: center; gap: 10px; min-width: 0; }
.ch-bot > span { display: grid; min-width: 0; }
.ch-name { font-weight: 600; }
.ch-sub { font-size: 12px; color: var(--night-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pass-chip { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 4px 6px 4px 12px; border-radius: 999px; border: 1px solid rgba(62, 207, 142, .45); font-size: 12px; }
.pass-chip .link { min-height: 32px; padding: 0 6px; }
.stream { flex: 1; overflow-y: auto; padding: 20px clamp(12px, 3vw, 28px) 12px; display: flex; flex-direction: column; gap: 14px; overscroll-behavior: contain; }
.stream > * { width: 100%; max-width: 780px; margin-left: auto; margin-right: auto; }
.chat-intro { display: grid; justify-items: center; text-align: center; gap: 6px; padding: 28px 8px 8px; }
.role-line { max-width: 520px; color: var(--night-ink); font-size: 14px; opacity: .85; }
.msg { display: flex; flex-direction: column; gap: 3px; }
.msg.user { align-items: flex-end; }
.msg.user .bubble { background: var(--night-4); border-radius: 16px 16px 4px 16px; padding: 9px 14px; max-width: min(560px, 88%); }
.msg-time { font-size: 11px; color: var(--night-muted); }
.msg.bot { display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 10px; align-items: start; }
.msg-body { display: grid; gap: 8px; min-width: 0; }
.msg-name { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; }
.msg-name .msg-time { font-weight: 400; }
.msg.bot .bubble { padding: 0; max-width: 680px; }
.bubble { overflow-wrap: anywhere; }
.bubble p + p, .bubble p + ul, .bubble ul + p, .bubble p + ol, .bubble p + .tbl-wrap, .bubble .tbl-wrap + p { margin-top: 8px; }
.bubble ul, .bubble ol { margin: 0; padding-left: 20px; }
.bubble code { font-family: var(--mono); font-size: .9em; background: var(--night-3); padding: 1px 5px; border-radius: 5px; }
.msg.note { align-items: center; text-align: center; }
.msg.note p { font-size: 13px; color: var(--night-muted); max-width: 560px; padding: 6px 12px; border-radius: 10px; background: var(--night-2); border: 1px dashed var(--night-line); }
.msg.note.offline p { border-color: rgba(245, 184, 74, .45); color: #f5d49a; }
.msg.note .card { text-align: left; width: min(520px, 100%); }
.dots { display: inline-flex; gap: 4px; padding: 6px 0; }
.dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--night-muted); animation: blink 1.2s infinite ease-in-out; }
.dots i:nth-child(2) { animation-delay: .15s; }
.dots i:nth-child(3) { animation-delay: .3s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }

.composer { padding: 8px clamp(12px, 3vw, 28px) max(12px, env(safe-area-inset-bottom)); border-top: 1px solid var(--night-line); background: var(--night); }
.composer > * { max-width: 780px; margin-left: auto; margin-right: auto; }
.suggest { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.comp-row { display: flex; align-items: flex-end; gap: 8px; padding: 6px 6px 6px 14px; border: 1px solid var(--night-line); border-radius: 20px; background: var(--night-2); }
.comp-row:focus-within { border-color: rgba(244, 71, 0, .6); }
.comp-row textarea { flex: 1; min-width: 0; border: 0; background: transparent; resize: none; outline: none; padding: 8px 0; max-height: 180px; line-height: 1.45; font-size: 15px; }
.send { flex: none; width: 40px; height: 40px; border-radius: 50%; border: 0; background: var(--brand); color: #fff; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
.send:disabled { opacity: .4; cursor: default; }
.comp-foot { margin-top: 6px; text-align: center; }

/* ------------------------------------------------------------------ cards */

.card { border: 1px solid var(--night-line); border-radius: var(--radius); background: var(--night-2); padding: 14px; display: grid; gap: 10px; min-width: 0; }
.card.approval.open { border-color: rgba(244, 71, 0, .55); background: linear-gradient(180deg, rgba(244, 71, 0, .07), rgba(244, 71, 0, 0) 60%), var(--night-2); }
.card.mini { gap: 8px; padding: 12px 14px; }
.card.receipt.ok { border-color: rgba(62, 207, 142, .45); }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.kicker { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--night-muted); }
.card-title { display: flex; align-items: center; gap: 8px; font-size: 18px; font-weight: 600; letter-spacing: -0.01em; overflow-wrap: anywhere; }
.card-title.small { font-size: 15px; }
.reason { color: #ff8a5c; font-size: 14px; font-weight: 500; }
.why { font-size: 13px; color: var(--night-muted); }
.post-text { margin: 0; padding: 10px 12px; border-left: 3px solid var(--brand); background: var(--night-3); border-radius: 0 10px 10px 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.facts { display: grid; gap: 6px; margin: 0; }
.facts > div { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; border-bottom: 1px solid var(--night-line); padding-bottom: 5px; }
.facts > div:last-child { border-bottom: 0; padding-bottom: 0; }
.facts dt { color: var(--night-muted); flex: none; }
.facts dd { margin: 0; text-align: right; min-width: 0; overflow-wrap: anywhere; }
.facts.wide > div { align-items: baseline; }
.answers { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.ans {
  min-height: 44px; padding: 8px 10px; border-radius: 12px; border: 1px solid var(--night-line); background: var(--night-3);
  font-size: 13px; font-weight: 500; line-height: 1.2; cursor: pointer; text-align: center;
}
.ans:hover { border-color: var(--night-muted); }
.ans-once { background: var(--brand); border-color: var(--brand); color: #fff; }
.ans-once:hover { background: #ff5a17; }
.ans-deny { background: transparent; }
.ans[aria-disabled="true"] { opacity: .38; cursor: not-allowed; }
.ans-once[aria-disabled="true"] { background: var(--night-3); border-color: var(--night-line); color: var(--night-ink); }
.ans:disabled { opacity: .5; }
.card-note { font-size: 12px; color: var(--night-muted); }
.card-time { font-size: 11px; color: var(--night-muted); }
.card-result { display: flex; align-items: center; gap: 8px; font-size: 13px; padding: 8px 10px; border-radius: 10px; background: var(--night-3); overflow-wrap: anywhere; }
.card-result .ic { color: var(--up); }
.card-result.denied .ic, .card-result.failed .ic { color: #ff8a73; }
.pass-form { display: grid; gap: 10px; padding: 12px; border-radius: 12px; background: var(--night-3); }
.pass-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.pass-grid label { font-size: 12px; }
.tbl-wrap { overflow-x: auto; max-width: 100%; }
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { text-align: left; font-weight: 500; color: var(--night-muted); padding: 6px 8px; border-bottom: 1px solid var(--night-line); white-space: nowrap; }
.tbl td { padding: 7px 8px; border-bottom: 1px solid var(--night-line); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl .r { text-align: right; white-space: nowrap; }
.sym { display: inline-flex; align-items: center; gap: 7px; font-weight: 500; }

/* ------------------------------------------------------------------ panels and forms */

.panel-main { padding: 0; }
.panel { width: min(880px, 100%); margin: 0 auto; padding: clamp(18px, 3vw, 36px) clamp(12px, 3vw, 28px) 64px; display: grid; gap: 18px; align-content: start; }
.panel.narrow { width: min(560px, 100%); }
.panel-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; flex-wrap: wrap; }
.panel-head > div { display: grid; gap: 6px; max-width: 640px; min-width: 0; }
.panel-card { border: 1px solid var(--night-line); border-radius: var(--radius-lg); background: var(--night-2); padding: clamp(14px, 2.4vw, 22px); display: grid; gap: 14px; min-width: 0; }
.panel-card h2 { display: flex; align-items: center; gap: 10px; }
.sec-h { display: flex; align-items: center; gap: 8px; font-size: 15px; color: var(--night-muted); font-weight: 500; margin-top: 6px; }
label { display: grid; gap: 6px; font-size: 13px; color: var(--night-muted); min-width: 0; }
input, select, textarea {
  width: 100%; min-height: 42px; padding: 9px 12px; border-radius: 10px; border: 1px solid var(--night-line);
  background: var(--night); color: var(--night-ink); font-size: 15px; outline: none;
}
textarea { line-height: 1.45; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: rgba(244, 71, 0, .65); }
input[type=checkbox], input[type=radio] { width: 18px; min-height: 18px; height: 18px; accent-color: var(--brand); padding: 0; }
.in-wrap { display: flex; align-items: center; gap: 6px; border: 1px solid var(--night-line); border-radius: 10px; background: var(--night); padding: 0 10px; min-height: 42px; color: var(--night-muted); }
.in-wrap:focus-within { border-color: rgba(244, 71, 0, .65); }
.in-wrap input:focus-visible, .in-wrap select:focus-visible, .comp-row textarea:focus-visible { outline: none; }
.in-wrap input, .in-wrap select { border: 0; background: transparent; padding: 8px 0; min-height: 40px; min-width: 0; }
.in-wrap select { width: auto; flex: none; color: var(--night-ink); }
fieldset { border: 0; padding: 0; margin: 0; display: grid; gap: 8px; min-width: 0; }
legend { font-size: 13px; color: var(--night-muted); margin-bottom: 6px; padding: 0; }
fieldset.rule { border: 1px solid var(--night-line); border-radius: 14px; padding: 12px; }
fieldset.rule legend { padding: 0 6px; margin: 0; }
.check { display: flex; align-items: center; gap: 10px; color: var(--night-ink); font-size: 14px; min-height: 40px; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.grid4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.seg { display: flex; flex-wrap: wrap; gap: 8px; }
.seg legend { width: 100%; }
.seg-i { display: flex; align-items: center; gap: 8px; min-height: 40px; padding: 6px 14px; border-radius: 999px; border: 1px solid var(--night-line); color: var(--night-ink); font-size: 14px; cursor: pointer; }
.seg-i:has(input:checked) { border-color: var(--brand); background: rgba(244, 71, 0, .08); }
.seg-i:has(input:disabled) { opacity: .45; cursor: not-allowed; }
.sym-picks { display: flex; flex-wrap: wrap; gap: 6px; }
.sym-pick { display: inline-flex; flex-direction: row; align-items: center; gap: 6px; min-height: 40px; padding: 4px 12px 4px 8px; border: 1px solid var(--night-line); border-radius: 999px; color: var(--night-ink); font-size: 13px; cursor: pointer; }
.sym-pick span { display: inline-flex; align-items: center; gap: 6px; }
.sym-pick:has(input:checked) { border-color: var(--brand); background: rgba(244, 71, 0, .08); }
.sym-pick input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.start-opts { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.start-opts[hidden] { display: none; }
.start-opts > * { flex: 1 1 140px; width: auto; }
.start-opts > .muted { flex: 0 0 auto; }
[hidden] { display: none !important; }

.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.tpl { display: grid; gap: 8px; align-content: start; padding: 16px; border-radius: var(--radius-lg); border: 1px solid var(--night-line); background: var(--night-2); min-height: 168px; transition: border-color .15s, transform .15s; }
.tpl:hover { border-color: rgba(244, 71, 0, .55); transform: translateY(-1px); }
.tpl-name { font-weight: 600; font-size: 16px; }
.tpl-blurb { font-size: 13px; color: var(--night-muted); }
.tpl-powers { display: flex; flex-wrap: wrap; gap: 5px; margin-top: auto; }
.bot-top { display: flex; gap: 14px; align-items: center; }
.bot-top > div { display: grid; gap: 4px; min-width: 0; }
.routine-list, .appr-list { display: grid; gap: 12px; }
.routine-card.off { opacity: .6; }
.appr-wrap { display: grid; gap: 6px; justify-items: start; }
.appr-wrap .card { width: 100%; }

.stat-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.stat { display: grid; gap: 4px; padding: 14px 16px; border-radius: var(--radius); border: 1px solid var(--night-line); background: var(--night-2); min-width: 0; }
.stat-k { font-size: 12px; color: var(--night-muted); text-transform: uppercase; letter-spacing: .06em; }
.stat-v { font-size: 22px; font-weight: 600; letter-spacing: -0.01em; overflow-wrap: anywhere; }
.stat-v.small { font-size: 16px; }
.prelim-card { background: radial-gradient(120% 90% at 100% 0, rgba(244, 71, 0, .16), rgba(244, 71, 0, 0) 60%), var(--night-2); }
.prelim-card p { color: var(--night-ink); opacity: .9; }
.prelim-card .muted { opacity: 1; }
.prelim-card .pill { justify-self: start; }
form[data-dep], form[data-wd] { display: grid; gap: 8px; align-content: start; }

/* ------------------------------------------------------------------ record */

.rec-list { list-style: none; margin: 0; padding: 0; display: grid; }
.rec-row { display: grid; grid-template-columns: 150px 78px minmax(0, 1fr) auto; gap: 12px; align-items: baseline; padding: 10px 4px; border-bottom: 1px solid var(--night-line); font-size: 13px; }
.rec-time { color: var(--night-muted); font-size: 12px; }
.rec-kind { justify-self: start; padding: 1px 8px; border-radius: 999px; font-size: 11px; border: 1px solid var(--night-line); color: var(--night-muted); }
.rec-kind.k-trade { border-color: rgba(244, 71, 0, .5); color: #ff8a5c; }
.rec-kind.k-answer { border-color: rgba(62, 207, 142, .45); color: var(--up); }
.rec-kind.k-routine { border-color: rgba(138, 150, 255, .5); color: #aab3ff; }
.rec-text { overflow-wrap: anywhere; }
.rec-text strong { font-weight: 500; color: var(--night-muted); margin-right: 4px; }
.rec-tx { display: grid; justify-items: end; gap: 2px; }
.rec-hash { font-size: 11px; }
.rec-main { padding-top: 56px; }
.rec-foot { width: min(880px, 100%); margin: 0 auto; padding: 0 clamp(12px, 3vw, 28px) 40px; display: flex; gap: 8px; flex-wrap: wrap; }
.rec-form .row input { flex: 1 1 280px; width: auto; }
.record-page .top .btn.small { min-height: 40px; }
.record-page .mode-chip.on { border-color: var(--night-line); color: var(--night-muted); }

/* ------------------------------------------------------------------ phone */

@media (max-width: 860px) {
  .icon-btn { display: inline-flex; }
  .top { padding: 0 10px; gap: 8px; }
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side { position: fixed; top: 56px; bottom: 0; left: 0; z-index: 35; width: min(86vw, 300px); transform: translateX(-102%); transition: transform .22s var(--ease-out); }
  body.drawer-open .side { transform: none; box-shadow: 0 0 40px rgba(0, 0, 0, .6); }
  .grid4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .answers { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid2 { grid-template-columns: minmax(0, 1fr); }
  .rec-row { grid-template-columns: minmax(0, 1fr) auto; }
  .rec-row .rec-time { grid-column: 1; }
  .rec-row .rec-kind { grid-column: 2; grid-row: 1; justify-self: end; }
  .rec-row .rec-text { grid-column: 1 / -1; }
  .rec-row .rec-tx { grid-column: 1 / -1; justify-items: start; }
  .stat-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .stat-row .stat:last-child { grid-column: 1 / -1; }
  .hide-sm { display: none; }
}
@media (max-width: 480px) {
  .top-right .top-link { display: none; }
  .msg.bot { grid-template-columns: minmax(0, 1fr); }
  .msg.bot > .avatar { display: none; }
  .pass-grid { grid-template-columns: minmax(0, 1fr); }
  .wallet-chip { padding: 6px 10px; }
  .card { padding: 12px; }
  .chat-head { padding: 8px 12px; }
}
@media (max-width: 420px) {
  .mode-chip { display: none; }
}
@media (max-width: 360px) {
  .grid4 { grid-template-columns: minmax(0, 1fr); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
