:root {
  color-scheme: dark;
  --bg: #100f0e;
  --bg-soft: #171513;
  --panel: rgba(28, 25, 22, 0.94);
  --paper: #e8e0d2;
  --muted: #aaa196;
  --dim: #756e67;
  --line: rgba(232, 224, 210, 0.13);
  --accent: #c99b63;
  --accent-bright: #e4bd86;
  --accent-deep: #6a4930;
  --danger: #db8c82;
  --success: #9abea1;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.38);
  --serif: Iowan Old Style, Baskerville, "Times New Roman", serif;
  --sans: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: 6.5rem;
}

body {
  min-width: 320px;
  margin: 0;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 16% 4%, rgba(108, 73, 47, 0.17), transparent 32rem),
    linear-gradient(180deg, #12110f 0%, var(--bg) 42%, #0d0c0b 100%);
  color: var(--paper);
  font-family: var(--sans);
  line-height: 1.6;
}

body.panel-open {
  overflow: hidden;
}

button,
input,
textarea {
  font: inherit;
}

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

a {
  color: inherit;
  text-decoration: none;
}

button {
  color: inherit;
}

:focus-visible {
  outline: 2px solid var(--accent-bright);
  outline-offset: 4px;
}

.skip-link,
.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;
}

.skip-link:focus {
  z-index: 100;
  top: 1rem;
  left: 1rem;
  width: auto;
  height: auto;
  padding: 0.7rem 1rem;
  clip: auto;
  background: var(--paper);
  color: var(--bg);
}

.ambient {
  position: fixed;
  z-index: -1;
  border-radius: 50%;
  filter: blur(70px);
  pointer-events: none;
}

.ambient-one {
  top: 10rem;
  right: -12rem;
  width: 30rem;
  height: 30rem;
  background: rgba(113, 70, 43, 0.09);
}

.ambient-two {
  bottom: 5rem;
  left: -9rem;
  width: 24rem;
  height: 24rem;
  background: rgba(184, 136, 79, 0.05);
}

.site-header {
  position: sticky;
  z-index: 20;
  top: 0;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 2rem;
  min-height: 5.25rem;
  padding: 0.8rem clamp(1.25rem, 4vw, 4.5rem);
  border-bottom: 1px solid var(--line);
  background: rgba(16, 15, 14, 0.83);
  backdrop-filter: blur(18px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.8rem;
  width: fit-content;
}

.brand-mark {
  display: grid;
  width: 2.35rem;
  height: 2.35rem;
  place-items: center;
  border: 1px solid rgba(228, 189, 134, 0.56);
  border-radius: 50%;
  color: var(--accent-bright);
  font-family: var(--serif);
  font-size: 1.2rem;
  font-style: italic;
}

.brand-mark.large {
  width: 3.5rem;
  height: 3.5rem;
  margin-bottom: 2.4rem;
  font-size: 1.7rem;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-family: var(--serif);
  font-size: 1.18rem;
  font-weight: 500;
  letter-spacing: 0.04em;
}

.brand small {
  color: var(--dim);
  font-size: 0.61rem;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.main-nav {
  display: flex;
  gap: 2.2rem;
  color: var(--muted);
  font-size: 0.82rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.main-nav a {
  position: relative;
  padding: 0.4rem 0;
}

.main-nav a::after {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  height: 1px;
  background: var(--accent);
  content: "";
  opacity: 0;
  transform: scaleX(0.35);
  transition: 180ms ease;
}

.main-nav a:hover,
.main-nav a[aria-current="true"] {
  color: var(--paper);
}

.main-nav a:hover::after,
.main-nav a[aria-current="true"]::after {
  opacity: 1;
  transform: scaleX(1);
}

.header-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 0.8rem;
}

.primary-button,
.secondary-button,
.text-button,
.icon-button,
.story-open,
.filter-button,
.chat-tabs button,
.auth-tabs button {
  border: 0;
  cursor: pointer;
}

.primary-button,
.secondary-button {
  display: inline-flex;
  min-height: 3rem;
  align-items: center;
  justify-content: center;
  padding: 0.7rem 1.3rem;
  border: 1px solid var(--accent);
  border-radius: 999px;
  letter-spacing: 0.02em;
  transition: transform 160ms ease, background 160ms ease, color 160ms ease;
}

.primary-button {
  background: var(--accent);
  color: #1a130e;
  font-weight: 650;
}

.secondary-button {
  background: transparent;
  color: var(--accent-bright);
}

.primary-button:hover:not(:disabled),
.secondary-button:hover:not(:disabled) {
  transform: translateY(-2px);
}

.primary-button:hover:not(:disabled) {
  background: var(--accent-bright);
}

.secondary-button:hover:not(:disabled) {
  background: rgba(201, 155, 99, 0.1);
}

.primary-button:disabled,
.secondary-button:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

.compact {
  min-height: 2.5rem;
  padding: 0.5rem 1rem;
  font-size: 0.83rem;
}

.full {
  width: 100%;
}

.text-button {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.4rem;
  background: transparent;
  color: var(--muted);
}

.text-button:hover {
  color: var(--paper);
}

.avatar {
  display: grid;
  width: 2rem;
  height: 2rem;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: rgba(201, 155, 99, 0.1);
  color: var(--accent-bright);
  font-family: var(--serif);
}

.hero {
  display: flex;
  min-height: calc(100vh - 5.25rem);
  max-width: 88rem;
  flex-direction: column;
  justify-content: center;
  margin: 0 auto;
  padding: 7rem clamp(1.5rem, 8vw, 8rem) 6rem;
}

.eyebrow {
  color: var(--accent);
  font-size: 0.7rem;
  font-weight: 650;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.hero h1,
.section-heading h2,
.about-section h2,
.auth-intro h2,
.profile-shell h2,
.reader-content h2 {
  margin: 1.2rem 0;
  font-family: var(--serif);
  font-weight: 400;
  line-height: 1.06;
}

.hero h1 {
  max-width: 62rem;
  font-size: clamp(3.4rem, 8vw, 7.4rem);
  letter-spacing: -0.04em;
}

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

.hero-copy {
  max-width: 38rem;
  margin: 1rem 0 2.2rem;
  color: var(--muted);
  font-size: clamp(1rem, 2vw, 1.18rem);
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem;
}

.hero-note {
  display: flex;
  max-width: 32rem;
  align-items: flex-start;
  gap: 0.9rem;
  margin-top: 5rem;
  padding-top: 1.4rem;
  border-top: 1px solid var(--line);
  color: var(--dim);
  font-size: 0.82rem;
}

.hero-note span {
  color: var(--accent);
}

.hero-note p {
  margin: 0;
}

.archive-section,
.about-section {
  padding: 8rem clamp(1.5rem, 8vw, 8rem);
}

.archive-section {
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.012);
}

.section-heading {
  display: grid;
  max-width: 76rem;
  grid-template-columns: minmax(0, 1.4fr) minmax(16rem, 0.6fr);
  align-items: end;
  gap: 5rem;
  margin: 0 auto 4rem;
}

.section-heading h2,
.about-section h2 {
  font-size: clamp(2.5rem, 5vw, 4.8rem);
  letter-spacing: -0.025em;
}

.section-heading p,
.about-copy {
  color: var(--muted);
}

code {
  color: var(--accent-bright);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.86em;
}

.archive-toolbar {
  display: flex;
  max-width: 76rem;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin: 0 auto 2.2rem;
}

.search-field {
  display: flex;
  width: min(100%, 26rem);
  align-items: center;
  gap: 0.7rem;
  padding: 0.7rem 1rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.1);
  color: var(--dim);
}

.search-field input {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--paper);
}

