@import "@fontsource/hubot-sans/latin.css";

/* ────────────────────────────────────────────────────────────────────────────
   Design tokens
   Light = warm cream, charcoal text, brass accent
   Dark  = near-black, cream text, brass accent
   ──────────────────────────────────────────────────────────────────────────── */

:root {
  --bg: #f5f1e8;
  --surface: #ffffff;
  --surface-soft: #faf6ec;
  --surface-muted: #ede7d6;
  --border: #e3dcc8;
  --border-soft: #ece6d4;
  --border-strong: #cfc6ad;

  --text: #1c1a16;
  --text-muted: #6b6457;
  --text-subtle: #9b9483;

  --accent: #b8956f;
  --accent-strong: #9d7a55;
  --accent-soft: rgba(184, 149, 111, 0.12);
  --accent-line: rgba(184, 149, 111, 0.3);

  --diff-old-bg: #fcefef;
  --diff-old-border: #e9c2c2;
  --diff-old-text: #8c2f2f;
  --diff-new-bg: #ecf5ec;
  --diff-new-border: #b9d8b9;
  --diff-new-text: #28632a;
  --warn: #b07c2a;
  --warn-bg: #fbf3df;

  --status-good: #2ea96d;
  --status-bad: #b85a3e;

  --radius: 12px;
  --radius-sm: 8px;
  --radius-pill: 999px;
  --shadow-card: 0 1px 2px rgba(28, 26, 22, 0.04);
  --shadow-elev: 0 4px 12px rgba(28, 26, 22, 0.08);

  --on-accent-fg: rgba(255, 255, 255, 0.95);

  --font-serif: "Cormorant Garamond", "EB Garamond", Georgia, "Times New Roman", serif;
  --font-sans: "Hubot Sans", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

/* Dark theme tokens — applied either when the user explicitly selects dark
   (data-theme="dark") OR when the system is dark and no explicit override
   is set. data-theme="light" wins over the media query. */

:root[data-theme="dark"],
:root:not([data-theme]) {
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0a0908;
    --surface: #14120e;
    --surface-soft: #1a1813;
    --surface-muted: #211e17;
    --border: #2b2720;
    --border-soft: #221f19;
    --border-strong: #3a3528;

    --text: #e8e0d0;
    --text-muted: #9d957f;
    --text-subtle: #6e6757;

    --accent: #c9a87b;
    --accent-strong: #d8b98c;
    --accent-soft: rgba(201, 168, 123, 0.14);
    --accent-line: rgba(201, 168, 123, 0.3);

    --diff-old-bg: rgba(220, 80, 80, 0.12);
    --diff-old-border: rgba(220, 80, 80, 0.4);
    --diff-old-text: #f0b3b3;
    --diff-new-bg: rgba(95, 200, 140, 0.1);
    --diff-new-border: rgba(95, 200, 140, 0.4);
    --diff-new-text: #b9f0d2;
    --warn: #d8a547;
    --warn-bg: rgba(216, 165, 71, 0.1);

    --status-good: #5fc88c;
    --status-bad: #e89f4c;

    --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-elev: 0 4px 12px rgba(0, 0, 0, 0.5);

    --on-accent-fg: #141008;
  }
}

:root[data-theme="dark"] {
  --bg: #0a0908;
  --surface: #14120e;
  --surface-soft: #1a1813;
  --surface-muted: #211e17;
  --border: #2b2720;
  --border-soft: #221f19;
  --border-strong: #3a3528;

  --text: #e8e0d0;
  --text-muted: #9d957f;
  --text-subtle: #6e6757;

  --accent: #c9a87b;
  --accent-strong: #d8b98c;
  --accent-soft: rgba(201, 168, 123, 0.14);
  --accent-line: rgba(201, 168, 123, 0.3);

  --diff-old-bg: rgba(220, 80, 80, 0.12);
  --diff-old-border: rgba(220, 80, 80, 0.4);
  --diff-old-text: #f0b3b3;
  --diff-new-bg: rgba(95, 200, 140, 0.1);
  --diff-new-border: rgba(95, 200, 140, 0.4);
  --diff-new-text: #b9f0d2;
  --warn: #d8a547;
  --warn-bg: rgba(216, 165, 71, 0.1);

  --status-good: #5fc88c;
  --status-bad: #e89f4c;

  --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-elev: 0 4px 12px rgba(0, 0, 0, 0.5);

  --on-accent-fg: #141008;
}

