/* ==========================================================================
   JAZZBOT NEWS — Design System
   Literary journal meets premium newsletter.
   Serif typography, earth-tone palette, warm parchment aesthetic.
   ========================================================================== */

/* --------------------------------------------------------------------------
   Design Tokens
   -------------------------------------------------------------------------- */
:root {
  /* Palette */
  --bg:             #FAF6F1;
  --bg-sidebar:     #F0EBE3;
  --text-primary:   #1A1210;
  --text-body:      #2C2421;
  --text-secondary: #6B5D52;
  --text-muted:     #9B8E82;
  --text-label:     #7A6E63;
  --accent:         #8B6914;
  --accent-hover:   #7A5C10;
  --card-bg:        #FFFFFF;
  --card-border:    #D9D0C7;
  --border:         #D1C7BC;
  --border-light:   #E5DED6;
  --surface:        #F5F0EA;

  /* Format colors */
  --fmt-mental-model: #8B6914;
  --fmt-script:       #5B7F5B;
  --fmt-pre-mortem:   #A0522D;
  --fmt-debate:       #B8860B;
  --fmt-tool-audit:   #6B5B73;
  --fmt-wild-card:    #5F7D8A;

  /* Feedback */
  --success-bg:    #E8F5E9;
  --success-fg:    #2E7D32;
  --success-border:#A5D6A7;
  --error-bg:      #FFEBEE;
  --error-fg:      #C62828;
  --error-border:  #EF9A9A;
  --warning-bg:    #FFF8E1;
  --warning-fg:    #F57F17;
  --warning-border:#FFE082;

  /* Typography */
  --font-serif: 'Source Serif 4', 'Lora', Georgia, 'Times New Roman', serif;
  --font-sans:  'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;

  /* Layout */
  --sidebar-w:    260px;
  --content-max:  860px;
  --radius:       6px;
  --radius-sm:    3px;
}

/* --------------------------------------------------------------------------
   Reset & Base
   -------------------------------------------------------------------------- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-sans);
  color: var(--text-body);
  background: var(--bg);
  line-height: 1.6;
  min-height: 100vh;
}

/* --------------------------------------------------------------------------
   Typography
   -------------------------------------------------------------------------- */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-serif);
  color: var(--text-primary);
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.3;
}

h1 { font-size: 1.75rem; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.1rem; }

a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.15s ease;
}
a:hover {
  color: var(--accent-hover);
}

p {
  margin-bottom: 0.75em;
}
p:last-child {
  margin-bottom: 0;
}

/* --------------------------------------------------------------------------
   Layout
   -------------------------------------------------------------------------- */
.layout {
  display: flex;
  min-height: 100vh;
}

.layout.no-sidebar .main-content {
  margin: 0 auto;
  width: 100%;
}

/* --------------------------------------------------------------------------
   Sidebar
   -------------------------------------------------------------------------- */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--card-border);
  padding: 0 20px 40px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 100;
}

.sidebar-logo {
  text-align: center;
  padding: 28px 0;
}

.sidebar-logo .ghost {
  font-size: 40px;
  margin-bottom: 6px;
  line-height: 1;
}

.sidebar-logo .title {
  font-family: var(--font-serif);
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: 3px;
}

.sidebar-logo .subtitle {
  font-family: var(--font-sans);
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 2.5px;
  text-transform: uppercase;
  margin-top: 4px;
}

.sidebar-rule {
  border: none;
  border-top: 1px solid var(--card-border);
  margin: 0 0 16px;
}

/* --------------------------------------------------------------------------
   Sidebar Navigation
   -------------------------------------------------------------------------- */
.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 16px;
}

.nav-link {
  display: block;
  padding: 10px 14px;
  border-radius: var(--radius);
  border-left: 3px solid transparent;
  text-decoration: none;
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 14px;
  transition: background-color 0.15s, color 0.15s, border-color 0.15s;
}

.nav-link:hover {
  background: rgba(139, 105, 20, 0.05);
  color: var(--accent);
}

.nav-link.active {
  background: var(--border-light);
  color: var(--text-primary);
  font-weight: 600;
  border-left-color: var(--accent);
}

