:root {
  color-scheme: light;
  --ink: #18202b;
  --ink-soft: #68707a;
  --paper: #fbfaf4;
  --paper-2: #eff3ed;
  --panel: rgba(255, 255, 252, 0.9);
  --line: rgba(24, 32, 43, 0.13);
  --rule: rgba(24, 32, 43, 0.16);
  --accent: #c94f3d;
  --accent-2: #2f7669;
  --accent-3: #d9a441;
  --accent-4: #2e5f9e;
  --good: #2f7669;
  --danger: #a74337;
  --shadow: 0 18px 42px rgba(24, 32, 43, 0.1);
  --radius-xl: 12px;
  --radius-lg: 8px;
  --radius-md: 6px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: "Manrope", "Avenir Next", "Segoe UI", sans-serif;
  background:
    linear-gradient(90deg, rgba(24, 32, 43, 0.035) 1px, transparent 1px),
    linear-gradient(180deg, rgba(24, 32, 43, 0.03) 1px, transparent 1px),
    linear-gradient(155deg, var(--paper), var(--paper-2));
  background-size: 24px 24px, 24px 24px, auto;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image: linear-gradient(rgba(255, 255, 255, 0.45), rgba(255, 255, 255, 0.1));
}

button,
input,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
}

[hidden] {
  display: none !important;
}

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

textarea {
  resize: vertical;
}

.app-shell {
  width: min(1840px, 100% - 14px);
  margin: 10px auto 32px;
  position: relative;
  z-index: 1;
}

.hero {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 14px;
  border-radius: var(--radius-xl);
  background: rgba(255, 255, 252, 0.74);
  border: 1px solid var(--line);
  box-shadow: none;
  padding: 12px 16px;
  margin-bottom: 8px;
  animation: rise 460ms ease;
}

.eyebrow {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.19em;
  font-size: 0.72rem;
  color: var(--accent-2);
  font-weight: 700;
}

h1,
h2,
h3 {
  margin: 0;
  font-family: "Spectral", "Iowan Old Style", serif;
}

h1 {
  margin-top: 4px;
  font-size: 1.9rem;
  line-height: 1.08;
}

h2 {
  font-size: clamp(1.35rem, 2vw, 1.8rem);
}

h3 {
  font-size: 1.12rem;
}

.hero-copy {
  margin: 4px 0 0;
  max-width: 720px;
  color: var(--ink-soft);
  line-height: 1.45;
  font-size: 0.92rem;
}

.viewer-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  white-space: nowrap;
  border-radius: 999px;
  background: rgba(15, 118, 109, 0.1);
  color: var(--accent-2);
  padding: 6px 11px;
  font-size: 0.78rem;
  font-weight: 800;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  margin-bottom: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--line);
}

.metric-card {
  background: rgba(255, 255, 252, 0.86);
  border: 0;
  border-radius: 0;
  backdrop-filter: blur(4px);
  padding: 8px 10px;
  box-shadow: none;
  animation: rise 520ms ease;
}

.metric-label {
  margin: 0;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.62rem;
  font-weight: 700;
}

.metric-value {
  margin: 2px 0 0;
  font-size: 1.12rem;
  font-weight: 800;
  color: var(--accent-2);
}

.metric-note {
  margin: 1px 0 0;
  color: var(--ink-soft);
  font-size: 0.68rem;
  line-height: 1.4;
}

.journal-filter-panel {
  display: block;
  margin-bottom: 8px;
  overflow: hidden;
  padding: 10px 14px;
}

.journal-filter-compact {
  display: block;
}

.journal-filter-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(150px, 1fr)) auto;
  gap: 8px;
  align-items: end;
}

.filter-field {
  display: grid;
  gap: 6px;
}

