:root {
  color-scheme: light;
  --bg: #f5f2ea;
  --surface: #fffdf8;
  --surface-strong: #ffffff;
  --ink: #151915;
  --muted: #626a64;
  --line: #d8d1c4;
  --primary: #0b6f61;
  --primary-strong: #06483f;
  --primary-soft: #dcefe9;
  --ai: #b46a12;
  --ai-soft: #f7e7cd;
  --danger: #a33b2d;
  --danger-soft: #f7dcd6;
  --focus: #0f8c78;
  --shadow: 0 18px 42px rgba(28, 31, 29, 0.08);
  --radius: 8px;
  --radius-small: 6px;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --font: "Segoe UI", "Microsoft YaHei UI", "Microsoft YaHei", sans-serif;
}

body.theme-dark {
  color-scheme: dark;
  --bg: #171916;
  --surface: #20231f;
  --surface-strong: #292d28;
  --ink: #f2eee4;
  --muted: #bab4a7;
  --line: #3a403a;
  --primary: #5cc7b0;
  --primary-strong: #92ddce;
  --primary-soft: #163a35;
  --ai: #e6a64f;
  --ai-soft: #45301a;
  --danger: #ef8d7c;
  --danger-soft: #4a241e;
  --focus: #7bd5c3;
  --shadow: 0 18px 42px rgba(0, 0, 0, 0.22);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  min-height: 100%;
  margin: 0;
  background:
    linear-gradient(180deg, rgba(11, 111, 97, 0.08), transparent 280px),
    var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  letter-spacing: 0;
}

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

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

.app-shell {
  width: min(1760px, calc(100% - 32px));
  margin: 0 auto;
  padding: var(--space-5) 0;
}

.topbar {
  min-height: 72px;
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--space-4);
  margin-bottom: var(--space-5);
}

.brand-mark {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: var(--radius);
  background: var(--ink);
  color: var(--surface);
  font-size: 17px;
  font-weight: 800;
}

.topbar h1,
.topbar p,
.list-header h2,
.list-header p,
.side-panel h2,
.detail-panel h2,
.detail-panel p,
.idea-card h3,
.idea-card p {
  margin: 0;
}

.topbar h1 {
  font-size: 24px;
  line-height: 1.15;
}

.topbar p,
.list-header p,
.meta-line,
.muted,
.empty-detail p {
  color: var(--muted);
}

.topbar p {
  margin-top: 3px;
  font-size: 14px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.route-view {
  display: none;
}

.route-view.is-active {
  display: grid;
}

.route-view:not(.is-active) {
  display: none;
}

.list-route {
  display: grid;
  grid-template-columns: 320px minmax(420px, 1fr);
  gap: var(--space-4);
  align-items: start;
}

.side-panel,
.list-panel,
.detail-panel,
.editor-panel {
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.side-panel {
  border-radius: var(--radius);
  overflow: hidden;
}

.editor-route,
.detail-route {
  grid-template-columns: minmax(0, 1220px);
  justify-content: center;
  align-items: start;
}

.editor-panel,
.detail-panel {
  width: 100%;
  border-radius: var(--radius);
}

.editor-panel {
  display: grid;
  gap: var(--space-5);
  padding: var(--space-5);
}

.page-heading {
  display: grid;
  gap: var(--space-2);
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--line);
}

.page-heading p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.page-heading h2 {
  margin: 0;
  font-size: 28px;
  line-height: 1.18;
}

.idea-editor-form {
  display: grid;
  gap: var(--space-4);
}

.new-ai-tools {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-3);
  padding: var(--space-3);
  border: 1px dashed color-mix(in srgb, var(--ai) 36%, var(--line));
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--ai-soft) 34%, transparent);
}

.new-ai-tools span {
  color: var(--muted);
  font-size: 14px;
}

.new-ai-output {
  display: grid;
}

.new-ai-output[hidden] {
  display: none;
}

.quick-capture,
.filters {
  padding: var(--space-4);
}

.quick-capture {
  border-bottom: 1px solid var(--line);
}

.side-panel h2,
.list-header h2,
.detail-panel h2 {
  font-size: 17px;
  line-height: 1.25;
}

form,
.filters {
  display: grid;
  gap: var(--space-3);
}

label {
  display: grid;
  gap: var(--space-2);
}

label span,
.section-title,
.meta-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-small);
  background: var(--surface-strong);
  color: var(--ink);
  padding: 10px 11px;
  outline: none;
  transition: border-color 150ms ease, box-shadow 150ms ease, background 150ms ease;
}

textarea {
  resize: vertical;
  min-height: 104px;
  line-height: 1.55;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--focus);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 20%, transparent);
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-2);
}

.primary-button,
.secondary-button,
.ghost-button,
.danger-button,
.icon-button {
  min-height: 42px;
  border-radius: var(--radius-small);
  border: 1px solid transparent;
  padding: 0 14px;
  transition: transform 120ms ease, background 150ms ease, border-color 150ms ease, color 150ms ease;
}

.primary-button {
  background: var(--primary);
  color: #fffdf8;
  font-weight: 700;
}

.primary-button:hover {
  background: var(--primary-strong);
}

.secondary-button {
  background: var(--primary-soft);
  color: var(--primary-strong);
  border-color: color-mix(in srgb, var(--primary) 28%, transparent);
  font-weight: 700;
}