/* --------------------------------------------------------------------------
   Sidebar — Saved Newsletters List
   -------------------------------------------------------------------------- */
.sidebar-newsletters {
  padding: 0 8px;
}

.sidebar-newsletters-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 0 6px;
  margin-bottom: 6px;
}

.sidebar-newsletter-item {
  display: block;
  padding: 6px 10px;
  font-size: 13px;
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-newsletter-item:hover {
  background: rgba(139, 105, 20, 0.05);
  color: var(--accent);
}

.sidebar-newsletter-item.active {
  color: var(--text-primary);
  font-weight: 600;
}

/* --------------------------------------------------------------------------
   Sidebar — Today's Format & Profile Cards
   -------------------------------------------------------------------------- */
.today-format {
  background: var(--bg);
  border-radius: 4px;
  padding: 14px 16px;
  margin-top: 0;
  border: 1px solid var(--border-light);
}

.today-format .tf-label {
  font-family: var(--font-sans);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.today-format .tf-day {
  font-family: var(--font-serif);
  font-size: 14px;
  font-weight: 600;
  color: var(--text-body);
}

.today-format .tf-desc {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 12px;
  color: var(--text-label);
  margin-top: 8px;
  line-height: 1.45;
}

.today-format .profile-summary {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 6px;
  line-height: 1.7;
}

.today-format .profile-summary strong {
  color: var(--text-body);
  font-weight: 600;
}

/* --------------------------------------------------------------------------
   Main Content
   -------------------------------------------------------------------------- */
.main-content {
  flex: 1;
  padding: 32px 48px;
  max-width: var(--content-max);
  min-width: 0;
}

/* --------------------------------------------------------------------------
   Page Headers
   -------------------------------------------------------------------------- */
.page-header {
  border-bottom: 2px solid var(--text-primary);
  padding-bottom: 8px;
  margin-bottom: 6px;
}

.page-header h2 {
  font-size: 28px;
  margin: 0;
}

.page-subtitle {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 15px;
  color: var(--text-label);
  margin-bottom: 28px;
  margin-top: 6px;
}

/* --------------------------------------------------------------------------
   Section / Column Headers
   -------------------------------------------------------------------------- */
.section-rule {
  border: none;
  border-top: 1px solid var(--border);
  margin: 28px 0;
}

.col-header {
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
  margin-bottom: 20px;
}

/* --------------------------------------------------------------------------
   Two-Column Layout
   -------------------------------------------------------------------------- */
.two-col {
  display: flex;
  gap: 48px;
}

.col-left,
.col-right {
  flex: 1;
  min-width: 0;
}

/* --------------------------------------------------------------------------
   Form Fields
   -------------------------------------------------------------------------- */
.field-label {
  display: block;
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--text-label);
  margin-bottom: 6px;
  margin-top: 16px;
}

.field-label:first-of-type {
  margin-top: 0;
}

.field-input {
  display: block;
  width: 100%;
  padding: 10px 14px;
  background-color: var(--card-bg);
  color: var(--text-body);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  transition: border-color 0.15s, box-shadow 0.15s;
  -webkit-appearance: none;
  appearance: none;
}

.field-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(139, 105, 20, 0.12);
}

.field-textarea {
  min-height: 100px;
  resize: vertical;
}

/* Select — ensure light background, not black */
select.field-input {
  background-color: var(--card-bg);
  color: var(--text-body);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%236B5D52' fill='none' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
  cursor: pointer;
}

select.field-input option {
  background: var(--card-bg);
  color: var(--text-body);
}

/* --------------------------------------------------------------------------
   Buttons
   -------------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  background-color: var(--bg);
  color: var(--text-secondary);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
  text-align: center;
  line-height: 1.4;
}

.btn:hover {
  background-color: var(--bg-sidebar);
  color: var(--text-primary);
  border-color: var(--accent);
  box-shadow: 0 2px 8px rgba(139, 105, 20, 0.1);
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0);
  background-color: var(--border-light);
}

/* Primary: warm outlined */
.btn-primary {
  background-color: var(--bg);
  color: var(--text-secondary);
  border-color: #B8A99A;
}

.btn-primary:hover {
  background-color: var(--bg-sidebar);
  color: var(--text-primary);
  border-color: var(--accent);
  box-shadow: 0 2px 8px rgba(139, 105, 20, 0.15);
}

