:root {
  color-scheme: light;
  --bg: #f5f6f4;
  --surface: #fff;
  --line: #dfe3df;
  --line-strong: #c7cec8;
  --text: #202622;
  --muted: #69736c;
  --green: #216e4e;
  --green-soft: #e7f4ed;
  --amber: #9b5d0a;
  --amber-soft: #fff3d9;
  --blue: #315f9b;
  --blue-soft: #e9f0fa;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; margin: 0; background: var(--bg); color: var(--text); }
body { font-size: 15px; letter-spacing: 0; }
button, input, textarea { font: inherit; letter-spacing: 0; }
a { color: inherit; }

.app-shell { display: grid; min-height: 100vh; grid-template-columns: 220px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 24px 16px; background: #eef0ed; border-right: 1px solid var(--line); }
.brand { display: flex; min-width: 0; align-items: center; gap: 11px; margin: 0 8px 32px; text-decoration: none; }
.brand-mark, .avatar, .connection-icon { display: grid; flex: 0 0 auto; place-items: center; color: #fff; background: var(--green); font-weight: 750; }
.brand-mark { width: 34px; height: 34px; border-radius: 7px; }
.brand span:last-child { min-width: 0; }
.brand strong, .brand small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brand strong { font-size: 14px; }
.brand small { margin-top: 1px; color: var(--muted); font-size: 12px; }
.sidebar nav { display: grid; gap: 3px; }
.sidebar nav a { padding: 9px 11px; border-radius: 6px; color: #4d5750; font-weight: 650; text-decoration: none; }
.sidebar nav a:hover { background: #e4e8e4; }
.sidebar nav a[aria-current="page"] { color: var(--text); background: var(--surface); box-shadow: 0 1px 2px rgb(31 37 33 / 8%); }
.account-menu { position: absolute; right: 16px; bottom: 20px; left: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
.account-menu span { display: block; overflow: hidden; margin-bottom: 4px; color: var(--muted); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.account-menu button { padding: 4px 0; color: #4d5750; background: transparent; border: 0; cursor: pointer; font-weight: 650; }

.main { width: min(980px, 100%); padding: 36px 44px 80px; }
.page-header { display: flex; min-height: 58px; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 26px; }
.page-header h1 { margin: 2px 0 0; font-size: 28px; line-height: 1.15; }
.page-header .subtle { max-width: 700px; }
.eyebrow { margin: 0; color: var(--muted); font-size: 12px; font-weight: 750; text-transform: uppercase; }
.subtle { margin: 6px 0 0; color: var(--muted); line-height: 1.5; }
.back-link { display: inline-block; margin-bottom: 10px; color: var(--blue); font-size: 13px; text-decoration: none; }
.header-links { display: flex; gap: 18px; }

.tabs { display: flex; gap: 22px; margin-bottom: 18px; border-bottom: 1px solid var(--line); }
.tabs a { display: flex; gap: 7px; padding: 0 1px 11px; color: var(--muted); font-size: 14px; font-weight: 650; text-decoration: none; border-bottom: 2px solid transparent; }
.tabs a[aria-current="page"] { color: var(--text); border-bottom-color: var(--green); }
.tabs span { color: #8a938d; font-variant-numeric: tabular-nums; }

.notice { margin: 0 0 18px; padding: 11px 13px; border: 1px solid; border-radius: 6px; font-size: 14px; }
.notice.warning { color: #704307; background: var(--amber-soft); border-color: #ead5a7; }
.notice.success { color: #17573d; background: var(--green-soft); border-color: #bfdfcc; }

.task-list, .conversation-list, .connection-list, .schedule-list { overflow: hidden; background: var(--surface); border: 1px solid var(--line); border-radius: 7px; }
.task-row { display: grid; min-height: 88px; grid-template-columns: minmax(0, 1fr) 120px; align-items: center; gap: 20px; padding: 16px 18px; text-decoration: none; border-bottom: 1px solid var(--line); }
.task-row:last-child, .conversation-row:last-child, .connection-row:last-child, .schedule-row:last-child { border-bottom: 0; }
.task-row:hover, .conversation-row:hover { background: #fafbf9; }
.task-copy { min-width: 0; }
.task-copy strong, .task-copy span { display: block; }
.task-copy strong { margin-bottom: 5px; font-size: 16px; }
.task-copy span { overflow: hidden; color: var(--muted); line-height: 1.4; text-overflow: ellipsis; white-space: nowrap; }
.task-meta { color: var(--muted); font-size: 12px; text-align: right; }

.task-start { margin-bottom: 28px; padding: 18px; background: var(--surface); border: 1px solid var(--line); border-radius: 7px; }
.task-start form { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 12px; }
.task-start textarea { min-height: 72px; }
.recent-work { margin-bottom: 22px; }
.recent-work > summary { width: fit-content; margin-bottom: 0; cursor: pointer; font-size: 15px; font-weight: 680; }
.recent-work[open] > summary { margin-bottom: 10px; }
.compact-list { overflow: hidden; background: var(--surface); border: 1px solid var(--line); border-radius: 7px; }
.compact-list a, .compact-list > div { display: flex; min-height: 45px; align-items: center; justify-content: space-between; gap: 16px; padding: 9px 13px; text-decoration: none; border-bottom: 1px solid var(--line); }
.compact-list > :last-child { border-bottom: 0; }
.compact-list a:hover { background: #fafbf9; }
.compact-list small { color: var(--muted); }
.run-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.run-meta { display: flex; flex: 0 0 auto; align-items: center; gap: 12px; color: var(--muted); font-size: 12px; white-space: nowrap; }
.load-more-button { display: block; margin: 9px auto 0; padding: 5px 9px; color: var(--blue); background: transparent; border: 0; cursor: pointer; font-size: 13px; font-weight: 650; }
.load-more-button:hover { text-decoration: underline; }
.load-more-button[hidden], [data-run-item][hidden] { display: none; }

.editor-section { background: var(--surface); border: 1px solid var(--line); border-bottom: 0; }
.editor-section:first-of-type { border-radius: 7px 7px 0 0; }
.editor-section:last-of-type { border-bottom: 1px solid var(--line); border-radius: 0 0 7px 7px; }
.editor-section summary { display: flex; min-height: 62px; align-items: center; justify-content: space-between; gap: 20px; padding: 12px 16px; cursor: pointer; list-style: none; }
.editor-section summary::-webkit-details-marker { display: none; }
.editor-section summary:hover { background: #fafbf9; }
.editor-section summary span:first-child strong, .editor-section summary span:first-child small { display: block; }
.editor-section summary small { margin-top: 3px; color: var(--muted); font-size: 12px; font-weight: 400; }
.editor-section summary > span:last-child { color: var(--blue); font-size: 13px; font-weight: 650; }
.editor-section[open] summary { border-bottom: 1px solid var(--line); }
.editor-section form, .editor-section > .definition-list, .empty-inline { margin: 0; padding: 16px; }
.file-location { overflow: hidden; margin: 0 0 10px; color: var(--muted); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.document-editor { min-height: 360px; margin-bottom: 10px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }
.definition-list { display: grid; gap: 0; }
.definition-list div { display: grid; grid-template-columns: 110px minmax(0, 1fr); gap: 18px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.definition-list div:last-child { border-bottom: 0; }
.definition-list dt { color: var(--muted); }
.definition-list dd { margin: 0; }

.run-header { margin-bottom: 20px; }
.run-context { margin-bottom: 24px; padding: 16px 0 17px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.run-context h2 { margin: 5px 0 5px; font-size: 18px; }
.run-context h2 a { color: var(--blue); text-decoration: none; }
.run-context p:last-child { max-width: 720px; margin: 0; color: var(--muted); line-height: 1.5; }
.run-section { padding: 20px 0; border-bottom: 1px solid var(--line); }
.run-section > h2, .run-section-heading h2 { margin: 0 0 12px; font-size: 17px; }
.run-section blockquote { margin: 0; padding-left: 14px; line-height: 1.55; border-left: 3px solid var(--line-strong); }
.run-section > p:not(.subtle) { margin: 0; line-height: 1.55; }
.run-section-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.run-section-heading a { color: var(--blue); font-size: 13px; text-decoration: none; }
.channel-thread-list { overflow: hidden; background: var(--surface); border: 1px solid var(--line); border-radius: 7px; }
.channel-thread-list a { display: grid; min-height: 68px; grid-template-columns: 150px minmax(0, 1fr) auto; align-items: center; gap: 18px; padding: 11px 14px; text-decoration: none; border-bottom: 1px solid var(--line); }
.channel-thread-list a:last-child { border-bottom: 0; }
.channel-thread-list a:hover { background: #fafbf9; }
.channel-thread-list strong, .channel-thread-list small { display: block; }
.channel-thread-list small { overflow: hidden; color: var(--muted); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.channel-thread-preview { overflow: hidden; color: var(--muted); text-overflow: ellipsis; white-space: nowrap; }
.owner-chat { border-bottom: 0; }
.owner-chat-thread { min-height: 260px; }
.owner-chat .message-composer { position: static; padding-top: 12px; }

.conversation-row { display: grid; min-height: 72px; grid-template-columns: 38px minmax(0, 1fr) auto; align-items: center; gap: 13px; padding: 12px 15px; text-decoration: none; border-bottom: 1px solid var(--line); }
.avatar, .connection-icon { width: 36px; height: 36px; border-radius: 50%; background: var(--blue); }
.conversation-copy, .row-title, .row-preview, .connection-copy { display: block; min-width: 0; }
.row-title { overflow: hidden; margin-bottom: 4px; font-weight: 680; text-overflow: ellipsis; white-space: nowrap; }
.row-preview { overflow: hidden; color: var(--muted); text-overflow: ellipsis; white-space: nowrap; }
.row-meta { display: grid; min-width: 112px; justify-items: end; gap: 8px; color: var(--muted); font-size: 12px; }
.attention-dot { width: 8px; height: 8px; border-radius: 50%; background: #c47a12; }
.empty-state { padding: 64px 28px; color: var(--muted); text-align: center; }
.empty-state h2 { margin: 0 0 6px; color: var(--text); font-size: 18px; }
.empty-state p { margin: 0; }

.conversation-header { margin-bottom: 20px; }
.owner-question { margin-bottom: 20px; padding: 18px; background: var(--amber-soft); border: 1px solid #ead5a7; border-radius: 7px; }
.owner-question h2 { max-width: 760px; margin: 5px 0 16px; font-size: 18px; line-height: 1.4; }
.answer-row { display: flex; align-items: end; gap: 10px; }
.answer-row textarea { min-height: 44px; flex: 1; }
.option-list { display: grid; gap: 8px; }
.option-button { display: grid; width: 100%; gap: 2px; padding: 10px 12px; background: #fff; border: 1px solid #dec89a; border-radius: 5px; cursor: pointer; text-align: left; }
.option-button:hover { border-color: var(--amber); }
.option-button span { color: var(--muted); font-size: 13px; }
.option-answer { margin-top: 10px; }
.chat-thread { min-height: 420px; padding: 24px; background: var(--surface); border: 1px solid var(--line); border-radius: 7px; }
.message { display: flex; margin-bottom: 14px; }
.message.outbound { justify-content: flex-end; }
.message-bubble { max-width: min(640px, 78%); padding: 10px 12px 7px; background: #eff2ef; border-radius: 7px 7px 7px 2px; }
.message.outbound .message-bubble { background: var(--green-soft); border-radius: 7px 7px 2px 7px; }
.message-bubble p { margin: 0; line-height: 1.5; white-space: pre-wrap; }
.message-bubble time { display: block; margin-top: 5px; color: var(--muted); font-size: 11px; text-align: right; }
.delivery-status { display: inline-block; margin-top: 6px; font-size: 12px; font-weight: 700; }
.delivery-status.failed { color: #9a372f; }
.delivery-status.pending { color: var(--amber); }
.message-composer { position: sticky; bottom: 0; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 10px; padding: 14px 0 4px; background: var(--bg); }

.schedule-row { display: grid; min-height: 72px; grid-template-columns: minmax(220px, 1fr) minmax(200px, .8fr) 70px; align-items: center; gap: 20px; padding: 13px 16px; border-bottom: 1px solid var(--line); }
.schedule-row strong, .schedule-row small { display: block; }
.schedule-row small { margin-top: 4px; color: var(--muted); }
.schedule-state { color: var(--green); font-size: 13px; font-weight: 700; text-align: right; }
.connection-row { display: grid; min-height: 72px; grid-template-columns: 38px minmax(0, 1fr) 120px 140px; align-items: center; gap: 13px; padding: 12px 15px; border-bottom: 1px solid var(--line); }
.owner-route-setup { display: flex; align-items: center; justify-content: space-between; gap: 24px; margin-bottom: 18px; padding: 17px 18px; background: var(--blue-soft); border: 1px solid #cbd9ec; border-radius: 7px; }
.owner-route-setup h2 { margin: 0 0 4px; font-size: 17px; }
.owner-route-setup p { margin: 0; color: var(--muted); }
.connection-copy strong, .connection-copy span { display: block; }
.connection-copy span, .connection-count { margin-top: 3px; color: var(--muted); font-size: 13px; }
.connection-state { color: var(--green); font-size: 13px; font-weight: 650; }
.connection-state i { display: inline-block; width: 7px; height: 7px; margin-right: 6px; border-radius: 50%; background: var(--green); }
.connection-count { text-align: right; }

label { display: grid; gap: 6px; color: #545f57; font-size: 12px; font-weight: 680; }
input, textarea { width: 100%; padding: 9px 10px; color: var(--text); background: #fff; border: 1px solid var(--line-strong); border-radius: 5px; outline: none; }
input:focus, textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-soft); }
textarea { line-height: 1.45; resize: vertical; }
.primary-button { min-height: 38px; padding: 8px 14px; color: #fff; background: var(--green); border: 0; border-radius: 6px; cursor: pointer; font-weight: 680; }
.primary-button:hover { background: #185c40; }

.login-page { display: grid; min-height: 100vh; place-items: center; padding: 24px; }
.login-shell { width: min(360px, 100%); }
.login-shell .brand-mark { margin-bottom: 22px; }
.login-shell h1 { margin: 0 0 8px; font-size: 26px; }
.login-shell > p { margin: 0 0 24px; color: var(--muted); }
.google-login { display: flex; min-height: 44px; width: 100%; align-items: center; justify-content: center; gap: 10px; padding: 8px 14px; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 6px; font-weight: 680; text-decoration: none; }
.google-login:hover { background: #fafbf9; border-color: #9ca69f; }
.google-login span { color: var(--blue); font-weight: 750; }
.form-error { padding: 10px 12px; color: #8f3028 !important; background: #faeae8; border-radius: 5px; }

@media (max-width: 800px) {
  .app-shell { display: block; }
  .sidebar { position: static; width: auto; height: auto; padding: 13px 16px 0; border-right: 0; border-bottom: 1px solid var(--line); }
  .brand { margin: 0 0 12px; }
  .sidebar nav { display: flex; overflow-x: auto; gap: 16px; }
  .sidebar nav a { padding: 8px 1px 11px; border-bottom: 2px solid transparent; border-radius: 0; background: transparent !important; box-shadow: none !important; white-space: nowrap; }
  .sidebar nav a[aria-current="page"] { border-bottom-color: var(--green); }
  .account-menu { position: static; display: flex; align-items: center; justify-content: space-between; padding: 10px 0; }
  .account-menu span { margin: 0; }
  .main { padding: 24px 16px 56px; }
  .task-row { grid-template-columns: minmax(0, 1fr) auto; }
  .task-meta { display: none; }
  .task-start form { grid-template-columns: 1fr; }
  .connection-row { grid-template-columns: 38px minmax(0, 1fr) auto; }
  .connection-count { display: none; }
  .schedule-row { grid-template-columns: minmax(0, 1fr) auto; }
  .schedule-row > span:nth-child(2) { grid-column: 1; color: var(--muted); font-size: 13px; }
  .schedule-state { grid-column: 2; grid-row: 1; }
  .channel-thread-list a { grid-template-columns: 120px minmax(0, 1fr); }
  .channel-thread-list a > small:last-child { display: none; }
}

@media (max-width: 520px) {
  .brand-mark { display: none; }
  .page-header h1 { font-size: 24px; }
  .tabs { overflow-x: auto; gap: 16px; }
  .conversation-row { grid-template-columns: 34px minmax(0, 1fr); }
  .avatar { width: 34px; height: 34px; }
  .row-meta { display: none; }
  .message-bubble { max-width: 90%; }
  .answer-row, .message-composer { grid-template-columns: 1fr; flex-direction: column; align-items: stretch; }
  .message-composer { display: grid; }
}