.filter-field span {
  color: var(--ink-soft);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.filter-field input {
  width: 100%;
  min-height: 36px;
  border: 1px solid rgba(29, 38, 48, 0.13);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  color: var(--ink);
  padding: 7px 10px;
  outline: none;
}

.clear-filters {
  min-height: 36px;
  border-radius: 8px;
  white-space: nowrap;
}

.journal-results {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.journal-results.is-hidden {
  display: none;
}

.journal-result-card {
  display: grid;
  gap: 8px;
  border: 1px solid rgba(29, 38, 48, 0.1);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.76);
  padding: 11px 12px;
}

.journal-result-card h3 {
  font-family: "Manrope", "Avenir Next", "Segoe UI", sans-serif;
  font-size: 0.95rem;
}

.journal-result-card p,
.results-empty {
  margin: 0;
  color: var(--ink-soft);
  line-height: 1.5;
}

.inline-auto-link {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border: 1px solid rgba(15, 118, 109, 0.2);
  border-radius: 8px;
  background: rgba(15, 118, 109, 0.09);
  color: var(--accent-2);
  padding: 1px 6px;
  font-weight: 800;
  line-height: 1.35;
}

.inline-auto-link.is-date {
  border-color: rgba(217, 164, 65, 0.28);
  background: rgba(217, 164, 65, 0.14);
  color: #7a5312;
}

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

.result-meta-row span {
  display: grid;
  gap: 2px;
  min-width: 0;
  border-radius: 8px;
  background: rgba(15, 118, 109, 0.08);
  color: var(--ink);
  padding: 7px 8px;
  overflow-wrap: anywhere;
}

.result-meta-row strong {
  color: var(--accent-2);
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  position: relative;
}

.side-stack {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(300px, 0.85fr);
  gap: 10px;
  width: 100%;
}

.panel {
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--panel);
  backdrop-filter: blur(5px);
  box-shadow: 0 10px 26px rgba(24, 32, 43, 0.08);
  padding: 14px;
  animation: rise 600ms ease;
}

.link-hint,
.subhead,
.status,
.reward-status,
.footnote {
  color: var(--ink-soft);
}

.link-hint,
.subhead {
  margin: 8px 0 0;
  line-height: 1.55;
}

.linked-panel,
.map-panel {
  display: grid;
  gap: 10px;
  overflow: hidden;
}

.thread-search {
  display: grid;
  gap: 6px;
}

.thread-search span {
  color: var(--ink-soft);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.thread-search input {
  width: 100%;
  min-height: 40px;
  border: 1px solid rgba(29, 38, 48, 0.13);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  color: var(--ink);
  padding: 9px 11px;
  outline: none;
}

.thread-search input:focus {
  border-color: rgba(15, 118, 109, 0.45);
  box-shadow: 0 0 0 4px rgba(15, 118, 109, 0.09);
}

.linked-words,
.map {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  max-height: 150px;
  overflow: auto;
  padding-right: 4px;
}

.link-pill,
.map-node,
.secondary,
.month-nav,
.ghost,
.primary {
  transition:
    transform 180ms ease,
    border-color 180ms ease,
    background 180ms ease,
    box-shadow 180ms ease;
}

.link-pill,
.map-node {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid rgba(29, 38, 48, 0.14);
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink);
  font-weight: 700;
  box-shadow: 0 8px 18px rgba(25, 30, 37, 0.06);
}

.link-pill.active,
.map-node.active {
  border-color: rgba(15, 118, 109, 0.28);
  background: linear-gradient(135deg, rgba(15, 118, 109, 0.14), rgba(241, 179, 79, 0.18));
  box-shadow: 0 14px 26px rgba(15, 118, 109, 0.12);
}

.link-pill:hover,
.map-node:hover,
.secondary:hover,
.month-nav:hover,
.ghost:hover,
.primary:hover {
  transform: translateY(-1px);
}

.pill-count {
  display: inline-grid;
  place-items: center;
  min-width: 28px;
  height: 28px;
  padding: 0 8px;
  border-radius: 999px;
  background: rgba(15, 118, 109, 0.1);
  color: var(--accent-2);
  font-size: 0.82rem;
}

.linked-preview,
.versions,
.map-surface {
  border-radius: var(--radius-lg);
  border: 1px solid rgba(29, 38, 48, 0.1);
  background: rgba(255, 255, 255, 0.74);
  padding: 14px;
}

.transclusion-header,
.day-sheet-header,
.calendar-header,
.backlink-header,
.calendar-controls,
.day-sheet-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.badge,
.meta-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(15, 118, 109, 0.1);
  color: var(--accent-2);
  font-size: 0.82rem;
  font-weight: 700;
}

.transclusion-text,
.note-desc,
.backlink-empty,
.versions-empty {
  margin: 12px 0 0;
  line-height: 1.6;
  color: var(--ink-soft);
}

.backlinks,
.versions {
  margin-top: 14px;
}

.backlinks-title {
  margin: 0 0 10px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.72rem;
  color: var(--ink-soft);
  font-weight: 700;
}

#backlinks-list,
#versions-list,
.backlink-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 8px;
}

.backlink-button,
.version-chip {
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(29, 38, 48, 0.1);
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink);
}

.backlink-button strong,
.version-chip strong {
  display: block;
}

.backlink-button span,
.version-chip span {
  display: block;
  margin-top: 4px;
  color: var(--ink-soft);
  font-size: 0.84rem;
}

