/* ompweb — Kanagawa Lotus (light), mobile-first, no frameworks, no external assets */

:root, [data-theme="matcha"] {
  --bg: #dde0b0;
  --surface: #ccd199;
  --surface2: #b9c184;
  --accent: #587f00;
  --muted: #576154;
  --text: #333f3c;
  --ok: #587f00;
  --danger: #d8543f;
  --line: rgba(51, 63, 60, 0.30);
  --line2: rgba(51, 63, 60, 0.45);
  --code: #c6cc93;
  --bubbleA: #eef0cf;
  --bubbleU: #dbe7d0;
  --radius: 10px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --rail: 48px;
  --side: 300px;
}
[data-theme="mono"] {
  --bg: #e4e4e1;
  --surface: #d4d4cf;
  --surface2: #c0c0ba;
  --accent: #33373d;
  --muted: #666665;
  --text: #2b2b2b;
  --ok: #647053;
  --danger: #96503f;
  --line: rgba(43, 43, 43, 0.30);
  --line2: rgba(43, 43, 43, 0.45);
  --code: #cbccc6;
  --bubbleA: #f4f4f1;
  --bubbleU: #d9d9d6;
}
[data-theme="ocean"] {
  --bg: #d5dbe4;
  --surface: #c3cddc;
  --surface2: #aebccf;
  --accent: #2c4f8a;
  --muted: #5c6b80;
  --text: #2e3a4d;
  --ok: #2f7f7a;
  --danger: #b04a5a;
  --line: rgba(46, 58, 77, 0.30);
  --line2: rgba(46, 58, 77, 0.45);
  --code: #bccadf;
  --bubbleA: #e9eef5;
  --bubbleU: #d2dcea;
}
[data-theme="plum"] {
  --bg: #ddd5e3;
  --surface: #cfc5da;
  --surface2: #bab0c7;
  --accent: #6b3fa0;
  --muted: #665d73;
  --text: #3d3449;
  --ok: #6e8a5f;
  --danger: #b04a63;
  --line: rgba(61, 52, 73, 0.30);
  --line2: rgba(61, 52, 73, 0.45);
  --code: #c9bfd4;
  --bubbleA: #ece7f2;
  --bubbleU: #dbd0e7;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

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

body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.38 system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
}

button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

#app {
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
}

#main {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

/* =============================== header =============================== */

#hdr {
  flex: none;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  padding: calc(3px + env(safe-area-inset-top)) 10px 3px;
  z-index: 20;
}
.hin {
  max-width: 960px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 2px 6px;
}
.htitle {
  order: 1;
  flex: 1 1 auto;
  min-width: 0;
  min-height: 30px;
  display: flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: 0;
  padding: 0 4px 0 0;
  text-align: left;
}
#sess-title {
  font-size: 14px;
  font-weight: 650;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dot {
  flex: none;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--danger);
}
.dot.on { background: var(--ok); box-shadow: 0 0 6px rgba(111, 137, 78, .55); }
.agent-chip {
  flex: none;
  font-size: 11px;
  color: var(--danger);
  border: 1px solid rgba(200, 64, 83, .4);
  border-radius: 999px;
  padding: 2px 8px;
  background: rgba(200, 64, 83, .08);
}
.hbtns { order: 2; display: flex; gap: 2px; }
.hbtns button {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: 0;
  border-radius: 8px;
  color: var(--muted);
}
.hbtns button:active { background: var(--surface2); }
.hbtns svg { width: 18px; height: 18px; }
#btn-bell.on { color: var(--accent); }
#btn-bell.denied { opacity: .45; }
.hchips { display: none; }
#model-label { display: none; }
.chip {
  display: inline-flex;
  align-items: center;
  background: var(--bg);
  border: 1px solid var(--line2);
  color: var(--muted);
  border-radius: 999px;
  font-size: 12px;
  padding: 4px 11px;
  min-height: 36px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 70vw;
}
.chip-btn { background: var(--bg); }
.chip-btn:active { border-color: var(--accent); color: var(--text); }

/* ============================ status strip ============================ */

