@font-face { font-family: "IBM Plex Sans"; src: url("../fonts/IBMPlexSans-400.woff2") format("woff2"); font-weight: 400; }
@font-face { font-family: "IBM Plex Sans"; src: url("../fonts/IBMPlexSans-500.woff2") format("woff2"); font-weight: 500; }
@font-face { font-family: "IBM Plex Sans"; src: url("../fonts/IBMPlexSans-600.woff2") format("woff2"); font-weight: 600; }
@font-face { font-family: "IBM Plex Sans"; src: url("../fonts/IBMPlexSans-700.woff2") format("woff2"); font-weight: 700; }
@font-face { font-family: "IBM Plex Mono"; src: url("../fonts/IBMPlexMono-400.woff2") format("woff2"); font-weight: 400; }
@font-face { font-family: "IBM Plex Mono"; src: url("../fonts/IBMPlexMono-500.woff2") format("woff2"); font-weight: 500; }

:root {
  --bg: #fbf6ee; --card: #fffdf9; --line: #eadfce; --text: #3a2414; --muted: #7d6552;
  --tea: #6b3f1d; --tea-50: #f5ebdd; --saffron: #e07a1f; --saffron-50: #fdf0e3;
  --good: #2f7a3e; --good-50: #e8f4ea; --bad: #b3261e; --bad-50: #fbe9e7; --warn: #9a5b00;
  --sans: "IBM Plex Sans", system-ui, sans-serif; --mono: "IBM Plex Mono", ui-monospace, monospace;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 var(--sans); }