.filter-group {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.45rem;
}

.filter-button {
  padding: 0.45rem 0.75rem;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  color: var(--dim);
  font-size: 0.75rem;
  text-transform: capitalize;
}

.filter-button:hover,
.filter-button.active {
  border-color: var(--line);
  background: rgba(201, 155, 99, 0.08);
  color: var(--accent-bright);
}

.story-grid {
  display: grid;
  max-width: 76rem;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
  margin: 0 auto;
}

.story-card {
  display: flex;
  min-height: 25rem;
  flex-direction: column;
  padding: 1.6rem;
  border: 1px solid var(--line);
  border-radius: 1.1rem;
  background: linear-gradient(150deg, rgba(255, 255, 255, 0.035), rgba(255, 255, 255, 0.008));
  transition: border-color 180ms ease, transform 180ms ease, background 180ms ease;
}

.story-card:hover {
  border-color: rgba(201, 155, 99, 0.43);
  background: linear-gradient(150deg, rgba(201, 155, 99, 0.075), rgba(255, 255, 255, 0.01));
  transform: translateY(-4px);
}

.story-card-top,
.story-card-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.story-number {
  color: var(--dim);
  font-family: var(--serif);
  font-style: italic;
}

.story-mood {
  padding: 0.25rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--accent);
  font-size: 0.65rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.story-card h3 {
  margin: 4rem 0 1rem;
  font-family: var(--serif);
  font-size: 2rem;
  font-weight: 400;
  line-height: 1.1;
}