#status {
  flex: none;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 12px 5px;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
  font-size: 12px;
  color: var(--muted);
  min-height: 28px;
  overflow-x: auto;
  scrollbar-width: none;
}
#status::-webkit-scrollbar { display: none; }
#st-theme { display: none; }
.st-cwd {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--text);
}
.st-item {
  flex: none;
  max-width: 28vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--mono);
  font-size: 11.5px;
}
#st-todo {
  color: var(--accent);
  font-weight: 600;
  cursor: pointer;
}
#st-todo:active {
  border-color: var(--accent);
}
.ctxbar {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 110px;
  width: min(220px, 32vw);
}
.ctx-track {
  flex: 1 1 auto;
  height: 8px;
  background: var(--surface2);
  border: 1px solid var(--line);
  border-radius: 999px;
  overflow: hidden;
}
.ctx-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  border-radius: 999px;
  transition: width .2s ease;
}
.ctx-fill.warn { background: #c4a35a; }
.ctx-fill.hot { background: var(--danger); }
#ctx-pct {
  flex: none;
  font-family: var(--mono);
  font-size: 11px;
  min-width: 2.6em;
  text-align: right;
  color: var(--text);
}

/* ============================ status banner ============================ */

#banner {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: rgba(196, 163, 90, .18);
  border-bottom: 1px solid rgba(119, 113, 63, .35);
  color: #6b5c22;
  font-size: 12.5px;
  padding: 4px 10px;
}
.pulse {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #c4a35a;
  animation: pulse 1s ease-in-out infinite;
}
@keyframes pulse { 50% { opacity: .3; } }

/* ============================== transcript ============================== */

#transcript {
  flex: 1 1 auto;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  padding: 8px 10px 16px;
  scrollbar-width: thin;
  scrollbar-color: var(--line2) transparent;
  text-align: left;
}
#transcript::-webkit-scrollbar { width: 8px; }
#transcript::-webkit-scrollbar-thumb { background: var(--line2); border-radius: 4px; }

#feed {
  max-width: 860px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 7px;
  text-align: left;
}
.empty { color: var(--muted); font-size: 13px; text-align: center; padding: 22px 10px; }
.skel {
  align-self: stretch;
  height: 64px;
  border-radius: var(--radius);
  background: linear-gradient(100deg, var(--surface) 40%, var(--surface2) 50%, var(--surface) 60%);
  background-size: 200% 100%;
  animation: sksh 1.1s linear infinite;
}
@keyframes sksh { to { background-position: -200% 0; } }

.msg-user {
  align-self: flex-end;
  max-width: 85%;
  background: var(--bubbleU);
  border: 1px solid var(--line2);
  border-radius: 14px 14px 4px 14px;
  padding: 7px 10px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  text-align: left;
  color: var(--text);
}
.msg-user.flash {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent);
  transition: box-shadow .25s ease;
}

.assistant {
  position: relative;
  align-self: stretch;
  min-width: 0;
  background: var(--bubbleA);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px 10px;
  text-align: left;
}
.msg-speed {
  position: absolute;
  top: -9px;
  right: 10px;
  font-family: var(--mono);
  font-size: 10.5px;
  line-height: 1.6;
  color: var(--muted);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 8px;
  margin: 0;
  white-space: nowrap;
  user-select: none;
  pointer-events: none;
}
.msg-speed:empty, .msg-speed[hidden] {
  display: none !important;
}
.strip-head {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 32px;
  padding: 4px 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  text-align: left;
  font-size: 12px;
  cursor: pointer;
  touch-action: manipulation;
}
.strip-head:active { border-color: var(--accent); }
.tool-strip .chev {
  flex: none;
  width: 8px;
  height: 8px;
  margin-right: 3px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(-45deg);
  transition: transform .15s;
}
.tool-strip.exp .chev,
.tool-strip:not(.collapsed) .chev {
  transform: rotate(45deg);
}
.tool-strip.collapsed .strip-body {
  display: none;
}
.strip-body {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding-top: 3px;
}
.attach {
  max-width: 960px;
  margin: 0 auto 6px;
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
}
.attach:empty, .attach[hidden] { display: none; }
.attach::-webkit-scrollbar { display: none; }
.athumb {
  position: relative;
  flex: none;
  width: 56px;
  height: 56px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--line2);
  background: var(--code);
}
.athumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.athumb-x {
  position: absolute;
  top: 0;
  right: 0;
  width: 22px;
  height: 22px;
  border: 0;
  border-radius: 0 0 0 8px;
  background: rgba(0, 0, 0, .55);
  color: #fff;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
}
.uthumbs { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.uthumbs img {
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--line2);
}

