:root {
  --page: #fbfaf7;
  --paper: #fffefa;
  --paper-soft: #f7f3ec;
  --paper-warm: #f2eee6;
  --line: #e4ded5;
  --line-strong: #d7cec2;
  --ink: #2f2b27;
  --ink-soft: #514b45;
  --muted: #787068;
  --faint: #a69d92;
  --accent: #3f3a34;
  --accent-soft: #ece6dc;
  --success-bg: #eef5ee;
  --success-ink: #3d6044;
  --warn-bg: #fbefed;
  --warn-ink: #7b3b34;
  --danger: #c73b32;
  --shadow: 0 18px 45px rgba(58, 48, 38, .08);
  --radius: 8px;
  --serif: Georgia, "Times New Roman", Times, serif;
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--page);
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    linear-gradient(180deg, rgba(242, 238, 230, .62), rgba(251, 250, 247, 0) 360px),
    var(--page);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.55;
  letter-spacing: 0;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  font: inherit;
  cursor: pointer;
}

a {
  color: var(--ink);
  text-decoration-color: rgba(47, 43, 39, .35);
  text-underline-offset: 3px;
  transition: color .15s ease, text-decoration-color .15s ease;
}

a:hover {
  color: #111;
  text-decoration-color: currentColor;
}

.hidden {
  display: none !important;
}

.notion-shell {
  width: min(1260px, calc(100% - 32px));
  margin: 0 auto;
  padding: 34px 0 32px;
}

.page-hero {
  max-width: none;
  margin: 0 auto 26px;
  text-align: center;
}

#app-title {
  max-width: none;
  margin: 0 auto 10px;
  color: var(--ink);
  font-family: var(--serif);
  font-size: clamp(1.18rem, 2.1vw, 2.08rem);
  font-weight: 500;
  line-height: 1;
  letter-spacing: 0;
  white-space: nowrap;
}

.title-home {
  display: inline-block;
  color: inherit;
  text-decoration: none;
}

.title-home:hover #app-title,
.title-home:focus-visible #app-title {
  color: #111;
}

#app-subtitle {
  max-width: 650px;
  margin: 0 auto;
  color: var(--muted);
  font-size: .98rem;
}

.articulation-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 254, 250, .7);
  padding: 6px;
  box-shadow: 0 1px 2px rgba(58, 48, 38, .04);
}

.articulation-toggle {
  display: flex;
  width: 100%;
  min-height: 38px;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted);
  padding: 8px 9px;
  text-align: left;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  transition: background .15s ease, color .15s ease;
}

.articulation-toggle:hover {
  background: var(--paper-soft);
  color: var(--ink);
}

.articulation-chevron {
  color: var(--faint);
  transition: transform .16s ease;
}

.articulation-panel.is-collapsed .articulation-chevron {
  transform: rotate(-90deg);
}

.articulation-list {
  display: grid;
  gap: 4px;
  padding: 4px 0 2px;
}

.articulation-list[hidden] {
  display: none;
}

.joint-btn {
  display: inline-flex;
  width: 100%;
  min-height: 40px;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: var(--ink-soft);
  padding: 9px;
  font-size: .92rem;
  font-weight: 600;
  text-align: left;
  transition: background .15s ease, color .15s ease;
}

.joint-btn:hover {
  background: var(--paper-soft);
  color: var(--ink);
}

.joint-btn.is-active {
  background: var(--accent-soft);
  color: var(--ink);
}

.articulation-item[data-joint="sources"] {
  margin-top: 4px;
  border-top: 1px solid var(--line);
  border-radius: 0 0 var(--radius) var(--radius);
  padding-top: 12px;
}

.notice-trigger-wrap {
  display: flex;
  justify-content: center;
  margin: 0 auto 34px;
}

.notice-trigger {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  color: var(--ink);
  padding: 8px 12px;
  font-size: .9rem;
  font-weight: 650;
  box-shadow: 0 1px 2px rgba(58, 48, 38, .05);
  transition: background .15s ease, border-color .15s ease;
}

.notice-trigger:hover {
  border-color: var(--line-strong);
  background: var(--paper-soft);
}

.notice-trigger-icon,
.notice-popover-icon {
  color: var(--danger);
}

.notice-popover {
  width: min(580px, calc(100vw - 32px));
  max-height: min(80vh, 680px);
  margin: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  color: var(--ink);
  padding: 0;
  box-shadow: 0 28px 80px rgba(58, 48, 38, .22);
  overflow: auto;
}

.notice-popover::backdrop {
  background: rgba(47, 43, 39, .24);
  backdrop-filter: blur(3px);
}

.notice-popover-head {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--line);
  background: rgba(247, 243, 236, .58);
  padding: 15px 16px;
}

