/*
 * css/app.css: the app, the receipt page and the burn page. Flat pages in the gallery's language: glaze panels
 * with gilt hairlines, the door as a wall label beside a painting, receipts as catalogue entries.
 */
.app .page, .flat .page { padding-top: calc(var(--head-h) + clamp(22px, 4vw, 44px)); }
.linkish { background: none; border: 0; padding: 8px 0; color: var(--dim); text-decoration: underline; text-decoration-color: var(--line); text-underline-offset: 3px; font-size: 13.5px; text-align: left; min-height: 40px; }
.linkish:hover { color: var(--cream); }
.linkish.dark { color: var(--ink-2); text-decoration-color: rgba(27, 19, 14, 0.3); }
.linkish.dark:hover { color: var(--ink); }
.check { display: inline-flex; align-items: center; gap: 9px; font-size: 14px; color: var(--dim); min-height: 40px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--clay); flex: none; }
.btn.danger:hover { border-color: var(--bad); color: var(--bad); }

/* ---------------------------------------------------------------- the door */
.gate { display: grid; grid-template-columns: minmax(0, 0.9fr) minmax(0, 1fr); gap: clamp(24px, 5vw, 70px); align-items: center; min-height: calc(100vh - var(--head-h) - 160px); }
.gate-art { justify-self: end; padding: 16px; background: linear-gradient(135deg, #e7c77e, #9a742f 28%, #d9b566 52%, #7c5a22 78%, #c9a35a); box-shadow: 0 0 0 1px #5a4118, 0 40px 80px -24px #000, inset 0 0 0 6px rgba(0, 0, 0, 0.24); }
.gate-art img { width: min(380px, 34vw); height: auto; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.7), inset 0 0 30px rgba(0, 0, 0, 0.5); }
.gate-card { max-width: 480px; }
.gate-card .room-no { font-family: var(--mono); font-size: 11.5px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--clay-deep); margin: 0; }
.gate-card h1 { font-size: clamp(36px, 4.4vw, 54px); font-weight: 600; color: var(--ink); margin-top: 12px; }
.gate-steps { margin-top: 16px; border-top: 1px solid rgba(27, 19, 14, 0.16); }
.gate-steps li { display: flex; align-items: center; gap: 14px; padding: 9px 0; border-bottom: 1px solid rgba(27, 19, 14, 0.1); font-size: 14.5px; color: var(--ink-2); }
.gate-steps b { font-family: var(--display); font-size: 20px; color: var(--red); width: 16px; }
.gate-actions { display: grid; gap: 12px; margin-top: 22px; justify-items: start; }
.gate-msg { min-height: 20px; margin-top: 12px; font-size: 14px; color: var(--red) !important; }

/* ---------------------------------------------------------------- the desk */
.desk { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: clamp(18px, 2.4vw, 30px); align-items: start; }
.side { position: sticky; top: calc(var(--head-h) + 18px); display: grid; gap: 14px; }
.acct { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
.acct-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.acct-top .kicker { display: block; }
.acct-top b { font-size: 15px; color: var(--cream); font-weight: 500; }
.meter { display: grid; gap: 6px; padding-top: 14px; border-top: 1px solid var(--line-2); }
.meter-top { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; font-size: 14px; color: var(--dim); }
.meter-top b { font-size: 17px; color: var(--cream); font-weight: 500; }
.meter .note { font-size: 12.5px; line-height: 1.45; }
.bar { height: 5px; background: rgba(240, 220, 192, 0.1); border-radius: 3px; overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--clay-deep), var(--gilt-hi)); transition: width 0.5s var(--ease); }
.acct .btn { width: 100%; white-space: normal; text-align: center; padding: 10px 14px; line-height: 1.25; }
.house { padding: 12px 14px; border: 1px solid rgba(224, 105, 74, 0.5); border-left-width: 3px; border-radius: var(--r); font-size: 13.5px; color: var(--cream); background: rgba(126, 42, 28, 0.25); }

