/* AI Signal - Modern Editorial Theme */
:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-alt: #f1f5f9;
  --border: #e2e8f0;
  --border-subtle: #cbd5e1;
  --text: #0f172a;
  --text-muted: #475569;
  --text-subtle: #64748b;
  --primary: #0284c7;
  --primary-hover: #0369a1;
  --primary-bg: #e0f2fe;
  --hn-orange: #f06a14;
  --hn-bg: #fff5ee;
  --soul-purple: #9333ea;
  --soul-bg: #faf5ff;
  --soul-border: #d8b4fe;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --font-base: 16px;
  --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.05), 0 1px 2px -1px rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.07), 0 2px 4px -2px rgb(0 0 0 / 0.05);
}

[data-theme="dark"] {
  --bg: #0b1120;
  --surface: #131d31;
  --surface-alt: #1a2640;
  --border: #23324d;
  --border-subtle: #334466;
  --text: #f8fafc;
  --text-muted: #94a3b8;
  --text-subtle: #64748b;
  --primary: #38bdf8;
  --primary-hover: #7dd3fc;
  --primary-bg: rgba(56, 189, 248, 0.12);
  --hn-orange: #ff7733;
  --hn-bg: rgba(240, 106, 20, 0.14);
  --soul-purple: #c084fc;
  --soul-bg: rgba(168, 85, 247, 0.12);
  --soul-border: rgba(192, 132, 252, 0.3);
  --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.3);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.4);
}

[data-size="lg"] { --font-base: 18px; }
[data-size="xl"] { --font-base: 20px; }

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
  font-size: var(--font-base);
  line-height: 1.7;
  color: var(--text);
  background-color: var(--bg);
  transition: background-color 0.2s ease, color 0.2s ease;
  -webkit-font-smoothing: antialiased;
}

.container {
  max-width: 860px;
  margin: 0 auto;
  padding: 24px 20px 80px;
}

/* Header & Navigation */
.header {
  border-bottom: 2px solid var(--border);
  padding-bottom: 20px;
  margin-bottom: 32px;
}

.header-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 16px;
}

.brand {
  text-decoration: none;
  color: var(--text);
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.brand-title {
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, var(--text) 30%, var(--primary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-badge {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  background-color: var(--primary-bg);
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  -webkit-text-fill-color: initial;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s ease;
}

.btn:hover {
  color: var(--text);
  border-color: var(--border-subtle);
  background: var(--surface-alt);
}

.meta-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.88rem;
  color: var(--text-subtle);
  flex-wrap: wrap;
  gap: 10px;
}

.meta-source {
  display: flex;
  align-items: center;
  gap: 6px;
}

.source-dot {
  width: 8px;
  height: 8px;
  background: var(--hn-orange);
  border-radius: 50%;
  display: inline-block;
}

/* Section Headings */
h1 {
  font-size: 2.1rem;
  font-weight: 800;
  line-height: 1.3;
  margin-bottom: 24px;
  letter-spacing: -0.025em;
}

h2 {
  font-size: 1.35rem;
  font-weight: 700;
  margin-top: 40px;
  margin-bottom: 20px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
  letter-spacing: -0.015em;
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-icon {
  font-size: 1.3rem;
}

/* Callout Lead Card */
.lead-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  padding: 20px 24px;
  margin-bottom: 32px;
  box-shadow: var(--shadow);
}

.lead-text {
  font-size: 1.05rem;
  line-height: 1.8;
  color: var(--text);
}

/* Soul Feature Hero Card */
.soul-card {
  background: var(--surface);
  border: 2px solid var(--soul-border);
  border-radius: var(--radius-lg);
  padding: 24px 26px;
  margin-bottom: 36px;
  box-shadow: var(--shadow-md);
  position: relative;
  overflow: hidden;
}

.soul-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--soul-purple), var(--primary));
}

.soul-badge-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  flex-wrap: wrap;
  gap: 8px;
}

.soul-tag {
  font-size: 0.8rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--soul-bg);
  color: var(--soul-purple);
  border: 1px solid var(--soul-border);
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.soul-title {
  font-size: 1.35rem;
  font-weight: 800;
  line-height: 1.4;
  margin-bottom: 14px;
}

.soul-title a {
  color: var(--text);
  text-decoration: none;
}

.soul-title a:hover {
  color: var(--soul-purple);
  text-decoration: underline;
}

.editor-note-box {
  background: var(--soul-bg);
  border: 1px solid var(--soul-border);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  margin: 16px 0;
  font-size: 0.95rem;
  color: var(--text);
}

.editor-note-title {
  font-weight: 700;
  color: var(--soul-purple);
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Standard Item Cards */
.item-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 22px 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.item-card:hover {
  border-color: var(--border-subtle);
  box-shadow: var(--shadow-md);
}

.item-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.item-title {
  font-size: 1.2rem;
  font-weight: 700;
  line-height: 1.4;
  color: var(--text);
}

.item-title a {
  color: var(--text);
  text-decoration: none;
}

.item-title a:hover {
  color: var(--primary);
  text-decoration: underline;
}

.item-badges {
  display: flex;
  align-items: center;
  gap: 8px;
}

.badge-cat {
  font-size: 0.78rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  background: var(--surface-alt);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.badge-points {
  font-size: 0.78rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--hn-bg);
  color: var(--hn-orange);
  border: 1px solid rgba(240, 106, 20, 0.2);
}

.field {
  margin-bottom: 12px;
}

.field-label {
  font-weight: 700;
  color: var(--text);
  display: inline-block;
  margin-bottom: 4px;
}

.tldr-box {
  background: var(--surface-alt);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  color: var(--text);
  margin-bottom: 12px;
  border-left: 3px solid var(--border-subtle);
}

.sublist {
  list-style: circle;
  padding-left: 22px;
  margin: 6px 0 12px;
}

.sublist li {
  margin-bottom: 6px;
  color: var(--text-muted);
  line-height: 1.65;
}

.so-what-text {
  color: var(--text);
  line-height: 1.65;
}

/* Action Links */
.action-links {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.link-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  font-weight: 500;
  padding: 5px 12px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  background: var(--surface-alt);
  color: var(--primary);
  border: 1px solid var(--border);
  transition: all 0.15s ease;
}

.link-btn:hover {
  background: var(--primary-bg);
  color: var(--primary-hover);
  border-color: var(--primary);
}

.link-btn.hn {
  color: var(--hn-orange);
}

.link-btn.hn:hover {
  background: var(--hn-bg);
  border-color: var(--hn-orange);
}

/* Quick Links Table / List */
.quick-list {
  list-style: none;
  margin-top: 16px;
}

.quick-item {
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin-bottom: 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: all 0.15s ease;
}

.quick-item:hover {
  border-color: var(--border-subtle);
  background: var(--surface-alt);
}

.quick-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
}