.map {
  position: relative;
  min-height: 92px;
  align-items: center;
}

.map::before {
  display: none;
}

.map-node {
  position: relative;
  z-index: 1;
}

.calendar-panel {
  min-height: 100%;
  padding: 14px 16px 18px;
  background:
    linear-gradient(90deg, rgba(46, 95, 158, 0.08) 0 3px, transparent 3px 100%),
    rgba(255, 255, 252, 0.94);
}

.week-board-head,
.week-row {
  display: grid;
  grid-template-columns: 86px minmax(0, 1fr) minmax(180px, 250px);
  gap: 12px;
}

.week-board-head {
  margin-top: 10px;
  padding: 0 10px;
  color: #1b2c44;
  font-family: "Spectral", "Iowan Old Style", serif;
  font-size: 0.98rem;
  font-weight: 600;
}

.calendar-grid {
  margin-top: 8px;
  display: grid;
  gap: 8px;
}

.week-row {
  align-items: stretch;
  min-height: clamp(166px, 18vh, 230px);
}

.week-label {
  display: grid;
  place-items: center;
  color: var(--accent-4);
  font-family: "Spectral", "Iowan Old Style", serif;
  font-size: 1.22rem;
  font-weight: 600;
}

.week-cell {
  position: relative;
  border: 1px solid rgba(24, 32, 43, 0.28);
  border-radius: 8px;
  background:
    repeating-linear-gradient(
      180deg,
      rgba(255, 255, 252, 0.92) 0,
      rgba(255, 255, 252, 0.92) 30px,
      var(--rule) 31px
    );
  box-shadow: 3px 4px 0 rgba(24, 32, 43, 0.06);
  overflow: hidden;
}

.week-cell.is-locked {
  opacity: 0.66;
  background:
    repeating-linear-gradient(
      180deg,
      rgba(246, 247, 243, 0.82) 0,
      rgba(246, 247, 243, 0.82) 30px,
      rgba(24, 32, 43, 0.09) 31px
    );
}

.week-textarea {
  width: 100%;
  height: 100%;
  min-height: clamp(166px, 18vh, 230px);
  border: 0;
  border-radius: 0;
  padding: 28px 14px 14px;
  color: var(--ink);
  background: transparent;
  line-height: 1.55;
}

.week-textarea:disabled {
  color: rgba(30, 34, 40, 0.45);
}

.week-cell-label {
  position: absolute;
  top: 7px;
  right: 11px;
  color: rgba(24, 32, 43, 0.56);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  pointer-events: none;
}

.week-lock-note {
  position: absolute;
  inset: auto 12px 10px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 700;
  pointer-events: none;
}

.day-sheet {
  display: none;
  margin-top: 18px;
  border-top: 1px solid rgba(29, 38, 48, 0.1);
  padding-top: 18px;
}

.day-sheet[aria-expanded="false"] {
  opacity: 0.82;
}

.day-sheet[aria-expanded="false"] .notes-grid,
.day-sheet[aria-expanded="false"] .week-planner,
.day-sheet[aria-expanded="false"] .day-sheet-actions,
.day-sheet[aria-expanded="false"] .reward-status,
.day-sheet[aria-expanded="false"] .versions {
  display: none;
}

.week-planner {
  margin-top: 16px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 340px);
  gap: 12px;
  align-items: stretch;
}

.week-main,
.week-objective {
  border: 2px solid rgba(27, 44, 68, 0.72);
  border-radius: 8px;
  background:
    repeating-linear-gradient(
      180deg,
      rgba(255, 255, 255, 0.92) 0,
      rgba(255, 255, 255, 0.92) 34px,
      rgba(27, 44, 68, 0.12) 35px
    );
  box-shadow: 4px 6px 0 rgba(27, 44, 68, 0.08);
}

.week-main {
  position: relative;
  min-height: 440px;
  padding: 16px;
}

.week-objective {
  display: grid;
  align-content: start;
  gap: 10px;
  padding: 16px;
}