.work { min-width: 0; }
.tabs { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0; border: 1px solid var(--line); border-bottom: 0; border-radius: var(--r) var(--r) 0 0; overflow: hidden; }
.tabs button { display: flex; align-items: center; justify-content: center; gap: 10px; min-height: 58px; padding: 8px 10px; background: var(--pit); border: 0; border-right: 1px solid var(--line); color: var(--faint); font-family: var(--display); font-size: 21px; font-weight: 500; }
.tabs button:last-child { border-right: 0; }
.tabs button:hover { color: var(--cream); }
.tabs button[aria-selected="true"] { background: var(--glaze); color: var(--cream); box-shadow: inset 0 2px 0 var(--clay); }
.tabs button[aria-selected="true"] .ic { color: var(--clay-hi); }
.tool { border-radius: 0 0 var(--r) var(--r); min-height: 460px; }
.tool-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 18px; }
.tool-head h2 { font-size: clamp(28px, 3vw, 36px); }
.tool-head .note { margin-top: 6px; max-width: 60ch; color: var(--dim); font-size: 14px; }

/* chat */
.chat-log { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; align-content: start; min-height: 240px; max-height: min(56vh, 620px); overflow-y: auto; padding: 4px 4px 4px 0; margin-bottom: 14px; }
.msg { max-width: min(680px, 92%); }
.msg.me { justify-self: end; background: rgba(196, 104, 63, 0.16); border: 1px solid rgba(196, 104, 63, 0.4); border-radius: 12px 12px 2px 12px; padding: 10px 14px; color: var(--cream); white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.it { justify-self: start; border-left: 2px solid var(--gilt); padding: 2px 0 2px 16px; }
.msg.it .md { color: rgba(240, 220, 192, 0.86); }
.msg.it .md > :last-child { margin-bottom: 0; }
.msg-steps { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.msg-steps .chip { font-size: 11.5px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-paid { display: block; margin-top: 8px; font-size: 11px; color: var(--faint); letter-spacing: 0.06em; text-transform: uppercase; }
.msg.wait, .running { display: flex; align-items: center; gap: 12px; color: var(--dim); font-size: 14px; }
.dots { display: inline-flex; gap: 5px; }
.dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--gilt); animation: dot 1.1s infinite ease-in-out; }
.dots i:nth-child(2) { animation-delay: 0.16s; } .dots i:nth-child(3) { animation-delay: 0.32s; }
@keyframes dot { 0%, 80%, 100% { opacity: 0.25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
.empty { display: grid; justify-items: center; gap: 12px; text-align: center; padding: 36px 12px; color: var(--dim); }
.empty .ic { color: var(--clay); }
.empty p { max-width: 44ch; font-size: 15px; }
.starters { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.chip-btn { min-height: 40px; padding: 0 14px; border: 1px solid var(--line); border-radius: 99px; background: transparent; color: var(--dim); font-size: 13.5px; }
.chip-btn:hover { border-color: var(--gilt); color: var(--cream); }
.composer { display: grid; gap: 8px; border-top: 1px solid var(--line-2); padding-top: 14px; }
.composer .textarea { min-height: 64px; }
.composer-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }

/* ask forms, results, history */
.ask { display: grid; gap: 14px; justify-items: start; }
.ask .field { width: 100%; }
.ask .row { display: flex; gap: 16px; flex-wrap: wrap; width: 100%; align-items: flex-end; }
.ask .row.end { justify-content: flex-end; }
.ask .row .field { width: auto; flex: 0 0 200px; }
.checks { display: grid; }
.job-form { padding: 16px; border: 1px solid var(--line); border-radius: var(--r); margin-bottom: 18px; background: var(--pit); }
.result { margin-top: 20px; display: grid; gap: 12px; }
.result:empty { display: none; }
.history h3, .jobs h3 { font-size: 22px; margin: 26px 0 8px; }
.runs li { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line-2); }
.runs a { display: grid; gap: 2px; text-decoration: none; min-width: 0; }
.run-in { color: var(--cream); font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.run-at { font-size: 11.5px; color: var(--faint); }
.runs a:hover .run-in { text-decoration: underline; }
.share-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }

/* jobs */
.job-list { display: grid; gap: 14px; }
.job { border: 1px solid var(--line-2); border-radius: var(--r); padding: 16px; background: var(--pit); display: grid; gap: 10px; }
.job-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.job-top b { display: block; font-family: var(--display); font-size: 24px; font-weight: 500; color: var(--cream); line-height: 1.1; overflow-wrap: anywhere; }
.job-meta { font-size: 11.5px; color: var(--gilt); letter-spacing: 0.06em; }
.job-task { color: var(--dim); font-size: 14.5px; white-space: pre-wrap; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.job-acts { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---------------------------------------------------------------- the receipt */
.receipt { border: 1px solid var(--line); border-radius: var(--r); background: var(--pit); padding: clamp(16px, 2.2vw, 26px); display: grid; gap: 16px; box-shadow: 0 0 0 4px var(--glaze), 0 0 0 5px rgba(201, 163, 90, 0.25); }
.receipt-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.receipt-kind { display: flex; align-items: center; gap: 12px; min-width: 0; }
.receipt-kind .ic { color: var(--clay-hi); }
.receipt-kind b { display: block; font-family: var(--display); font-size: 24px; font-weight: 500; color: var(--cream); line-height: 1.1; overflow-wrap: anywhere; }
.receipt-kind span { font-family: var(--mono); font-size: 11.5px; color: var(--faint); }
.receipt-input p { color: var(--cream); margin-top: 6px; white-space: pre-wrap; overflow-wrap: anywhere; }
.receipt-err { display: flex; gap: 10px; align-items: flex-start; color: var(--bad); font-size: 14.5px; }
.receipt-err .ic { margin-top: 3px; }
.receipt-steps summary { cursor: pointer; font-family: var(--mono); font-size: 11.5px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--gilt); min-height: 36px; display: flex; align-items: center; }
.steps { display: grid; gap: 0; margin-top: 4px; border-top: 1px solid var(--line-2); }
.step { display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line-2); align-items: start; }
.step-ic { color: var(--faint); padding-top: 2px; }
.step.code .step-ic, .step.tool .step-ic { color: var(--clay-hi); }
.step-top { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; }
.step-top b { font-size: 14px; color: var(--cream); font-weight: 500; }
.step-arg { font-family: var(--mono); font-size: 12px; color: var(--dim); overflow-wrap: anywhere; }
.step-sum { font-size: 13.5px; color: var(--faint); margin-top: 2px; overflow-wrap: anywhere; }
.step-cost { font-size: 11.5px; color: var(--faint); padding-top: 3px; }
.step-code summary { cursor: pointer; font-size: 12.5px; color: var(--dim); min-height: 30px; display: inline-flex; align-items: center; }
.step-code pre { margin: 6px 0 0; background: var(--glaze); border: 1px solid var(--line-2); border-radius: var(--r); padding: 10px 12px; overflow-x: auto; font-size: 12.5px; line-height: 1.5; color: var(--cream); max-height: 320px; }
.receipt-out { border-top: 1px solid var(--line-2); padding-top: 16px; }
.receipt-sources ol { margin-top: 8px; display: grid; gap: 6px; counter-reset: s; }
.receipt-sources li { counter-increment: s; display: flex; gap: 8px; align-items: baseline; font-size: 14px; min-width: 0; }
.receipt-sources li::before { content: counter(s); font-family: var(--mono); font-size: 11.5px; color: var(--gilt); width: 18px; flex: none; }
.receipt-sources a { color: var(--cream); overflow-wrap: anywhere; }
.src-host { font-size: 11.5px; color: var(--faint); white-space: nowrap; }
.receipt-note { font-size: 13px; color: var(--faint); }
.receipt-foot { display: flex; flex-wrap: wrap; gap: 8px 22px; align-items: center; border-top: 1px solid var(--line-2); padding-top: 14px; font-size: 13px; color: var(--faint); }
.receipt-foot b { color: var(--dim); font-weight: 500; }
.receipt-link { margin-left: auto; display: inline-flex; align-items: center; gap: 6px; color: var(--clay-hi); text-decoration: none; font-weight: 600; min-height: 40px; }
.receipt-link:hover { text-decoration: underline; }
.receipt.compact { box-shadow: none; }

/* dialogs */
.dlg-body { display: grid; gap: 14px; color: var(--dim); font-size: 15px; }
.dlg-list { display: grid; gap: 7px; }
.dlg-list li { position: relative; padding-left: 20px; }
.dlg-list li::before { content: ""; position: absolute; left: 2px; top: 0.7em; width: 7px; height: 1px; background: var(--gilt); }
.dlg-row { display: flex; justify-content: flex-end; gap: 10px; }
.dlg-msg { min-height: 20px; font-size: 14px; color: var(--dim); }
.dlg-msg.bad { color: var(--bad); }

/* the burn page */
.burn-grid { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 0.75fr); gap: clamp(20px, 3vw, 40px); align-items: start; margin-top: 34px; }
.burn-art { padding: 14px; background: linear-gradient(135deg, #e7c77e, #9a742f 28%, #d9b566 52%, #7c5a22 78%, #c9a35a); box-shadow: 0 0 0 1px #5a4118, 0 30px 60px -20px #000, inset 0 0 0 5px rgba(0, 0, 0, 0.22); }
.burn-art img { width: 100%; height: auto; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.7); }
.burn-art + .credit-line { margin-top: 12px; font-family: var(--display); font-style: italic; font-size: 16px; color: var(--faint); }
.page .stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); margin: 30px 0 0; border: 1px solid var(--line); box-shadow: 0 0 0 4px var(--pit), 0 0 0 5px rgba(201, 163, 90, 0.3); }
.page .stats > div { padding: 20px clamp(12px, 2vw, 24px); border-right: 1px solid var(--line); }
.page .stats > div:last-child { border-right: 0; }
.page .stats dt { font-family: var(--mono); font-size: 11.5px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--gilt); }
.page .stats dd { margin: 8px 0 2px; font-family: var(--display); font-size: clamp(30px, 4vw, 52px); line-height: 1; color: var(--cream); font-variant-numeric: lining-nums tabular-nums; }
.page .stats span { font-size: 12.5px; color: var(--faint); }

