:root {
  --ink: #171815;
  --muted: #6d6d65;
  --paper: #f2eee4;
  --card: #fbfaf6;
  --line: #d6d0c4;
  --acid: #e7ff4f;
  --coral: #ff6b4a;
  --blue: #3957dd;
  --shadow: 0 16px 45px rgba(39, 35, 27, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 82% 2%, rgba(231, 255, 79, 0.16), transparent 24rem),
    var(--paper);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

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

button,
select,
.file-button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  z-index: 20;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 72px;
  padding: 0 5vw;
  border-bottom: 1px solid rgba(23, 24, 21, 0.12);
  background: rgba(242, 238, 228, 0.86);
  backdrop-filter: blur(16px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  font-size: 0.82rem;
  font-weight: 850;
  letter-spacing: 0.13em;
  text-decoration: none;
}

.brand-mark {
  display: flex;
  gap: 2px;
  align-items: flex-end;
  height: 24px;
}

.brand-mark i {
  display: block;
  width: 5px;
  background: var(--ink);
  transform: rotate(8deg);
}

.brand-mark i:nth-child(1) {
  height: 15px;
}

.brand-mark i:nth-child(2) {
  height: 23px;
  background: var(--coral);
}

.brand-mark i:nth-child(3) {
  height: 19px;
}

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

.quiet-button,
.primary-button {
  min-height: 42px;
  padding: 0 17px;
  border: 1px solid var(--ink);
  border-radius: 999px;
  color: var(--ink);
  background: transparent;
  font-size: 0.84rem;
  font-weight: 750;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.quiet-button:hover,
.primary-button:hover,
.file-button:hover {
  transform: translateY(-2px);
}

.primary-button {
  border-color: var(--acid);
  background: var(--acid);
  box-shadow: 0 6px 18px rgba(108, 122, 25, 0.18);
}

.hero {
  max-width: 1440px;
  margin: 0 auto;
  padding: clamp(74px, 10vw, 140px) 5vw clamp(64px, 8vw, 110px);
}

.eyebrow {
  display: inline-flex;
  padding: 7px 10px 6px;
  transform: rotate(-1deg);
  background: var(--ink);
  color: var(--paper);
  font-size: 0.68rem;
  font-weight: 850;
  letter-spacing: 0.16em;
}

.hero h1 {
  max-width: 920px;
  margin: 24px 0 26px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(3.5rem, 8.4vw, 8.4rem);
  font-weight: 400;
  line-height: 0.85;
  letter-spacing: -0.065em;
}

.hero h1 em {
  color: var(--blue);
  font-weight: 400;
}

.hero p {
  max-width: 580px;
  margin: 0;
  color: var(--muted);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.1rem, 1.5vw, 1.35rem);
  line-height: 1.5;
}

.workspace {
  padding: 0 5vw 90px;
}

.dashboard {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  max-width: 1440px;
  margin: 0 auto 28px;
  border-top: 1px solid var(--ink);
  border-bottom: 1px solid var(--ink);
}

.stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 24px 0 22px;
  border: 0;
  color: inherit;
  background: transparent;
  text-align: left;
}

.stat + .stat {
  padding-left: 34px;
  border-left: 1px solid var(--line);
}

.stat-button:hover .stat-label span {
  display: inline-block;
  transform: translateX(4px);
}

.stat-value {
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2.4rem, 4vw, 4rem);
  line-height: 1;
}

.stat-label {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 720;
}

.controls,
.filter-row,
.result-bar,
.idea-grid,
.empty-state {
  max-width: 1440px;
  margin-left: auto;
  margin-right: auto;
}

.controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 190px auto;
  gap: 12px;
}

.view-toggle {
  display: flex;
  width: max-content;
  border: 1px solid var(--line);
  border-radius: 9px;
  overflow: hidden;
  background: var(--card);
}

.view-button {
  min-height: 42px;
  border: 0;
  padding: 0 14px;
  color: var(--muted);
  background: transparent;
  font-size: 0.72rem;
  font-weight: 800;
}

.view-button + .view-button {
  border-left: 1px solid var(--line);
}

.view-button.active {
  color: var(--paper);
  background: var(--ink);
}

.search-box,
.select-wrap {
  display: flex;
  align-items: center;
  min-height: 54px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(251, 250, 246, 0.64);
}

