/* ============================================================================
   CLAWED — stylesheet
   Warm off-white, coral accent, serif greeting. You know the one.
   ========================================================================= */

:root {
  --bg:            #faf9f5;
  --bg-sidebar:    #f2f1ea;
  --bg-raised:     #ffffff;
  --bg-hover:      #eceadf;
  --bg-user:       #f0eee4;
  --bg-inset:      #f4f2ea;

  --text:          #1f1e1d;
  --text-soft:     #6b6a63;
  --text-faint:    #97958c;

  --line:          #e4e2d8;
  --line-soft:     #edebe2;

  --accent:        #d97757;
  --accent-ink:    #b3573a;
  --accent-wash:   #f7ebe4;

  --radius:        12px;
  --radius-lg:     18px;
  --sidebar-w:     264px;

  --shadow-sm:     0 1px 2px rgba(31,30,29,.05);
  --shadow-md:     0 2px 6px rgba(31,30,29,.06), 0 1px 2px rgba(31,30,29,.04);
  --shadow-lg:     0 12px 34px rgba(31,30,29,.13), 0 2px 8px rgba(31,30,29,.07);

  --sans: ui-sans-serif, -apple-system, "Segoe UI", Inter, system-ui, sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, ui-serif, serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", Consolas, monospace;
}

[data-theme="dark"] {
  --bg:            #262624;
  --bg-sidebar:    #1d1d1b;
  --bg-raised:     #30302e;
  --bg-hover:      #3a3a37;
  --bg-user:       #1f1f1d;
  --bg-inset:      #2b2b29;

  --text:          #f4f3ee;
  --text-soft:     #a8a69d;
  --text-faint:    #7c7a72;

  --line:          #3d3d39;
  --line-soft:     #343431;

  --accent:        #e08767;
  --accent-ink:    #eda184;
  --accent-wash:   #3a2b24;

  --shadow-sm:     0 1px 2px rgba(0,0,0,.3);
  --shadow-md:     0 2px 6px rgba(0,0,0,.34);
  --shadow-lg:     0 14px 38px rgba(0,0,0,.48);
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
svg { width: 20px; height: 20px; fill: currentColor; flex: none; }
ul  { list-style: none; margin: 0; padding: 0; }

.app { display: flex; height: 100%; }

/* ══════════════════════════ sidebar ══════════════════════════ */

.sidebar {
  width: var(--sidebar-w);
  flex: none;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  transition: margin-left .22s ease;
}
.app.collapsed .sidebar { margin-left: calc(var(--sidebar-w) * -1); }

.sb-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 12px 6px 16px;
}
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; color: inherit; }
.brand-mark { width: 22px; height: 22px; color: var(--accent); }
.brand-name { font-size: 18px; font-weight: 600; letter-spacing: -.02em; }

.sb-nav { padding: 6px 8px 10px; display: flex; flex-direction: column; gap: 1px; }
.sb-item {
  display: flex; align-items: center; gap: 11px;
  padding: 8px 8px; border-radius: 9px;
  color: var(--text-soft); font-size: 14.5px; text-align: left; width: 100%;
  text-decoration: none; cursor: pointer;
}
.sb-item svg { width: 17px; height: 17px; }
.sb-item:hover { background: var(--bg-hover); color: var(--text); }
.sb-item.accent { color: var(--accent); font-weight: 500; }
.sb-item.accent:hover { color: var(--accent-ink); }

