:root {
  color-scheme: dark;
  font-family: "Avenir Next", "PingFang SC", "Hiragino Sans GB", sans-serif;
  --ink: #f1f1e9;
  --muted: #9ba8ad;
  --subtle: #71818a;
  --base: #101c27;
  --panel: #142330;
  --panel-raised: #1a2d3b;
  --line: #2d414d;
  --accent: #e7a887;
  --accent-light: #ffceb1;
}

* { box-sizing: border-box; }
html { min-width: 320px; }
body { margin: 0; background: var(--base); color: var(--ink); }
button, select, textarea { font: inherit; }
button { cursor: pointer; }
button:focus-visible, select:focus-visible { outline: 2px solid var(--accent-light); outline-offset: 3px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

.app { min-height: 100vh; min-height: 100dvh; background: var(--base); }
.topbar { height: 69px; padding: 0 32px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.brand { display: flex; align-items: center; gap: 13px; font-size: 15px; font-weight: 700; letter-spacing: .03em; white-space: nowrap; }
.brand-mark { width: 22px; height: 22px; display: flex; align-items: flex-end; gap: 3px; transform: rotate(-26deg); }
.brand-mark span { display: block; width: 5px; background: var(--accent); border-radius: 1px; }
.brand-mark span:nth-child(1) { height: 12px; }
.brand-mark span:nth-child(2) { height: 20px; }
.brand-mark span:nth-child(3) { height: 15px; }
.brand-slash { color: var(--subtle); padding: 0 3px; }
.brand-subtitle { color: var(--muted); font-size: 10px; letter-spacing: .19em; font-weight: 600; }
.read-only-badge { border: 1px solid #795c4e; border-radius: 100px; color: var(--accent-light); font-size: 11px; font-weight: 700; letter-spacing: .06em; padding: 7px 11px; white-space: nowrap; display: inline-flex; align-items: center; gap: 7px; }
.access-logout { border: 1px solid var(--line); border-radius: 6px; background: transparent; color: var(--muted); padding: 6px 9px; font-size: 10px; cursor: pointer; }
.access-logout:hover { color: var(--ink); border-color: var(--accent); }
.access-logout:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.badge-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); display: inline-block; flex: none; }

.workspace { display: grid; grid-template-columns: minmax(290px, 356px) minmax(0, 1fr); min-height: calc(100vh - 69px); min-height: calc(100dvh - 69px); }
.sidebar { display: flex; flex-direction: column; min-width: 0; border-right: 1px solid var(--line); background: var(--panel); }
.sidebar-heading { padding: 38px 28px 30px; }
.eyebrow { color: var(--accent); font-size: 10px; font-weight: 700; letter-spacing: .22em; margin: 0 0 14px; }
h1, h2, p { margin-top: 0; }
h1 { font-size: clamp(29px, 3vw, 37px); letter-spacing: -.05em; line-height: 1.15; margin-bottom: 10px; }
.heading-period { color: var(--accent); }
.sidebar-intro { color: var(--muted); font-size: 12px; line-height: 1.7; margin-bottom: 0; }
.project-control { padding: 0 28px 30px; }
.project-control label { display: block; color: var(--muted); font-size: 11px; letter-spacing: .07em; margin-bottom: 10px; }
.select-wrap { position: relative; }
.select-wrap select { appearance: none; width: 100%; border: 1px solid #45606c; border-radius: 8px; color: var(--ink); background: var(--panel-raised); padding: 13px 37px 13px 14px; font-size: 14px; font-weight: 600; cursor: pointer; text-overflow: ellipsis; }
.select-wrap select:disabled { opacity: .65; cursor: not-allowed; }
.select-wrap > span { pointer-events: none; position: absolute; right: 14px; top: 10px; color: var(--accent); font-size: 20px; }
.project-meta { min-height: 17px; color: var(--subtle); font-size: 11px; margin: 9px 0 0; overflow-wrap: anywhere; }
.new-thread-button { margin-top: 13px; border: 1px solid #607780; border-radius: 7px; background: transparent; color: var(--ink); padding: 8px 11px; font-size: 11px; font-weight: 700; cursor: pointer; }
.new-thread-button:hover { border-color: var(--accent); color: var(--accent-light); }
.new-thread-button:disabled { opacity: .55; cursor: progress; }
.list-heading { padding: 0 28px 12px; display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .06em; }
.list-count { color: var(--subtle); font-variant-numeric: tabular-nums; }
.thread-list { border-top: 1px solid var(--line); flex: 1; }
.thread-row { appearance: none; width: 100%; border: 0; border-bottom: 1px solid var(--line); background: transparent; color: inherit; text-align: left; display: block; padding: 18px 28px 17px; transition: background .15s ease, border-color .15s ease; }
.thread-row:hover, .thread-row:focus-visible { background: #203543; }
.thread-row.active { background: #263a45; box-shadow: inset 3px 0 var(--accent); }
.row-top { display: flex; gap: 8px; align-items: center; justify-content: space-between; }
.row-title { font-size: 13px; font-weight: 700; line-height: 1.45; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-arrow { color: var(--accent); font-size: 17px; flex: none; }
.row-preview { color: var(--muted); font-size: 11px; line-height: 1.55; margin: 6px 0 10px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.row-bottom { display: flex; gap: 10px; align-items: center; color: var(--subtle); font-size: 10px; }
.status-chip { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 4px; padding: 2px 6px; color: var(--muted); max-width: 100%; overflow-wrap: anywhere; }
.status-chip.running { color: #b5dbc4; border-color: #547565; }
.status-chip.failed { color: #f4afa5; border-color: #8b5a55; }
.pagination { padding: 14px 28px; }
.load-more, .action-button { background: transparent; border: 1px solid #607780; border-radius: 7px; color: var(--ink); padding: 10px 15px; font-size: 12px; font-weight: 700; }
.load-more { width: 100%; }
.load-more:hover, .action-button:hover { border-color: var(--accent); color: var(--accent-light); }
.load-more:disabled { opacity: .55; cursor: progress; }
.sidebar-footer { color: var(--subtle); border-top: 1px solid var(--line); font-size: 10px; line-height: 1.5; padding: 16px 28px; margin: 0; }

.detail { min-width: 0; display: flex; flex-direction: column; background: radial-gradient(circle at 84% 5%, #203541 0, transparent 37%), var(--base); }
.detail-topline { min-height: 56px; padding: 0 42px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: flex-end; }
.detail-mode { font-size: 10px; letter-spacing: .18em; font-weight: 700; color: var(--subtle); }
.detail-mode span { color: var(--accent); font-size: 14px; margin-left: 5px; }
.back-button { display: none; border: 0; background: none; color: var(--ink); padding: 10px 0; font-size: 12px; font-weight: 700; }
.back-button span { color: var(--accent); font-size: 18px; vertical-align: -1px; margin-right: 5px; }
.detail-content { width: min(100%, 850px); margin: 0 auto; padding: 55px 50px 65px; flex: 1; }
.detail-content h2 { font-size: clamp(26px, 3.5vw, 41px); letter-spacing: -.045em; line-height: 1.25; overflow-wrap: anywhere; margin: 0 0 17px; }
.detail-kicker { color: var(--accent); font-size: 10px; font-weight: 700; letter-spacing: .2em; margin-bottom: 15px; }
.detail-subtitle { color: var(--muted); font-size: 13px; line-height: 1.65; overflow-wrap: anywhere; margin-bottom: 0; }
.section-divider { display: flex; align-items: center; gap: 14px; color: var(--subtle); font-size: 10px; font-weight: 700; letter-spacing: .12em; margin: 44px 0 24px; }
.section-divider::after { content: ""; height: 1px; flex: 1; background: var(--line); }
.message { border: 1px solid var(--line); border-radius: 10px; background: #192b37; padding: 18px 21px; margin-bottom: 14px; }
.message.user { border-left: 3px solid var(--accent); }
.message-label { color: var(--accent-light); font-size: 10px; font-weight: 700; letter-spacing: .11em; margin-bottom: 12px; overflow-wrap: anywhere; }
.message-body { color: #e0e8e7; font-size: 13px; line-height: 1.75; white-space: pre-wrap; overflow-wrap: anywhere; }
.approval-card { border: 1px solid #9b6c62; border-radius: 10px; background: #2a2526; padding: 16px 18px; margin-bottom: 14px; }
.approval-title { color: var(--accent-light); font-size: 12px; font-weight: 700; margin-bottom: 10px; }
.approval-command { white-space: pre-wrap; overflow-wrap: anywhere; border: 1px solid var(--line); border-radius: 6px; background: #101c27; color: var(--ink); padding: 10px; font: 12px/1.55 ui-monospace, SFMono-Regular, Menlo, monospace; }
.approval-detail { color: var(--muted); font-size: 11px; line-height: 1.6; margin: 8px 0 0; overflow-wrap: anywhere; }
.approval-actions { display: flex; gap: 8px; margin-top: 14px; }
.approval-actions button { border-radius: 6px; padding: 8px 12px; font-size: 11px; font-weight: 700; cursor: pointer; }
.approval-reject { border: 1px solid #8b5a55; background: transparent; color: #f3ad9c; }
.approval-approve { border: 1px solid var(--accent); background: var(--accent); color: var(--base); }
.empty-panel { border: 1px dashed #48606a; border-radius: 12px; padding: 27px; max-width: 540px; background: #192b36; }
.empty-symbol { color: var(--accent); font-size: 25px; display: block; margin-bottom: 18px; }
.empty-panel h2 { font-size: 22px; margin-bottom: 8px; }
.empty-panel p { color: var(--muted); font-size: 12px; line-height: 1.7; margin-bottom: 0; overflow-wrap: anywhere; }
.empty-panel .action-button { margin-top: 18px; }
.list-state { padding: 24px 28px; color: var(--muted); font-size: 12px; line-height: 1.6; }
.list-state strong { display: block; color: var(--ink); font-size: 13px; margin-bottom: 5px; }
.list-state .action-button { margin-top: 12px; }
.composer { position: sticky; bottom: 0; padding: 17px max(42px, calc((100% - 750px) / 2)); background: #101c27f2; border-top: 1px solid var(--line); }
.composer[hidden] { display: none; }
.composer-caption { color: var(--accent-light); font-size: 10px; font-weight: 700; letter-spacing: .05em; display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.composer textarea { display: block; width: 100%; resize: none; border: 1px solid var(--line); border-radius: 8px; background: #1a2a34; color: var(--muted); padding: 13px 15px; font-size: 12px; }
.composer textarea:disabled { opacity: 1; cursor: not-allowed; }
.composer textarea::placeholder { color: var(--subtle); }
.composer textarea:not(:disabled) { color: var(--ink); }
.composer textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.composer-actions { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-top: 10px; }
.composer-buttons { display: flex; align-items: center; gap: 8px; flex: none; }
.submission-status { color: var(--muted); font-size: 11px; line-height: 1.5; margin: 0; overflow-wrap: anywhere; }
.submission-status.error { color: #f3ad9c; }
.send-button { flex: none; border: 1px solid var(--accent); border-radius: 7px; background: var(--accent); color: var(--base); padding: 10px 16px; font-size: 12px; font-weight: 700; cursor: pointer; }
.send-button[hidden] { display: none; }
.send-button:disabled { opacity: .55; cursor: progress; }
.send-button:not(:disabled):hover { filter: brightness(1.12); }
.send-button:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.stop-button { border: 1px solid #9b6c62; border-radius: 7px; background: transparent; color: #f3ad9c; padding: 10px 14px; font-size: 12px; font-weight: 700; cursor: pointer; }
.stop-button[hidden] { display: none; }
.stop-button:disabled { opacity: .55; cursor: progress; }
.stop-button:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.access-panel { position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; padding: 24px; background: #0b151de8; }
.access-panel[hidden] { display: none; }
.access-card { width: min(100%, 420px); border: 1px solid var(--line); border-radius: 14px; background: #162733; padding: 30px; box-shadow: 0 24px 80px #0008; }
.access-card h2 { margin: 0 0 10px; font-size: 25px; letter-spacing: -.035em; }
.access-card > p:not(.detail-kicker):not(.access-error) { color: var(--muted); font-size: 13px; line-height: 1.65; margin-bottom: 24px; }
.access-card label { display: block; color: var(--accent-light); font-size: 11px; font-weight: 700; margin-bottom: 8px; }
.access-card input { display: block; width: 100%; border: 1px solid var(--line); border-radius: 7px; background: #10202a; color: var(--ink); padding: 12px; font: inherit; }
.access-card input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.access-card button { margin-top: 14px; border: 1px solid var(--accent); border-radius: 7px; background: var(--accent); color: var(--base); padding: 10px 16px; font-size: 12px; font-weight: 700; cursor: pointer; }
.access-error { min-height: 18px; color: #f3ad9c; font-size: 11px; margin: 12px 0 0; }

@media (max-width: 700px) {
  .topbar { height: 58px; padding: 0 20px; }
  .brand { font-size: 13px; gap: 10px; }
  .brand-subtitle { font-size: 9px; }
  .read-only-badge { font-size: 10px; padding: 6px 9px; }
  .workspace { display: block; min-height: calc(100dvh - 58px); }
  .sidebar, .detail { min-height: calc(100dvh - 58px); }
  .app[data-view="list"] .detail, .app[data-view="detail"] .sidebar { display: none; }
  .sidebar-heading { padding: 35px 22px 28px; }
  .project-control { padding: 0 22px 30px; }
  .list-heading { padding: 0 22px 12px; }
  .thread-row { padding: 19px 22px; }
  .pagination { padding: 16px 22px; }
  .sidebar-footer { padding: 18px 22px max(18px, env(safe-area-inset-bottom)); }
  .detail-topline { min-height: 55px; padding: 0 22px; justify-content: space-between; }
  .back-button { display: inline-block; }
  .detail-content { padding: 36px 22px 48px; }
  .section-divider { margin-top: 35px; }
  .message { padding: 17px; }
  .composer { padding: 14px 22px max(18px, env(safe-area-inset-bottom)); }
  .composer-actions { align-items: flex-start; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
