/* Panel styles. Colours come from the app's theme (CC applyTheme sets the variables);
   the defaults below are the "Claude" theme. Radii: 8 small, 12 cards, 22 sheets/pills. */
:root {
  --bg: #141413; --bar: #1c1c1a; --key: #2b2a27; --keytext: #ece9e1; --input: #262522;
  --text: #f2efe7; --dim: #8a877e; --accent: #d97757; --onaccent: #141413;
  --fg: #e8e5dc; --red: #e5675f; --green: #8fbf74; --yellow: #e3b964; --blue: #7aa3d9;
  --magenta: #c38fd1; --cyan: #6fc1bf; --bred: #f07f77; --bgreen: #a6d48b;
  --mono: ui-monospace, "JetBrains Mono", "Roboto Mono", monospace;
  --sans: "Google Sans Text", "Google Sans", Roboto, system-ui, sans-serif;
  --scale: 1;
  /* derived */
  --line: color-mix(in srgb, var(--text) 10%, transparent);
  --raised: color-mix(in srgb, var(--key) 70%, var(--bg));
  --dim2: color-mix(in srgb, var(--dim) 65%, var(--text));
  --accent-soft: color-mix(in srgb, var(--accent) 16%, transparent);
  --add-bg: color-mix(in srgb, var(--green) 16%, transparent);
  --del-bg: color-mix(in srgb, var(--red) 16%, transparent);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); height: 100%; }