.week-section-title {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.week-section-title h3,
.week-objective h3 {
  color: #1b2c44;
}

.planner-lock {
  position: absolute;
  inset: 72px 18px 18px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  border: 1px dashed rgba(27, 44, 68, 0.45);
  background: rgba(255, 250, 242, 0.82);
  color: var(--ink-soft);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  z-index: 2;
}

.planner-lock[hidden] {
  display: none;
}

.weekday-block {
  display: grid;
  gap: 10px;
}

.weekday-block span,
.objective-grid span {
  color: #1b2c44;
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.weekday-block.is-locked {
  opacity: 0.5;
}

.weekday-block textarea,
.week-objective textarea {
  width: 100%;
  border: 0;
  border-radius: 6px;
  padding: 10px 12px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.72);
  line-height: 1.5;
}

.weekday-block textarea {
  min-height: 330px;
  font-size: 1rem;
}

.objective-grid {
  display: grid;
  gap: 10px;
}

.objective-grid label {
  display: grid;
  gap: 6px;
}

.week-objective textarea {
  min-height: 76px;
}

.weekday-block textarea:disabled {
  color: rgba(30, 34, 40, 0.44);
  background: rgba(255, 255, 255, 0.42);
}

.notes-grid {
  margin-top: 16px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.note-card {
  display: grid;
  gap: 8px;
  padding: 14px;
  border-radius: var(--radius-lg);
  border: 1px solid rgba(29, 38, 48, 0.1);
  background: rgba(255, 255, 255, 0.74);
}

.note-title {
  font-weight: 700;
}

.note-desc {
  margin: 0;
  font-size: 0.84rem;
}

.note-card textarea {
  border: 1px solid rgba(29, 38, 48, 0.12);
  border-radius: 12px;
  min-height: 100px;
  padding: 12px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.96);
}

.day-sheet-actions {
  margin-top: 14px;
}

.status,
.reward-status {
  margin: 12px 0 0;
  line-height: 1.55;
}

.secondary,
.month-nav,
.ghost,
.primary {
  padding: 10px 14px;
  border-radius: 999px;
  font-weight: 700;
}

.secondary {
  background: rgba(15, 118, 109, 0.1);
  color: var(--accent-2);
}

.month-nav {
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid rgba(29, 38, 48, 0.12);
  color: var(--ink);
}

.ghost {
  background: rgba(255, 255, 255, 0.68);
  border: 1px solid rgba(29, 38, 48, 0.12);
  color: var(--ink);
}

.primary {
  background: linear-gradient(135deg, rgba(217, 110, 44, 0.95), rgba(241, 179, 79, 0.95));
  color: #fffaf2;
  box-shadow: 0 12px 22px rgba(217, 110, 44, 0.18);
}

.secondary:hover,
.month-nav:hover,
.ghost:hover,
.primary:hover,
.backlink-button:hover,
.version-chip:hover {
  box-shadow: 0 10px 22px rgba(25, 30, 37, 0.08);
}

.backlink-view.is-hidden,
.calendar-view.is-hidden {
  display: none;
}

.backlink-list {
  margin-top: 18px;
}

.footnote {
  margin: 18px 4px 0;
  font-size: 0.9rem;
  line-height: 1.55;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 2px solid rgba(15, 118, 109, 0.55);
  outline-offset: 2px;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

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

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

  .journal-filter-grid,
  .result-meta-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .clear-filters {
    grid-column: 1 / -1;
  }

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

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

  .calendar-panel {
    padding: 14px;
  }
}

@media (max-width: 720px) {
  .app-shell {
    width: min(100% - 16px, 100%);
    margin: 16px auto 32px;
  }

  .metrics-grid,
  .notes-grid,
  .journal-filter-grid,
  .result-meta-row,
  .week-planner {
    grid-template-columns: 1fr;
  }

  .journal-filter-panel {
    padding: 8px;
  }

  .journal-filter-grid {
    grid-template-columns: minmax(0, 0.9fr) minmax(0, 1fr) minmax(0, 0.9fr) 34px;
    gap: 6px;
  }

  .filter-field {
    gap: 3px;
  }

  .filter-field span {
    font-size: 0.56rem;
    letter-spacing: 0.08em;
  }

  .filter-field input {
    min-height: 32px;
    padding: 5px 7px;
    font-size: 0.82rem;
  }

  .journal-filter-grid .clear-filters {
    grid-column: auto;
    width: 34px;
    min-width: 34px;
    min-height: 32px;
    padding: 0;
    font-size: 0;
  }

  .journal-filter-grid .clear-filters::before {
    content: "X";
    font-size: 0.78rem;
    font-weight: 900;
  }

  .hero {
    display: grid;
  }

  .week-board-head {
    display: none;
  }

  .week-row {
    grid-template-columns: 1fr;
    gap: 8px;
    min-height: auto;
  }

  .week-label {
    place-items: start;
    font-size: 1.25rem;
    padding-left: 4px;
  }

  .week-main {
    min-height: 360px;
  }

  .weekday-block textarea {
    min-height: 260px;
  }

  .week-textarea {
    min-height: 140px;
  }

  .hero {
    padding: 14px;
  }

  h1 {
    font-size: 1.8rem;
  }
}

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