:root {
  color-scheme: light;
  --bg: #f4f3ef;
  --ink: #202124;
  --muted: #6b6f76;
  --line: #dedbd2;
  --panel: #ffffff;
  --accent: #1e7a6f;
  --coral: #d95f43;
  --yellow: #f1c75b;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  border-right: 1px solid var(--line);
  padding: 28px 20px;
  background: #fbfaf7;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 36px;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 8px;
  background: var(--ink);
  color: white;
  font-weight: 800;
}

.brand small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
}

.nav {
  display: grid;
  gap: 8px;
}

.nav button,
.ghost-button,
.filters button,
.panel-header button {
  min-height: 38px;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
}

.nav button {
  text-align: left;
  padding: 0 12px;
}

.nav .active,
.filters .active {
  background: #e7eee9;
  color: var(--accent);
  font-weight: 700;
}

.workspace {
  padding: 30px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: flex-start;
  margin-bottom: 24px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  max-width: 760px;
  margin-bottom: 0;
  font-size: 34px;
  line-height: 1.2;
}

.ghost-button,
.panel-header button {
  padding: 0 14px;
  border: 1px solid var(--line);
}

.import-panel,
.episode-panel,
.insights-panel,
.card-panel,
.notebook-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.import-panel {
  padding: 20px;
  margin-bottom: 20px;
}

.import-panel label {
  display: block;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.url-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 132px;
  gap: 12px;
}

.url-row input {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 14px;
  color: var(--ink);
}

.url-row button {
  min-height: 48px;
  border-radius: 8px;
  background: var(--accent);
  color: white;
  font-weight: 800;
}

.source-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.parse-message {
  min-height: 22px;
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.parse-message.success {
  color: var(--accent);
  font-weight: 700;
}

.parse-message.error {
  color: #b7422c;
  font-weight: 700;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 10;
  max-width: min(360px, calc(100vw - 48px));
  border: 1px solid rgba(30, 122, 111, 0.28);
  border-radius: 8px;
  padding: 12px 14px;
  background: #ffffff;
  color: var(--accent);
  box-shadow: 0 18px 48px rgba(28, 31, 35, 0.16);
  font-size: 14px;
  font-weight: 800;
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition:
    opacity 160ms ease,
    transform 160ms ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.source-row span {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 10px;
  color: var(--muted);
  font-size: 13px;
}

.grid {
  display: grid;
  grid-template-columns: minmax(320px, 0.95fr) minmax(360px, 1.1fr) minmax(300px, 0.85fr);
  gap: 20px;
  align-items: start;
}

.episode-panel,
.insights-panel,
.card-panel,
.notebook-panel {
  padding: 18px;
}

.is-hidden {
  display: none;
}

.grid.focus-view {
  grid-template-columns: minmax(0, 1fr);
}

.cover {
  aspect-ratio: 1;
  border-radius: 8px;
  background-size: cover;
  background-position: center;
  background:
    linear-gradient(135deg, rgba(30, 122, 111, 0.92), rgba(217, 95, 67, 0.9)),
    radial-gradient(circle at 24% 18%, var(--yellow), transparent 32%);
  margin-bottom: 18px;
}

.status {
  color: var(--accent);
  font-weight: 800;
}

.episode-meta h2 {
  font-size: 24px;
  line-height: 1.25;
}

.episode-meta p {
  color: var(--muted);
}

.progress {
  display: grid;
  gap: 10px;
  padding-left: 20px;
  color: var(--muted);
}

.progress .done {
  color: var(--accent);
}

.progress .active {
  color: var(--coral);
  font-weight: 800;
}

.progress .done {
  font-weight: 800;
}

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

.panel-header h2 {
  margin-bottom: 0;
  font-size: 20px;
}

.filters {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 8px;
}

.filters button {
  flex: 0 0 auto;
  padding: 0 12px;
}

.insight-list {
  display: grid;
  gap: 12px;
}

.insight {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

.insight.active {
  border-color: var(--accent);
  background: #f0f7f4;
}

.insight span {
  display: block;
  margin-bottom: 8px;
  color: var(--coral);
  font-size: 13px;
  font-weight: 800;
}

.insight h3 {
  margin-bottom: 8px;
  font-size: 17px;
  line-height: 1.45;
}

.insight p {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.5;
}

.insight-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.insight-actions button,
.insight-actions select {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  background: white;
  color: var(--accent);
  font-size: 13px;
  font-weight: 800;
}

.insight-actions select {
  max-width: 100%;
  color: var(--ink);
}

.insight-actions button.saved {
  border-color: var(--accent);
  background: #e7eee9;
  color: var(--accent);
}

.share-card {
  display: grid;
  min-height: 380px;
  align-content: space-between;
  gap: 28px;
  border-radius: 8px;
  padding: 28px;
  background:
    linear-gradient(145deg, rgba(66, 87, 82, 0.94), rgba(202, 194, 178, 0.9)),
    #425752;
  color: #fffaf0;
  overflow: hidden;
  position: relative;
  transition:
    background 180ms ease,
    color 180ms ease;
}

.share-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.04), rgba(0, 0, 0, 0.26));
  pointer-events: none;
}

