:root {
  --ink: #172224;
  --ink-soft: #3d4a49;
  --muted: #6f7b78;
  --paper: #f3f5f0;
  --panel: #fbfcf9;
  --panel-strong: #ffffff;
  --line: #cad3ce;
  --line-strong: #9daaa5;
  --orange: #e65032;
  --orange-dark: #b8321d;
  --teal: #187f74;
  --teal-soft: #d9ebe6;
  --amber: #cc8a25;
  --red-soft: #f7dfd8;
  --shadow: 0 24px 80px rgba(23, 34, 36, 0.12);
  --display: "Bahnschrift", "Segoe UI Variable Display", "Microsoft YaHei UI", sans-serif;
  --body: "Segoe UI Variable Text", "Microsoft YaHei UI", "PingFang SC", sans-serif;
  --mono: "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  color: var(--ink);
  background: var(--paper);
  font-family: var(--body);
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100dvh;
  overflow: hidden;
}

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

button {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible {
  outline: 3px solid rgba(24, 127, 116, 0.28);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

.noise {
  position: fixed;
  inset: 0;
  z-index: 1000;
  pointer-events: none;
  opacity: 0.045;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.5'/%3E%3C/svg%3E");
}

.login-view {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 28px;
  background:
    linear-gradient(rgba(23, 34, 36, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(23, 34, 36, 0.045) 1px, transparent 1px),
    radial-gradient(circle at 82% 18%, rgba(24, 127, 116, 0.14), transparent 30%),
    var(--paper);
  background-size: 32px 32px, 32px 32px, auto, auto;
}

.login-card {
  width: min(100%, 470px);
  padding: clamp(26px, 5vw, 48px);
  border: 1px solid var(--line);
  border-top: 5px solid var(--teal);
  background: rgba(251, 252, 249, 0.94);
  box-shadow: var(--shadow);
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 13px;
}

.brand-mark {
  display: inline-grid;
  width: 48px;
  height: 48px;
  place-items: center;
  color: var(--teal);
}

.brand-mark svg {
  width: 100%;
  height: 100%;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
}

.brand-mark--small {
  width: 34px;
  height: 34px;
}

.wordmark,
.wordmark-sub,
.login-copy p,
.login-footnote,
.topbar-title span,
.topbar-title strong {
  margin: 0;
}

.wordmark {
  font-family: var(--display);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.wordmark-sub {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.login-copy {
  margin: 48px 0 34px;
}

.section-kicker {
  margin: 0 0 10px;
  color: var(--teal);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.08em;
}

.login-copy h1 {
  margin: 0 0 16px;
  font-family: var(--display);
  font-size: clamp(37px, 8vw, 54px);
  font-weight: 650;
  line-height: 1.02;
  letter-spacing: -0.025em;
}

.login-copy > p:last-child {
  max-width: 38ch;
  color: var(--ink-soft);
  font-size: 14px;
  line-height: 1.75;
}

.pair-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

.pair-form label {
  grid-column: 1 / -1;
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 650;
}

.pair-code-input {
  width: 100%;
  min-width: 0;
  padding: 13px 15px;
  border: 1px solid var(--line-strong);
  background: var(--panel-strong);
  font-family: var(--mono);
  font-size: 22px;
  letter-spacing: 0.18em;
}

.server-url-input {
  grid-column: 1 / -1;
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--line-strong);
  background: var(--panel-strong);
  font-family: var(--mono);
  font-size: 12px;
}

.primary-action,
.outline-action,
.new-thread-button,
.sidebar-project-button,
.danger-outline,
.stop-button {
  min-height: 46px;
  border: 1px solid transparent;
  font-weight: 650;
}

.primary-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 0 18px;
  border-color: var(--ink);
  background: var(--ink);
  color: white;
}

.primary-action:hover {
  background: #293536;
}

.primary-action:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.primary-action--compact,
.outline-action--compact {
  min-height: 42px;
  padding: 0 16px;
}

.button-signal {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--orange);
  box-shadow: 0 0 0 4px rgba(230, 80, 50, 0.18);
}

.form-error {
  grid-column: 1 / -1;
  min-height: 18px;
  margin: 2px 0 0;
  color: var(--orange-dark);
  font-size: 12px;
}

.login-footnote {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
}

.signal-dot {
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--teal);
  box-shadow: 0 0 0 4px rgba(24, 127, 116, 0.13);
}

.signal-dot--quiet {
  background: var(--line-strong);
  box-shadow: none;
}

.app-view {
  height: 100dvh;
}

.topbar {
  position: relative;
  z-index: 20;
  height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 0 20px;
  border-bottom: 1px solid var(--line);
  background: rgba(251, 252, 249, 0.92);
  backdrop-filter: blur(16px);
}

.topbar-left,
.topbar-actions,
.thread-actions,
.thread-breadcrumb,
.composer-bottom,
.empty-actions,
.sidebar-top,
.pane-heading,
.sheet-header,
.sheet-footer {
  display: flex;
  align-items: center;
}

.topbar-left {
  min-width: 0;
  gap: 10px;
}

.topbar-title {
  display: grid;
  min-width: 0;
}

.topbar-title strong {
  font-family: var(--display);
  font-size: 15px;
}

.topbar-title span {
  overflow: hidden;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-actions {
  gap: 8px;
}

.connection-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 34px;
  padding: 0 11px;
  border: 1px solid var(--line);
  background: var(--panel-strong);
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 600;
}

.connection-pill.is-online .signal-dot {
  animation: signal-breathe 2.4s ease-in-out infinite;
}

.connection-pill.is-offline {
  color: var(--orange-dark);
}

.connection-pill.is-offline .signal-dot {
  background: var(--orange);
  box-shadow: 0 0 0 4px rgba(230, 80, 50, 0.12);
}

.connection-pill.is-connecting .signal-dot {
  background: var(--amber);
  box-shadow: none;
}

@keyframes signal-breathe {
  0%, 100% { box-shadow: 0 0 0 4px rgba(24, 127, 116, 0.12); }
  50% { box-shadow: 0 0 0 7px rgba(24, 127, 116, 0.04); }
}

.icon-button {
  display: inline-grid;
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid transparent;
  background: transparent;
}

.icon-button:hover {
  border-color: var(--line);
  background: var(--panel-strong);
}

.icon-button svg,
.new-thread-button svg,
.sidebar-project-button svg,
.send-button svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.new-thread-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 14px;
  border-color: var(--ink);
  background: var(--ink);
  color: white;
}