.sb-recents { flex: 1; overflow-y: auto; padding: 6px 8px 8px; min-height: 0; }
.sb-label {
  font-size: 12px; color: var(--text-faint); font-weight: 500;
  padding: 8px 8px 6px; letter-spacing: .01em;
}
.sb-recents li a {
  display: block; padding: 7px 8px; border-radius: 8px;
  color: var(--text-soft); font-size: 14px; text-decoration: none;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sb-recents li a:hover { background: var(--bg-hover); color: var(--text); }
.sb-recents li a.on { background: var(--bg-hover); color: var(--text); }

.sb-foot { padding: 8px; border-top: 1px solid var(--line-soft); }
.user-pill {
  display: flex; align-items: center; gap: 9px; width: 100%;
  padding: 7px 8px; border-radius: 10px; text-align: left;
}
.user-pill:hover { background: var(--bg-hover); }
.avatar {
  width: 28px; height: 28px; border-radius: 50%; flex: none;
  background: var(--accent); color: #fff;
  display: grid; place-items: center; font-size: 13px; font-weight: 600;
}
.user-meta { display: flex; flex-direction: column; line-height: 1.25; flex: 1; min-width: 0; }
.user-name { font-size: 14px; font-weight: 500; }
.user-plan { font-size: 12px; color: var(--text-faint); }
.chev { width: 15px; height: 15px; color: var(--text-faint); }

.scrim { display: none; }

/* ══════════════════════════ main ══════════════════════════ */

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.topbar {
  height: 52px; flex: none;
  display: flex; align-items: center; gap: 10px;
  padding: 0 16px;
}
.topbar-title { font-size: 14.5px; font-weight: 500; color: var(--text-soft); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }

.icon-btn {
  width: 32px; height: 32px; border-radius: 8px;
  display: grid; place-items: center; color: var(--text-soft);
}
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn:hover { background: var(--bg-hover); color: var(--text); }
.icon-btn.sm { width: 30px; height: 30px; }

.only-collapsed { display: none; }
.app.collapsed .only-collapsed { display: grid; }

/* contract-address pill */
.ca-pill {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 4px 10px 4px 4px; border-radius: 999px;
  background: var(--bg-inset); border: 1px solid var(--line);
  font-size: 12.5px; color: var(--text-soft);
  max-width: 100%;
}
.ca-pill .ticker {
  background: var(--accent); color: #fff;
  font-size: 11.5px; font-weight: 650; letter-spacing: .01em;
  padding: 3px 8px; border-radius: 999px; flex: none;
}
.ca-text {
  font-family: var(--mono); font-size: 12px; color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ca-ico { width: 14px; height: 14px; flex: none; color: var(--text-faint); }
.ca-pill:hover:not(.pending) { background: var(--bg-hover); border-color: var(--accent); }
.ca-pill:hover:not(.pending) .ca-ico { color: var(--accent); }
.ca-pill.pending { cursor: default; }
.ca-pill.pending .ca-text { color: var(--text-faint); font-family: var(--sans); font-style: italic; }
.ca-pill.pending .ca-ico { display: none; }
.ca-pill.copied { border-color: var(--accent); }
.ca-pill.copied .ca-ico { color: var(--accent); }
/* clipboard blocked — the full address is shown and selected instead */
.ca-pill.expanded { border-color: var(--accent); }
.ca-pill.expanded .ca-text { user-select: all; max-width: none; font-size: 11.5px; }

.treats {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12.5px; color: var(--text-soft);
  background: var(--bg-inset); border: 1px solid var(--line-soft);
  padding: 4px 10px; border-radius: 999px;
}
.treats svg { width: 13px; height: 13px; color: var(--accent); }
.treats b { font-weight: 600; color: var(--text); }
.treats.empty { color: var(--accent-ink); border-color: var(--accent); }

#theme .ico-moon { display: none; }
[data-theme="dark"] #theme .ico-sun { display: none; }
[data-theme="dark"] #theme .ico-moon { display: block; }

/* ── scroll area ── */
.scroll { flex: 1; overflow-y: auto; min-height: 0; }
.stage { max-width: 760px; margin: 0 auto; padding: 0 24px; }

/* ── welcome ── */
.welcome {
  display: flex; align-items: center; justify-content: center; gap: 13px;
  padding: clamp(48px, 14vh, 130px) 0 30px;
}
.welcome.hide { display: none; }
.welcome-mark { width: 42px; height: 42px; color: var(--accent); }
.greeting {
  font-family: var(--serif);
  font-size: clamp(30px, 5vw, 42px);
  font-weight: 400; letter-spacing: -.015em; margin: 0;
}

/* ══════════════════════════ messages ══════════════════════════ */

.thread { padding-bottom: 28px; display: flex; flex-direction: column; gap: 26px; }
.thread:empty { display: none; }
.thread.top { padding-top: 26px; }

.turn { display: flex; flex-direction: column; }
.turn.user { align-items: flex-end; }

.bubble {
  background: var(--bg-user);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-lg);
  padding: 11px 16px;
  max-width: 78%;
  white-space: pre-wrap;
  word-break: break-word;
}

.reply { display: flex; gap: 14px; }
.reply-mark {
  width: 26px; height: 26px; flex: none; margin-top: 1px;
  color: var(--accent);
}
.reply-body { min-width: 0; flex: 1; }

/* markdown-ish output */
.md > *:first-child { margin-top: 0; }
.md > *:last-child { margin-bottom: 0; }
.md p { margin: 0 0 14px; }
.md strong { font-weight: 650; }
.md em { color: var(--text-soft); }
.md ol, .md ul { margin: 0 0 14px; padding-left: 22px; }
.md ol { list-style: decimal; }
.md ul { list-style: disc; }
.md li { margin: 4px 0; }
.md blockquote {
  margin: 0 0 14px; padding: 2px 0 2px 15px;
  border-left: 2.5px solid var(--accent);
  color: var(--text-soft); font-style: italic;
}
.md code {
  font-family: var(--mono); font-size: .88em;
  background: var(--bg-inset); border: 1px solid var(--line-soft);
  padding: 1.5px 5px; border-radius: 5px;
}
.md pre {
  margin: 0 0 14px; padding: 13px 15px; overflow-x: auto;
  background: var(--bg-inset); border: 1px solid var(--line-soft);
  border-radius: var(--radius);
}
.md pre code { background: none; border: 0; padding: 0; font-size: 13px; line-height: 1.65; }

.caret {
  display: inline-block; width: 8px; height: 15px;
  background: var(--accent); border-radius: 1px;
  vertical-align: -2px; margin-left: 2px;
  animation: blink 1s steps(2, start) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

.interrupt {
  margin-top: 14px; padding: 9px 13px;
  background: var(--bg-inset); border: 1px dashed var(--line);
  border-radius: 9px;
  font-size: 13.5px; color: var(--text-faint); font-style: italic;
}

/* ── thinking + tool blocks ── */
.block {
  border: 1px solid var(--line);
  background: var(--bg-inset);
  border-radius: var(--radius);
  margin-bottom: 14px;
  overflow: hidden;
}
.block-head {
  display: flex; align-items: center; gap: 9px; width: 100%;
  padding: 9px 13px; font-size: 13.5px; color: var(--text-soft);
}
.block-head:hover { background: var(--bg-hover); }
.block-head svg { width: 15px; height: 15px; }
.block-head .chev { margin-left: auto; transition: transform .18s ease; }
.block.open .block-head .chev { transform: rotate(180deg); }
.block-head b { font-weight: 550; color: var(--text); }

.block-body {
  display: none;
  padding: 2px 14px 13px 36px;
  font-size: 14px; color: var(--text-soft);
  white-space: pre-wrap;
}
.block.open .block-body { display: block; }

.tool-lines { padding: 2px 14px 12px 36px; display: flex; flex-direction: column; gap: 5px; }
.tool-lines div {
  font-size: 13.5px; color: var(--text-soft);
  opacity: 0; transform: translateY(3px);
  animation: rise .3s ease forwards;
}
.tool-lines b { color: var(--text); font-weight: 550; }
@keyframes rise { to { opacity: 1; transform: none; } }

.pulse { animation: pulse 1.5s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .45; } }

/* ══════════════════════════ composer ══════════════════════════ */

.composer-wrap {
  flex: none;
  padding: 6px 24px 12px;
  max-width: 760px; width: 100%; margin: 0 auto;
}

.composer {
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 12px 12px 10px;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.composer:focus-within { border-color: #d3d0c4; box-shadow: var(--shadow-lg); }
[data-theme="dark"] .composer:focus-within { border-color: #4c4c47; }

#input {
  width: 100%; border: 0; outline: 0; resize: none;
  background: none; color: var(--text);
  font: inherit; line-height: 1.55;
  padding: 2px 4px 8px; max-height: 200px;
}
#input::placeholder { color: var(--text-faint); }

.composer-bar { display: flex; align-items: center; gap: 8px; }
.composer-left, .composer-right { display: flex; align-items: center; gap: 6px; }
.composer-right { margin-left: auto; }

.pill-btn {
  display: flex; align-items: center; gap: 6px;
  padding: 5px 10px; border-radius: 8px;
  font-size: 13.5px; color: var(--text-soft);
}
.pill-btn svg { width: 15px; height: 15px; }
.pill-btn:hover { background: var(--bg-hover); color: var(--text); }
.pill-btn.on { color: var(--accent); background: var(--accent-wash); }
.model-btn .chev { width: 14px; height: 14px; }

.send {
  width: 32px; height: 32px; border-radius: 9px;
  background: var(--accent); color: #fff;
  display: grid; place-items: center;
  transition: opacity .15s ease, transform .1s ease;
}
.send svg { width: 17px; height: 17px; }
.send:hover:not(:disabled) { background: var(--accent-ink); }
.send:active:not(:disabled) { transform: scale(.93); }
.send:disabled { opacity: .28; cursor: default; }

/* ── menus ── */
.menu-anchor { position: relative; }
.menu {
  position: absolute; bottom: calc(100% + 8px);
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 5px;
  display: none; z-index: 40;
}
.menu.open { display: block; animation: pop .13s ease; }
@keyframes pop { from { opacity: 0; transform: translateY(4px); } }

.tools-menu { left: 0; width: 330px; }
.model-menu { right: 0; width: 300px; }

.menu-label {
  font-size: 11.5px; color: var(--text-faint); font-weight: 500;
  padding: 6px 9px 5px; text-transform: uppercase; letter-spacing: .04em;
}
.menu-row {
  display: flex; align-items: flex-start; gap: 10px; width: 100%;
  padding: 8px 9px; border-radius: 8px; text-align: left;
}
.menu-row:hover { background: var(--bg-hover); }
.row-ico { width: 16px; height: 16px; color: var(--text-soft); margin-top: 2px; }
.row-text { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.row-text b { font-size: 13.5px; font-weight: 500; }
.row-text i { font-size: 12.5px; color: var(--text-faint); font-style: normal; line-height: 1.45; }
.row-check { width: 15px; height: 15px; color: var(--accent); opacity: 0; margin-top: 3px; }
.menu-row.on .row-check { opacity: 1; }
.menu-row.on .row-ico { color: var(--accent); }

/* ── suggestions ── */
.suggestions {
  display: flex; flex-wrap: wrap; gap: 8px;
  justify-content: center; padding: 14px 0 2px;
}
.suggestions.hide { display: none; }
.chip {
  display: flex; align-items: center; gap: 7px;
  padding: 7px 13px; border-radius: 999px;
  background: var(--bg-raised); border: 1px solid var(--line);
  font-size: 13.5px; color: var(--text-soft);
  box-shadow: var(--shadow-sm);
}
.chip svg { width: 15px; height: 15px; color: var(--accent); }
.chip:hover { background: var(--bg-hover); color: var(--text); }

.disclaimer {
  text-align: center; font-size: 12px; color: var(--text-faint);
  margin: 12px 0 0;
}

/* ══════════════════════════ mobile ══════════════════════════ */

@media (max-width: 820px) {
  .sidebar {
    position: fixed; inset: 0 auto 0 0; z-index: 60;
    margin-left: calc(var(--sidebar-w) * -1);
    box-shadow: var(--shadow-lg);
  }
  .app.open .sidebar { margin-left: 0; }
  .app.collapsed .sidebar { margin-left: calc(var(--sidebar-w) * -1); }
  .only-collapsed { display: grid; }

  .scrim {
    display: block; position: fixed; inset: 0; z-index: 55;
    background: rgba(31,30,29,.4);
    opacity: 0; pointer-events: none; transition: opacity .2s ease;
  }
  .app.open .scrim { opacity: 1; pointer-events: auto; }

  .stage, .composer-wrap { padding-left: 14px; padding-right: 14px; }
  /* the contract stays; the treat counter is the one that goes */
  .treats { display: none; }
  .topbar { padding: 0 10px; gap: 6px; }
  .topbar-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
  .ca-pill { padding-right: 8px; }
  .ca-text { max-width: 34vw; }
  .bubble { max-width: 88%; }
  .tools-menu { width: min(330px, calc(100vw - 40px)); }
  .suggestions .chip:nth-child(n+3) { display: none; }
}
