:root {
  color-scheme: light;
  --bg: #f7f8fa;
  --panel: #ffffff;
  --panel-2: #f0f3f5;
  --panel-3: #e7ebee;
  --line: #d4dae0;
  --line-soft: #e5e8eb;
  --text: #18212a;
  --muted: #596672;
  --faint: #7b8792;
  --green: #209b63;
  --green-strong: #14784b;
  --green-ink: #ffffff;
  --amber: #a75e00;
  --red: #c63c3c;
  --blue: #2866c7;
  --sidebar: 320px;
  --radius: 14px;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 70% -20%, rgba(32, 155, 99, 0.09), transparent 34rem),
    var(--bg);
  color: var(--text);
}

.auth-gate {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: max(24px, env(safe-area-inset-top)) 18px max(24px, env(safe-area-inset-bottom));
  overflow-y: auto;
}

.auth-card {
  width: min(440px, 100%);
  padding: clamp(24px, 7vw, 38px);
  border: 1px solid var(--line);
  border-radius: 24px;
  background: linear-gradient(155deg, rgba(255, 255, 255, .99), rgba(247, 249, 250, .99));
  box-shadow: 0 28px 90px rgba(28, 42, 54, .14), 0 0 80px rgba(32, 155, 99, .05);
}

.auth-mark {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  margin-bottom: 24px;
  border-radius: 14px;
  background: linear-gradient(145deg, #35ad72, #14784b);
  color: var(--green-ink);
  font-size: 23px;
  font-weight: 900;
}

.auth-eyebrow { margin: 0 0 7px; color: var(--green); font-size: 10px; font-weight: 750; letter-spacing: .16em; }
.auth-card h1 { margin: 0; font-size: clamp(25px, 7vw, 34px); letter-spacing: -.035em; }
.auth-status { min-height: 44px; margin: 12px 0 20px; color: var(--muted); font-size: 13px; line-height: 1.65; }
.auth-status.error { color: var(--red); }
.auth-primary { width: 100%; min-height: 48px; }
.enrollment-details { margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--line-soft); color: var(--muted); font-size: 12px; }
.enrollment-details summary { color: var(--text); cursor: pointer; font-weight: 650; }
.enrollment-details p { margin: 13px 0 10px; line-height: 1.6; }
.enrollment-details > code { display: block; overflow-x: auto; padding: 11px; border-radius: 9px; background: #eef1f3; color: #34414c; font: 10px/1.55 ui-monospace, SFMono-Regular, Menlo, monospace; white-space: nowrap; }
.enrollment-form { display: grid; gap: 9px; margin-top: 14px; }
.enrollment-form label { color: var(--muted); font-size: 11px; }
.enrollment-form input { width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px; outline: 0; background: var(--bg); color: var(--text); font: 13px ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .06em; }
.enrollment-form input:focus { border-color: rgba(103, 213, 155, .55); }
.enrollment-form .quiet-button { min-height: 42px; }
.auth-footnote { margin: 20px 0 0; color: var(--faint); font-size: 10px; line-height: 1.55; }

button, input, textarea { font: inherit; }
button { color: inherit; }

.hidden { display: none !important; }
.mobile-only { display: none; }

.app-shell {
  height: 100dvh;
  display: grid;
  grid-template-columns: var(--sidebar) minmax(0, 1fr);
  grid-template-rows: 58px minmax(0, 1fr);
}

.topbar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 18px;
  padding-top: env(safe-area-inset-top);
  border-bottom: 1px solid var(--line-soft);
  background: rgba(255, 255, 255, 0.90);
  backdrop-filter: blur(18px);
  z-index: 30;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  width: 31px;
  height: 31px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  background: linear-gradient(145deg, #35ad72, #14784b);
  box-shadow: 0 0 24px rgba(54, 185, 121, 0.18);
  color: var(--green-ink);
  font-weight: 900;
}

.brand strong, .brand small { display: block; }
.brand strong { font-size: 14px; letter-spacing: .01em; }
.brand small { margin-top: 1px; color: var(--muted); font-size: 10px; }

.topbar-actions { display: flex; align-items: center; gap: 12px; }

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--faint);
}
.status-dot.ready { background: var(--green); box-shadow: 0 0 10px rgba(103, 213, 155, .55); }
.status-dot.pending { background: var(--amber); }
.status-dot.error { background: var(--red); }