.app-grid {
  height: calc(100dvh - 68px);
  display: grid;
  grid-template-columns: 310px minmax(0, 1fr);
}

.sidebar {
  min-height: 0;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--line);
  background: var(--panel);
}

.sidebar-top {
  justify-content: space-between;
  gap: 8px;
  padding: 15px 14px 11px;
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  width: 174px;
  padding: 3px;
  border: 1px solid var(--line);
  background: var(--paper);
}

.segmented-button {
  height: 30px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.segmented-button.is-active {
  background: var(--panel-strong);
  color: var(--ink);
  box-shadow: 0 1px 3px rgba(23, 34, 36, 0.09);
}

.project-filter {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 0 14px 12px;
  scrollbar-width: none;
}

.project-filter::-webkit-scrollbar {
  display: none;
}

.filter-chip {
  flex: 0 0 auto;
  height: 28px;
  padding: 0 10px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink-soft);
  font-size: 11px;
  white-space: nowrap;
}

.filter-chip.is-active {
  border-color: var(--teal);
  background: var(--teal-soft);
  color: #105e56;
}

.sidebar-scroll {
  min-height: 0;
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.pane-heading {
  justify-content: space-between;
  padding: 13px 14px 8px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
}

.count-tag {
  min-width: 23px;
  padding: 2px 6px;
  background: #e7ebe7;
  text-align: center;
  font-family: var(--mono);
  font-size: 10px;
}

.thread-list,
.projects-list {
  display: grid;
  gap: 2px;
  padding: 0 8px 12px;
}

.thread-item {
  position: relative;
  width: 100%;
  padding: 12px 12px 12px 15px;
  border: 1px solid transparent;
  background: transparent;
  color: inherit;
  text-align: left;
}

.thread-item::before {
  content: "";
  position: absolute;
  top: 12px;
  bottom: 12px;
  left: 3px;
  width: 2px;
  background: transparent;
}

.thread-item:hover {
  background: #eff2ed;
}

.thread-item.is-active {
  border-color: var(--line);
  background: var(--panel-strong);
}

.thread-item.is-active::before {
  background: var(--orange);
}

.thread-item-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.thread-item-title {
  overflow: hidden;
  font-size: 13px;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.thread-time {
  flex: 0 0 auto;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 9px;
}

.thread-item-preview {
  display: -webkit-box;
  margin-top: 5px;
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.thread-meta {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 10px;
}

.thread-live-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--line-strong);
}

.thread-live-dot.is-live {
  background: var(--orange);
  animation: live-pulse 1.5s ease-in-out infinite;
}

@keyframes live-pulse {
  50% { opacity: 0.35; }
}

.project-card {
  width: 100%;
  padding: 14px;
  border: 1px solid var(--line);
  background: var(--panel-strong);
  text-align: left;
}

.project-card:hover {
  border-color: var(--teal);
}

.project-card + .project-card {
  margin-top: 7px;
}

.project-card-name {
  display: block;
  font-family: var(--display);
  font-size: 14px;
  font-weight: 650;
}

.project-card-path {
  display: block;
  margin-top: 6px;
  overflow: hidden;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 9px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.project-card-foot {
  display: flex;
  justify-content: space-between;
  margin-top: 12px;
  color: var(--muted);
  font-size: 10px;
}

.text-button {
  border: 0;
  background: none;
  color: var(--teal);
  font-size: 11px;
  font-weight: 650;
}

.sidebar-project-button {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  margin: 10px;
  padding: 0 13px;
  border-color: var(--line);
  background: transparent;
  color: var(--ink-soft);
}

.sidebar-project-button:hover {
  border-color: var(--teal);
  background: var(--teal-soft);
}

.workspace {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background:
    linear-gradient(90deg, transparent 31px, rgba(23, 34, 36, 0.035) 32px, transparent 33px),
    var(--paper);
  background-size: 32px 100%;
}

.empty-state,
.offline-blocker {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  padding: clamp(28px, 8vw, 100px);
  background: rgba(243, 245, 240, 0.96);
}

.empty-index {
  position: absolute;
  top: 34px;
  right: 42px;
  color: rgba(23, 34, 36, 0.13);
  font-family: var(--display);
  font-size: clamp(50px, 11vw, 130px);
  font-weight: 700;
  letter-spacing: -0.05em;
}

.empty-state h2,
.offline-blocker h2 {
  max-width: 630px;
  margin: 0 0 20px;
  font-family: var(--display);
  font-size: clamp(34px, 5vw, 68px);
  font-weight: 600;
  line-height: 1.02;
  letter-spacing: -0.035em;
}

.empty-state > p:not(.section-kicker),
.offline-blocker > p:not(.section-kicker) {
  max-width: 54ch;
  margin: 0;
  color: var(--ink-soft);
  font-size: 14px;
  line-height: 1.8;
}

.empty-actions {
  gap: 10px;
  margin-top: 30px;
}

.outline-action,
.danger-outline {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 17px;
  border-color: var(--line-strong);
  background: transparent;
}

.outline-action:hover {
  border-color: var(--ink);
  background: var(--panel-strong);
}

.danger-outline {
  border-color: #d9a89d;
  background: transparent;
  color: var(--orange-dark);
}

.offline-blocker {
  z-index: 12;
}

.offline-illustration {
  display: flex;
  align-items: end;
  gap: 5px;
  height: 46px;
  margin-bottom: 30px;
}

.offline-illustration span {
  width: 7px;
  background: var(--orange);
}

.offline-illustration span:nth-child(1) { height: 15px; opacity: 0.45; }
.offline-illustration span:nth-child(2) { height: 24px; opacity: 0.7; }
.offline-illustration span:nth-child(3) { height: 40px; }

.offline-blocker .outline-action {
  margin-top: 26px;
}

.thread-view {
  height: 100%;
  display: flex;
  flex-direction: column;
}

.thread-header {
  min-height: 78px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 12px clamp(18px, 4vw, 46px);
  border-bottom: 1px solid var(--line);
  background: rgba(243, 245, 240, 0.9);
  backdrop-filter: blur(12px);
}

.thread-heading-copy {
  min-width: 0;
}

.thread-breadcrumb {
  gap: 7px;
  overflow: hidden;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 9px;
  white-space: nowrap;
}

.thread-breadcrumb span {
  overflow: hidden;
  text-overflow: ellipsis;
}

.thread-heading-copy h2 {
  max-width: min(60vw, 760px);
  margin: 4px 0 0;
  overflow: hidden;
  font-family: var(--display);
  font-size: 21px;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.thread-actions {
  gap: 8px;
}

.status-badge {
  height: 28px;
  padding: 6px 9px;
  border: 1px solid var(--line);
  background: var(--panel-strong);
  color: var(--muted);
  font-size: 10px;
  font-weight: 650;
  white-space: nowrap;
}

.status-badge.is-live {
  border-color: #e2b09e;
  background: #fae9e4;
  color: var(--orange-dark);
}

.status-badge.is-waiting {
  border-color: #e4c693;
  background: #fbf0d9;
  color: #885c16;
}

.stop-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  min-height: 34px;
  padding: 0 11px;
  border-color: #d9a89d;
  background: transparent;
  color: var(--orange-dark);
  font-size: 11px;
}

.stop-square {
  width: 7px;
  height: 7px;
  background: currentColor;
}

.messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 32px clamp(18px, 7vw, 110px) 220px;
}

.message {
  max-width: 880px;
  margin: 0 auto 22px;
}

.message-user {
  display: flex;
  justify-content: flex-end;
}

.message-user .message-bubble {
  max-width: min(82%, 680px);
  padding: 13px 15px;
  border: 1px solid #b8c9c3;
  background: var(--teal-soft);
  line-height: 1.7;
  white-space: pre-wrap;
}

.message-agent {
  padding-left: 20px;
  border-left: 2px solid var(--line-strong);
}

.message-agent.is-commentary {
  max-width: 760px;
  border-left-color: var(--teal);
  color: var(--ink-soft);
  font-size: 13px;
}

.message-text {
  margin: 0;
  font-size: 14px;
  line-height: 1.78;
  white-space: pre-wrap;
}

.message-label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 9px;
}