.sysline {
  align-self: center;
  max-width: 92%;
  color: var(--muted);
  font-size: 12.5px;
  text-align: center;
  overflow-wrap: anywhere;
}
.history-more {
  align-self: center;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--accent);
  background: var(--surface);
  border: 1px solid var(--line2);
  border-radius: 999px;
  padding: 7px 16px;
  min-height: 36px;
  cursor: pointer;
}
.history-more:active { border-color: var(--accent); }

/* markdown */
.md { overflow-wrap: anywhere; text-align: left; }
.md.live-text { white-space: pre-wrap; }
.md pre {
  margin: 6px 0;
  background: var(--code);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  overflow-x: auto;
  font: 12.5px/1.55 var(--mono);
  color: var(--text);
  text-align: left;
}
.md code {
  background: var(--code);
  border-radius: 5px;
  padding: 1px 5px;
  font: 12.5px/1.4 var(--mono);
  color: var(--text);
}
.md pre code { background: none; padding: 0; font: inherit; color: inherit; }
.md a { color: var(--accent); }
.md strong { color: #3d3d4e; }
.md h3, .md h4, .md h5 { margin: 7px 0 3px; line-height: 1.3; color: var(--text); }
.md h3 { font-size: 1.05em; }
.md h4 { font-size: 1em; }
.md h5 { font-size: .95em; color: var(--muted); }
.tbl-wrap {
  overflow-x: auto;
  margin: 6px 0;
  border: 1px solid var(--line2);
  border-radius: 8px;
  background: var(--bg);
}
.md table {
  border-collapse: collapse;
  width: 100%;
  min-width: 430px;
  font-size: 12.5px;
}
.md th, .md td {
  border-bottom: 1px solid var(--line);
  padding: 6px 8px;
  text-align: left;
  vertical-align: top;
  overflow-wrap: anywhere;
}
.md thead th {
  background: var(--surface2);
  font-weight: 650;
  white-space: nowrap;
}
.md tbody tr:last-child th, .md tbody tr:last-child td { border-bottom: 0; }
details.thinking {
  margin: 2px 0 6px;
  border-left: 3px solid rgba(77, 105, 155, .4);
  padding: 2px 0 2px 8px;
  color: var(--muted);
  font-size: 12px;
  text-align: left;
}
details.thinking summary {
  cursor: pointer;
  user-select: none;
  min-height: 28px;
  display: flex;
  align-items: center;
  color: var(--accent);
  font-weight: 550;
  font-size: 12px;
}
.think-body {
  overflow-wrap: anywhere;
  font-size: 12px;
  max-height: 200px;
  overflow-y: auto;
  text-align: left;
}

/* tool cards */
.tool-card {
  align-self: stretch;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  margin-top: 2px;
  text-align: left;
}
.assistant > .tool-card:first-child { margin-top: 0; }
.tool-head {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  min-height: 28px;
  padding: 2px 8px;
  background: none;
  border: 0;
  text-align: left;
  font-size: 12px;
}
.tstat {
  flex: none;
  width: 14px;
  height: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 12px;
}
.tstat svg { width: 13px; height: 13px; }
.spin {
  width: 11px;
  height: 11px;
  border: 2px solid var(--muted);
  border-top-color: transparent;
  border-radius: 50%;
  animation: rot .7s linear infinite;
}
@keyframes rot { to { transform: rotate(360deg); } }
.tool-card[data-st="ok"] .tstat { color: var(--ok); }
.tool-card[data-st="fail"] .tstat { color: var(--danger); }

.scroll-bot {
  position: absolute;
  bottom: calc(10px + 64px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  z-index: 35;
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--line2);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  box-shadow: 0 4px 18px rgba(84, 84, 100, .25);
  cursor: pointer;
  white-space: nowrap;
}
.scroll-bot:active { background: var(--surface2); }
.tname {
  flex: none;
  max-width: 40%;
  font-weight: 650;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: left;
}
.targs {
  flex: 1 1 auto;
  min-width: 0;
  color: var(--muted);
  font: 11.5px/1.3 var(--mono);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: left;
}
.chev {
  flex: none;
  width: 8px;
  height: 8px;
  margin-right: 3px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(-45deg);
  transition: transform .15s;
}
.tool-card.exp .chev { transform: rotate(45deg); }
.tool-body {
  border-top: 1px solid var(--line);
  background: var(--code);
  padding: 8px 10px;
  max-height: 300px;
  overflow: auto;
  text-align: left;
}
.tool-body pre {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font: 11.5px/1.5 var(--mono);
  color: var(--text);
  text-align: left;
}

/* tool group compaction */
.tool-group {
  align-self: stretch;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  margin-top: 3px;
  text-align: left;
}
.assistant > .tool-group:first-child { margin-top: 0; }
.tool-group-head {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 32px;
  padding: 4px 10px;
  background: none;
  border: 0;
  text-align: left;
  font-size: 12px;
  cursor: pointer;
  color: var(--text);
  font-family: inherit;
}
.tool-group-head:active {
  background: var(--surface2);
}
.tool-group-icon {
  flex: none;
  width: 14px;
  height: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
}
.tool-group-summary {
  flex: 1 1 auto;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 12px;
  font-weight: 550;
  color: var(--muted);
  font-family: var(--mono);
}
.tool-group .chev {
  flex: none;
  width: 8px;
  height: 8px;
  margin-right: 3px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(-45deg);
  transition: transform .15s;
}
.tool-group.exp .chev,
.tool-group:not(.collapsed) .chev {
  transform: rotate(45deg);
}
.tool-group.collapsed .tool-group-body {
  display: none;
}
.tool-group-body {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 4px 8px 8px;
  border-top: 1px solid var(--line);
  background: var(--bg);
}
.tool-group-body > .tool-card {
  margin-top: 0;
}
.tool-strip {
  align-self: stretch;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.waiting {
  align-self: flex-start;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12.5px;
  padding: 8px 4px;
}

/* ============================== composer ============================== */

#composer {
  flex: none;
  background: var(--surface);
  border-top: 1px solid var(--line);
  padding: 6px 10px calc(8px + env(safe-area-inset-bottom));
}
.crow {
  max-width: 960px;
  margin: 0 auto;
  display: flex;
  flex-direction: row;
  align-items: flex-end;
  gap: 6px;
}
#input {
  flex: 1 1 auto;
  min-width: 0;
  width: 100%;
  resize: none;
  background: var(--bg);
  border: 1px solid var(--line2);
  border-radius: 12px;
  color: var(--text);
  font: inherit;
  line-height: 1.45;
  padding: 8px 12px;
  min-height: calc(3 * 1.45em + 18px);
  max-height: calc(6 * 1.45em + 18px);
}
@media (pointer: coarse) { #input { font-size: 16px; } }
.cside { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; align-content: end; flex: none; }
.cside .pill { min-height: 32px; font-size: 11.5px; padding: 0 4px; border-radius: 10px; }
#btn-send, #btn-stop {
  height: 32px;
  border-radius: 10px;
  border: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
#btn-send { background: var(--accent); color: #f2ecbc; }
#btn-send:disabled { opacity: .4; cursor: default; }
#btn-stop {
  background: rgba(200, 64, 83, .12);
  border: 1px solid rgba(200, 64, 83, .45);
  color: var(--danger);
}
#btn-send svg, #btn-stop svg { width: 20px; height: 20px; }