.quick-title {
  font-weight: 600;
  font-size: 1rem;
  color: var(--primary);
  text-decoration: none;
}

.quick-title:hover {
  text-decoration: underline;
}

.quick-note {
  font-size: 0.9rem;
  color: var(--text-muted);
}

/* Archive Controls & Search */
.archive-controls {
  margin-bottom: 24px;
}

.archive-search-box {
  display: flex;
  align-items: center;
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 4px 14px;
  box-shadow: var(--shadow);
  transition: all 0.2s ease;
}

.archive-search-box:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.15);
}

.search-icon {
  font-size: 1.1rem;
  margin-right: 8px;
  color: var(--text-muted);
}

.archive-search-input {
  flex: 1;
  border: none;
  background: transparent;
  padding: 10px 4px;
  font-size: 0.95rem;
  color: var(--text);
  outline: none;
  width: 100%;
}

.search-clear-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 8px;
  font-size: 1rem;
  border-radius: var(--radius-sm);
  transition: color 0.15s ease;
}

.search-clear-btn:hover {
  color: var(--text);
}

.search-results-info {
  margin-top: 10px;
  font-size: 0.88rem;
  color: var(--text-muted);
  padding-left: 4px;
}

/* Month Navigation Chips */
.month-chips-nav {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
}

.chips-label {
  color: var(--text-muted);
  font-weight: 600;
}

.month-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text);
  text-decoration: none;
  font-weight: 500;
  transition: all 0.15s ease;
}

.month-chip:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--surface);
}

.chip-count {
  color: var(--text-muted);
  font-size: 0.8rem;
}

/* Month Accordion */
.archive-month-group {
  margin-bottom: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: border-color 0.15s ease;
}

.archive-month-group[open] {
  border-color: var(--border-subtle);
}

.archive-month-summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px;
  background: var(--surface-alt);
  cursor: pointer;
  user-select: none;
  font-weight: 700;
  list-style: none;
  transition: background 0.15s ease;
}

.archive-month-summary::-webkit-details-marker {
  display: none;
}

.archive-month-summary:hover {
  background: var(--surface);
}

.summary-left {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.05rem;
}

.summary-chevron {
  display: inline-block;
  transition: transform 0.2s ease;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.archive-month-group[open] .summary-chevron {
  transform: rotate(90deg);
}

.month-count {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 2px 10px;
  border-radius: 999px;
}

/* Archive Items List inside Month */
.archive-list {
  list-style: none;
  padding: 12px 14px;
  margin: 0;
}

.archive-item {
  margin-bottom: 10px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--border);
  transition: all 0.15s ease;
}

.archive-item:last-child {
  margin-bottom: 0;
}

.archive-item:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}

.archive-link {
  display: block;
  padding: 14px 16px;
  text-decoration: none;
  color: inherit;
}

.archive-item-main {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 4px;
  flex-wrap: wrap;
}

.archive-title {
  font-size: 1.02rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.4;
}

.archive-link:hover .archive-title {
  color: var(--primary);
}

.archive-date {
  font-family: ui-monospace, monospace;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--primary);
  white-space: nowrap;
}

.archive-soul-preview {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.88rem;
  color: var(--text-muted);
  margin-top: 6px;
}

.soul-badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  color: #d97706;
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.25);
  padding: 1px 6px;
  border-radius: 4px;
  white-space: nowrap;
}

.soul-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

/* Footer */
.footer {
  margin-top: 60px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
  font-size: 0.85rem;
  color: var(--text-subtle);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

/* Mobile Responsive Optimization (Screens <= 640px) */
@media (max-width: 640px) {
  .container {
    padding: 16px 14px 60px;
  }
  
  .header-top {
    gap: 12px;
  }
  
  .nav-actions {
    width: 100%;
    justify-content: space-between;
    gap: 6px;
    flex-wrap: wrap;
  }
  
  .btn {
    padding: 6px 8px;
    font-size: 0.78rem;
    flex: 1 1 45%;
    justify-content: center;
  }

  h1 {
    font-size: 1.55rem;
    line-height: 1.35;
    margin-bottom: 18px;
  }

  h2 {
    font-size: 1.25rem;
    margin-top: 32px;
    margin-bottom: 16px;
  }

  .lead-card, .soul-card, .item-card {
    padding: 18px 16px;
    border-radius: var(--radius-md);
  }

  .soul-title {
    font-size: 1.22rem;
  }

  .item-title {
    font-size: 1.1rem;
  }

  .action-links {
    flex-direction: column;
    gap: 8px;
  }

  .link-btn {
    width: 100%;
    justify-content: center;
    padding: 8px 12px;
  }

  .archive-soul-preview {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }

  .soul-text {
    white-space: normal;
  }
}