/* Accent: filled gold for emphasis */
.btn-accent {
  background-color: var(--accent);
  color: #FFFFFF;
  border-color: var(--accent);
}

.btn-accent:hover {
  background-color: var(--accent-hover);
  color: #FFFFFF;
  border-color: var(--accent-hover);
  box-shadow: 0 2px 10px rgba(139, 105, 20, 0.25);
}

/* Approve: sage green */
.btn-approve {
  background-color: var(--fmt-script);
  color: #FFFFFF;
  border-color: var(--fmt-script);
}

.btn-approve:hover {
  background-color: #4A6E4A;
  color: #FFFFFF;
  border-color: #4A6E4A;
}

/* Reject / Danger: warm red */
.btn-reject {
  background-color: var(--bg);
  color: var(--fmt-pre-mortem);
  border-color: var(--fmt-pre-mortem);
}

.btn-reject:hover {
  background-color: var(--fmt-pre-mortem);
  color: #FFFFFF;
}

/* Outline: subtle variant */
.btn-outline {
  background-color: transparent;
  color: var(--text-muted);
  border-color: var(--border);
}

.btn-outline:hover {
  color: var(--accent);
  border-color: var(--accent);
  background-color: transparent;
}

/* Small */
.btn-sm {
  font-size: 12px;
  padding: 6px 14px;
}

.button-row {
  display: flex;
  gap: 12px;
  margin-top: 24px;
}

/* --------------------------------------------------------------------------
   Format Badge
   -------------------------------------------------------------------------- */
.format-badge {
  display: inline-block;
  font-family: var(--font-sans);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  padding: 4px 12px;
  border-radius: var(--radius-sm);
  color: #FFFFFF;
  line-height: 1.4;
  vertical-align: middle;
}

/* Individual format colors — applied via inline style from backend
   or via these utility classes */
.format-badge-mental-model { background-color: var(--fmt-mental-model); }
.format-badge-script       { background-color: var(--fmt-script); }
.format-badge-pre-mortem   { background-color: var(--fmt-pre-mortem); }
.format-badge-debate       { background-color: var(--fmt-debate); }
.format-badge-tool-audit   { background-color: var(--fmt-tool-audit); }
.format-badge-wild-card    { background-color: var(--fmt-wild-card); }

/* --------------------------------------------------------------------------
   Preview Cards (Topic Tuner — five-day preview)
   -------------------------------------------------------------------------- */
.preview-card {
  background: var(--card-bg);
  border-radius: 2px;
  padding: 22px 26px;
  margin-bottom: 14px;
  border-left: 3px solid var(--border);
  border-bottom: 1px solid var(--border-light);
  transition: all 0.15s ease;
}

.preview-card:hover {
  background: #FBF8F4;
  border-left-width: 4px;
  box-shadow: 0 2px 8px rgba(26, 18, 16, 0.04);
}

/* Color the left border by format via data attribute */
.preview-card[data-format="MENTAL_MODEL"] { border-left-color: var(--fmt-mental-model); }
.preview-card[data-format="SCRIPT"]       { border-left-color: var(--fmt-script); }
.preview-card[data-format="PRE_MORTEM"]   { border-left-color: var(--fmt-pre-mortem); }
.preview-card[data-format="DEBATE"]       { border-left-color: var(--fmt-debate); }
.preview-card[data-format="TOOL_AUDIT"]   { border-left-color: var(--fmt-tool-audit); }
.preview-card[data-format="WILD_CARD"]    { border-left-color: var(--fmt-wild-card); }

.preview-card .card-rank-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.preview-card .card-rank {
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.5px;
}

.preview-card .card-headline {
  font-family: var(--font-serif);
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.35;
  margin-bottom: 8px;
}

.preview-card .card-gist {
  font-family: var(--font-sans);
  font-size: 13px;
  color: var(--text-label);
  line-height: 1.55;
}

/* --------------------------------------------------------------------------
   Draft Cards (Draft Editor)
   -------------------------------------------------------------------------- */