.ghost-button,
.icon-button {
  background: var(--surface-strong);
  color: var(--ink);
  border-color: var(--line);
}

.ghost-button.is-current,
.primary-button.is-current {
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 20%, transparent);
}

.danger-button {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 28%, transparent);
  font-weight: 700;
}

.primary-button:active,
.secondary-button:active,
.ghost-button:active,
.danger-button:active,
.icon-button:active,
.idea-card:active {
  transform: translateY(1px);
}

.full-width {
  width: 100%;
}

.list-panel,
.detail-panel {
  border-radius: var(--radius);
  min-height: calc(100vh - 144px);
}

.list-header {
  min-height: 73px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-4);
  border-bottom: 1px solid var(--line);
}

.segmented-control {
  display: inline-grid;
  grid-template-columns: 1fr 1fr;
  border: 1px solid var(--line);
  border-radius: var(--radius-small);
  overflow: hidden;
  background: var(--surface-strong);
}

.segmented-control button {
  min-height: 34px;
  border: 0;
  padding: 0 11px;
  background: transparent;
  color: var(--muted);
}

.segmented-control button.is-active {
  background: var(--ink);
  color: var(--surface);
}

.idea-list {
  display: grid;
  gap: var(--space-4);
  padding: var(--space-4);
}

.group-block {
  display: grid;
  gap: var(--space-4);
}

.group-title {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  padding-top: var(--space-1);
  margin-bottom: var(--space-1);
}

.group-title::after {
  content: "";
  height: 1px;
  flex: 1;
  background: var(--line);
}

.idea-card {
  width: 100%;
  min-height: 142px;
  display: grid;
  gap: var(--space-3);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-strong);
  color: inherit;
  padding: var(--space-4);
  text-align: left;
  transition: border-color 150ms ease, transform 150ms ease, box-shadow 150ms ease;
}

.idea-card:hover,
.idea-card.is-selected {
  border-color: color-mix(in srgb, var(--primary) 55%, var(--line));
  box-shadow: 0 10px 24px rgba(28, 31, 29, 0.08);
  transform: translateY(-1px);
}

.idea-card h3 {
  font-size: 18px;
  line-height: 1.25;
  text-wrap: pretty;
}

.idea-card p {
  color: var(--muted);
  line-height: 1.55;
  text-wrap: pretty;
}

.card-row,
.detail-actions,
.chip-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.card-row {
  justify-content: space-between;
}

.chip {
  display: inline-flex;
  min-height: 26px;
  align-items: center;
  border-radius: var(--radius-small);
  background: var(--primary-soft);
  color: var(--primary-strong);
  padding: 3px 8px;
  font-size: 12px;
  font-weight: 700;
}

.chip.ai {
  background: var(--ai-soft);
  color: var(--ai);
}

.chip.neutral {
  background: color-mix(in srgb, var(--line) 45%, transparent);
  color: var(--muted);
}

.compact .idea-card {
  min-height: 104px;
  gap: var(--space-2);
  padding: var(--space-3);
}

.compact .idea-card p {
  display: none;
}

.detail-panel {
  padding: var(--space-5);
}

.empty-detail {
  min-height: 360px;
  display: grid;
  align-content: center;
  gap: var(--space-2);
  text-align: center;
  padding: var(--space-5);
}

.detail-content {
  display: grid;
  gap: var(--space-4);
}

.detail-heading {
  display: grid;
  gap: var(--space-2);
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--line);
}

.detail-heading h2 {
  font-size: 24px;
  text-wrap: pretty;
}

.detail-section {
  display: grid;
  gap: var(--space-3);
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--line);
}

.detail-section:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.ai-output {
  display: grid;
  gap: var(--space-3);
  border: 1px solid color-mix(in srgb, var(--ai) 30%, var(--line));
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--ai-soft) 64%, transparent);
  padding: var(--space-3);
}

.readonly-box {
  white-space: pre-wrap;
  line-height: 1.6;
  color: var(--ink);
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  max-width: min(420px, calc(100% - 40px));
  padding: 12px 14px;
  border-radius: var(--radius);
  background: var(--ink);
  color: var(--surface);
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
  z-index: 20;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 1220px) {
  .list-route {
    grid-template-columns: 320px minmax(0, 1fr);
  }

  .editor-route,
  .detail-route {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 820px) {
  .app-shell {
    width: min(100% - 20px, 760px);
    padding: var(--space-3) 0;
  }

  .topbar {
    grid-template-columns: 44px minmax(0, 1fr);
  }

  .topbar-actions {
    grid-column: 1 / -1;
    justify-content: stretch;
    flex-wrap: wrap;
  }

  .topbar-actions .primary-button,
  .topbar-actions .secondary-button,
  .topbar-actions .ghost-button {
    flex: 1;
  }

  .list-route {
    grid-template-columns: 1fr;
  }

  .editor-route,
  .detail-route {
    grid-template-columns: minmax(0, 1fr);
  }

  .side-panel,
  .list-panel,
  .detail-panel,
  .editor-panel {
    min-height: auto;
  }

  .detail-panel,
  .editor-panel {
    padding: var(--space-4);
  }

  .field-grid {
    grid-template-columns: 1fr;
  }

  .list-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .segmented-control {
    width: 100%;
  }
}

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