.pill {
  position: relative;
  min-height: 44px;
  border-radius: 12px;
  border: 1px solid var(--line2);
  background: var(--bg);
  color: var(--muted);
  font-size: 12.5px;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  cursor: pointer;
}
.pill input { position: absolute; inset: 0; margin: 0; opacity: 0; }
.pill.on {
  background: rgba(77, 105, 155, .16);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 650;
}

/* =============================== sidebar =============================== */

#scrim {
  position: fixed;
  inset: 0;
  background: rgba(84, 84, 100, .28);
  z-index: 39;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s;
}
#scrim.show { opacity: 1; pointer-events: auto; }

#sidebar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  top: auto;
  z-index: 40;
  display: flex;
  flex-direction: column;
  max-height: 78dvh;
  background: var(--surface);
  border-top: 1px solid var(--line2);
  border-radius: 14px 14px 0 0;
  transform: translateY(110%);
  visibility: hidden;
  transition: transform .22s ease, visibility .22s;
  padding-bottom: env(safe-area-inset-bottom);
  pointer-events: auto;
}
#sidebar.open { transform: none; visibility: visible; }

.rail { display: none; }

.sidebar-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1 1 auto;
  pointer-events: auto;
}
.dhead {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 6px 4px 12px;
  border-bottom: 1px solid var(--line);
  gap: 8px;
}
.dhead h2 { margin: 0; font-size: 15px; }
.side-tabs {
  display: flex;
  gap: 4px;
  flex: 1 1 auto;
  min-width: 0;
}
.side-tab {
  background: none;
  border: 0;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  font-weight: 650;
  font-size: 13.5px;
  min-height: 40px;
  padding: 6px 10px;
}
.side-tab.on {
  color: var(--text);
  border-bottom-color: var(--accent);
}
.dclose {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: 0;
  border-radius: 10px;
  color: var(--muted);
}
.dclose svg { width: 20px; height: 20px; }
.dstatus {
  flex: none;
  padding: 8px 16px;
  color: var(--muted);
  font-size: 12px;
  border-bottom: 1px solid var(--line);
}
.newbtn {
  flex: none;
  margin: 10px 12px;
  min-height: 44px;
  border-radius: var(--radius);
  border: 1px dashed var(--accent);
  background: rgba(77, 105, 155, .08);
  color: var(--accent);
  font-weight: 650;
}
.slist {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 4px 8px 16px;
  pointer-events: auto;
}
.sess-item {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  gap: 4px;
  text-align: left;
  background: none;
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 4px 6px 4px 4px;
  min-height: 52px;
  pointer-events: auto;
  color: var(--text);
}
.sess-item:active { background: var(--surface2); }
.sess-item.active {
  background: rgba(77, 105, 155, .12);
  border-color: rgba(77, 105, 155, .4);
}
.sess-main {
  flex: 1 1 auto;
  min-width: 0;
  display: block;
  text-align: left;
  background: none;
  border: 0;
  color: inherit;
  padding: 6px 4px;
  cursor: pointer;
}
.s-title {
  display: block;
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.45;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.s-meta { display: block; font-size: 11.5px; line-height: 1.45; color: var(--muted); }
.s-actions {
  flex: none;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
}
.s-act {
  background: none;
  border: 0;
  color: var(--muted);
  font-size: 10px;
  min-height: 22px;
  padding: 0 6px;
  border-radius: 6px;
}
.s-act:hover { background: var(--surface2); color: var(--text); }
.ctx-abs {
  font-size: 10px;
  color: var(--muted);
  opacity: .85;
  white-space: nowrap;
}
.dfoot {
  flex: none;
  padding: 8px 16px;
  font-size: 11px;
  color: var(--muted);
  border-top: 1px solid var(--line);
}

.side-row-btn {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: calc(100% - 24px);
  margin: 2px 12px 10px;
  min-height: 40px;
  padding: 6px 12px;
  background: var(--bg);
  border: 1px solid var(--line2);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
}
.side-row-btn:active { border-color: var(--accent); }
#theme-side-name { color: var(--muted); font-size: 12.5px; }
.theme-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid var(--line2);
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
}
.theme-pip {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: block;
}
.theme-sheet-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 6px 0;
}
.theme-sheet-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--line2);
  border-radius: var(--radius);
  color: var(--text);
  cursor: pointer;
  font-size: 14px;
  text-align: left;
  transition: border-color .15s ease;
}
.theme-sheet-btn:active {
  border-color: var(--accent);
}
.theme-sheet-btn.on {
  border-color: var(--accent);
  box-shadow: 0 0 0 1.5px var(--accent);
  font-weight: 650;
}
.theme-sheet-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.theme-sheet-name {
  font-size: 13.5px;
  font-weight: 600;
}
.theme-sheet-desc {
  font-size: 11.5px;
  color: var(--muted);
}