.sidebar {
  grid-column: 1;
  grid-row: 2;
  position: relative;
  z-index: 2;
  min-height: 0;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--line-soft);
  background: rgba(250, 251, 252, .97);
}

.sidebar-resize-handle {
  position: absolute;
  top: 0;
  right: -5px;
  bottom: 0;
  z-index: 4;
  width: 10px;
  padding: 0;
  border: 0;
  outline: 0;
  background: transparent;
  cursor: col-resize;
  touch-action: none;
}
.sidebar-resize-handle::after {
  content: "";
  position: absolute;
  top: 12px;
  bottom: 12px;
  left: 4px;
  width: 2px;
  border-radius: 2px;
  background: var(--green);
  opacity: 0;
  transition: opacity .14s ease;
}
.sidebar-resize-handle:hover::after,
.sidebar-resize-handle:focus-visible::after,
body.sidebar-resizing .sidebar-resize-handle::after { opacity: 1; }
body.sidebar-resizing,
body.sidebar-resizing * { cursor: col-resize !important; user-select: none !important; }

.sidebar-head { padding: 16px 14px 10px; }

.primary-button, .quiet-button, .danger-button, .send-button, .icon-button, .text-button {
  border: 0;
  cursor: pointer;
  transition: transform .14s ease, background .14s ease, border-color .14s ease, opacity .14s ease;
}
.primary-button:active, .quiet-button:active, .danger-button:active, .send-button:active { transform: scale(.98); }
.primary-button:disabled, .send-button:disabled { opacity: .45; cursor: wait; }

.primary-button {
  min-height: 42px;
  padding: 0 16px;
  border-radius: 11px;
  background: var(--green);
  color: var(--green-ink);
  font-weight: 750;
}
.primary-button:hover { background: #188754; }
.primary-button.full { width: 100%; }

.quiet-button, .danger-button {
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--panel-2);
  font-size: 12px;
}
.quiet-button:hover { background: var(--panel-3); }
.danger-button { color: var(--red); border-color: rgba(255, 123, 123, .35); }
.danger-button:hover { background: rgba(255, 123, 123, .08); }

.text-button { padding: 5px; color: var(--green); background: transparent; font-size: 12px; }
.icon-button { width: 36px; height: 36px; border-radius: 9px; background: transparent; font-size: 21px; }
.icon-button:hover { background: var(--panel-2); }

.search-box {
  height: 38px;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  padding: 0 11px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: var(--panel-2);
  color: var(--muted);
}
.search-box:focus-within { border-color: rgba(103, 213, 155, .45); }
.search-box input { min-width: 0; flex: 1; border: 0; outline: 0; background: transparent; color: var(--text); }
.search-box input::placeholder { color: var(--faint); }

.thread-list { min-height: 0; flex: 1; overflow-y: auto; padding: 4px 8px 14px; }
.thread-empty { padding: 28px 12px; color: var(--muted); text-align: center; font-size: 13px; }
.thread-group { margin-top: 8px; }
.thread-group:first-child { margin-top: 0; }
.thread-group-toggle {
  width: 100%;
  display: grid;
  grid-template-columns: 16px minmax(0, 1fr) auto;
  align-items: center;
  gap: 4px;
  padding: 8px 10px 5px;
  border: 0;
  background: transparent;
  color: var(--faint);
  text-align: left;
  cursor: pointer;
}
.thread-group-toggle:hover { color: var(--muted); }
.thread-group-title { font-size: 11px; font-weight: 750; letter-spacing: .06em; }
.thread-group-count { font-size: 10px; font-variant-numeric: tabular-nums; }
.thread-group-chevron { font-size: 14px; line-height: 1; transform: rotate(0); transition: transform .14s ease; }
.thread-group.collapsed .thread-group-chevron { transform: rotate(-90deg); }
.thread-group.collapsed .thread-group-rows { display: none; }

