/* Console */
.app-main { padding-top: 28px; padding-bottom: 72px; min-height: calc(100vh - 160px); }
.view[hidden] { display: none; }
h1 { font-size: clamp(28px, 6vw, 40px); line-height: 1.1; letter-spacing: -.02em; margin: 10px 0 12px; font-weight: 700; }
h2 { font-size: 18px; margin: 0; letter-spacing: -.01em; }
h3 { font-size: 16px; margin: 0 0 6px; }
.lede { color: var(--text-2); max-width: 60ch; margin: 0 0 24px; }
.hint { color: var(--text-3); font-size: 14px; margin: 0 0 14px; }
.hint a, .lede a, .connect a { color: var(--signal); }
code { font-size: .92em; }
.note { padding: 14px; border: 1px solid var(--line-2); border-radius: var(--r); }

/* Start */
.start-head { max-width: 640px; }
.start-grid { display: grid; gap: 16px; grid-template-columns: 1fr; }
@media (min-width: 860px) { .start-grid { grid-template-columns: 1.4fr 1fr; align-items: start; } }
.panel { background: var(--ink-raised); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 20px; display: grid; gap: 14px; }
.panel-quiet { background: transparent; }
.panel h2 { margin-bottom: 2px; }
.field { display: grid; gap: 6px; min-width: 0; }
.field > span { font-size: 14px; color: var(--text-2); font-weight: 500; }
.field small { color: var(--text-3); font-size: 13px; }
input:not([type=checkbox]), select, textarea {
  width: 100%; min-width: 0; min-height: 44px; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line-2);
  background: var(--ink-deep); color: var(--text); font-size: 16px; transition: border-color .15s;
}
textarea { resize: vertical; min-height: 84px; }
input.mono, textarea.mono { font-family: var(--mono); font-variation-settings: "MONO" 1; font-size: 14px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--signal); box-shadow: 0 0 0 3px var(--signal-soft); }
input[aria-invalid=true] { border-color: var(--clash); }
input::placeholder, textarea::placeholder { color: #6b6b75; }
.check { display: flex; gap: 10px; align-items: center; font-size: 15px; color: var(--text-2); min-height: 44px; cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--signal); }
.form-err { color: var(--clash); font-size: 14px; margin: 0; }
.form-err[hidden] { display: none; }

/* Keys */
.keys { display: grid; gap: 12px; margin: 8px 0 12px; }
.keycard { border: 1px solid var(--line-2); border-radius: var(--r-lg); padding: 16px; background: var(--ink-raised); }
.keycard-head { display: grid; gap: 2px; margin-bottom: 10px; }
.keycard-head span { color: var(--text-3); font-size: 14px; }
.keyrow { display: flex; gap: 8px; align-items: center; min-width: 0; }
.keyrow code { flex: 1; min-width: 0; overflow-wrap: anywhere; background: var(--ink-deep); border: 1px solid var(--line); padding: 10px 12px; border-radius: 10px; font-size: 13px; color: var(--signal); }
.keyrow[hidden] { display: none; }
#k-continue { margin-top: 8px; }

/* Dashboard head */
.dash-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; margin-bottom: 18px; }
.dash-title { min-width: 0; }
.dash-title h1 { margin: 0 0 8px; overflow-wrap: anywhere; }
.dash-meta { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; align-items: center; }
.addr { background: var(--ink-raised); border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; font-size: 13px; color: var(--text-2); cursor: pointer; min-height: 44px; }
.addr:hover { color: var(--signal); border-color: var(--signal); }
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-2); padding: 6px 10px; border-radius: 999px; border: 1px solid var(--line); min-height: 32px; }
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--text-3); }
.pill.on::before { background: var(--ok); }
.pill-live::before { background: var(--signal); animation: pulse 2.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; } }