.story-card > p {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.story-card-bottom {
  margin-top: auto;
  padding-top: 2rem;
  border-top: 1px solid var(--line);
}

.story-length {
  color: var(--dim);
  font-size: 0.72rem;
}

.story-open {
  padding: 0;
  background: transparent;
  color: var(--accent-bright);
  font-size: 0.78rem;
}

.story-open span {
  display: inline-block;
  margin-left: 0.3rem;
  transition: transform 160ms ease;
}

.story-open:hover span {
  transform: translateX(4px);
}

.empty-state {
  color: var(--dim);
  text-align: center;
}

.about-section {
  max-width: 88rem;
  margin: 0 auto;
}

.quote-mark {
  height: 5rem;
  color: var(--accent-deep);
  font-family: var(--serif);
  font-size: 8rem;
  line-height: 1;
}

.about-section blockquote {
  max-width: 66rem;
  margin: 2rem 0 8rem;
  font-family: var(--serif);
  font-size: clamp(2.2rem, 5vw, 4.7rem);
  line-height: 1.12;
}

.about-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7rem;
  padding-top: 4rem;
  border-top: 1px solid var(--line);
}

.about-copy {
  max-width: 35rem;
  font-size: 1.02rem;
}

.about-copy p:first-child {
  margin-top: 0;
}

.site-footer {
  display: flex;
  justify-content: space-between;
  gap: 2rem;
  padding: 2rem clamp(1.5rem, 4vw, 4.5rem);
  border-top: 1px solid var(--line);
  color: var(--dim);
  font-size: 0.72rem;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

dialog {
  padding: 0;
  border: 0;
  color: var(--paper);
}

dialog::backdrop {
  background: rgba(5, 4, 4, 0.82);
  backdrop-filter: blur(8px);
}

.reader-dialog {
  width: 100vw;
  max-width: none;
  height: 100vh;
  max-height: none;
  margin: 0;
  background: #151310;
}

.reader-shell {
  min-height: 100%;
  background:
    radial-gradient(circle at 50% -10%, rgba(201, 155, 99, 0.1), transparent 35rem),
    #151310;
}

.reader-header {
  position: sticky;
  z-index: 2;
  top: 0;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 2rem;
  padding: 1.1rem clamp(1rem, 4vw, 3rem);
  border-bottom: 1px solid var(--line);
  background: rgba(21, 19, 16, 0.92);
  backdrop-filter: blur(16px);
}

.icon-button {
  display: grid;
  width: 2.7rem;
  height: 2.7rem;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  font-size: 1.3rem;
}

.icon-button:hover {
  border-color: var(--accent);
  color: var(--paper);
}

.reader-progress {
  height: 2px;
  overflow: hidden;
  background: var(--line);
}

.reader-progress span {
  display: block;
  width: 0;
  height: 100%;
  background: var(--accent);
}

.reader-content {
  max-width: 46rem;
  margin: 0 auto;
  padding: 8rem 2rem 12rem;
}

.reader-content h2 {
  margin-top: 1.6rem;
  font-size: clamp(3rem, 8vw, 6rem);
}

.soundtrack-card {
  margin: 5rem 0 2rem;
  overflow: hidden;
  border: 1px solid rgba(201, 155, 99, 0.3);
  border-radius: 1rem;
  background:
    linear-gradient(145deg, rgba(201, 155, 99, 0.09), transparent 52%),
    rgba(0, 0, 0, 0.18);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.22);
}

.soundtrack-card > header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.2rem 1.3rem;
  border-bottom: 1px solid var(--line);
}

.soundtrack-card h3 {
  margin: 0.35rem 0 0;
  font-family: var(--serif);
  font-size: 1.45rem;
  font-weight: 400;
  line-height: 1.2;
}

.soundtrack-card > header > span {
  padding: 0.25rem 0.55rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--dim);
  font-size: 0.62rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.youtube-player {
  width: 100%;
  min-height: 200px;
  aspect-ratio: 16 / 9;
  background: #090807;
}

.youtube-player iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
}

.soundtrack-card > p {
  margin: 0;
  padding: 0.8rem 1.3rem;
  color: var(--dim);
  font-size: 0.72rem;
}

.soundtrack-dock {
  position: fixed;
  z-index: 4;
  right: 1.25rem;
  bottom: 1.25rem;
  left: 1.25rem;
  display: flex;
  width: min(48rem, calc(100% - 2.5rem));
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin: 0 auto;
  padding: 0.75rem 0.9rem 0.75rem 1.1rem;
  border: 1px solid rgba(201, 155, 99, 0.34);
  border-radius: 1rem;
  background: rgba(25, 22, 19, 0.94);
  box-shadow: 0 14px 50px rgba(0, 0, 0, 0.46);
  backdrop-filter: blur(18px);
}

.soundtrack-dock-title {
  display: grid;
  min-width: 0;
}