#pane-sessions, #pane-subagents, #pane-files {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1 1 auto;
}

/* subagents */
.sublist {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 8px 8px 16px;
}
.sub-item {
  border: 1px solid var(--line2);
  border-radius: var(--radius);
  margin-bottom: 6px;
  overflow: hidden;
  background: var(--bg);
}
.sub-head {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 48px;
  padding: 8px 10px;
  background: none;
  border: 0;
  text-align: left;
}
.sub-title-wrap {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.sub-name {
  font-size: 13.5px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sub-meta {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.badge {
  flex: none;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: .06em;
  border-radius: 999px;
  padding: 3px 8px;
  border: 1px solid var(--line2);
  color: var(--muted);
}
.badge.running { color: var(--accent); border-color: rgba(77, 105, 155, .5); background: rgba(77, 105, 155, .12); }
.badge.done { color: var(--ok); border-color: rgba(111, 137, 78, .5); background: rgba(111, 137, 78, .1); }
.badge.failed { color: var(--danger); border-color: rgba(200, 64, 83, .5); background: rgba(200, 64, 83, .1); }
.sub-panel {
  border-top: 1px solid var(--line2);
  background: var(--code);
  max-height: 260px;
  overflow: auto;
  padding: 8px 10px;
  text-align: left;
}
.sub-panel pre {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font: 11.5px/1.5 var(--mono);
  color: var(--muted);
  text-align: left;
}

/* ================================ modals ================================ */

.modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(84, 84, 100, .38);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
}
#wmodal { z-index: 50; }
#picker { z-index: 55; }
.sheet {
  background: var(--surface);
  border: 1px solid var(--line2);
  border-radius: 14px;
  width: min(94vw, 480px);
  max-height: 82dvh;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px;
  box-shadow: 0 18px 60px rgba(84, 84, 100, .22);
  text-align: left;
}
.m-title { margin: 0; font-size: 15.5px; overflow-wrap: anywhere; }
.m-desc { margin: 0; color: var(--muted); font-size: 13px; white-space: pre-wrap; overflow-wrap: anywhere; }
.m-list { display: flex; flex-direction: column; gap: 6px; overflow-y: auto; min-height: 0; }
.mbtn {
  display: flex;
  flex-direction: column;
  gap: 2px;
  align-items: flex-start;
  min-height: 48px;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--line2);
  border-radius: var(--radius);
  font-size: 14px;
  text-align: left;
  color: var(--text);
}
.mbtn:active { border-color: var(--accent); }
.mbtn .sub { font-size: 11.5px; color: var(--muted); }
.mbtn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #f2ecbc;
  font-weight: 650;
  justify-content: center;
  align-items: center;
}
.m-row { display: flex; gap: 8px; }
.m-row .mbtn { flex: 1; justify-content: center; align-items: center; }
.m-input, .m-area {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--line2);
  border-radius: var(--radius);
  color: var(--text);
  font: inherit;
  padding: 10px 12px;
  min-height: 44px;
}
.m-input:focus, .m-area:focus { outline: none; border-color: var(--accent); }
.m-area { min-height: 150px; max-height: 40dvh; resize: vertical; font: 12.5px/1.5 var(--mono); }
.m-count { font-size: 11.5px; color: var(--muted); text-align: center; }
.m-more { font-size: 11px; color: var(--muted); text-align: center; }
.m-dismiss {
  background: none;
  border: 0;
  color: var(--muted);
  font-size: 12.5px;
  min-height: 44px;
}