.thread-row {
  width: 100%;
  display: grid;
  grid-template-columns: 10px minmax(0, 1fr) auto;
  align-items: center;
  gap: 5px 8px;
  padding: 11px 10px;
  border: 1px solid transparent;
  border-radius: 11px;
  background: transparent;
  text-align: left;
  cursor: pointer;
}
.thread-row:hover { background: var(--panel-2); }
.thread-row.active { border-color: var(--line); background: var(--panel-2); }
.thread-row strong { overflow: hidden; color: var(--text); font-size: 13px; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }
.thread-row time { color: var(--faint); font-size: 10px; }
.thread-row small { overflow: hidden; color: var(--faint); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.thread-path { grid-column: 2; min-width: 0; }
.attention-dot {
  width: 9px;
  height: 9px;
  flex: 0 0 9px;
  border-radius: 50%;
  background: transparent;
}
.attention-dot.unread { background: var(--green); box-shadow: 0 0 0 3px rgba(32, 155, 99, .11); }
.attention-dot.working { background: #d38a12; box-shadow: 0 0 0 3px rgba(211, 138, 18, .12); animation: attention-pulse 1.5s ease-in-out infinite; }
.attention-dot.waiting { background: var(--red); box-shadow: 0 0 0 3px rgba(198, 60, 60, .12); }
@keyframes attention-pulse { 50% { opacity: .42; transform: scale(.82); } }

.sidebar-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line-soft);
  color: var(--faint);
  font-size: 11px;
}

.sidebar-scrim { display: none; }

.workspace {
  grid-column: 2;
  grid-row: 2;
  min-width: 0;
  min-height: 0;
  position: relative;
}

.empty-state {
  height: 100%;
  display: grid;
  place-content: center;
  justify-items: center;
  padding: 28px;
  text-align: center;
}
.empty-state h1 { margin: 22px 0 8px; font-size: clamp(24px, 4vw, 38px); letter-spacing: -.035em; }
.empty-state p { max-width: 500px; margin: 0 0 24px; color: var(--muted); line-height: 1.65; }
.empty-orbit { width: 82px; height: 82px; display: grid; place-items: center; border: 1px solid rgba(103, 213, 155, .25); border-radius: 50%; box-shadow: 0 0 60px rgba(54, 185, 121, .10); }
.empty-orbit span { width: 50px; height: 50px; display: grid; place-items: center; border-radius: 15px; background: var(--green); color: var(--green-ink); font-size: 25px; font-weight: 900; }

.conversation {
  height: 100%;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
}