.soundtrack-dock-title span {
  color: var(--accent);
  font-size: 0.58rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.soundtrack-dock-title strong {
  overflow: hidden;
  font-family: var(--serif);
  font-size: 0.92rem;
  font-weight: 400;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.soundtrack-controls,
.volume-control {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.volume-control {
  color: var(--dim);
  font-size: 0.7rem;
}

.volume-control input {
  width: 6rem;
  accent-color: var(--accent);
}

.reader-lead {
  margin: 2rem 0 4rem;
  color: var(--muted);
  font-family: var(--serif);
  font-size: 1.35rem;
  font-style: italic;
}

.reader-body {
  font-family: var(--serif);
  font-size: clamp(1.14rem, 2vw, 1.3rem);
  line-height: 1.9;
}

.reader-body p {
  margin: 0 0 var(--story-paragraph-gap, 2.8rem);
  white-space: pre-line;
}

.story-media-group:empty {
  display: none;
}

.story-figure {
  width: min(100%, 46rem);
  margin: 3.5rem 0;
}

.story-figure-cover {
  margin: 2.8rem 0 4rem;
}

.story-layout-cinematic,
.story-layout-panorama {
  position: relative;
  left: 50%;
  transform: translateX(-50%);
}

.story-layout-cinematic {
  width: min(82vw, 70rem);
  margin-top: 4.5rem;
  margin-bottom: 5rem;
}

.story-layout-panorama {
  width: min(94vw, 88rem);
  margin-top: 5rem;
  margin-bottom: 5.5rem;
}

.story-layout-inset {
  width: min(100%, 36rem);
}

.story-layout-portrait {
  width: min(100%, 29rem);
  margin-top: 4.5rem;
  margin-bottom: 4.5rem;
}

.story-layout-inset.story-align-left,
.story-layout-portrait.story-align-left {
  margin-right: auto;
  margin-left: 0;
}

.story-layout-inset.story-align-center,
.story-layout-portrait.story-align-center {
  margin-right: auto;
  margin-left: auto;
}

.story-layout-inset.story-align-right,
.story-layout-portrait.story-align-right {
  margin-right: 0;
  margin-left: auto;
}

.story-figure img {
  display: block;
  width: 100%;
  height: auto;
  max-height: none;
  aspect-ratio: auto;
  object-fit: contain;
  object-position: center;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 1rem;
  background: rgba(0, 0, 0, 0.25);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.28);
  opacity: 0.78;
  transform: scale(1.008);
  transition: opacity 500ms ease, transform 700ms cubic-bezier(0.22, 1, 0.36, 1);
}

.story-figure.image-ready img {
  opacity: 1;
  transform: none;
}

.story-focus-contain img {
  height: auto;
  max-height: none;
  aspect-ratio: auto;
  object-fit: contain;
}

.story-focus-center img {
  object-position: center;
}

.story-focus-top img {
  object-position: center top;
}

.story-focus-bottom img {
  object-position: center bottom;
}

.story-focus-left img {
  object-position: left center;
}

.story-focus-right img {
  object-position: right center;
}

.story-image-collection {
  position: relative;
  left: 50%;
  display: grid;
  width: min(90vw, 78rem);
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: start;
  gap: clamp(0.65rem, 1.5vw, 1.25rem);
  margin: 5rem 0;
  transform: translateX(-50%);
}

.story-image-collection .story-figure {
  position: static;
  left: auto;
  width: auto;
  min-width: 0;
  align-self: start;
  margin: 0;
  transform: none;
}

.story-image-collection .story-figure img {
  width: 100%;
  height: auto;
  max-height: none;
  aspect-ratio: auto;
  object-fit: contain;
}

.story-image-count-3 .story-figure:first-child {
  grid-column: 1 / -1;
  grid-row: auto;
}

.story-image-collection .story-figure figcaption {
  padding: 0 0.35rem;
  text-align: left;
}

.story-figure figcaption {
  max-width: 38rem;
  margin: 0.8rem auto 0;
  color: var(--dim);
  font-family: var(--sans);
  font-size: 0.72rem;
  line-height: 1.55;
  text-align: center;
}

.chat-panel {
  position: fixed;
  z-index: 60;
  top: 0;
  right: 0;
  display: flex;
  width: min(100%, 31rem);
  height: 100dvh;
  flex-direction: column;
  padding: 1.5rem;
  border-left: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px);
  transform: translateX(104%);
  transition: transform 260ms cubic-bezier(0.22, 1, 0.36, 1);
}

.chat-panel.open {
  transform: translateX(0);
}

.panel-backdrop {
  position: fixed;
  z-index: 50;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(3px);
}

.panel-header,
.profile-shell header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.panel-header h2,
.profile-shell h2 {
  margin: 0.35rem 0 0;
  font-family: var(--serif);
  font-size: 2.1rem;
  font-weight: 400;
}

.context-card {
  display: grid;
  gap: 0.15rem;
  margin: 1.4rem 0;
  padding: 0.9rem 1rem;
  border: 1px solid rgba(201, 155, 99, 0.26);
  border-radius: 0.8rem;
  background: rgba(201, 155, 99, 0.06);
}

.context-card span {
  color: var(--dim);
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.context-card strong {
  color: var(--accent-bright);
  font-family: var(--serif);
  font-size: 1rem;
  font-weight: 400;
}

.chat-tabs,
.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.3rem;
  padding: 0.25rem;
  border: 1px solid var(--line);
  border-radius: 0.7rem;
  background: rgba(0, 0, 0, 0.15);
}

.chat-tabs button,
.auth-tabs button {
  padding: 0.6rem;
  border-radius: 0.5rem;
  background: transparent;
  color: var(--dim);
}

.chat-tabs button.active,
.auth-tabs button.active {
  background: rgba(201, 155, 99, 0.12);
  color: var(--accent-bright);
}

.chat-view {
  display: flex;
  min-height: 0;
  flex: 1;
  flex-direction: column;
}

.message-list {
  min-height: 0;
  flex: 1;
  overflow-y: auto;
  padding: 1.1rem 0;
  scrollbar-color: var(--accent-deep) transparent;
}

.message {
  padding: 1rem 0;
  border-bottom: 1px solid var(--line);
}

.message-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  color: var(--dim);
  font-size: 0.7rem;
}