/* Tabs: wraps into rows on phones, never scrolls the page sideways */
.tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 4px; background: var(--ink-deep); border: 1px solid var(--line); border-radius: 14px; margin-bottom: 22px; }
@media (min-width: 640px) { .tabs { grid-template-columns: repeat(6, 1fr); } }
.tabs button { min-height: 44px; border: 0; background: transparent; color: var(--text-2); border-radius: 10px; cursor: pointer; font-weight: 600; font-size: 14px; transition: background-color .15s, color .15s; position: relative; }
.tabs button:hover { color: var(--text); }
.tabs button[aria-selected=true] { background: var(--ink-high); color: var(--text); }
.tabs button .count { font-family: var(--mono); font-variation-settings: "MONO" 1; font-size: 11px; color: var(--signal); margin-left: 4px; }
.tabpanel[hidden] { display: none; }
.tabpanel { animation: fadein .25s var(--ease); }
@keyframes fadein { from { opacity: 0; transform: translateY(4px); } }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin: 6px 0 12px; }
.panel-head + .panel-head, #balances + .panel-head { margin-top: 30px; }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.inline-form { display: grid; gap: 12px; padding: 16px; border: 1px dashed var(--line-2); border-radius: var(--r-lg); margin-bottom: 16px; }
.inline-form[hidden] { display: none; }
@media (min-width: 720px) { #setbal-form { grid-template-columns: repeat(2, minmax(0, 1fr)); } #setbal-form .form-err, #setbal-form .row-actions { grid-column: 1 / -1; } }

/* Ledger tape: each balance is a strip of paper with ruled lines */
.tape { background: var(--paper); color: var(--ink); border-radius: 12px; padding: 16px 16px 14px; margin-bottom: 12px; position: relative; overflow: hidden;
  background-image: repeating-linear-gradient(to bottom, transparent 0 27px, rgba(32,32,36,.06) 27px 28px); }
.tape::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--signal); }
.tape-top { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.tape-asset { font-weight: 700; font-size: 17px; }
.tape-asset small { font-family: var(--mono); font-variation-settings: "MONO" 1; font-weight: 400; font-size: 12px; color: var(--ink-text-2); margin-left: 6px; }
.tape-free { font-family: var(--mono); font-variation-settings: "MONO" 1; font-size: 22px; font-weight: 600; letter-spacing: -.01em; }
.tape-free small { font-size: 12px; font-weight: 400; color: var(--ink-text-2); margin-left: 4px; }
.bar { display: flex; height: 10px; border-radius: 6px; overflow: hidden; background: #d7d7dd; margin: 12px 0 10px; }
.bar i { display: block; height: 100%; transition: width .5s var(--ease); }
.bar .b-res { background: var(--signal-deep); }
.bar .b-sub { background: repeating-linear-gradient(135deg, var(--signal-deep) 0 4px, #7cc6ec 4px 8px); }
.bar .b-free { background: #b9e6fb; }
.figs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 14px; margin: 0; font-size: 13px; }
@media (min-width: 640px) { .figs { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.figs div { min-width: 0; }
.figs dt { color: var(--ink-text-2); display: flex; align-items: center; gap: 6px; }
.figs dt i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; flex: none; }
.figs dd { margin: 0; font-family: var(--mono); font-variation-settings: "MONO" 1; font-weight: 600; overflow-wrap: anywhere; }
.tape-src { font-size: 12px; color: var(--ink-text-2); margin: 10px 0 0; }
.tape-src.warn { color: #a2401f; }

/* Lists */
.list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.list li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; align-items: center; padding: 12px 2px; border-bottom: 1px solid var(--line); animation: fadein .3s var(--ease); }
.list .main { min-width: 0; display: grid; gap: 2px; }
.list .main strong { font-weight: 600; overflow-wrap: anywhere; }
.list .sub { color: var(--text-3); font-size: 13px; overflow-wrap: anywhere; }
.list .num { font-family: var(--mono); font-variation-settings: "MONO" 1; font-size: 14px; text-align: right; }
.state { display: inline-block; font-family: var(--mono); font-variation-settings: "MONO" 1; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; padding: 2px 8px; border-radius: 999px; border: 1px solid currentColor; }
.state-held, .state-leased, .state-running { color: var(--signal); }
.state-submitted { color: #b6e3ff; }
.state-done, .state-free, .state-settled { color: var(--ok); }
.state-expired, .state-released { color: var(--text-3); }
.list .act { grid-column: 1 / -1; display: flex; gap: 8px; flex-wrap: wrap; }
@media (min-width: 640px) { .list li { grid-template-columns: minmax(0, 1fr) auto auto; } .list .act { grid-column: auto; } }

.empty { border: 1px dashed var(--line-2); border-radius: var(--r-lg); padding: 22px 18px; display: grid; gap: 6px; justify-items: start; color: var(--text-2); }
.empty svg { width: 72px; height: 30px; color: var(--text-3); margin-bottom: 4px; }
.empty strong { color: var(--text); font-weight: 600; }
.empty p { margin: 0; font-size: 14px; max-width: 56ch; }

.connect { margin-top: 28px; border-top: 1px solid var(--line); padding-top: 22px; }
.connect p { color: var(--text-2); font-size: 15px; }
pre.code { background: var(--ink-deep); border: 1px solid var(--line); border-radius: 12px; padding: 14px; overflow-x: auto; font-size: 13px; line-height: 1.6; margin: 0 0 12px; max-width: 100%; }
pre.code code { color: var(--paper-dim); white-space: pre; }

.events { list-style: none; margin: 0; padding: 0 0 0 18px; position: relative; }
.events::before { content: ""; position: absolute; left: 5px; top: 6px; bottom: 6px; width: 2px; background: var(--line-2); border-radius: 2px; }
.events li { position: relative; padding: 8px 0 10px; display: grid; gap: 2px; animation: fadein .3s var(--ease); }
.events li::before { content: ""; position: absolute; left: -17px; top: 15px; width: 10px; height: 10px; border-radius: 50%; background: var(--ink); border: 2px solid var(--text-3); }
.events li.k-held::before, .events li.k-claimed::before, .events li.k-leased::before { border-color: var(--signal); }
.events li.k-settled::before, .events li.k-done::before { border-color: var(--ok); background: var(--ok); }
.events li.k-refused::before { border-color: var(--clash); background: var(--clash); }
.events .what { overflow-wrap: anywhere; }
.events .when { color: var(--text-3); font-size: 12px; font-family: var(--mono); font-variation-settings: "MONO" 1; }
.events .empty { margin-left: -18px; }

.settings { display: grid; gap: 14px; max-width: 720px; }
.setting { border: 1px solid var(--line); border-radius: var(--r-lg); padding: 16px; display: grid; gap: 10px; }
.setting h3 { margin: 0; }
.setting p { margin: 0; color: var(--text-2); font-size: 14px; }
.setting .inline { display: flex; gap: 8px; }
.setting-danger { border-color: rgba(255,154,118,.3); }

.toast { position: fixed; left: 50%; bottom: max(18px, env(safe-area-inset-bottom)); transform: translate(-50%, 20px); opacity: 0; background: var(--paper); color: var(--ink); padding: 10px 16px; border-radius: 999px; font-weight: 600; font-size: 14px; pointer-events: none; transition: opacity .2s, transform .2s var(--ease); z-index: 90; max-width: calc(100vw - 32px); text-align: center; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