/* ────────────────────────────────────────────────────────────────────────────
   Base
   ──────────────────────────────────────────────────────────────────────────── */

html,
body,
#root {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

* {
  box-sizing: border-box;
}

input,
textarea,
button {
  font-family: inherit;
  font-size: 13px;
  color: var(--text);
}

input,
textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

input:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

textarea {
  resize: none;
  min-height: 48px;
  line-height: 1.5;
}

/* ────────────────────────────────────────────────────────────────────────────
   Buttons
   ──────────────────────────────────────────────────────────────────────────── */

.primary-btn,
.ghost-btn,
.icon-btn,
.link-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: var(--radius-sm);
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  border: 1px solid transparent;
  transition: background 0.15s, border-color 0.15s, color 0.15s, transform 0.1s;
}

.primary-btn {
  background: var(--accent);
  color: var(--on-accent-fg);
  padding: 8px 14px;
  font-size: 12px;
}
.primary-btn:hover:not(:disabled) {
  background: var(--accent-strong);
  color: var(--on-accent-fg);
}
.primary-btn:disabled {
  background: var(--surface-muted);
  color: var(--text-muted);
  border-color: var(--border-strong);
  cursor: not-allowed;
}

.ghost-btn {
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--text);
  padding: 8px 14px;
  font-size: 12px;
}
.ghost-btn:hover:not(:disabled) {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.icon-btn {
  width: 32px;
  height: 32px;
  padding: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
}
.icon-btn:hover {
  color: var(--text);
  border-color: var(--accent-line);
}

.link-btn {
  background: transparent;
  border: none;
  color: var(--accent);
  padding: 0;
  font-size: 11px;
  letter-spacing: 0.04em;
}
.link-btn:hover {
  color: var(--accent-strong);
  text-decoration: underline;
}

/* ────────────────────────────────────────────────────────────────────────────
   App shell
   ──────────────────────────────────────────────────────────────────────────── */

.app {
  display: flex;
  flex-direction: column;
  margin: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  height: calc(100% - 16px);
  background: var(--surface);
  overflow: hidden;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--surface);
}

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

.brand-logo {
  width: 28px;
  height: 28px;
  object-fit: contain;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}

.brand-title {
  font-family: var(--font-serif);
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
}

.brand-subtitle {
  font-size: 9.5px;
  font-weight: 500;
  color: var(--text-subtle);
  letter-spacing: 0.18em;
  margin-top: 2px;
  text-transform: uppercase;
}

.header-actions {
  display: flex;
  gap: 6px;
}

.tab-bar {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0;
  padding: 4px;
  margin: 0 16px 14px;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
}

.tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 8px;
  border: none;
  background: transparent;
  border-radius: var(--radius-pill);
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.tab:hover {
  color: var(--text);
}
.tab svg {
  flex-shrink: 0;
}
.tab-active {
  background: var(--surface);
  color: var(--accent);
  font-weight: 600;
  box-shadow: var(--shadow-card);
}
/* Tab-active background uses surface-muted in dark theme */
:root[data-theme="dark"] .tab-active {
  background: var(--surface-muted);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .tab-active {
    background: var(--surface-muted);
  }
}

.content {
  flex: 1;
  overflow-y: auto;
  padding: 8px 18px 14px;
}

/* ────────────────────────────────────────────────────────────────────────────
   Empty state
   ──────────────────────────────────────────────────────────────────────────── */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 28px 4px 12px;
}

.empty-logo-frame {
  width: 76px;
  height: 76px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 22px;
}

.empty-logo-frame img {
  width: 40px;
  height: 40px;
  object-fit: contain;
}

.empty-headline {
  font-family: var(--font-serif);
  font-size: 26px;
  font-weight: 600;
  margin: 0 0 8px;
  letter-spacing: -0.005em;
  color: var(--text);
}

.empty-subline {
  margin: 0 8px 22px;
  font-size: 13px;
  color: var(--text-muted);
  max-width: 320px;
  line-height: 1.5;
}

.starter-section {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.starter-label {
  font-size: 10px;
  letter-spacing: 0.16em;
  color: var(--text-subtle);
  text-align: left;
  padding-left: 4px;
}

.starter-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.starter-card {
  text-align: left;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 13px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.starter-card:hover {
  background: var(--accent-soft);
  border-color: var(--accent-line);
}

.starter-card-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
}

.starter-card-subtitle {
  font-size: 11.5px;
  color: var(--text-muted);
  line-height: 1.3;
}

.empty-footer {
  margin-top: 22px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-subtle);
}