.message-author {
  color: var(--paper);
  font-weight: 650;
}

.message-context {
  display: inline-flex;
  margin: 0.55rem 0 0.35rem;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  background: rgba(201, 155, 99, 0.09);
  color: var(--accent);
  font-size: 0.66rem;
}

.message-body {
  margin: 0.3rem 0 0;
  color: #d8d0c4;
  font-size: 0.9rem;
  white-space: pre-wrap;
  word-break: break-word;
}

.message.deleted {
  opacity: 0.58;
}

.message.deleted .message-body {
  font-style: italic;
}

.moderation-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 0.7rem;
}

.moderation-actions button {
  padding: 0.35rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.7rem;
}

.message-form {
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}

.message-form label,
.auth-forms label,
.profile-shell label {
  display: grid;
  gap: 0.4rem;
  color: var(--muted);
  font-size: 0.76rem;
}

.message-form textarea,
.auth-forms input,
.profile-shell input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 0.7rem;
  outline: 0;
  background: rgba(0, 0, 0, 0.16);
  color: var(--paper);
}

.message-form textarea {
  margin-top: 0.35rem;
  padding: 0.8rem;
  resize: vertical;
}

.message-form textarea:focus,
.auth-forms input:focus,
.profile-shell input:focus {
  border-color: var(--accent);
}

.form-row,
.profile-actions,
.moderation-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.form-row {
  margin-top: 0.65rem;
  color: var(--dim);
  font-size: 0.7rem;
}

.form-status {
  min-height: 1.25rem;
  margin: 0.5rem 0 0;
  color: var(--danger);
  font-size: 0.74rem;
}

.form-status.success {
  color: var(--success);
}

.empty-state.compact {
  margin: auto;
  padding: 2rem;
  font-size: 0.84rem;
}

.moderation-toolbar {
  margin-top: 1rem;
}

.moderation-toolbar p {
  margin: 0;
  color: var(--dim);
  font-size: 0.72rem;
}

.auth-dialog {
  width: min(62rem, calc(100% - 2rem));
  max-height: calc(100dvh - 2rem);
  border: 1px solid var(--line);
  border-radius: 1.2rem;
  background: #191714;
  box-shadow: var(--shadow);
}

.auth-shell {
  display: grid;
  min-height: 36rem;
  grid-template-columns: 0.9fr 1.1fr;
}

.auth-intro,
.auth-forms {
  padding: clamp(1.5rem, 5vw, 3.5rem);
}

.auth-intro {
  border-right: 1px solid var(--line);
  background:
    linear-gradient(150deg, rgba(201, 155, 99, 0.08), transparent 55%),
    rgba(0, 0, 0, 0.12);
}

.auth-intro h2 {
  font-size: clamp(2.5rem, 5vw, 4rem);
}

.auth-intro p {
  color: var(--muted);
  font-size: 0.9rem;
}

.auth-forms {
  overflow-y: auto;
}

.auth-tabs {
  margin-bottom: 1.4rem;
}

.auth-forms form,
.profile-shell {
  display: grid;
  gap: 1rem;
}

.auth-forms input,
.profile-shell input {
  padding: 0.7rem 0.8rem;
}

.auth-forms small {
  color: var(--dim);
  font-size: 0.65rem;
}

.profile-dialog {
  width: min(30rem, calc(100% - 2rem));
  border: 1px solid var(--line);
  border-radius: 1rem;
  background: #191714;
  box-shadow: var(--shadow);
}

.profile-shell {
  padding: 1.5rem;
}

.profile-shell header {
  margin-bottom: 1rem;
}

.profile-shell input:disabled {
  color: var(--dim);
}

.danger-text {
  color: var(--danger);
}

.studio-dialog {
  width: min(94rem, 100%);
  max-width: none;
  height: min(58rem, 100dvh);
  max-height: 100dvh;
  border: 1px solid var(--line);
  border-radius: 1.1rem;
  background: #151310;
  box-shadow: var(--shadow);
}