h1, h2 { margin: 0; line-height: 1.2; }
code, .mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.btn { font: inherit; font-weight: 500; padding: 7px 14px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--card); color: var(--tea); cursor: pointer; }
.btn:hover:not(:disabled) { border-color: var(--tea); }
.btn.primary { background: var(--tea); border-color: var(--tea); color: #fff; }
.btn:disabled { opacity: .5; cursor: default; }
.banner { padding: 8px 12px; border-radius: 8px; margin: 8px 0; font-size: 14px; }
.banner.bad { background: var(--bad-50); color: var(--bad); border: 1px solid #f1c4bf; }

/* kulhad: a clay chai cup, the coin of ChaiCoin */
.kulhad { display: inline-block; position: relative; width: 22px; height: 24px; flex: none; }
.kulhad::before { content: ""; position: absolute; inset: 3px 1px 0; border-radius: 0 0 4px 4px;
  background: linear-gradient(90deg, #9a4a22, #c8743f 45%, #a4552a); clip-path: polygon(0 0, 100% 0, 84% 100%, 16% 100%); }
.kulhad::after { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 7px; border-radius: 50%;
  background: radial-gradient(ellipse at 50% 60%, #7a4a26 0 45%, #d9a066 52% 100%); }
.kulhad.big { width: 38px; height: 42px; }
.kulhad.big::before { inset: 5px 2px 0; }
.kulhad.big::after { height: 12px; }

/* ---------------------------------------------------------------- friend page */
body.node { padding: 12px 14px 24px; }
body.node.offline { background: #f1ebe2; }
.node-head { display: flex; align-items: center; gap: 12px; }
.node-head .who { flex: 1; min-width: 0; }
.node-head h1 { font-size: 21px; }
.node-head #keyline { margin: 0; font-size: 11px; color: var(--muted); }
.switch { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; font-weight: 500; font-size: 13px; }
.switch input { appearance: none; margin: 0; width: 34px; height: 19px; border-radius: 99px; background: #cdbfae; position: relative; cursor: pointer; transition: background .2s; }
.switch input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 15px; height: 15px; border-radius: 50%; background: #fff; transition: transform .2s; }
.switch input:checked { background: var(--good); }
.switch input:checked::after { transform: translateX(15px); }
.offline .switch span { color: var(--bad); }
.link { color: var(--tea); font-size: 13px; }
.chips { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 10px 0 0; }
.chip { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); font-size: 13.5px; min-width: 0; }
.chip > span { display: flex; align-items: center; gap: 6px; min-width: 0; }
.chip b { font: 600 17px var(--mono); color: var(--tea); }
.chip.me { border-color: var(--tea); background: var(--tea-50); font-weight: 600; }
.chip .kulhad { width: 14px; height: 16px; }
.chip .kulhad::after { height: 5px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin: 10px 0; }
.card h2 { font-size: 15px; }
.card h2 .muted { font-weight: 400; font-size: 13px; }
.card h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 12px 0 6px; font-weight: 500; }
.pay { display: flex; flex-direction: column; align-items: stretch; gap: 8px; }
.pay select, .pay input { width: 100%; font: inherit; padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--text); min-width: 0; }
.pay .btn { width: 100%; }
.pay .inr { font-size: 12px; color: var(--muted); }
.pay .inr:empty { display: none; }
.msg { margin: 6px 0 0; font-size: 13px; }
.msg:empty { display: none; }
.msg.bad { color: var(--bad); }
.msg.good { color: var(--good); }
.txlist { list-style: none; margin: 0; padding: 0; font-size: 13.5px; }
.txlist li { padding: 4px 8px; background: var(--saffron-50); border-radius: 6px; margin-bottom: 4px; }
.mine-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 10px; }
#mine-status { font-size: 12px; }

/* blocks: chai-stall bill slips tied together by a dotted string */
.chain { display: flex; flex-direction: column; gap: 18px; margin-top: 8px; }
.block { position: relative; background: #fffaf2; border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px 7px; font-size: 13px; box-shadow: 0 1px 0 var(--line); }
.block + .block::before { content: ""; position: absolute; top: -19px; left: 23px; height: 18px; border-left: 2px dotted #c9a57f; }
.block header { display: flex; align-items: flex-start; gap: 8px; padding-bottom: 6px; border-bottom: 1px dashed var(--line); }
.block .meta { flex: 1; min-width: 0; display: flex; flex-wrap: wrap; align-items: baseline; column-gap: 8px; row-gap: 2px; }
.block .badge { display: inline-grid; place-items: center; width: 24px; height: 24px; flex: none; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #d58a52, #9a4a22); color: #fff; font: 600 12px var(--mono); box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .25); }
.block .by { color: var(--muted); font-size: 12.5px; white-space: nowrap; }
.block .by b { color: var(--text); font-weight: 600; }
.block .hash { flex-basis: 100%; font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.block i { font-style: normal; color: var(--muted); margin-right: 5px; font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; }
.block em { font-style: normal; color: var(--saffron); font-weight: 500; }
.block .tag { font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; font-weight: 600; padding: 1px 7px; border-radius: 99px; background: var(--line); color: var(--muted); }
.items { list-style: none; margin: 4px 0; padding: 0; }
.items li { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 6px 0; }
.items li span { min-width: 0; }
.items li b { font: 500 13px var(--mono); }
.items li b small { display: block; font-size: 11px; font-weight: 400; color: var(--muted); }
.items li q { display: block; font-size: 12px; font-style: italic; color: var(--muted); }
.items li q::before { content: "“"; }
.items li q::after { content: "”"; }
.items li.join { color: var(--muted); }
.items .genesis-msg { font-style: italic; color: var(--muted); }
.items li.edited { background: #fff3c4; margin: 2px -6px; padding: 3px 6px; border-radius: 4px; font-weight: 600; color: var(--text); }
.items li.edited s { display: block; font-weight: 400; font-size: 12px; color: var(--muted); }
.block footer { padding-top: 5px; border-top: 1px dashed var(--line); font-size: 11.5px; color: var(--muted); }
.block.bad { border-color: #eab3ad; background: var(--bad-50); }
.block.bad .badge { background: var(--bad); }
.block.bad .tag { background: var(--bad); color: #fff; }
.block .reason { margin: 6px 0 0; color: var(--bad); font-weight: 500; font-size: 12.5px; }
.block.dropped { opacity: .55; }
.block.dropped .badge { background: #b9ab9a; }
.dropped-title + .block::before { content: none; }
.dropped-title { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 6px 0 -10px; }

.log { list-style: none; margin: 6px 0 0; padding: 0; font-size: 13px; max-height: 150px; overflow: auto; }
.log li { padding: 4px 0; border-top: 1px solid var(--line); }
.log li:first-child { border-top: 0; }
.log time { color: var(--muted); font: 11px var(--mono); margin-right: 8px; }
.log .good { color: var(--good); }
.log .bad { color: var(--bad); }
.log .warn { color: var(--warn); }
.trouble summary { cursor: pointer; font-weight: 600; font-size: 15px; }
.trouble-btns { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.trouble-btns .btn { width: 100%; }

/* ---------------------------------------------------------------- stall page */
body.stall { height: 100vh; display: flex; flex-direction: column; overflow: hidden; }
.stall-head { display: flex; align-items: center; gap: 16px; padding: 10px 16px; border-bottom: 1px solid var(--line); background: var(--card); flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; margin-right: auto; }
.brand h1 { font-size: 22px; color: var(--tea); }
.brand p { margin: 0; color: var(--muted); font-size: 13.5px; }
.scenarios { display: flex; gap: 6px; flex-wrap: wrap; }
.scn { font: inherit; font-weight: 500; font-size: 14px; padding: 6px 12px 6px 6px; border-radius: 99px; border: 1px solid var(--line); background: var(--card); color: var(--tea); cursor: pointer; }
.scn b { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--tea-50); margin-right: 8px; font-size: 12px; }
.scn:hover:not(:disabled) { border-color: var(--tea); }
.scn.active { background: var(--tea); border-color: var(--tea); color: #fff; }
.scn.active b { background: rgba(255, 255, 255, .2); }
.scn:disabled { opacity: .55; cursor: default; }
.controls { display: flex; gap: 10px; align-items: center; font-size: 13.5px; color: var(--muted); }
.controls select { font: inherit; padding: 4px 6px; border-radius: 6px; border: 1px solid var(--line); background: #fff; color: var(--text); }
.story { padding: 10px 16px 12px; border-bottom: 1px solid var(--line); background: var(--tea-50); }
.story h2 { display: inline; font-size: 16px; color: var(--tea); margin-right: 10px; }
.story .lead { display: inline; margin: 0; color: var(--muted); font-size: 14px; }
.story ol { list-style: none; counter-reset: step; margin: 8px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.story ol:empty { display: none; }
.story li { counter-increment: step; font-size: 13.5px; padding: 4px 12px 4px 6px; border-radius: 99px; background: var(--card); border: 1px solid var(--line); color: var(--muted); }
.story li::before { content: counter(step); display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; background: var(--line); color: var(--text); font-size: 11px; margin-right: 6px; }
.story li.now { border-color: var(--saffron); background: var(--saffron-50); color: var(--text); }
.story li.now::before { background: var(--saffron); color: #fff; }
.story li.done { color: var(--text); }
.story li.done::before { content: "✓"; background: var(--good); color: #fff; }
.story li.failed { border-color: var(--bad); color: var(--bad); }
.story .outcome { margin: 8px 0 0; font-weight: 500; color: var(--good); }
.story .outcome:empty { display: none; }
.story .outcome.bad { color: var(--bad); }
.friends { flex: 1; min-height: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; background: var(--line); }
.friend { position: relative; min-height: 0; background: var(--bg); }
.friend iframe { display: block; width: 100%; height: 100%; border: 0; }
.friend .away { display: none; }
.friend.popped iframe { display: none; }
.friend.popped .away { display: grid; place-items: center; height: 100%; text-align: center; color: var(--muted); }
@media (max-width: 900px) {
  body.stall { height: auto; overflow: auto; }
  .friends { grid-template-columns: 1fr; }
  .friend { height: 90vh; }
}