.search-box:focus-within,
.select-wrap:focus-within {
  border-color: var(--ink);
  box-shadow: 0 0 0 3px rgba(23, 24, 21, 0.08);
}

.search-box > span {
  padding-left: 17px;
  font-size: 1.7rem;
  line-height: 0;
}

.search-box input {
  width: 100%;
  height: 52px;
  border: 0;
  outline: 0;
  padding: 0 12px;
  background: transparent;
}

kbd {
  margin-right: 14px;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 6px;
  color: var(--muted);
  background: var(--card);
  font-size: 0.7rem;
}

.select-wrap select {
  width: 100%;
  height: 52px;
  border: 0;
  outline: 0;
  padding: 0 16px;
  background: transparent;
  font-size: 0.82rem;
  font-weight: 700;
}

.filter-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 16px 0 8px;
  scrollbar-width: none;
}

.filter-row::-webkit-scrollbar {
  display: none;
}

.filter-chip {
  flex: 0 0 auto;
  min-height: 34px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: transparent;
  font-size: 0.73rem;
  font-weight: 750;
}

.filter-chip:hover {
  border-color: var(--ink);
  color: var(--ink);
}

.filter-chip.active {
  border-color: var(--ink);
  color: var(--paper);
  background: var(--ink);
}

.result-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 54px;
}

.result-bar p {
  color: var(--muted);
  font-size: 0.78rem;
}

.text-button {
  border: 0;
  padding: 5px 0;
  color: var(--ink);
  background: transparent;
  font-size: 0.76rem;
  font-weight: 780;
  text-decoration: underline;
  text-underline-offset: 4px;
}

.idea-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}

.idea-list {
  display: grid;
  gap: 30px;
  padding-top: 8px;
}

.list-theme h2 {
  margin: 0;
  padding-bottom: 9px;
  border-bottom: 2px solid var(--ink);
  font-size: 0.72rem;
  font-weight: 850;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.list-theme ol {
  margin: 0;
  padding: 0;
  list-style: none;
}

.list-theme li {
  border-bottom: 1px solid var(--line);
}

.list-theme button {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  width: 100%;
  gap: 20px;
  border: 0;
  padding: 12px 4px;
  color: var(--ink);
  background: transparent;
  text-align: left;
}

.list-theme button:hover span {
  text-decoration: underline;
  text-underline-offset: 4px;
}

.list-theme span {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1rem;
  line-height: 1.35;
}

.list-theme time {
  padding-top: 3px;
  color: var(--muted);
  font-size: 0.68rem;
  white-space: nowrap;
}

.idea-card {
  position: relative;
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--card);
  box-shadow: 0 1px 0 rgba(23, 24, 21, 0.03);
  transition: transform 200ms ease, box-shadow 200ms ease, border-color 200ms ease;
}

.idea-card:hover {
  transform: translateY(-5px);
  border-color: #aaa397;
  box-shadow: var(--shadow);
}

.card-button {
  display: block;
  width: 100%;
  border: 0;
  padding: 0;
  color: inherit;
  background: transparent;
  text-align: left;
}

.idea-image,
.dialog-image {
  position: relative;
  overflow: hidden;
  background-color: #d9d6cc;
  background-repeat: no-repeat;
}

.idea-image {
  aspect-ratio: 16 / 9;
  border-bottom: 1px solid var(--line);
  filter: saturate(0.84) contrast(1.04);
}

.idea-image::after,
.dialog-image::after {
  position: absolute;
  inset: 0;
  content: "";
  background: linear-gradient(125deg, rgba(255,255,255,0.16), transparent 45%);
  pointer-events: none;
}

.confidence-dot {
  position: absolute;
  z-index: 2;
  top: 12px;
  right: 12px;
  width: 10px;
  height: 10px;
  border: 2px solid var(--card);
  border-radius: 50%;
  background: #46a262;
  box-shadow: 0 1px 4px rgba(0,0,0,0.15);
}

.confidence-dot.medium {
  background: #e2a934;
}

.confidence-dot.low {
  background: var(--coral);
}

.card-content {
  padding: 19px 20px 20px;
}

.card-kicker {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 11px;
  color: var(--muted);
  font-size: 0.65rem;
  font-weight: 820;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.card-kicker span:first-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-content h2 {
  margin: 0 0 10px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.25rem, 1.9vw, 1.65rem);
  font-weight: 400;
  line-height: 1.05;
  letter-spacing: -0.025em;
}