.notice-popover-icon {
  display: inline-grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border-radius: var(--radius);
  background: var(--warn-bg);
}

.notice-close {
  display: inline-grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted);
}

.notice-close:hover {
  background: var(--paper-warm);
  color: var(--ink);
}

.notice-popover-body {
  padding: 18px;
}

.notice-popover h2,
.sidebar-title,
.eyebrow {
  margin: 0;
  color: var(--muted);
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.notice-popover p {
  margin: 0;
  color: var(--ink-soft);
  font-size: .94rem;
}

.notice-popover p + p {
  margin-top: 12px;
}

.red-flags {
  border-radius: var(--radius);
  background: var(--warn-bg);
  color: var(--warn-ink) !important;
  padding: 12px 14px;
}

.workspace-layout {
  display: grid;
  grid-template-columns: minmax(340px, 410px) minmax(0, 1fr);
  gap: 24px;
  align-items: stretch;
}

.workspace-side-stack {
  position: sticky;
  top: 20px;
  align-self: start;
  display: grid;
  gap: 14px;
}

.workspace-sidebar {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 254, 250, .7);
  padding: 14px;
}

.sidebar-title {
  padding: 4px 4px 12px;
}

.sidebar-list {
  display: grid;
  gap: 4px;
  overflow-x: hidden;
  overflow-y: visible;
  padding-right: 2px;
}

.nav-row,
.category-btn {
  width: 100%;
  min-height: 40px;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: var(--ink-soft);
  padding: 9px 9px;
  text-align: left;
}

.nav-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.nav-row-main {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 9px;
}

.nav-row-title {
  overflow: visible;
  color: inherit;
  font-size: .9rem;
  font-weight: 500;
  line-height: 1.28;
  text-overflow: clip;
  white-space: normal;
}

.nav-chevron {
  margin-top: 2px;
}

.nav-row:hover,
.category-btn:hover {
  background: var(--paper-soft);
  color: var(--ink);
}

.nav-row.is-active,
.category-btn.is-active {
  background: var(--accent-soft);
  color: var(--ink);
}

.nav-chevron {
  flex: 0 0 auto;
  color: var(--faint);
}

.workspace-document {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.empty-state,
.document-section,
.detail-card,
.source-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  box-shadow: 0 1px 2px rgba(58, 48, 38, .04);
}

.empty-state {
  min-height: 100%;
  flex: 1;
  display: grid;
  place-items: center;
  padding: 54px;
  text-align: center;
}

.empty-icon {
  display: inline-grid;
  width: 58px;
  height: 58px;
  margin: 0 auto 16px;
  place-items: center;
  border-radius: var(--radius);
  background: var(--paper-soft);
  color: var(--faint);
}

.empty-state p {
  margin: 0;
}

#empty-title {
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1.55rem;
}

#empty-copy {
  max-width: 420px;
  margin-top: 6px;
  color: var(--muted);
  font-size: .94rem;
}

.content-stack {
  display: grid;
  gap: 18px;
}

.document-section {
  overflow: hidden;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border-bottom: 1px solid var(--line);
  background: rgba(247, 243, 236, .55);
  padding: 18px 20px;
}

.section-header h3 {
  margin: 0;
  color: var(--ink);
  font-family: var(--serif);
  font-size: clamp(1.35rem, 2.8vw, 2.35rem);
  font-weight: 500;
  line-height: 1.08;
  letter-spacing: 0;
}

#reset-btn {
  display: inline-grid;
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted);
}

#reset-btn:hover {
  background: var(--paper-warm);
  color: var(--ink);
}

.hypothesis-grid,
.sources-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  padding: 14px;
}

.hypothesis-card,
.hypo-btn {
  appearance: none;
  display: block;
  width: 100%;
  min-height: 112px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 254, 250, .78);
  color: var(--ink);
  padding: 14px;
  text-align: left;
  transition: background .15s ease, border-color .15s ease;
}

.hypothesis-card:hover,
.hypo-btn:hover,
.hypothesis-card.is-active,
.hypo-btn.is-active {
  border-color: var(--line-strong);
  background: var(--paper-soft);
}

.hypothesis-card h4 {
  margin: 0;
  color: var(--ink);
  font-size: .98rem;
  font-weight: 650;
  line-height: 1.32;
}

.hypothesis-card p {
  display: -webkit-box;
  margin: 8px 0 0;
  overflow: hidden;
  color: var(--muted);
  font-size: .84rem;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.detail-card {
  overflow: hidden;
}

.detail-head {
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--line);
  background: var(--paper);
  padding: 18px 20px;
}

.detail-head h3 {
  margin: 0;
  color: var(--ink);
  font-family: var(--serif);
  font-size: clamp(1.45rem, 3vw, 2.5rem);
  font-weight: 500;
  line-height: 1.05;
}

