/* OpenModel chat — dark, minimal, Filecoin-blue accent. No framework. */
:root {
  --bg: #0d1117;
  --panel: #161b22;
  --panel2: #1c2129;
  --border: #2d333c;
  --text: #e6e8eb;
  --muted: #8b949e;
  --accent: #0090ff;
  --accent-dim: #0a5ea8;
  --danger: #f85149;
  --ok: #3fb950;
}
* { box-sizing: border-box; margin: 0; }
html, body, #app { height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
}
#app { display: flex; }

/* ---- sidebar ---- */
#sidebar {
  width: 320px;
  min-width: 260px;
  background: var(--panel);
  border-right: 1px solid var(--border);
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow-y: auto;
}
.brand-name { font-size: 22px; font-weight: 700; letter-spacing: .3px; }
.brand-name::before { content: "◍ "; color: var(--accent); }
.brand-sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.badge {
  background: var(--accent-dim);
  color: #fff;
  border-radius: 10px;
  padding: 1px 8px;
  font-size: 11px;
  vertical-align: middle;
}
.card {
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.card h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); }
.kv { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 14px; }
.kv > span { color: var(--muted); }
.row { display: flex; gap: 8px; flex-wrap: wrap; }
/* An amount field must never shrink below its own placeholder: in the 287px
   sidebar the currency select and button left it a 54px content box, which cut
   "amount" mid-word. Wrapping is the right fallback, not squeezing. */
.row input { flex: 1 1 110px; min-width: 110px; }
/* currency + amount + action: when the three do not fit on one line the button
   wraps and fills its own line instead of hanging in the corner. */
.amount-row button { flex: 1 1 auto; }
.hint { color: var(--muted); font-size: 12.5px; }
.foot { margin-top: auto; padding: 4px 2px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }

button {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 12px;
  font-size: 13.5px;
  cursor: pointer;
}
button:hover:not(:disabled) { border-color: var(--accent); }
button:disabled { opacity: .45; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
button.primary:hover:not(:disabled) { background: #1a9dff; }
button.danger:hover:not(:disabled) { border-color: var(--danger); color: var(--danger); }
input, select, textarea {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 13.5px;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }
details summary { cursor: pointer; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---- chat ---- */
#chat { flex: 1; display: flex; flex-direction: column; min-width: 0; }
#messages { flex: 1; overflow-y: auto; padding: 28px clamp(16px, 6vw, 90px); display: flex; flex-direction: column; gap: 14px; }
.msg { max-width: 46em; border-radius: 12px; padding: 10px 14px; overflow-wrap: break-word; }
.msg.user { align-self: flex-end; background: var(--accent-dim); }
.msg.assistant { align-self: flex-start; background: var(--panel2); border: 1px solid var(--border); }
.msg.system { align-self: center; color: var(--muted); background: none; text-align: center; max-width: 40em; }
.msg.system p + p { margin-top: 8px; }
.msg.error { border-color: var(--danger); }
.msg pre {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  margin: 8px 0;
  overflow-x: auto;
  font-size: 13px;
}
.msg code { background: var(--bg); border-radius: 4px; padding: 1px 5px; font-size: 13px; }
.receipt { margin-top: 8px; padding-top: 6px; border-top: 1px dashed var(--border); color: var(--muted); font-size: 12px; }
.receipt::before { content: "✓ "; color: var(--ok); }

/* ---- model price display ---- */
#model-price { font-size: 12px; margin-top: -2px; }
#model-price-bar {
  padding: 7px clamp(16px, 6vw, 90px);
  border-bottom: 1px solid var(--border);
  background: var(--panel);
  color: var(--muted);
  font-size: 12.5px;
}
table.pricing { width: 100%; border-collapse: collapse; font-size: 12px; margin-top: 6px; }
table.pricing th, table.pricing td { text-align: right; padding: 3px 4px; border-bottom: 1px solid var(--border); }
table.pricing th:first-child, table.pricing td:first-child { text-align: left; }
table.pricing th { color: var(--muted); font-weight: 600; }
table.pricing tr.offline td { opacity: .5; }
table.pricing tr.offline td:first-child::after { content: " ·offline"; color: var(--muted); font-size: 10px; }

/* ---- wallet picker (EIP-6963) ---- */
#wallet-picker { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
button.wallet-option {
  display: flex; align-items: center; gap: 10px;
  text-align: left; padding: 8px 10px;
}
button.wallet-option:hover { border-color: var(--accent); }
.wallet-icon { width: 22px; height: 22px; border-radius: 5px; }

/* ---- key management panel ---- */
button.small { padding: 3px 9px; font-size: 12px; }
.keyrow { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--border); }
.keyrow:last-child { border-bottom: none; }
.keyrow-info { min-width: 0; }
.hint.warn { color: #e8b339; }
/* white-space: pre-wrap so a <pre> (the API snippet) keeps its newlines but still
 * wraps long lines; word-break handles the unbreakable URL / bearer token. Without
 * it the <pre> defaults to white-space: pre and overflows the card, clipping the
 * curl command on the right. */
.mono.wrap { display: block; white-space: pre-wrap; word-break: break-all; background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: 8px; margin: 6px 0; max-width: 100%; }

#composer { display: flex; gap: 10px; padding: 14px clamp(16px, 6vw, 90px); border-top: 1px solid var(--border); background: var(--panel); }
#composer textarea { flex: 1; resize: none; }
#statusline { padding: 4px clamp(16px, 6vw, 90px) 10px; background: var(--panel); min-height: 24px; }

/* ---- narrow screens ---- */
@media (max-width: 760px) {
  #app { flex-direction: column; }
  #sidebar { width: 100%; min-width: 0; border-right: none; border-bottom: 1px solid var(--border); max-height: 45vh; }
  #messages, #composer, #statusline { padding-left: 12px; padding-right: 12px; }
}

/* receipt viewer overlay */
#receipt-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: flex; align-items: center; justify-content: center; z-index: 60; }
#receipt-card { position: relative; background: var(--bg, #16181d); color: inherit; border: 1px solid var(--border, #2a2e37); border-radius: 10px; max-width: 640px; width: calc(100% - 40px); max-height: 80vh; overflow: auto; padding: 20px 22px; }
#receipt-card h3 { margin: 0 0 10px; }
#receipt-card pre { overflow-x: auto; font-size: 12px; background: rgba(127,127,127,.08); padding: 10px; border-radius: 6px; }
#receipt-card .dim { opacity: .65; }
#receipt-close { position: absolute; top: 8px; right: 12px; background: none; border: none; color: inherit; font-size: 22px; cursor: pointer; }

/* attention pulse for the guided register button */
@keyframes ompulse { 0%,100% { box-shadow: 0 0 0 0 rgba(96,165,250,.7);} 50% { box-shadow: 0 0 0 8px rgba(96,165,250,0);} }
.pulse { animation: ompulse 0.8s ease-out 3; }

/* Thinking-mode reasoning foldout: a quiet footnote above the answer. */
.think { margin: 0 0 8px; font-size: 12px; opacity: .75; }
.think summary { cursor: pointer; user-select: none; }
.think-body { white-space: pre-wrap; border-left: 2px solid rgba(128,128,128,.35);
  padding: 4px 0 4px 10px; margin-top: 4px; }