.card-content p {
  display: -webkit-box;
  overflow: hidden;
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.5;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.7rem;
}

.card-footer strong {
  color: var(--ink);
  font-size: 0.72rem;
}

.empty-state {
  padding: 80px 20px;
  text-align: center;
}

.empty-state > span {
  font-family: Georgia, serif;
  font-size: 4rem;
}

.empty-state h2 {
  margin: 10px 0 4px;
  font-family: Georgia, serif;
  font-weight: 400;
}

.empty-state p {
  margin: 0 0 20px;
  color: var(--muted);
}

footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 26px 5vw;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.72rem;
}

.danger-text {
  color: #9e2f24;
}

.idea-dialog {
  width: min(1040px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  border: 0;
  border-radius: 20px;
  padding: 0;
  color: var(--ink);
  background: var(--card);
  box-shadow: 0 30px 100px rgba(0,0,0,0.3);
}

.idea-dialog::backdrop {
  background: rgba(23, 24, 21, 0.66);
  backdrop-filter: blur(4px);
}

.dialog-shell {
  position: relative;
  display: block;
  margin: 0;
}

.close-button {
  position: absolute;
  z-index: 5;
  top: 14px;
  right: 14px;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid rgba(23,24,21,0.14);
  border-radius: 50%;
  background: rgba(251,250,246,0.84);
  font-size: 1.5rem;
  line-height: 1;
}

.dialog-image {
  display: grid;
  place-items: center;
  min-height: 420px;
  height: min(58vh, 620px);
  padding: 18px;
  border-bottom: 1px solid var(--line);
  background: #d9d6cc;
}

.dialog-canvas {
  position: relative;
  display: inline-block;
  max-width: 100%;
  max-height: 100%;
  line-height: 0;
}

.dialog-canvas img {
  display: block;
  width: auto;
  max-width: 100%;
  height: auto;
  max-height: min(54vh, 580px);
}

.confidence-badge {
  position: absolute;
  z-index: 2;
  left: 18px;
  bottom: 18px;
  padding: 7px 9px;
  border-radius: 6px;
  color: white;
  background: rgba(23,24,21,0.82);
  font-size: 0.66rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  backdrop-filter: blur(8px);
}

.dialog-focus {
  position: absolute;
  z-index: 3;
  border: 2px solid #5f7cff;
  border-radius: 3px;
  box-shadow:
    0 0 0 1px rgba(255,255,255,0.9),
    0 0 12px rgba(48, 79, 224, 0.34);
  pointer-events: none;
}

.dialog-content {
  max-width: 820px;
  overflow: visible;
  margin: 0 auto;
  padding: clamp(38px, 5vw, 66px);
}

.dialog-kicker {
  display: flex;
  gap: 7px;
  color: var(--blue);
  font-size: 0.68rem;
  font-weight: 850;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.dialog-content h2 {
  margin: 17px 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2.1rem, 4vw, 3.4rem);
  font-weight: 400;
  line-height: 0.98;
  letter-spacing: -0.045em;
}

.dialog-description {
  margin: 0;
  color: var(--muted);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.06rem;
  line-height: 1.55;
}

.transcript-block {
  margin-top: 34px;
  padding: 18px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.transcript-block > span,
.edit-mode label > span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.62rem;
  font-weight: 850;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.transcript-block blockquote {
  margin: 0;
  font-size: 0.88rem;
  line-height: 1.55;
}

.dialog-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  margin-top: 24px;
}

.source-link {
  border: 0;
  padding: 5px 0;
  color: var(--ink);
  background: transparent;
  font-size: 0.76rem;
  font-weight: 760;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.source-dialog {
  width: min(1400px, calc(100vw - 32px));
  height: min(920px, calc(100vh - 32px));
  overflow: hidden;
  border: 0;
  border-radius: 20px;
  padding: 0;
  color: var(--ink);
  background: #171815;
  box-shadow: 0 30px 100px rgba(0,0,0,0.42);
}

.source-dialog::backdrop {
  background: rgba(23, 24, 21, 0.8);
  backdrop-filter: blur(5px);
}

.source-dialog-shell {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  height: 100%;
}

.source-dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 18px 22px;
  color: var(--paper);
}

.source-dialog-header span {
  color: rgba(251, 250, 246, 0.58);
  font-size: 0.6rem;
  font-weight: 850;
  letter-spacing: 0.12em;
}

.source-dialog-header h2 {
  overflow: hidden;
  max-width: min(900px, 72vw);
  margin: 4px 0 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1rem, 2vw, 1.4rem);
  font-weight: 400;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.source-close-button {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid rgba(255,255,255,0.24);
  border-radius: 50%;
  color: white;
  background: rgba(255,255,255,0.08);
  font-size: 1.5rem;
}

.source-stage {
  display: grid;
  overflow: auto;
  place-items: center;
  min-height: 0;
  padding: 0 22px;
}

.source-canvas {
  position: relative;
  display: inline-block;
  max-width: 100%;
  max-height: 100%;
  line-height: 0;
}

.source-canvas img {
  display: block;
  width: auto;
  max-width: 100%;
  height: auto;
  max-height: calc(100vh - 170px);
  object-fit: contain;
}

.source-highlight {
  position: absolute;
  z-index: 2;
  border: 2px solid #5f7cff;
  border-radius: 3px;
  box-shadow:
    0 0 0 1px rgba(255,255,255,0.82),
    0 0 0 9999px rgba(14, 15, 13, 0.12);
  pointer-events: none;
}

.source-caption {
  margin: 0;
  padding: 14px 22px 18px;
  color: rgba(251, 250, 246, 0.64);
  font-size: 0.7rem;
  text-align: center;
}

.edit-mode {
  display: grid;
  gap: 18px;
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.edit-mode input,
.edit-mode textarea,
.edit-mode select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: 0;
  padding: 11px 12px;
  color: var(--ink);
  background: #fff;
}

.edit-mode textarea {
  resize: vertical;
  line-height: 1.45;
}

.edit-mode input:focus,
.edit-mode textarea:focus,
.edit-mode select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(57, 87, 221, 0.1);
}