.empty-footer svg {
  color: var(--accent);
}

/* ────────────────────────────────────────────────────────────────────────────
   Chat thread
   ──────────────────────────────────────────────────────────────────────────── */

.thread {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 4px 0;
}

.msg {
  display: flex;
}
.msg-user {
  justify-content: flex-end;
}
.msg-assistant {
  justify-content: flex-start;
}

.msg-bubble {
  max-width: 92%;
  padding: 10px 12px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.5;
}

.msg-user .msg-bubble {
  background: var(--accent);
  color: #141008;
  border-bottom-right-radius: 4px;
}
.msg-user .msg-bubble p {
  margin: 0;
}

.msg-assistant .msg-bubble {
  background: var(--surface-soft);
  border: 1px solid var(--border);
  color: var(--text);
  border-bottom-left-radius: 4px;
}

.typing-dots {
  display: flex;
  gap: 4px;
  align-items: center;
  padding: 4px 0;
}
.typing-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: typing 1.4s infinite;
}
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typing {
  0%, 60%, 100% { opacity: 0.3; }
  30% { opacity: 1; }
}

.draft-actions-inline {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

/* Markdown */
.markdown-body { font-size: 13px; line-height: 1.55; }
.markdown-body p { margin: 0 0 8px; }
.markdown-body p:last-child { margin-bottom: 0; }
.markdown-body strong { font-weight: 600; color: var(--text); }
.markdown-body em { font-style: italic; }
.markdown-body ul, .markdown-body ol { margin: 6px 0 8px; padding-left: 20px; }
.markdown-body li { margin: 2px 0; }
.markdown-body h1, .markdown-body h2, .markdown-body h3 {
  margin: 12px 0 6px; font-weight: 600; font-family: var(--font-serif);
  color: var(--text);
}
.markdown-body h1 { font-size: 17px; }
.markdown-body h2 { font-size: 15px; }
.markdown-body h3 { font-size: 13.5px; }
.markdown-body code {
  background: var(--surface-muted);
  padding: 1px 5px; border-radius: 4px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px;
}
.markdown-body pre {
  background: var(--surface-muted);
  border: 1px solid var(--border);
  padding: 10px; border-radius: 6px; overflow-x: auto; font-size: 12px;
}
.markdown-body pre code { background: transparent; padding: 0; }
.markdown-body blockquote {
  border-left: 3px solid var(--accent-line);
  margin: 6px 0; padding: 2px 10px; color: var(--text-muted);
}
.markdown-body table { border-collapse: collapse; margin: 6px 0; font-size: 12px; }
.markdown-body th, .markdown-body td { border: 1px solid var(--border); padding: 4px 8px; }
.markdown-body a { color: var(--accent); text-decoration: underline; }

/* ────────────────────────────────────────────────────────────────────────────
   Citations
   ──────────────────────────────────────────────────────────────────────────── */

.citation-list {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.citation-list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 10px;
  letter-spacing: 0.12em;
  color: var(--text-subtle);
  text-transform: uppercase;
  margin-bottom: 2px;
}

.citation-chip {
  display: grid;
  grid-template-columns: auto auto auto 1fr;
  gap: 6px;
  align-items: center;
  text-align: left;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 8px;
  background: var(--surface);
  cursor: pointer;
  font-size: 12px;
  color: var(--text);
  width: 100%;
}
.citation-chip:hover {
  background: var(--accent-soft);
  border-color: var(--accent-line);
}
.citation-num { font-weight: 600; color: var(--accent); }
.citation-doc {
  font-weight: 500; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; max-width: 120px;
}
.citation-page { color: var(--text-muted); font-size: 11px; }
.citation-excerpt {
  color: var(--text-muted); font-style: italic;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ────────────────────────────────────────────────────────────────────────────
   Redline panel
   ──────────────────────────────────────────────────────────────────────────── */

.redline-loading {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 12px;
}
.redline-loading p { margin: 0; }

.redline-panel {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 12px;
}

.redline-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  text-transform: uppercase;
  padding: 4px 6px 8px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}

.redline-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  transition: border-color 0.15s, background 0.15s;
}
.redline-item.status-accepted {
  border-color: var(--status-good);
  background: rgba(46, 169, 109, 0.06);
}
.redline-item.status-ignored { opacity: 0.5; }
.redline-item.status-missing {
  border-color: var(--warn);
  background: var(--warn-bg);
}