/* todo HUD and drawer */
.todo-phase-block {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 8px;
}
.todo-phase-block:last-child {
  margin-bottom: 0;
}
.todo-phase-head {
  font-size: 11.5px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  padding: 4px 2px 2px;
}
.todo-task-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 6px 8px;
  background: var(--bg);
  border: 1px solid var(--line2);
  border-radius: var(--radius);
  font-size: 13px;
  color: var(--text);
  line-height: 1.4;
}
.todo-task-check {
  flex: none;
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 1px;
  color: var(--muted);
}
.todo-task-check svg {
  width: 14px;
  height: 14px;
}
.todo-task-item[data-st="completed"] .todo-task-check,
.todo-task-item[data-st="done"] .todo-task-check {
  color: var(--ok);
}
.todo-task-item[data-st="completed"] .todo-task-text,
.todo-task-item[data-st="done"] .todo-task-text {
  color: var(--muted);
  text-decoration: line-through;
}
.todo-task-item[data-st="in_progress"] {
  border-color: var(--accent);
}
.todo-task-item[data-st="in_progress"] .todo-task-check {
  color: var(--accent);
}
.todo-task-item[data-st="blocked"] {
  border-color: var(--danger);
}
.todo-task-item[data-st="blocked"] .todo-task-check {
  color: var(--danger);
}
.todo-task-text {
  flex: 1 1 auto;
  min-width: 0;
  overflow-wrap: anywhere;
}