.studio-shell {
  display: flex;
  height: 100%;
  flex-direction: column;
}

.studio-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 2rem;
  padding: 1.5rem 1.7rem;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.012);
}

.studio-header h2 {
  margin: 0.25rem 0 0;
  font-family: var(--serif);
  font-size: clamp(2rem, 4vw, 3rem);
  font-weight: 400;
  line-height: 1.1;
}

.studio-header p {
  max-width: 48rem;
  margin: 0.55rem 0 0;
  color: var(--muted);
  font-size: 0.84rem;
}

.studio-layout {
  display: grid;
  min-height: 0;
  flex: 1;
  grid-template-columns: 18rem minmax(0, 1fr);
}

.studio-sidebar {
  min-height: 0;
  overflow-y: auto;
  padding: 1rem;
  border-right: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.12);
}

.studio-story-list {
  display: grid;
  gap: 0.35rem;
  margin-top: 1rem;
}

.studio-story-item {
  display: grid;
  gap: 0.2rem;
  width: 100%;
  padding: 0.8rem;
  border: 1px solid transparent;
  border-radius: 0.7rem;
  background: transparent;
  color: var(--paper);
  cursor: pointer;
  text-align: left;
}

.studio-story-item:hover,
.studio-story-item.active {
  border-color: var(--line);
  background: rgba(201, 155, 99, 0.08);
}

.studio-story-item strong {
  overflow: hidden;
  font-family: var(--serif);
  font-size: 1rem;
  font-weight: 400;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.studio-story-item span {
  color: var(--dim);
  font-size: 0.68rem;
}

.story-editor {
  min-height: 0;
  overflow-y: auto;
  padding: clamp(1.2rem, 4vw, 2.5rem);
  scrollbar-color: var(--accent-deep) transparent;
}

.story-editor-heading,
.story-editor-actions,
.editor-publish-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.editor-kicker,
.reading-estimate,
.publish-help {
  color: var(--dim);
  font-size: 0.7rem;
}

.story-editor-heading h3 {
  margin: 0.2rem 0 0;
  font-family: var(--serif);
  font-size: 2rem;
  font-weight: 400;
  line-height: 1.1;
}

.editor-fields-row {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(11rem, 0.7fr);
  gap: 1rem;
  margin: 2rem 0 1rem;
}

.story-editor label,
.optional-fields-content label {
  display: grid;
  gap: 0.4rem;
  color: var(--muted);
  font-size: 0.76rem;
}

.story-editor input:not([type]),
.story-editor input[type="text"],
.story-editor textarea {
  width: 100%;
  padding: 0.78rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: 0.7rem;
  outline: 0;
  background: rgba(0, 0, 0, 0.18);
  color: var(--paper);
}

.story-editor input:focus,
.story-editor textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(201, 155, 99, 0.08);
}

.body-field {
  position: relative;
}

.body-field textarea {
  min-height: 27rem;
  resize: vertical;
  font-family: var(--serif);
  font-size: 1.12rem;
  line-height: 1.75;
  tab-size: 2;
}

.body-field small {
  color: var(--dim);
  font-size: 0.68rem;
}

.writing-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.2rem;
}

.writing-toolbar button {
  padding: 0.35rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--accent-bright);
  cursor: pointer;
  font-size: 0.7rem;
}

.writing-toolbar button:hover {
  background: rgba(201, 155, 99, 0.1);
}

.optional-fields {
  margin: 1.5rem 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.optional-fields summary {
  padding: 1rem 0;
  color: var(--accent-bright);
  cursor: pointer;
  font-size: 0.8rem;
}

.optional-fields summary span {
  color: var(--dim);
}

.optional-fields-content {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  padding-bottom: 1rem;
}

.optional-fields textarea {
  resize: vertical;
}

.media-editor-section {
  display: grid;
  grid-template-columns: minmax(12rem, 0.65fr) minmax(0, 1.35fr);
  gap: 1.5rem;
  margin-top: 1.5rem;
  padding: 1.2rem;
  border: 1px solid rgba(201, 155, 99, 0.25);
  border-radius: 0.8rem;
  background: rgba(201, 155, 99, 0.045);
}

.media-editor-section h4 {
  margin: 0.3rem 0;
  color: var(--paper);
  font-family: var(--serif);
  font-size: 1.25rem;
  font-weight: 400;
}

.media-editor-section p {
  margin: 0;
  color: var(--dim);
  font-size: 0.7rem;
}

.media-editor-fields {
  display: grid;
  gap: 0.8rem;
}

.image-editor-section {
  grid-column: 1 / -1;
  padding-top: 1.3rem;
  border-top: 1px solid var(--line);
}

.image-editor-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.image-editor-heading > span {
  padding: 0.28rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--dim);
  font-size: 0.66rem;
  white-space: nowrap;
}