.redline-summary {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  background: transparent;
  border: none;
  cursor: pointer;
  text-align: left;
  font-size: 13px;
  color: var(--text);
}
.redline-summary:hover {
  background: var(--accent-soft);
}

.redline-caret {
  font-size: 11px;
  color: var(--text-muted);
  width: 12px;
  flex-shrink: 0;
}

.redline-title {
  flex: 1;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.redline-status-tag {
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-subtle);
  flex-shrink: 0;
}
.status-accepted .redline-status-tag { color: var(--status-good); }
.status-ignored .redline-status-tag { color: var(--text-subtle); }
.status-missing .redline-status-tag { color: var(--warn); }

.redline-detail {
  padding: 12px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.redline-diff {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  line-height: 1.5;
}

.diff-old {
  background: var(--diff-old-bg);
  border: 1px solid var(--diff-old-border);
  color: var(--diff-old-text);
  text-decoration: line-through;
  padding: 6px 8px;
  border-radius: 6px;
  white-space: pre-wrap;
  word-break: break-word;
}

.diff-new {
  background: var(--diff-new-bg);
  border: 1px solid var(--diff-new-border);
  color: var(--diff-new-text);
  padding: 6px 8px;
  border-radius: 6px;
  white-space: pre-wrap;
  word-break: break-word;
}

.redline-reason {
  margin: 0;
  font-size: 12px;
  font-style: italic;
  color: var(--text-muted);
}

.redline-warning {
  margin: 0;
  font-size: 12px;
  color: var(--warn);
  background: var(--warn-bg);
  border: 1px solid var(--warn);
  border-radius: 6px;
  padding: 6px 8px;
}

.redline-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}

/* ────────────────────────────────────────────────────────────────────────────
   Composer + status
   ──────────────────────────────────────────────────────────────────────────── */

.composer-area {
  flex-shrink: 0;
  padding: 0 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.composer {
  position: relative;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 50px 12px 14px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.composer:focus-within {
  border-color: var(--accent-line);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.composer textarea,
.composer textarea:focus {
  width: 100%;
  border: none;
  outline: none;
  background: transparent;
  padding: 0;
  font-size: 13px;
  color: var(--text);
  resize: none;
  min-height: 36px;
  max-height: 140px;
  box-shadow: none;
}
.composer textarea::placeholder {
  color: var(--text-subtle);
}

.send-btn {
  position: absolute;
  right: 8px;
  bottom: 8px;
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 8px;
  background: var(--surface-muted);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
}
.send-btn:hover:not(:disabled) {
  background: var(--accent);
  color: #ffffff;
}
.send-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.status-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-subtle);
  padding: 0 4px;
}

.kbd-hint {
  letter-spacing: 0.02em;
}

.doc-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.doc-status .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--status-bad);
}
.doc-status.linked .dot {
  background: var(--status-good);
}

/* ────────────────────────────────────────────────────────────────────────────
   Auth screen — full-pane layout matching the reference design
   ──────────────────────────────────────────────────────────────────────────── */

.auth-shell {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: var(--surface);
  margin: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  height: calc(100% - 16px);
  overflow: hidden;
}

.auth-shell-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}

.auth-version {
  font-size: 11px;
  color: var(--text-subtle);
  font-variant-numeric: tabular-nums;
}

.auth-body {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  padding: 28px 22px 12px;
  text-align: center;
}

.auth-logo-frame {
  width: 64px;
  height: 64px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  align-self: center;
  margin-bottom: 18px;
}
.auth-logo-frame img {
  width: 32px;
  height: 32px;
  object-fit: contain;
}

.auth-headline {
  font-family: var(--font-serif);
  font-size: 28px;
  font-weight: 600;
  margin: 0 0 6px;
  color: var(--text);
  letter-spacing: -0.005em;
}

.auth-subline {
  margin: 0 0 22px;
  font-size: 13px;
  color: var(--text-muted);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  text-align: left;
}

.auth-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.auth-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.auth-label {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.14em;
  color: var(--text-muted);
}