.message-label::before {
  content: "";
  width: 16px;
  height: 1px;
  background: currentColor;
}

.tool-card,
.plan-card {
  max-width: 880px;
  margin: 0 auto 14px;
  border: 1px solid var(--line);
  background: rgba(251, 252, 249, 0.86);
}

.tool-card summary {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 13px;
  cursor: pointer;
  list-style: none;
}

.tool-card summary::-webkit-details-marker {
  display: none;
}

.tool-icon {
  width: 26px;
  height: 26px;
  display: inline-grid;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid var(--line);
  color: var(--teal);
  font-family: var(--mono);
  font-size: 10px;
}

.tool-title {
  min-width: 0;
  flex: 1;
  overflow: hidden;
  font-family: var(--mono);
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tool-status {
  color: var(--muted);
  font-size: 9px;
}

.tool-body {
  max-height: 330px;
  margin: 0;
  overflow: auto;
  padding: 13px;
  border-top: 1px solid var(--line);
  background: #eef1ed;
  font-family: var(--mono);
  font-size: 10px;
  line-height: 1.65;
  white-space: pre-wrap;
}

.plan-card {
  padding: 15px;
  border-left: 3px solid var(--amber);
  white-space: pre-wrap;
  font-size: 13px;
  line-height: 1.7;
}

.empty-messages {
  max-width: 440px;
  margin: 80px auto;
  color: var(--muted);
  text-align: center;
  font-size: 13px;
  line-height: 1.8;
}

.composer-wrap {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 8;
  padding: 30px clamp(16px, 6vw, 90px) max(18px, env(safe-area-inset-bottom));
  background: linear-gradient(transparent, var(--paper) 26%);
}

.composer,
.approval-card {
  max-width: 880px;
  margin: 0 auto;
  border: 1px solid var(--line-strong);
  background: var(--panel-strong);
  box-shadow: 0 14px 40px rgba(23, 34, 36, 0.09);
}

.composer:focus-within {
  border-color: var(--teal);
}

.composer textarea {
  display: block;
  width: 100%;
  max-height: 180px;
  resize: none;
  padding: 15px 16px 8px;
  border: 0;
  outline: none;
  background: transparent;
  font-size: 14px;
  line-height: 1.6;
}

.composer-bottom {
  justify-content: space-between;
  gap: 12px;
  padding: 6px 8px 8px 15px;
}

.composer-context {
  overflow: hidden;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 9px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.send-button {
  display: grid;
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  place-items: center;
  border: 0;
  background: var(--ink);
  color: white;
}

.send-button:hover {
  background: var(--teal);
}

.send-button:disabled {
  cursor: not-allowed;
  opacity: 0.35;
}

.approval-tray {
  display: grid;
  gap: 8px;
  max-width: 880px;
  margin: 0 auto 8px;
}

.approval-card {
  padding: 14px;
  border-left: 4px solid var(--amber);
}

.approval-card h3 {
  margin: 0 0 7px;
  font-size: 13px;
}

.approval-card p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 11px;
  line-height: 1.6;
}

.approval-command {
  margin: 10px 0 0;
  padding: 9px;
  overflow: auto;
  background: #eef1ed;
  font-family: var(--mono);
  font-size: 10px;
  white-space: pre-wrap;
}

.approval-actions {
  display: flex;
  gap: 8px;
  margin-top: 11px;
}

.approval-actions button {
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  background: var(--panel);
  font-size: 11px;
  font-weight: 650;
}

.approval-actions .approve {
  border-color: var(--teal);
  background: var(--teal);
  color: white;
}

.scrim {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgba(23, 34, 36, 0.28);
  backdrop-filter: blur(2px);
}

.toast-region {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 200;
  display: grid;
  gap: 8px;
  pointer-events: none;
}

.toast {
  max-width: 360px;
  padding: 12px 14px;
  border: 1px solid var(--ink);
  background: var(--ink);
  color: white;
  font-size: 12px;
  box-shadow: 0 10px 30px rgba(23, 34, 36, 0.22);
}

.toast.is-error {
  border-color: var(--orange-dark);
  background: var(--orange-dark);
}

.sheet {
  width: min(calc(100% - 28px), 600px);
  max-height: min(86dvh, 760px);
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.sheet::backdrop {
  background: rgba(23, 34, 36, 0.32);
  backdrop-filter: blur(3px);
}

.sheet form {
  margin: 0;
}

.sheet-header {
  justify-content: space-between;
  gap: 20px;
  padding: 22px 22px 15px;
  border-bottom: 1px solid var(--line);
}

.sheet-header h2 {
  margin: 0;
  font-family: var(--display);
  font-size: 24px;
}

.sheet-body {
  display: grid;
  gap: 16px;
  max-height: calc(86dvh - 160px);
  overflow-y: auto;
  padding: 22px;
}

.sheet-footer {
  justify-content: flex-end;
  gap: 9px;
  padding: 14px 22px 20px;
  border-top: 1px solid var(--line);
}

.field {
  display: grid;
  gap: 7px;
}

.field > span {
  color: var(--ink-soft);
  font-size: 11px;
  font-weight: 650;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 0;
  background: white;
  font-size: 13px;
}

.field textarea {
  resize: vertical;
  line-height: 1.65;
}

.field-note {
  margin: -4px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.6;
}

.check-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  color: var(--ink-soft);
  font-size: 12px;
  line-height: 1.5;
}

.check-row input {
  width: 17px;
  height: 17px;
  margin: 0;
  accent-color: var(--teal);
}

.settings-body {
  gap: 0;
}

.settings-row {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding: 13px 0;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
}

.settings-row span {
  color: var(--muted);
}

.settings-row strong {
  overflow: hidden;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 500;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.settings-body .check-row {
  margin: 18px 0 12px;
}

.mobile-only {
  display: none;
}

@media (min-width: 1180px) {
  .app-grid {
    grid-template-columns: 348px minmax(0, 1fr);
  }

  .messages {
    padding-right: clamp(110px, 12vw, 190px);
    padding-left: clamp(110px, 12vw, 190px);
  }
}

@media (max-width: 720px) {
  .mobile-only {
    display: inline-grid;
  }

  .login-view {
    padding: 16px;
  }

  .login-card {
    padding: 28px 22px;
  }

  .login-copy {
    margin-top: 40px;
  }

  .login-copy h1 {
    font-size: 40px;
  }

  .pair-form {
    grid-template-columns: 1fr;
  }

  .pair-form .primary-action {
    width: 100%;
  }

  .topbar {
    height: 62px;
    padding: 0 10px;
  }

  .topbar .brand-mark {
    display: none;
  }

  .topbar-title strong {
    font-size: 13px;
  }

  .topbar-title span {
    max-width: 132px;
  }

  .connection-pill {
    height: 30px;
    padding: 0 8px;
  }

  .connection-pill span:last-child {
    display: none;
  }

  .new-thread-button {
    width: 38px;
    height: 38px;
    min-height: 38px;
    padding: 0;
    justify-content: center;
  }

  .new-thread-button span {
    display: none;
  }

  .topbar-actions .icon-button {
    display: none;
  }

  .app-grid {
    height: calc(100dvh - 62px);
    display: block;
  }

  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 40;
    width: min(88vw, 360px);
    padding-top: env(safe-area-inset-top);
    transform: translateX(-105%);
    transition: transform 180ms ease;
  }

  .sidebar.is-open {
    transform: translateX(0);
    box-shadow: 30px 0 80px rgba(23, 34, 36, 0.2);
  }

  .workspace {
    height: 100%;
  }

  .empty-state,
  .offline-blocker {
    padding: 30px 25px 100px;
  }

  .empty-state h2,
  .offline-blocker h2 {
    font-size: 42px;
  }

  .empty-index {
    top: 24px;
    right: 22px;
    font-size: 66px;
  }

  .thread-header {
    min-height: 69px;
    padding: 10px 13px;
  }

  .thread-breadcrumb {
    max-width: 44vw;
  }

  .thread-heading-copy h2 {
    max-width: 58vw;
    font-size: 17px;
  }

  .thread-actions .status-badge,
  .thread-actions .icon-button {
    display: none;
  }

  .stop-button {
    width: 38px;
    min-height: 38px;
    height: 38px;
    padding: 0;
    justify-content: center;
  }

  .stop-button {
    font-size: 0;
  }

  .messages {
    padding: 22px 14px 220px;
  }

  .message {
    margin-bottom: 18px;
  }

  .message-user .message-bubble {
    max-width: 90%;
  }

  .message-agent {
    padding-left: 13px;
  }

  .message-text {
    font-size: 13px;
  }

  .composer-wrap {
    padding: 30px 10px max(10px, env(safe-area-inset-bottom));
  }

  .composer {
    box-shadow: 0 10px 30px rgba(23, 34, 36, 0.12);
  }

  .sheet {
    width: 100%;
    max-height: 92dvh;
    margin: auto 0 0;
    border-right: 0;
    border-bottom: 0;
    border-left: 0;
  }

  .sheet[open] {
    animation: sheet-up 180ms ease-out;
  }

  @keyframes sheet-up {
    from { transform: translateY(18px); opacity: 0.7; }
  }

  .sheet-body {
    max-height: calc(92dvh - 170px);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