.think-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}
.think-chip {
  background: var(--surface);
  border: 1px solid var(--line2);
  color: var(--muted);
  border-radius: 999px;
  font-size: 11px;
  padding: 3px 8px;
  min-height: 28px;
}
.think-chip:active { border-color: var(--accent); color: var(--accent); }
.browse-path {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text);
  overflow-wrap: anywhere;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
}
.f-toolbar {
  flex: none;
  display: flex;
  gap: 6px;
  padding: 8px 12px 0;
}
.f-up {
  flex: 1 1 auto;
  margin: 0;
  min-height: 36px;
}
.flist {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px 8px 16px;
  pointer-events: auto;
}
.f-row {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  gap: 4px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 2px 2px 2px 6px;
  min-height: 44px;
  pointer-events: auto;
}
.f-row:active { border-color: var(--accent); }
.f-main {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 1px;
  text-align: left;
  background: none;
  border: 0;
  color: var(--text);
  padding: 6px 4px;
  cursor: pointer;
}
.f-name {
  font-size: 13px;
  font-weight: 550;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.f-meta { font-size: 10.5px; color: var(--muted); font-family: var(--mono); }
.f-copy {
  flex: none;
  align-self: center;
  width: 40px;
  height: 36px;
  background: var(--surface2);
  border: 1px solid var(--line2);
  border-radius: 8px;
  color: var(--muted);
  font-size: 15px;
  cursor: pointer;
}
.f-copy:active { border-color: var(--accent); color: var(--accent); }

/* ============================ screenshot overlay ============================ */

#shot {
  position: fixed;
  inset: 0;
  z-index: 70;
  background: rgba(84, 84, 100, .82);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px;
  cursor: pointer;
  overflow: auto;
}
#shot img {
  object-fit: contain;
  max-width: 100%;
  max-height: 100dvh;
  width: auto;
  height: auto;
  border-radius: 8px;
  border: 1px solid var(--line2);
}
#shot .notavail { color: #f2ecbc; font-size: 15px; }

/* ================================ toasts ================================ */

#toasts {
  position: fixed;
  top: calc(8px + env(safe-area-inset-top));
  left: 0;
  right: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  z-index: 80;
  pointer-events: none;
  padding: 0 12px;
}
.toast {
  background: var(--surface);
  border: 1px solid var(--line2);
  border-radius: var(--radius);
  color: var(--text);
  padding: 9px 14px;
  max-width: 92vw;
  font-size: 13px;
  box-shadow: 0 8px 30px rgba(84, 84, 100, .22);
  animation: tIn .18s ease;
  overflow-wrap: anywhere;
}
.toast.out { opacity: 0; transition: opacity .25s; }
.toast b { display: block; font-weight: 650; }
.toast span { color: var(--muted); }
@keyframes tIn { from { opacity: 0; transform: translateY(-6px); } }

/* ============================ desktop collab layout ============================ */

@media (min-width: 860px) {
  #app {
    flex-direction: row;
    align-items: stretch;
  }
  #scrim { display: none !important; }

  #sidebar {
    position: relative;
    inset: auto;
    top: 0;
    left: 0;
    bottom: 0;
    right: auto;
    z-index: 12;
    max-height: none;
    height: 100%;
    width: auto;
    flex: none;
    flex-direction: row;
    transform: none;
    visibility: visible;
    border: 0;
    border-right: 1px solid var(--line2);
    border-radius: 0;
    padding-bottom: 0;
    background: var(--surface);
  }

  .rail {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    flex: none;
    width: var(--rail);
    padding: 8px 4px;
    background: var(--surface2);
    border-right: 1px solid var(--line);
  }
  .rail button {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: 0;
    border-radius: 10px;
    color: var(--muted);
  }
  .rail button:hover { background: var(--surface); color: var(--text); }
  .rail button.on { color: var(--accent); background: rgba(77, 105, 155, .14); }
  .rail svg { width: 20px; height: 20px; }

  .sidebar-panel {
    width: 0;
    overflow: hidden;
    visibility: hidden;
    flex: none;
  }
  #sidebar.open .sidebar-panel {
    width: var(--side);
    overflow: hidden;
    visibility: visible;
    height: 100%;
    display: flex;
    flex-direction: column;
    min-height: 0;
  }
  #sidebar.open .dclose { display: none; }

  #main { flex: 1 1 auto; min-width: 0; }
  .hchips { min-height: 32px; }
  .chip { min-height: 32px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