.auth-input {
  width: 100%;
  padding: 12px 14px;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 13px;
  color: var(--text);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.auth-input::placeholder {
  color: var(--text-subtle);
}
.auth-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.auth-input-wrap {
  position: relative;
}
.auth-input-wrap .auth-input {
  padding-right: 64px;
}

.auth-input-action {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.12em;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
}
.auth-input-action:hover {
  color: var(--accent);
}

.auth-inline-link {
  color: var(--accent);
  font-size: 12px;
  font-weight: 500;
  text-decoration: none;
}
.auth-inline-link:hover {
  text-decoration: underline;
}
.auth-inline-link.strong {
  font-weight: 600;
}

.auth-checkbox {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12.5px;
  color: var(--text);
  cursor: pointer;
  user-select: none;
}
.auth-checkbox input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}
.auth-checkbox-box {
  width: 18px;
  height: 18px;
  border-radius: 5px;
  border: 1px solid var(--border-strong);
  background: var(--surface-soft);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s, border-color 0.15s;
}
.auth-checkbox input:checked + .auth-checkbox-box {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}
.auth-checkbox input:focus-visible + .auth-checkbox-box {
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.auth-submit-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 14px 16px;
  border-radius: 12px;
  background: var(--accent);
  color: #ffffff;
  border: none;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
  margin-top: 4px;
}
.auth-submit-btn:hover:not(:disabled) {
  background: var(--accent-strong);
}
.auth-submit-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  background: var(--surface-muted);
  color: var(--text-muted);
}

.auth-request {
  margin: 6px 0 0;
  text-align: center;
  font-size: 12.5px;
  color: var(--text-muted);
}

.auth-shell-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-subtle);
  text-align: center;
}
.auth-shell-footer svg {
  color: var(--accent);
  flex-shrink: 0;
}

/* ────────────────────────────────────────────────────────────────────────────
   Errors
   ──────────────────────────────────────────────────────────────────────────── */

.error {
  color: var(--diff-old-text);
  background: var(--diff-old-bg);
  border: 1px solid var(--diff-old-border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-size: 12px;
  margin: 8px 0 0;
}

/* ────────────────────────────────────────────────────────────────────────────
   Draft form (Draft tab)
   ──────────────────────────────────────────────────────────────────────────── */

.form-pane {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 4px 0 8px;
}

.form-card {
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
}

.form-card-title {
  font-family: var(--font-serif);
  font-size: 15px;
  font-weight: 600;
  margin: 0 0 4px;
  color: var(--text);
}

.form-card-help {
  margin: 0 0 10px;
  font-size: 12px;
  color: var(--text-muted);
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.form-label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text-muted);
}

.form-label-block {
  margin-top: 10px;
}

.form-label-compact {
  flex: 1;
}

select {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  padding: 10px 30px 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  background-image: linear-gradient(45deg, transparent 50%, var(--accent) 50%),
                    linear-gradient(135deg, var(--accent) 50%, transparent 50%);
  background-position: calc(100% - 14px) 50%, calc(100% - 9px) 50%;
  background-size: 5px 5px;
  background-repeat: no-repeat;
  cursor: pointer;
}

select:focus {
  border-color: var(--accent);
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.form-prompts-toolbar {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  margin-bottom: 10px;
}

.form-prompts-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 10px;
}

.form-prompt-chip {
  display: flex;
  align-items: stretch;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.form-prompt-chip.active {
  border-color: var(--accent);
}

.form-prompt-main {
  flex: 1;
  text-align: left;
  background: transparent;
  border: none;
  padding: 8px 10px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 2px;
  color: var(--text);
}
.form-prompt-main:hover {
  background: var(--accent-soft);
}

.form-prompt-title {
  font-weight: 500;
  font-size: 12.5px;
}

.form-prompt-description {
  font-size: 11px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.form-prompt-delete {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 0 12px;
  cursor: pointer;
  font-size: 16px;
}
.form-prompt-delete:hover {
  color: var(--diff-old-text);
}

.form-field-row {
  display: grid;
  grid-template-columns: 1fr 100px 1fr auto;
  gap: 6px;
  margin-bottom: 6px;
}

.form-fields-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.form-empty-line {
  font-size: 12px;
  color: var(--text-subtle);
  margin: 0;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 10px;
}

.draft-output {
  width: 100%;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  background: var(--surface);
  margin-bottom: 10px;
}

/* ────────────────────────────────────────────────────────────────────────────
   Redline tab — Start button + panel actions
   ──────────────────────────────────────────────────────────────────────────── */

.redline-start-btn {
  margin-top: 6px;
  margin-bottom: 18px;
}

.redline-panel-actions {
  display: flex;
  gap: 12px;
}