@media (max-width: 900px) {
  .desk { grid-template-columns: minmax(0, 1fr); }
  .side { position: static; }
  .acct { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); column-gap: 18px; }
  .acct-top, .acct .btn, .acct .linkish { grid-column: 1 / -1; }
  .meter#hold { grid-column: 1 / -1; }
  .burn-grid { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .gate { grid-template-columns: 1fr; min-height: 0; }
  .gate-art { justify-self: center; order: -1; padding: 10px; }
  .gate-art img { width: min(190px, 46vw); }
  .tabs button { flex-direction: column; gap: 3px; font-size: 16px; min-height: 66px; padding: 6px 2px; }
  .tabs button .ic { width: 24px; height: 24px; }
  .tool { padding: 16px 14px; }
  .tool-head { flex-direction: column; }
  .page .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .page .stats > div:nth-child(2) { border-right: 0; }
  .page .stats > div:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .step { grid-template-columns: 22px minmax(0, 1fr); }
  .step-cost { grid-column: 2; padding-top: 0; }
  .receipt-link { margin-left: 0; }
  .ask .row .field { flex: 1 1 100%; }
}
@media (max-width: 400px) {
  .acct { column-gap: 14px; padding: 16px 14px; }
  .meter-top { flex-direction: column; gap: 2px; }
  .chat-log { max-height: 50vh; }
}
@media (max-width: 330px) {
  .acct { grid-template-columns: minmax(0, 1fr); }
}

.wallet-list { display: grid; gap: 8px; }
.wallet-list button { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 54px; padding: 8px 14px; background: var(--pit); border: 1px solid var(--line-2); border-radius: var(--r); color: var(--cream); font-size: 16px; text-align: left; }
.wallet-list button:hover { border-color: var(--gilt); }
.wallet-list img { border-radius: 6px; }
.wallet-list .ic { color: var(--clay-hi); }