.draft-card {
  background: var(--card-bg);
  border-radius: 2px;
  padding: 20px 24px;
  margin-bottom: 12px;
  border: 1px solid var(--border-light);
  border-left: 4px solid var(--border);
  transition: border-color 0.15s;
}

.draft-card:hover {
  border-color: var(--accent);
  border-left-color: var(--accent);
}

/* Color left border by format */
.draft-card[data-format="MENTAL_MODEL"] { border-left-color: var(--fmt-mental-model); }
.draft-card[data-format="SCRIPT"]       { border-left-color: var(--fmt-script); }
.draft-card[data-format="PRE_MORTEM"]   { border-left-color: var(--fmt-pre-mortem); }
.draft-card[data-format="DEBATE"]       { border-left-color: var(--fmt-debate); }
.draft-card[data-format="TOOL_AUDIT"]   { border-left-color: var(--fmt-tool-audit); }
.draft-card[data-format="WILD_CARD"]    { border-left-color: var(--fmt-wild-card); }

.draft-card-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.draft-subject {
  font-family: var(--font-serif);
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 12px;
}

.draft-date {
  font-size: 12px;
  color: var(--text-muted);
}

.draft-source {
  font-size: 12px;
  color: var(--accent);
}

.draft-source:hover {
  text-decoration: underline;
}

.draft-details {
  margin-bottom: 16px;
}

.draft-details summary {
  cursor: pointer;
  font-size: 13px;
  color: var(--text-label);
  font-weight: 500;
  margin-bottom: 8px;
  user-select: none;
}

.draft-details summary:hover {
  color: var(--accent);
}

.draft-body {
  background-color: var(--surface);
  border-radius: 4px;
  padding: 16px 20px;
  font-size: 14px;
  line-height: 1.7;
  color: var(--text-body);
  white-space: pre-wrap;
  max-height: 400px;
  overflow-y: auto;
  border: 1px solid var(--border-light);
}

.draft-edit-area {
  margin-bottom: 16px;
}

.draft-edit-area .field-input {
  font-size: 16px;
  font-family: var(--font-serif);
  font-weight: 600;
  margin-bottom: 12px;
}

.draft-edit-area .field-textarea {
  min-height: 360px;
  font-size: 14px;
  line-height: 1.7;
  font-family: var(--font-sans);
}

.draft-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  padding-top: 14px;
  border-top: 1px solid var(--border-light);
}

/* --------------------------------------------------------------------------
   Meta Box (sidebar info in draft cards)
   -------------------------------------------------------------------------- */
.meta-box {
  background-color: var(--surface);
  border-radius: 4px;
  padding: 16px 20px;
  margin-bottom: 12px;
  border: 1px solid var(--border-light);
}

.meta-box .meta-label {
  font-family: var(--font-sans);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.meta-box .meta-value {
  font-size: 14px;
  color: var(--text-secondary);
}

.meta-box .meta-value a {
  word-break: break-all;
}

/* --------------------------------------------------------------------------
   Email Preview
   -------------------------------------------------------------------------- */
.preview-select-row {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.preview-select-row .field-label {
  margin: 0;
  white-space: nowrap;
}

.preview-date-label {
  font-family: var(--font-sans);
  color: var(--text-muted);
  font-size: 13px;
}

.email-frame {
  display: flex;
  justify-content: center;
}

.email-preview-frame {
  width: 100%;
  max-width: 660px;
  background: var(--card-bg);
  border: 1px solid var(--border-light);
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(26, 18, 16, 0.06);
  overflow: hidden;
}

.email-preview-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 18px;
  background: var(--bg-sidebar);
  border-bottom: 1px solid var(--border-light);
  font-size: 12px;
  color: var(--text-muted);
}

.email-iframe {
  display: block;
  width: 100%;
  min-height: 700px;
  border: none;
  background: var(--card-bg);
}

/* --------------------------------------------------------------------------
   History Section
   -------------------------------------------------------------------------- */
.history-section {
  border: 1px solid var(--border-light);
  border-radius: 4px;
  padding: 4px;
  margin-top: 28px;
}

.history-section summary {
  padding: 12px 16px;
  cursor: pointer;
  font-family: var(--font-serif);
  font-size: 15px;
  font-weight: 600;
  color: var(--text-secondary);
  user-select: none;
  list-style: none;
}

.history-section summary::-webkit-details-marker {
  display: none;
}

.history-section summary::before {
  content: "\25B6";
  display: inline-block;
  font-size: 9px;
  margin-right: 10px;
  transition: transform 0.2s ease;
  color: var(--text-muted);
}

.history-section[open] summary::before {
  transform: rotate(90deg);
}

.history-section summary:hover {
  color: var(--accent);
}

.history-list {
  padding: 0 12px 12px;
}

.history-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background-color: var(--surface);
  border-radius: 4px;
  margin-bottom: 6px;
  font-size: 13px;
  border-bottom: 1px solid var(--border-light);
}