.detail-body {
  display: grid;
  gap: 22px;
  padding: 20px;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.detail-block {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(247, 243, 236, .42);
  padding: 14px;
}

.section-label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: .72rem;
  font-weight: 750;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.detail-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.detail-list li {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  color: var(--ink-soft);
  font-size: .9rem;
}

.detail-dot {
  width: 5px;
  height: 5px;
  margin-top: 10px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--faint);
}

.interpretation-box {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper-soft);
  padding: 16px;
}

.quote {
  margin: 0 0 12px;
  color: var(--muted);
  font-family: var(--serif);
  font-size: 1.15rem;
  font-style: italic;
}

.interpretation {
  margin: 0;
  color: var(--ink-soft);
  font-size: .94rem;
}

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

.management-item {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  border-radius: var(--radius);
  background: var(--success-bg);
  color: var(--success-ink);
  padding: 10px 11px;
  font-size: .88rem;
}

.management-dot {
  width: 5px;
  height: 5px;
  margin-top: 10px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: currentColor;
}

.source-card {
  padding: 16px;
}

.source-card-head {
  display: flex;
  align-items: center;
  gap: 9px;
}

.source-card-title {
  margin: 0;
  font-family: var(--serif);
  font-size: 1.35rem;
  font-weight: 500;
}

.source-card-copy {
  margin: 8px 0 14px;
  color: var(--muted);
  font-size: .9rem;
}

.source-list {
  display: grid;
  gap: 0;
  margin: 0;
  padding: 0;
  list-style: none;
}

.source-item {
  border-top: 1px solid var(--line);
  padding: 12px 0;
}

.source-item:first-child {
  border-top: 0;
  padding-top: 0;
}

.source-item:last-child {
  padding-bottom: 0;
}

.source-link {
  font-size: .92rem;
  font-weight: 650;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.source-meta {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: .78rem;
}

.site-footer {
  width: min(900px, calc(100% - 32px));
  margin: 24px auto 38px;
  border-top: 1px solid var(--line);
  padding-top: 16px;
  color: var(--muted);
  text-align: center;
  font-size: .78rem;
}

.site-footer p {
  margin: 0;
}

.footer-credit {
  margin-top: 5px !important;
}

.icon-svg {
  display: inline-block;
  flex: 0 0 auto;
  width: 1em;
  height: 1em;
  stroke: currentColor;
  vertical-align: middle;
}

.icon-xs {
  width: 16px;
  height: 16px;
}

.icon-sm {
  width: 18px;
  height: 18px;
}

.icon-md {
  width: 22px;
  height: 22px;
}

.icon-lg {
  width: 30px;
  height: 30px;
}

.fade-in {
  animation: fadeIn .22s ease-out;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.custom-scrollbar {
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}

.custom-scrollbar::-webkit-scrollbar {
  width: 6px;
}

.custom-scrollbar::-webkit-scrollbar-track {
  background: transparent;
}

.custom-scrollbar::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: var(--line-strong);
}

.joint-btn:focus-visible,
.articulation-toggle:focus-visible,
.nav-row:focus-visible,
.category-btn:focus-visible,
.hypothesis-card:focus-visible,
.hypo-btn:focus-visible,
#reset-btn:focus-visible,
.title-home:focus-visible,
a:focus-visible {
  outline: 2px solid rgba(63, 58, 52, .28);
  outline-offset: 2px;
}

@media (max-width: 900px) {
  .notion-shell {
    width: min(100% - 28px, 720px);
    padding-top: 34px;
  }

  .workspace-layout {
    grid-template-columns: 1fr;
    gap: 18px;
  }

  .workspace-side-stack {
    position: static;
  }

  .sidebar-list {
    max-height: none;
    overflow-y: visible;
  }

  .notice-trigger-wrap {
    margin-bottom: 24px;
  }
}

@media (max-width: 640px) {
  body {
    font-size: 15px;
  }

  .notion-shell {
    width: min(100% - 22px, 540px);
    padding-top: 28px;
  }

  #app-title {
    font-size: clamp(1rem, 6.5vw, 1.68rem);
    white-space: normal;
  }

  .notice-trigger,
  .notice-popover,
  .articulation-panel,
  .workspace-sidebar,
  .empty-state,
  .document-section,
  .detail-card,
  .source-card {
    border-radius: 7px;
  }

  .empty-state {
    min-height: 300px;
    flex: initial;
    padding: 34px 20px;
  }

  .hypothesis-grid,
  .sources-grid,
  .detail-grid,
  .management-grid {
    grid-template-columns: 1fr;
  }

  .section-header,
  .detail-head,
  .detail-body {
    padding: 16px;
  }
}