.share-card > * {
  position: relative;
  z-index: 1;
}

.share-card.style-ins {
  border: 1px solid rgba(210, 202, 190, 0.9);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.74), rgba(255, 255, 255, 0.38)),
    url("https://images.unsplash.com/photo-1518895949257-7621c3c786d7?auto=format&fit=crop&w=1200&q=80");
  background-size: cover;
  background-position: center;
  color: #4d4841;
}

.share-card.style-ins::before {
  inset: 18px;
  border: 1px solid rgba(255, 255, 255, 0.68);
  border-radius: 8px;
  background: rgba(255, 250, 244, 0.68);
  backdrop-filter: blur(2px);
}

.share-card.style-ins .card-type {
  color: #8f7d6b;
}

.share-card.style-ins blockquote {
  font-size: 28px;
  font-weight: 700;
}

.share-card.style-ins footer {
  color: #7a6c5f;
}

.share-card.style-cute {
  border: 3px solid #ff9fc6;
  background:
    radial-gradient(circle at 18% 18%, rgba(255, 255, 255, 0.95) 0 7%, transparent 8%),
    radial-gradient(circle at 84% 24%, rgba(255, 255, 255, 0.88) 0 6%, transparent 7%),
    linear-gradient(145deg, #ffd3e7, #c9f4ff 52%, #fff0b8);
  color: #64324b;
}

.share-card.style-cute::before {
  background:
    radial-gradient(circle at 10% 82%, rgba(255, 159, 198, 0.44) 0 8%, transparent 9%),
    radial-gradient(circle at 88% 78%, rgba(255, 234, 157, 0.7) 0 10%, transparent 11%);
}

.share-card.style-cute blockquote {
  font-size: 28px;
}

.share-card.style-cartoon {
  border: 4px solid #202124;
  background:
    radial-gradient(circle at 16% 18%, #ffdf5d 0 10%, transparent 11%),
    radial-gradient(circle at 84% 20%, #ff7a59 0 9%, transparent 10%),
    linear-gradient(145deg, #7bdff2, #b2f7ef 48%, #eff7f6);
  color: #202124;
  box-shadow: 8px 8px 0 #202124;
}

.share-card.style-cartoon::before {
  background:
    linear-gradient(90deg, rgba(32, 33, 36, 0.1) 2px, transparent 2px),
    linear-gradient(0deg, rgba(32, 33, 36, 0.08) 2px, transparent 2px);
  background-size: 32px 32px;
}

.share-card.style-cartoon blockquote {
  font-size: 29px;
  text-shadow: 2px 2px 0 rgba(255, 255, 255, 0.75);
}

.share-card.style-healing {
  border: 1px solid rgba(255, 255, 255, 0.52);
  background:
    radial-gradient(circle at 15% 20%, rgba(255, 255, 255, 0.82), transparent 26%),
    linear-gradient(145deg, #cfe8d5, #f6e6cc 52%, #d7e2f2);
  color: #435049;
}

.share-card.style-healing::before {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.16), rgba(67, 80, 73, 0.08));
}

.share-card.style-healing blockquote {
  font-size: 29px;
  font-weight: 700;
}

.share-card.style-scenery {
  background:
    linear-gradient(180deg, rgba(13, 31, 40, 0.16), rgba(13, 31, 40, 0.76)),
    url("https://images.unsplash.com/photo-1500534314209-a25ddb2bd429?auto=format&fit=crop&w=1200&q=80");
  background-size: cover;
  background-position: center;
  color: #fffaf0;
}

.share-card.style-scenery::before {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(0, 0, 0, 0.28));
}

.card-type {
  color: rgba(255, 250, 240, 0.82);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

blockquote {
  margin: 0;
  font-size: 30px;
  line-height: 1.35;
  font-weight: 800;
}

footer {
  color: rgba(255, 250, 240, 0.74);
}

.style-controls {
  display: grid;
  gap: 16px;
  margin-top: 16px;
}

.style-controls p {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.theme-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.preset-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.preset-row button {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: #fbfaf7;
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
}

.preset-row button.active {
  border-color: var(--accent);
  background: #e7eee9;
  color: var(--accent);
}

.swatch {
  width: 34px;
  height: 34px;
  border: 2px solid white;
  border-radius: 50%;
  box-shadow: 0 0 0 1px var(--line);
}

.swatch.active {
  box-shadow: 0 0 0 3px #ffffff, 0 0 0 5px var(--accent);
}

.swatch[data-theme="morandi-sage"] {
  background: #7f9288;
}

.swatch[data-theme="morandi-dust"] {
  background: #c9a8a2;
}

.swatch[data-theme="morandi-clay"] {
  background: #a87861;
}

.swatch[data-theme="morandi-blue"] {
  background: #7f8fa3;
}

.swatch[data-theme="macaron-mint"] {
  background: #bdebd9;
}

.swatch[data-theme="macaron-peach"] {
  background: #ffd3c2;
}

.swatch[data-theme="macaron-lilac"] {
  background: #d8c7ff;
}

.swatch[data-theme="macaron-lemon"] {
  background: #ffe99f;
}

.background-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.background-row button {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfaf7;
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
}

.background-row button.active {
  border-color: var(--accent);
  background: #e7eee9;
  color: var(--accent);
}

.category-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 14px;
  background: #fbfaf7;
}

.category-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 10px;
}

.category-header p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.category-header button {
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  background: white;
  color: var(--accent);
  font-size: 13px;
  font-weight: 800;
}

.category-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.category-row button {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 12px;
  background: white;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.category-row button.active {
  border-color: var(--accent);
  background: #e7eee9;
  color: var(--accent);
}

.inline-create {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 64px 64px;
  gap: 8px;
  margin: 0 0 12px;
}

.inline-create.is-hidden {
  display: none;
}

.inline-create input {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  background: white;
  color: var(--ink);
}

.inline-create button {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--accent);
  font-size: 13px;
  font-weight: 800;
}

.category-notes {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.category-note {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: white;
}

.category-note span {
  display: block;
  margin-bottom: 5px;
  color: var(--coral);
  font-size: 12px;
  font-weight: 800;
}

.category-note p {
  margin-bottom: 0;
  color: var(--ink);
  font-size: 14px;
  line-height: 1.45;
}

.notebook-layout {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  gap: 18px;
}

.notebook-list {
  display: grid;
  align-content: start;
  gap: 8px;
}

.notebook-list button {
  min-height: 40px;
  border-radius: 8px;
  padding: 0 12px;
  background: #fbfaf7;
  color: var(--muted);
  text-align: left;
}

.notebook-list button.active {
  background: #e7eee9;
  color: var(--accent);
  font-weight: 800;
}

.saved-notes {
  display: grid;
  gap: 12px;
}

.saved-note {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

.saved-note span {
  display: block;
  margin-bottom: 8px;
  color: var(--coral);
  font-size: 13px;
  font-weight: 800;
}

.saved-note h3 {
  margin-bottom: 8px;
  font-size: 18px;
  line-height: 1.45;
}

.saved-note p {
  margin-bottom: 0;
  color: var(--muted);
}

@media (max-width: 1120px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .nav {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

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

  .notebook-layout {
    grid-template-columns: 1fr;
  }

  .inline-create {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .workspace,
  .sidebar {
    padding: 18px;
  }

  .topbar,
  .url-row {
    grid-template-columns: 1fr;
    display: grid;
  }

  h1 {
    font-size: 27px;
  }

  blockquote {
    font-size: 24px;
  }
}