.github-image-guide {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.75rem 1.2rem;
  margin-top: 1rem;
  padding: 1rem 1.1rem;
  border: 1px solid rgba(201, 155, 99, 0.38);
  border-radius: 0.9rem;
  background: rgba(201, 155, 99, 0.07);
}

.github-image-guide ol {
  display: grid;
  gap: 0.38rem;
  margin: 0;
  padding-left: 1.25rem;
  color: var(--dim);
  font-size: 0.74rem;
  line-height: 1.55;
}

.github-image-guide code {
  color: var(--paper);
}

.github-upload-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.7rem;
  padding: 0.7rem 0.9rem;
  border: 1px solid var(--accent);
  border-radius: 999px;
  color: var(--paper);
  font-size: 0.72rem;
  text-align: center;
  text-decoration: none;
  transition: background 160ms ease, color 160ms ease, transform 160ms ease;
}

.github-upload-link:hover,
.github-upload-link:focus-visible {
  background: var(--accent);
  color: #17120e;
  transform: translateY(-1px);
}

.github-image-guide small {
  grid-column: 1 / -1;
  color: var(--dim);
  font-size: 0.67rem;
}

.image-add-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-top: 1rem;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 0.9rem;
  background: rgba(0, 0, 0, 0.12);
}

.image-add-form.disabled {
  opacity: 0.48;
}

.image-add-form .image-path-field,
.image-add-form .image-position-field,
.image-add-form .image-focus-field {
  grid-column: 1 / -1;
}

.image-add-form select,
.image-editor-fields select {
  width: 100%;
  padding: 0.78rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: 0.7rem;
  outline: 0;
  background: #1d1a17;
  color: var(--paper);
}

.image-add-form select:focus,
.image-editor-fields select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(201, 155, 99, 0.08);
}

.image-add-form .primary-button {
  justify-self: start;
}

.image-style-note {
  display: grid;
  gap: 0.22rem;
  margin-top: 0.75rem;
  padding: 0.85rem 1rem;
  border-left: 2px solid var(--accent-deep);
  color: var(--dim);
  font-size: 0.69rem;
  line-height: 1.5;
}

.image-style-note strong {
  color: var(--accent-bright);
  font-weight: 600;
}

.image-upload-hint {
  color: var(--dim);
  font-size: 0.68rem;
  margin-top: 0.55rem !important;
}

.image-editor-list {
  display: grid;
  gap: 1rem;
  margin-top: 1.2rem;
}

.image-editor-card {
  display: grid;
  grid-template-columns: 11rem minmax(0, 1fr);
  gap: 1rem;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 0.9rem;
  background: rgba(0, 0, 0, 0.16);
}

.image-editor-preview {
  display: grid;
  align-content: start;
  gap: 0.55rem;
  min-width: 0;
}

.image-editor-preview img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: contain;
  border-radius: 0.65rem;
  background: rgba(0, 0, 0, 0.3);
  transition: aspect-ratio 180ms ease, width 180ms ease, object-position 180ms ease;
}

.image-editor-preview.preview-layout-cinematic img {
  aspect-ratio: 16 / 9;
}

.image-editor-preview.preview-layout-panorama img {
  aspect-ratio: 21 / 8;
}

.image-editor-preview.preview-layout-portrait img {
  width: 68%;
  aspect-ratio: 4 / 5;
}

.image-editor-preview.preview-layout-inset img {
  width: 82%;
}

.image-editor-preview.preview-align-center img,
.image-editor-preview.preview-align-auto img {
  margin-right: auto;
  margin-left: auto;
}

.image-editor-preview.preview-align-left img {
  margin-right: auto;
  margin-left: 0;
}

.image-editor-preview.preview-align-right img {
  margin-right: 0;
  margin-left: auto;
}

.image-editor-preview.preview-focus-contain img {
  object-fit: contain;
}

.image-editor-preview.preview-focus-top img {
  object-position: center top;
}

.image-editor-preview.preview-focus-bottom img {
  object-position: center bottom;
}

.image-editor-preview.preview-focus-left img {
  object-position: left center;
}

.image-editor-preview.preview-focus-right img {
  object-position: right center;
}