.conversation-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px clamp(16px, 3vw, 30px);
  border-bottom: 1px solid var(--line-soft);
  background: rgba(255, 255, 255, .78);
}
.conversation-title { min-width: 0; }
.conversation-title h1 { overflow: hidden; margin: 0; font-size: 15px; font-weight: 670; text-overflow: ellipsis; white-space: nowrap; }
.conversation-title p { overflow: hidden; margin: 4px 0 0; color: var(--faint); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.conversation-actions { display: flex; align-items: center; gap: 9px; }
.turn-state { color: var(--muted); font-size: 11px; white-space: nowrap; }
.turn-state.unread { color: var(--green-strong); }
.turn-state.working { color: var(--amber); }
.turn-state.waiting { color: var(--red); }

.approval-area { display: grid; gap: 10px; padding: 0 clamp(16px, 5vw, 64px); background: var(--bg); }
.approval-area:not(:empty) { padding-top: 14px; padding-bottom: 4px; }
.approval-card { max-width: 900px; width: 100%; margin: 0 auto; padding: 15px; border: 1px solid rgba(242, 188, 102, .34); border-radius: var(--radius); background: linear-gradient(145deg, rgba(242, 188, 102, .08), var(--panel)); }
.approval-card h3 { margin: 0 0 5px; color: var(--amber); font-size: 14px; }
.approval-card p { margin: 4px 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
.approval-card pre { max-height: 180px; overflow: auto; margin: 10px 0; padding: 10px; border-radius: 8px; background: #eef1f3; color: #34414c; font: 11px/1.55 ui-monospace, SFMono-Regular, Menlo, monospace; white-space: pre-wrap; word-break: break-word; }
.approval-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.approval-question { display: grid; gap: 7px; margin: 12px 0; padding: 11px; border-radius: 9px; background: rgba(37, 53, 66, .05); }
.approval-question strong { font-size: 12px; }
.approval-option { display: flex; align-items: flex-start; gap: 8px; color: var(--muted); font-size: 12px; }
.approval-option small { display: block; color: var(--faint); }
.approval-answer { width: 100%; padding: 9px 10px; border: 1px solid var(--line); border-radius: 8px; outline: 0; background: var(--bg); color: var(--text); }

.message-list {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 24px clamp(16px, 5vw, 64px) 32px;
}

.message {
  max-width: 900px;
  margin: 0 auto 18px;
  animation: message-in .2s ease-out;
}
@keyframes message-in { from { opacity: 0; transform: translateY(4px); } }
.message-label { display: flex; align-items: center; gap: 7px; margin-bottom: 7px; color: var(--faint); font-size: 10px; text-transform: uppercase; letter-spacing: .08em; }
.message-label .mini-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--faint); }
.message-time, .message-duration { font-variant-numeric: tabular-nums; letter-spacing: 0; text-transform: none; }
.message-time::before, .message-duration::before { content: "·"; margin-right: 7px; color: var(--line); }
.message.user .mini-dot { background: var(--blue); }
.message.agent .mini-dot { background: var(--green); }
.message.warning .mini-dot { background: var(--amber); }

.message-content {
  color: var(--text);
  font-size: 14px;
  line-height: 1.7;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.markdown-body { white-space: normal; }
.markdown-body > :first-child { margin-top: 0; }
.markdown-body > :last-child { margin-bottom: 0; }
.markdown-body p { margin: 0 0 .8em; }
.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4,
.markdown-body h5,
.markdown-body h6 { margin: 1.15em 0 .5em; line-height: 1.3; letter-spacing: -.015em; }
.markdown-body h1 { padding-bottom: .25em; border-bottom: 1px solid var(--line-soft); font-size: 1.55em; }
.markdown-body h2 { padding-bottom: .2em; border-bottom: 1px solid var(--line-soft); font-size: 1.34em; }
.markdown-body h3 { font-size: 1.18em; }
.markdown-body h4,
.markdown-body h5,
.markdown-body h6 { font-size: 1em; }
.markdown-body ul,
.markdown-body ol { margin: .45em 0 .85em; padding-left: 1.6em; }
.markdown-body li + li { margin-top: .22em; }
.markdown-body li > p { margin-bottom: .35em; }
.markdown-body blockquote { margin: .8em 0; padding: .15em 1em; border-left: 3px solid var(--green); color: var(--muted); background: rgba(32, 155, 99, .055); }
.markdown-body blockquote > :last-child { margin-bottom: 0; }
.markdown-body hr { height: 1px; margin: 1.15em 0; border: 0; background: var(--line); }
.markdown-body a { color: var(--blue); text-decoration-thickness: 1px; text-underline-offset: 2px; }
.markdown-body a:hover { color: var(--green-strong); }
.markdown-body :not(pre) > code { padding: .12em .38em; border: 1px solid var(--line-soft); border-radius: 5px; background: #eef1f3; color: #34414c; font: .9em/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; white-space: break-spaces; }
.markdown-code { overflow: hidden; margin: .8em 0; border: 1px solid var(--line); border-radius: 10px; background: #eef1f3; }
.markdown-code-head { min-height: 32px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 10px 0 12px; border-bottom: 1px solid var(--line); background: #e5e9ed; color: var(--muted); font: 10px ui-monospace, SFMono-Regular, Menlo, monospace; }
.markdown-code-head span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.markdown-code-head button { padding: 4px 6px; border: 0; border-radius: 5px; background: transparent; color: var(--blue); cursor: pointer; font-size: 10px; }
.markdown-code-head button:hover { background: rgba(40, 102, 199, .09); }
.markdown-code pre { overflow-x: auto; margin: 0; padding: 13px 14px; overscroll-behavior-inline: contain; }
.markdown-code pre code { display: block; min-width: max-content; color: #26333e; font: 12px/1.65 ui-monospace, SFMono-Regular, Menlo, monospace; white-space: pre; overflow-wrap: normal; tab-size: 4; }
.markdown-table { max-width: 100%; overflow-x: auto; margin: .8em 0; border: 1px solid var(--line); border-radius: 8px; }
.markdown-table table { width: 100%; border-collapse: collapse; background: var(--panel); font-size: .92em; white-space: nowrap; }
.markdown-table th,
.markdown-table td { padding: 7px 10px; border-right: 1px solid var(--line-soft); border-bottom: 1px solid var(--line-soft); text-align: left; }
.markdown-table th:last-child,
.markdown-table td:last-child { border-right: 0; }
.markdown-table tr:last-child td { border-bottom: 0; }
.markdown-table th { background: var(--panel-2); font-weight: 700; }
.markdown-body img { display: block; max-width: 100%; max-height: 70dvh; margin: .8em 0; border-radius: 8px; object-fit: contain; }
.markdown-body input[type="checkbox"] { margin: 0 .45em 0 0; accent-color: var(--green); }
.message.user .message-content { padding: 12px 14px; border: 1px solid #d6e2f3; border-radius: 13px; background: #f1f6fc; }
.message.reasoning { opacity: .84; }
.message.reasoning .message-content { color: var(--muted); font-size: 12px; }
.message.plan .message-content { padding-left: 12px; border-left: 2px solid var(--blue); }
.message.reasoning, .message.plan, .message.tool { display: none; }

.work-log { border: 1px solid var(--line-soft); border-radius: 11px; background: rgba(255, 255, 255, .58); }
.work-log-summary { margin: 0; padding: 10px 12px; cursor: pointer; list-style: none; user-select: none; }
.work-log-summary::-webkit-details-marker { display: none; }
.work-log-summary .mini-dot { background: var(--amber); }
.work-count { letter-spacing: 0; text-transform: none; }
.work-chevron { margin-left: auto; font-size: 14px; line-height: 1; transition: transform .16s ease; }
.work-log[open] .work-chevron { transform: rotate(180deg); }
.work-log-content { display: grid; gap: 12px; padding: 0 12px 12px 25px; color: var(--muted); font-size: 12px; line-height: 1.65; white-space: pre-wrap; overflow-wrap: anywhere; }
.work-entry + .work-entry { padding-top: 12px; border-top: 1px solid var(--line-soft); }
.work-entry.pending { margin: 0; color: var(--faint); }

.tool-card { border: 1px solid var(--line-soft); border-radius: 11px; background: var(--panel); overflow: hidden; }
.tool-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--line-soft); }
.tool-head strong { overflow: hidden; font: 11px ui-monospace, SFMono-Regular, Menlo, monospace; text-overflow: ellipsis; white-space: nowrap; }
.tool-status { color: var(--muted); font-size: 10px; white-space: nowrap; }
.tool-status.completed { color: var(--green); }
.tool-status.failed { color: var(--red); }
.tool-output { max-height: 340px; overflow: auto; margin: 0; padding: 12px; background: #eef1f3; color: #34414c; font: 11px/1.55 ui-monospace, SFMono-Regular, Menlo, monospace; white-space: pre-wrap; overflow-wrap: anywhere; }
.diff-output { color: #34414c; }

.composer {
  margin: 0 clamp(16px, 5vw, 64px) max(16px, env(safe-area-inset-bottom));
  padding: 11px 12px 9px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, .98);
  box-shadow: 0 16px 46px rgba(38, 52, 64, .13);
}
.composer textarea { width: 100%; max-height: 180px; resize: none; border: 0; outline: 0; background: transparent; color: var(--text); font-size: 14px; line-height: 1.5; }
.composer textarea::placeholder { color: var(--faint); }
.composer-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 6px; }
.composer-foot span { color: var(--faint); font-size: 10px; }
.send-button { min-width: 66px; min-height: 34px; padding: 0 13px; border-radius: 10px; background: var(--green); color: var(--green-ink); font-size: 12px; font-weight: 750; }

.new-thread-dialog { width: min(520px, calc(100% - 24px)); padding: 0; border: 1px solid var(--line); border-radius: 18px; background: var(--panel); color: var(--text); box-shadow: 0 24px 90px rgba(28, 42, 54, .22); }
.new-thread-dialog::backdrop { background: rgba(31, 42, 51, .34); backdrop-filter: blur(4px); }
.dialog-card { padding: 20px; }
.dialog-head { display: flex; align-items: flex-start; justify-content: space-between; }
.dialog-head h2 { margin: 0; font-size: 18px; }
.dialog-head p { margin: 5px 0 0; color: var(--muted); font-size: 12px; }
.project-choices { display: grid; gap: 9px; margin: 20px 0; }
.project-choice { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 3px 10px; padding: 12px; border: 1px solid var(--line); border-radius: 11px; cursor: pointer; }
.project-choice:has(input:checked) { border-color: var(--green-strong); background: rgba(54, 185, 121, .07); }
.project-choice input { grid-row: 1 / 3; align-self: center; accent-color: var(--green); }
.project-choice strong { font-size: 13px; }
.project-choice small { overflow: hidden; color: var(--faint); font: 10px ui-monospace, SFMono-Regular, Menlo, monospace; text-overflow: ellipsis; white-space: nowrap; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 9px; }

.login-panel { margin-top: 20px; color: var(--muted); font-size: 13px; line-height: 1.6; }
.device-code-panel { display: grid; justify-items: start; gap: 10px; margin-top: 18px; padding: 14px; border: 1px solid var(--line); border-radius: 11px; background: rgba(37, 53, 66, .05); }
.device-code-panel p { margin: 0; }
.device-code-panel code { padding: 8px 11px; border-radius: 8px; background: #eef1f3; color: var(--green-strong); font: 700 20px/1 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .12em; }
.verification-link { color: var(--green); }

.monitor-dialog {
  width: calc(100vw - 32px);
  max-width: 680px;
  min-width: 0;
  max-height: calc(100dvh - 24px);
  overflow-x: hidden;
  overflow-y: auto;
}
.monitor-card { width: 100%; min-width: 0; max-width: 100%; display: grid; gap: 16px; padding: 20px; overflow-x: hidden; }
.monitor-head { gap: 16px; }
.monitor-head-actions { display: flex; align-items: center; gap: 7px; }
.monitor-section {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  padding: 16px;
  overflow: hidden;
  border: 1px solid var(--line-soft);
  border-radius: 15px;
  background: linear-gradient(150deg, #fff, #fafbfc);
}
.monitor-section-title {
  min-width: 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}
.monitor-section-title h3 { margin: 0; font-size: 15px; }
.monitor-section-title p { margin: 4px 0 0; color: var(--muted); font-size: 11px; line-height: 1.5; }
.monitor-updated { color: var(--faint); font-size: 10px; white-space: nowrap; }
.monitor-section-title > div { min-width: 0; }
.monitor-network-actions { display: flex; flex: 0 0 auto; align-items: center; gap: 8px; }
.direct-access-link { display: inline-flex; align-items: center; text-decoration: none; white-space: nowrap; }
.metric-grid { width: 100%; min-width: 0; display: grid; gap: 9px; }
.account-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.speed-metrics { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.metric-card {
  min-width: 0;
  padding: 13px 14px;
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  background: var(--panel);
}
.metric-card.emphasis { border-color: rgba(32, 155, 99, .25); background: rgba(32, 155, 99, .055); }
.metric-card span, .metric-card small { display: block; color: var(--faint); font-size: 10px; }
.metric-card strong {
  display: block;
  overflow: hidden;
  margin-top: 7px;
  color: var(--text);
  font-size: clamp(18px, 2.5vw, 25px);
  font-variant-numeric: tabular-nums;
  letter-spacing: -.025em;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.metric-card.emphasis strong { color: var(--green-strong); }
.metric-card small { margin-top: 5px; }
.hardware-metrics { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.monitor-status { min-height: 18px; margin: 12px 0 8px; color: var(--muted); font-size: 11px; line-height: 1.55; }
.monitor-status.error { color: var(--red); }
.hardware-status { min-height: 0; margin-bottom: 0; }
.speed-section { margin-bottom: 0; }

.toast { position: fixed; left: 50%; bottom: calc(22px + env(safe-area-inset-bottom)); z-index: 100; max-width: calc(100% - 28px); padding: 10px 14px; border: 1px solid var(--line); border-radius: 10px; background: #ffffff; color: var(--text); box-shadow: 0 12px 40px rgba(28, 42, 54, .18); font-size: 12px; opacity: 0; pointer-events: none; transform: translate(-50%, 8px); transition: opacity .18s, transform .18s; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { border-color: rgba(255, 123, 123, .45); }

@media (max-width: 760px) {
  .mobile-only { display: grid; place-items: center; }
  .app-shell { grid-template-columns: 1fr; grid-template-rows: calc(54px + env(safe-area-inset-top)) minmax(0, 1fr); }
  .topbar { height: calc(54px + env(safe-area-inset-top)); padding-left: 9px; padding-right: 12px; }
  .topbar .brand { margin-right: auto; }
  .topbar-actions #notifyButton, .topbar-actions #logoutButton { display: none; }
  .sidebar { position: fixed; top: 0; bottom: 0; left: 0; width: min(88vw, 340px); z-index: 60; padding-top: calc(58px + env(safe-area-inset-top)); transform: translateX(-102%); transition: transform .2s ease; box-shadow: 18px 0 60px rgba(28, 42, 54, .22); }
  .sidebar-resize-handle { display: none; }
  .sidebar.open { transform: translateX(0); }
  .sidebar-scrim { position: fixed; inset: 0; z-index: 50; border: 0; background: rgba(0, 0, 0, .55); }
  .sidebar.open + .sidebar-scrim { display: block; }
  .workspace { grid-column: 1; grid-row: 2; }
  .conversation-head { padding: 11px 13px; }
  .conversation-title h1 { max-width: 60vw; }
  .conversation-title h1 { font-size: 17px; }
  .conversation-title p { font-size: 12px; }
  .turn-state { font-size: 13px; }
  .approval-area { padding-left: 10px; padding-right: 10px; }
  .message-list { padding: 18px 13px 24px; }
  .message { margin-bottom: 16px; }
  .message-label { font-size: 12px; }
  .message-content { font-size: 18px; line-height: 1.72; }
  .markdown-code-head,
  .markdown-code-head button { font-size: 12px; }
  .markdown-code pre { padding: 12px; }
  .markdown-code pre code { font-size: 14px; }
  .markdown-table table { font-size: 14px; }
  .composer { margin: 0 9px max(9px, env(safe-area-inset-bottom)); border-radius: 14px; }
  .composer textarea { font-size: 18px; line-height: 1.55; }
  .composer-foot span { display: none; }
  .composer-foot { justify-content: flex-end; }
  .send-button { min-width: 76px; min-height: 42px; font-size: 15px; }
  .primary-button { min-height: 46px; font-size: 15px; }
  .quiet-button, .danger-button, .text-button { font-size: 14px; }
  .thread-row strong { font-size: 16px; }
  .thread-row time, .thread-row small { font-size: 12px; }
  .thread-group-title { font-size: 13px; }
  .thread-empty, .sidebar-foot { font-size: 13px; }
  .search-box { height: 44px; }
  .search-box input { font-size: 16px; }
  .monitor-dialog { width: calc(100vw - 12px); max-width: calc(100vw - 12px); max-height: calc(100dvh - 12px); }
  .monitor-card { gap: 12px; padding: 12px; }
  .monitor-section { padding: 13px; }
  .monitor-section-title { align-items: center; }
  .monitor-network-actions { gap: 6px; }
  .hardware-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .speed-metrics { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .metric-card { padding: 11px 10px; }
  .metric-card strong { font-size: 19px; }
  .toast { font-size: 14px; }
  .tool-output { max-height: 260px; }
  .empty-state { padding-bottom: 15vh; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation: none !important; transition: none !important; }
}