.history-row:last-child {
  margin-bottom: 0;
}

.history-row .hr-date {
  flex-shrink: 0;
  font-size: 12px;
  color: var(--text-muted);
  min-width: 80px;
}

.history-row .hr-title {
  color: var(--text-secondary);
  font-family: var(--font-serif);
  flex-grow: 1;
}

.history-row .hr-format {
  flex-shrink: 0;
}

/* --------------------------------------------------------------------------
   Empty States
   -------------------------------------------------------------------------- */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.empty-state .empty-icon {
  font-size: 36px;
  margin-bottom: 16px;
  opacity: 0.5;
}

.empty-state .empty-text {
  font-family: var(--font-serif);
  font-size: 17px;
  font-style: italic;
  color: var(--text-label);
  line-height: 1.45;
}

.empty-state .empty-sub {
  font-family: var(--font-sans);
  font-size: 13px;
  margin-top: 8px;
  color: var(--text-muted);
}

/* --------------------------------------------------------------------------
   Flash Messages
   -------------------------------------------------------------------------- */
.flash {
  padding: 12px 20px;
  border-radius: var(--radius);
  margin-bottom: 20px;
  font-size: 14px;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: space-between;
  animation: flash-in 0.3s ease, flash-out 0.5s ease 4.5s forwards;
}

.flash-success {
  background-color: var(--success-bg);
  color: var(--success-fg);
  border: 1px solid var(--success-border);
}

.flash-error {
  background-color: var(--error-bg);
  color: var(--error-fg);
  border: 1px solid var(--error-border);
}

.flash-warning {
  background-color: var(--warning-bg);
  color: var(--warning-fg);
  border: 1px solid var(--warning-border);
}

.flash-close {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: inherit;
  opacity: 0.7;
  padding: 0 0 0 16px;
  line-height: 1;
}

.flash-close:hover {
  opacity: 1;
}