body {
  font: calc(15px * var(--scale)) / 1.5 var(--sans);
  overscroll-behavior: none;
  -webkit-text-size-adjust: 100%;
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
input { font: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }
code, pre, .mono { font-family: var(--mono); }
.icon { display: block; flex: none; }

#app { height: 100%; }
.screen { height: 100%; display: flex; flex-direction: column; }
.scroll { flex: 1; overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; }

/* ── Top bar ─────────────────────────────────────────────────── */
.topbar {
  flex: none; display: flex; align-items: center; gap: 4px;
  min-height: 52px; padding: 4px 6px; background: var(--bar);
  border-bottom: 1px solid var(--line);
}
.tb-btn {
  width: 44px; height: 44px; border-radius: 22px; display: flex; align-items: center;
  justify-content: center; color: var(--keytext); flex: none;
}
.tb-btn:active { background: var(--key); }
.tb-label { width: auto; padding: 0 14px; font-weight: 600; color: var(--accent); }
.tb-text { flex: 1; min-width: 0; padding: 0 4px; }
.tb-title { font-weight: 600; font-size: 1.05em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tb-sub { color: var(--dim2); font-size: .8em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── Lists and cards ─────────────────────────────────────────── */
.section { padding: 14px 16px 6px; color: var(--dim2); font-size: .78em; font-weight: 600;
  letter-spacing: .06em; text-transform: uppercase; }
.row {
  display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 8px 16px;
  border-bottom: 1px solid var(--line); width: 100%; text-align: left;
}
.row:active { background: var(--raised); }
.row-main { flex: 1; min-width: 0; }
.row-t { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-s { color: var(--dim2); font-size: .82em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-end { color: var(--dim); font-size: .8em; flex: none; text-align: right; }
.card {
  background: var(--raised); border-radius: 12px; margin: 8px 12px; padding: 12px 14px;
  border: 1px solid var(--line);
}
.card:active { border-color: color-mix(in srgb, var(--accent) 50%, transparent); }

.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 12px;
  border-radius: 15px; background: var(--key); color: var(--keytext); font-size: .85em;
  white-space: nowrap; flex: none;
}
.chip.on { background: var(--accent); color: var(--onaccent); font-weight: 600; }
.chips { display: flex; gap: 8px; padding: 8px 12px; overflow-x: auto; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 18px; border-radius: 22px; background: var(--accent);
  color: var(--onaccent); font-weight: 600;
}
.btn.ghost { background: var(--key); color: var(--keytext); }
.btn:active { filter: brightness(1.12); }
.btn[disabled] { opacity: .45; }

.badge { display: inline-block; padding: 1px 7px; border-radius: 8px; font-size: .75em;
  font-weight: 600; background: var(--key); color: var(--dim2); }
.badge.accent { background: var(--accent-soft); color: var(--accent); }
.badge.green { background: var(--add-bg); color: var(--green); }
.badge.red { background: var(--del-bg); color: var(--red); }
.badge.yellow { background: color-mix(in srgb, var(--yellow) 18%, transparent); color: var(--yellow); }

.muted { color: var(--dim2); }
.add { color: var(--green); }
.del { color: var(--red); }

.empty { padding: 48px 28px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.empty-t { font-weight: 600; font-size: 1.05em; }
.empty-s { color: var(--dim2); font-size: .9em; max-width: 320px; }
.loading { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 32px; color: var(--dim2); }
.spin {
  width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--key);
  border-top-color: var(--accent); animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.search-box {
  display: flex; align-items: center; gap: 8px; margin: 8px 12px; padding: 0 12px;
  height: 44px; border-radius: 22px; background: var(--input); color: var(--dim2);
}
.search-box input { flex: 1; background: none; border: 0; outline: 0; color: var(--text); height: 100%; }

/* ── State dots (match the app's StateDot) ───────────────────── */
.dot { width: 12px; height: 12px; border-radius: 50%; flex: none; position: relative; display: inline-block; }
.dot-working { border: 2px solid color-mix(in srgb, var(--accent) 25%, transparent); border-top-color: var(--accent);
  animation: spin 1s linear infinite; }
.dot-waiting { background: var(--yellow); }
.dot-waiting::after { content: "!"; position: absolute; inset: 0; font: 800 9px/12px var(--sans);
  color: var(--bg); text-align: center; }
.dot-ready { background: var(--green); }
.dot-asleep { border: 2px solid var(--dim); }
.dot-off { background: var(--red); }

/* ── Bottom sheet menu ───────────────────────────────────────── */
.sheet-bg { position: fixed; inset: 0; background: rgba(0,0,0,0); transition: background .2s; z-index: 50;
  display: flex; align-items: flex-end; }
.sheet-bg.open { background: rgba(0,0,0,.45); }
.sheet { width: 100%; background: var(--bar); border-radius: 22px 22px 0 0; padding: 6px 0 14px;
  transform: translateY(100%); transition: transform .2s ease-out; max-height: 80%; overflow-y: auto; }
.sheet-bg.open .sheet { transform: none; }
.grip { width: 36px; height: 4px; border-radius: 2px; background: var(--dim); opacity: .5; margin: 4px auto 8px; }
.sheet-title { padding: 6px 20px 10px; color: var(--dim2); font-size: .85em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sheet-item { display: block; width: 100%; text-align: left; padding: 0 20px; min-height: 50px; }
.sheet-item:active { background: var(--raised); }
.sheet-item.danger { color: var(--red); }

#toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0;
  background: var(--key); color: var(--keytext); padding: 10px 18px; border-radius: 22px;
  transition: opacity .2s, transform .2s; pointer-events: none; z-index: 99; font-size: .9em;
  box-shadow: 0 6px 24px rgba(0,0,0,.35); max-width: 86%;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ── Code ────────────────────────────────────────────────────── */
pre.code {
  margin: 0; padding: 10px 12px; overflow-x: auto; font-size: .82em; line-height: 1.45;
  background: color-mix(in srgb, var(--bg) 60%, black); border-radius: 8px; white-space: pre;
  tab-size: 4; color: var(--fg);
}
/* syntax colours (md.js highlighter) */
.hl-k { color: var(--magenta); } .hl-s { color: var(--green); } .hl-c { color: var(--dim); font-style: italic; }
.hl-n { color: var(--yellow); } .hl-f { color: var(--blue); } .hl-t { color: var(--cyan); }
.hl-p { color: var(--dim2); } .hl-a { color: var(--yellow); }

/* diffs (shared by chat edit cards and the Changes screen) */
.diff { font-family: var(--mono); font-size: .8em; line-height: 1.45; overflow-x: auto;
  background: color-mix(in srgb, var(--bg) 60%, black); border-radius: 8px; padding: 4px 0; }
.diff .ln { white-space: pre; padding: 0 10px 0 0; min-width: 100%; width: max-content; display: flex; }
.diff .ln .no { width: 3.2em; flex: none; text-align: right; padding-right: 8px; color: var(--dim); opacity: .7; user-select: none; }
.diff .ln .sg { width: 1.2em; flex: none; user-select: none; }
.diff .ln.a { background: var(--add-bg); } .diff .ln.a .sg { color: var(--green); }
.diff .ln.d { background: var(--del-bg); } .diff .ln.d .sg { color: var(--red); }
.diff .ln.h { color: var(--blue); opacity: .85; padding-left: 10px; }
.diff.wrap .ln { white-space: pre-wrap; width: auto; word-break: break-word; }
.diff .w-a { background: color-mix(in srgb, var(--green) 35%, transparent); border-radius: 2px; }
.diff .w-d { background: color-mix(in srgb, var(--red) 35%, transparent); border-radius: 2px; }