.edit-mode small {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.68rem;
}

.edit-actions {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  gap: 9px;
  align-items: center;
  padding-top: 5px;
}

.toast {
  position: fixed;
  z-index: 100;
  right: 24px;
  bottom: 24px;
  transform: translateY(20px);
  visibility: hidden;
  padding: 12px 16px;
  border-radius: 9px;
  color: white;
  background: var(--ink);
  box-shadow: var(--shadow);
  font-size: 0.78rem;
  font-weight: 700;
  opacity: 0;
  transition: 180ms ease;
}

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

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
}

[hidden] {
  display: none !important;
}

@media (max-width: 940px) {
  .idea-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .dialog-image {
    min-height: 260px;
    height: min(42vh, 460px);
  }

  .idea-dialog {
    overflow-y: auto;
  }

  .dialog-canvas img {
    max-height: min(39vh, 430px);
  }
}

@media (max-width: 640px) {
  .topbar {
    min-height: 64px;
    padding: 0 18px;
  }

  .top-actions .quiet-button {
    display: none;
  }

  .top-actions .primary-button {
    min-height: 38px;
    padding: 0 14px;
  }

  .hero {
    padding: 64px 18px 60px;
  }

  .hero h1 {
    font-size: clamp(3.3rem, 16vw, 5.2rem);
  }

  .workspace {
    padding: 0 18px 64px;
  }

  .dashboard {
    grid-template-columns: repeat(3, 1fr);
  }

  .stat {
    padding: 17px 0;
  }

  .stat + .stat {
    padding-left: 12px;
  }

  .stat-value {
    font-size: 2rem;
  }

  .stat-label {
    font-size: 0.62rem;
  }

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

  .select-wrap {
    display: none;
  }

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

  .idea-image {
    aspect-ratio: 16 / 8;
  }

  footer {
    align-items: flex-start;
    flex-direction: column;
    padding: 24px 18px;
  }

  .idea-dialog {
    width: calc(100vw - 18px);
    max-height: calc(100vh - 18px);
  }

  .dialog-image {
    min-height: 220px;
  }

  .dialog-content {
    padding: 32px 22px;
  }

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

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

  .edit-actions > span {
    display: none;
  }

  .edit-actions .danger-text {
    grid-column: 1 / -1;
    justify-self: start;
  }
}

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