@keyframes flash-in {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes flash-out {
  from { opacity: 1; max-height: 60px; margin-bottom: 20px; padding: 12px 20px; }
  to   { opacity: 0; max-height: 0; margin-bottom: 0; padding: 0 20px; overflow: hidden; }
}

/* --------------------------------------------------------------------------
   HTMX Loading Indicator
   -------------------------------------------------------------------------- */
.htmx-indicator {
  display: none;
  align-items: center;
  gap: 10px;
  padding: 12px 20px;
  margin-bottom: 20px;
  background-color: var(--warning-bg);
  border: 1px solid var(--warning-border);
  border-radius: var(--radius);
  color: var(--accent);
  font-size: 14px;
  font-weight: 500;
}

.htmx-indicator.htmx-request {
  display: flex;
}

.spinner {
  width: 18px;
  height: 18px;
  border: 2.5px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.65s linear infinite;
  flex-shrink: 0;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Inline spinner for buttons */
.btn .spinner {
  width: 14px;
  height: 14px;
  border-width: 2px;
}

/* --------------------------------------------------------------------------
   Responsive: Sidebar collapses to top bar
   -------------------------------------------------------------------------- */
@media (max-width: 900px) {
  .layout {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    min-width: auto;
    height: auto;
    position: static;
    border-right: none;
    border-bottom: 1px solid var(--card-border);
    padding: 16px 20px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
  }

  .sidebar-logo {
    padding: 0;
    text-align: left;
    display: flex;
    align-items: center;
    gap: 10px;
    margin-right: auto;
  }

  .sidebar-logo .ghost {
    font-size: 28px;
    margin-bottom: 0;
  }

  .sidebar-logo .subtitle {
    display: none;
  }

  .sidebar-rule {
    display: none;
  }

  .sidebar-nav {
    flex-direction: row;
    gap: 4px;
    margin-bottom: 0;
  }

  .nav-link {
    border-left: none;
    border-bottom: 2px solid transparent;
    border-radius: 0;
    padding: 6px 12px;
    font-size: 13px;
  }

  .nav-link.active {
    border-left-color: transparent;
    border-bottom-color: var(--accent);
    background: transparent;
  }

  .today-format {
    display: none;
  }

  .user-info {
    display: none;
  }

  .main-content {
    padding: 24px 20px;
    max-width: 100%;
  }

  .two-col {
    flex-direction: column;
    gap: 32px;
  }

  .email-preview-frame {
    max-width: 100%;
  }

  .preview-select-row {
    flex-direction: column;
    align-items: flex-start;
  }
}

@media (max-width: 480px) {
  .page-header h2 {
    font-size: 22px;
  }

  .draft-card {
    padding: 16px 18px;
  }

  .preview-card {
    padding: 16px 18px;
  }

  .button-row {
    flex-direction: column;
  }

  .btn {
    width: 100%;
  }
}

/* =========================================================
   SURVEY - Personalization Questions
   ========================================================= */

.survey-question {
  margin-bottom: 24px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
}
.survey-question:last-of-type {
  border-bottom: none;
  margin-bottom: 16px;
}

.survey-q-text {
  font-family: var(--font-serif);
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 12px;
}

.survey-choices {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.survey-pill {
  cursor: pointer;
  display: inline-block;
}

.survey-radio {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.survey-pill-label {
  display: inline-block;
  padding: 8px 16px;
  background-color: #FFFFFF;
  color: var(--text-secondary);
  border: 1.5px solid var(--border);
  border-radius: 20px;
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 500;
  transition: all 0.15s ease;
  cursor: pointer;
  user-select: none;
}

.survey-pill-label:hover {
  border-color: var(--accent);
  color: var(--text-primary);
  background-color: var(--bg-sidebar);
}

.survey-radio:checked + .survey-pill-label {
  background-color: var(--accent);
  color: #FFFFFF;
  border-color: var(--accent);
  box-shadow: 0 2px 8px rgba(139, 105, 20, 0.2);
}

.survey-done-hint {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 14px;
  color: var(--text-muted);
  margin-top: 16px;
  padding: 12px 16px;
  background-color: var(--bg-sidebar);
  border-radius: 6px;
  text-align: center;
}

/* Other free text */
.survey-pill-other {
  border-style: dashed;
}
.survey-other-wrap {
  margin-top: 10px;
}
.survey-other-input {
  max-width: 360px;
  font-size: 13px !important;
}

/* Research query on preview cards */
/* Thread label in preview card */
.card-thread {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: 0.3px;
  margin-bottom: 6px;
  font-style: italic;
}

.card-search-query {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 3px;
  font-family: 'SF Mono', 'Fira Code', Consolas, monospace;
}

/* Preview paragraph (replaces gist) */
.card-paragraph {
  font-family: var(--font-serif);
  font-size: 14px;
  line-height: 1.65;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

/* Citation link */
.card-citation {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  font-size: 11px;
}
.card-citation-label {
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  font-size: 10px;
  color: var(--text-muted);
  margin-right: 4px;
}
.card-citation-link {
  color: var(--accent);
  text-decoration: none;
  font-size: 12px;
  word-break: break-all;
}
.card-citation-link:hover {
  text-decoration: underline;
}

.card-research {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px dashed var(--border);
  font-size: 11px;
  line-height: 1.5;
  color: var(--text-muted);
}
.card-research-label {
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  font-size: 10px;
  margin-right: 4px;
}
.card-research-query {
  font-family: 'SF Mono', 'Fira Code', Consolas, monospace;
  font-size: 11px;
  color: var(--text-secondary);
}
.card-research-domains {
  display: block;
  margin-top: 2px;
  font-size: 10px;
  color: var(--text-muted);
  font-style: italic;
}

/* =========================================================
   THREADS - Topic Decomposition
   ========================================================= */

/* Scan results (collapsible article list above threads) */
.scan-results {
  margin-bottom: 18px;
  border: 1px solid var(--border-light);
  border-radius: 2px;
  background: var(--surface);
}

.scan-results-summary {
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-label);
  padding: 10px 14px;
  cursor: pointer;
  letter-spacing: 0.3px;
}

.scan-results-summary:hover {
  color: var(--accent);
}

.scan-results-list {
  padding: 4px 14px 12px;
}

.scan-item {
  padding: 6px 0;
  border-bottom: 1px solid var(--border-light);
}

.scan-item:last-child {
  border-bottom: none;
}

.scan-item-title {
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 500;
  color: var(--accent);
  text-decoration: none;
}

.scan-item-title:hover {
  text-decoration: underline;
}

.scan-item-snippet {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.5;
  margin-top: 2px;
}

.threads-intro {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 16px;
}

.thread-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  background-color: #FFFFFF;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.thread-card:hover {
  border-color: var(--accent);
  background-color: #FFFDF8;
}

.thread-checkbox {
  margin-top: 3px;
  accent-color: var(--accent);
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.thread-card-inner {
  flex: 1;
}

.thread-text {
  font-family: var(--font-serif);
  font-size: 15px;
  font-weight: 500;
  color: var(--text-primary);
  line-height: 1.4;
}

.thread-why {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
  font-style: italic;
}

/* Unchecked state — dim the card */
.thread-checkbox:not(:checked) + .thread-card-inner .thread-text {
  color: var(--text-muted);
  text-decoration: line-through;
  text-decoration-color: var(--border);
}

.thread-custom {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px dashed var(--border);
}

.threads-tone {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.tone-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.threads-hint {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 14px;
  color: var(--text-muted);
  margin-top: 20px;
  padding: 12px 16px;
  background-color: var(--bg-sidebar);
  border-radius: 6px;
  text-align: center;
}

/* Saved threads summary on page load */
.threads-saved-summary {
  padding: 12px 16px;
  background-color: #FFFFFF;
  border: 1px solid var(--border);
  border-radius: 6px;
}
.threads-saved-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.threads-saved-item {
  font-family: var(--font-serif);
  font-size: 14px;
  color: var(--text-secondary);
  padding: 4px 0;
  border-bottom: 1px solid var(--border-light, #EDE8E2);
}
.threads-saved-item:last-child {
  border-bottom: none;
}

/* ==========================================================================
   Login Page
   ========================================================================== */
.login-container {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 80vh;
}

.login-box {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  padding: 48px;
  text-align: center;
  max-width: 420px;
  width: 100%;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
}

.login-logo {
  margin-bottom: 32px;
}

.login-logo h1 {
  font-family: var(--font-serif);
  font-size: 32px;
  font-weight: 700;
  letter-spacing: 3px;
  color: var(--text-primary);
  margin: 16px 0 4px;
}

.login-subtitle {
  font-family: var(--font-sans);
  font-size: 14px;
  color: var(--text-muted);
}

.login-content {
  margin-bottom: 24px;
}

.login-content p {
  font-family: var(--font-sans);
  font-size: 15px;
  color: var(--text-secondary);
  margin-bottom: 24px;
}

.google-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  padding: 14px 24px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: var(--font-sans);
  font-size: 15px;
  font-weight: 500;
  color: var(--text-body);
  text-decoration: none;
  transition: all 0.2s ease;
}

.google-btn:hover {
  background: var(--surface);
  border-color: var(--text-muted);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.google-icon {
  flex-shrink: 0;
}

.login-note {
  font-family: var(--font-sans);
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
}

/* User info in sidebar */
.user-info {
  padding: 12px 16px;
  background: var(--surface);
  border-radius: 6px;
  margin-top: auto;
}

.user-info-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.user-info-name {
  font-family: var(--font-serif);
  font-size: 14px;
  color: var(--text-body);
}

.user-logout {
  display: inline-block;
  margin-top: 8px;
  font-family: var(--font-sans);
  font-size: 12px;
  color: var(--text-muted);
  text-decoration: underline;
  cursor: pointer;
}

.user-logout:hover {
  color: var(--text-body);
}