.image-editor-preview span {
  overflow: hidden;
  color: var(--dim);
  font-size: 0.65rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.image-editor-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.image-editor-fields .image-path-field,
.image-editor-fields .image-position-field,
.image-editor-fields .image-focus-field,
.image-editor-actions {
  grid-column: 1 / -1;
}

.image-editor-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.image-editor-actions .danger-text {
  margin-left: auto;
}

.editor-publish-row {
  padding: 0.9rem 1rem;
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  background: rgba(255, 255, 255, 0.015);
}

.switch-label {
  display: flex !important;
  align-items: center;
  color: var(--paper) !important;
  cursor: pointer;
}

.switch-label input {
  width: 1.15rem;
  height: 1.15rem;
  accent-color: var(--accent);
}

.story-editor-actions {
  margin-top: 1.2rem;
}

.story-editor-actions .form-status {
  margin: 0;
}

@media (max-width: 900px) {
  .site-header {
    grid-template-columns: 1fr auto;
  }

  .main-nav {
    display: none;
  }

  .header-actions .text-button > span:last-child {
    display: none;
  }

  .section-heading,
  .about-grid {
    grid-template-columns: 1fr;
    gap: 2rem;
  }

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

  .about-section blockquote {
    margin-bottom: 5rem;
  }

  .studio-dialog {
    width: 100%;
    height: 100dvh;
    border-radius: 0;
  }

  .studio-layout {
    grid-template-columns: 14rem minmax(0, 1fr);
  }
}

@media (max-width: 640px) {
  .site-header {
    min-height: 4.6rem;
    padding-inline: 1rem;
  }

  .brand small,
  #chat-open-button {
    display: none;
  }

  #content-open-button {
    min-height: 2.2rem;
    padding-inline: 0.75rem;
    font-size: 0.72rem;
  }

  .hero {
    min-height: calc(100vh - 4.6rem);
    padding: 5rem 1.3rem;
  }

  .hero h1 {
    font-size: clamp(3.15rem, 15vw, 5rem);
  }

  .hero-note {
    margin-top: 3.5rem;
  }

  .archive-section,
  .about-section {
    padding: 5.5rem 1.3rem;
  }

  .archive-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .search-field {
    width: 100%;
  }

  .filter-group {
    justify-content: flex-start;
  }

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

  .story-card {
    min-height: 22rem;
  }

  .about-grid {
    padding-top: 2.5rem;
  }

  .site-footer {
    flex-direction: column;
  }

  .reader-header {
    grid-template-columns: auto 1fr;
  }

  .reader-header .secondary-button {
    grid-column: 1 / -1;
  }

  .reader-content {
    padding: 5rem 1.4rem 13rem;
  }

  .story-layout-cinematic,
  .story-layout-panorama {
    width: calc(100vw - 0.8rem);
    margin-top: 3.4rem;
    margin-bottom: 3.8rem;
  }

  .story-layout-portrait {
    width: min(88%, 27rem);
  }

  .story-image-collection {
    width: calc(100vw - 0.8rem);
    grid-template-columns: 1fr;
    gap: 0.7rem;
    margin: 3.8rem 0;
  }

  .story-image-count-3 .story-figure:first-child {
    grid-column: auto;
    grid-row: auto;
  }

  .story-image-collection .story-figure img,
  .story-image-count-3 .story-figure:first-child img {
    height: auto;
    max-height: none;
    aspect-ratio: auto;
    object-fit: contain;
  }

  .story-figure img {
    border-radius: 0.7rem;
  }

  .soundtrack-dock {
    right: 0.7rem;
    bottom: 0.7rem;
    left: 0.7rem;
    width: calc(100% - 1.4rem);
    align-items: stretch;
    flex-direction: column;
  }

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

  .volume-control {
    grid-column: 1 / -1;
  }

  .volume-control input {
    width: 100%;
  }

  .auth-dialog {
    width: 100%;
    max-height: 100dvh;
    border-radius: 0;
  }

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

  .auth-intro {
    padding-bottom: 1rem;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .brand-mark.large {
    margin-bottom: 1.2rem;
  }

  .auth-intro h2 {
    margin-bottom: 0.5rem;
    font-size: 2.4rem;
  }

  .chat-panel {
    padding: 1rem;
  }

  .studio-header {
    padding: 1rem;
  }

  .studio-header p {
    display: none;
  }

  .studio-layout {
    display: block;
    overflow-y: auto;
  }

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

  .studio-story-list {
    display: flex;
    overflow-x: auto;
  }

  .studio-story-item {
    min-width: 12rem;
  }

  .story-editor {
    overflow: visible;
  }

  .editor-fields-row,
  .optional-fields-content,
  .media-editor-section {
    grid-template-columns: 1fr;
  }

  .story-editor-heading,
  .editor-publish-row,
  .story-editor-actions {
    align-items: flex-start;
    flex-direction: column;
  }

  .body-field textarea {
    min-height: 22rem;
  }

  .image-editor-heading,
  .image-editor-actions {
    align-items: flex-start;
    flex-direction: column;
  }

  .github-image-guide,
  .image-add-form,
  .image-editor-card,
  .image-editor-fields {
    grid-template-columns: 1fr;
  }

  .github-upload-link {
    justify-self: start;
  }

  .image-editor-preview img {
    max-height: 16rem;
  }

  .image-add-form .image-path-field,
  .image-add-form .image-position-field,
  .image-add-form .image-focus-field,
  .image-editor-fields .image-path-field,
  .image-editor-fields .image-position-field,
  .image-editor-fields .image-focus-field,
  .image-editor-actions {
    grid-column: auto;
  }

  .image-editor-actions .danger-text {
    margin-left: 0;
  }
}

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