@import url("https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600&family=Newsreader:opsz,wght@6..72,400;6..72,500;6..72,600&display=swap");

:root {
  color-scheme: light;
  font-family: "DM Sans", system-ui, sans-serif;
  color: #25241f;
  background: #e8e2d8;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgb(255 255 255 / 55%), transparent 34rem),
    linear-gradient(145deg, #e7e1d6, #d9d1c4);
}

button,
textarea {
  font: inherit;
}

.app-shell {
  width: min(100%, 820px);
  margin: 0 auto;
  padding: clamp(18px, 4vw, 48px) clamp(14px, 3vw, 28px) 72px;
}

.reader-card {
  min-height: calc(100vh - 96px);
  border: 1px solid rgb(62 59 50 / 10%);
  border-radius: 28px;
  background: #f7f3eb;
  box-shadow: 0 28px 80px rgb(49 43 35 / 12%);
  overflow: hidden;
}

.brand-line,
.reader-header {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-line {
  padding: 22px 26px;
  border-bottom: 1px solid rgb(62 59 50 / 9%);
  color: #6a665b;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.brand-line.compact {
  padding: 0;
  border: 0;
}

.home-link {
  background: transparent;
  cursor: pointer;
}

.brand-mark {
  position: relative;
  display: block;
  width: 42px;
  height: 31px;
  flex: 0 0 auto;
  overflow: hidden;
}

.brand-mark img {
  position: absolute;
  top: -9px;
  left: -4px;
  display: block;
  width: 48px;
  height: 48px;
  mix-blend-mode: multiply;
}

.intro-copy,
.library-copy,
.scene-copy,
.scene-image,
.ending-summary,
.run-details,
.run-rating,
.run-more-feedback,
.dev-navigation,
.scene-feedback,
.choice-list {
  width: min(100% - 48px, 610px);
  margin-inline: auto;
}

.intro-copy,
.library-copy {
  padding: clamp(54px, 10vw, 100px) 0 70px;
}

.eyebrow {
  margin: 0 0 14px;
  color: #817b6c;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-family: "Newsreader", Georgia, serif;
  font-size: clamp(46px, 8vw, 76px);
  font-weight: 500;
  line-height: 0.96;
  letter-spacing: -0.035em;
}

.story-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 26px 0 34px;
}

.story-meta span,
.ending-kind,
.step-label {
  border: 1px solid rgb(69 67 59 / 13%);
  border-radius: 999px;
  padding: 7px 10px;
  color: #6e695e;
  font-size: 11px;
  text-transform: capitalize;
}

.lede {
  max-width: 550px;
  margin: 0 0 34px;
  color: #4d4a42;
  font-family: "Newsreader", Georgia, serif;
  font-size: 24px;
  line-height: 1.45;
}

.objective-box {
  margin: 0 0 20px;
  border-left: 3px solid #a56c42;
  padding: 12px 18px;
  background: #f0eadf;
}

.objective-box p {
  margin: 5px 0 0;
  font-family: "Newsreader", Georgia, serif;
  font-size: 19px;
}

.objective-label,
.content-note,
.choice-prompt {
  color: #7a7468;
  font-size: 12px;
}

.primary-button,
.secondary-button,
.primary-small-button {
  min-height: 52px;
  border-radius: 14px;
  padding: 0 18px;
  cursor: pointer;
  font-weight: 600;
}

.primary-button,
.primary-small-button {
  border: 0;
  background: #2f3c35;
  color: white;
}

.primary-button {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  margin-top: 34px;
}

.primary-small-button {
  min-height: 42px;
}

.reader-header {
  justify-content: space-between;
  padding: 22px 26px 18px;
}

.reader-header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 14px;
}

.share-story-link.link-copied {
  color: #56705b;
}

.copy-link-target {
  position: fixed;
  left: -10000px;
  opacity: 0;
}

.header-home-link,
.more-feedback-link,
.text-link-button {
  border: 0;
  padding: 0;
  background: transparent;
  color: #7a604b;
  cursor: pointer;
  font-size: 12px;
  text-decoration: underline;
  text-decoration-color: rgb(122 96 75 / 35%);
  text-underline-offset: 3px;
}

.progress-track {
  height: 2px;
  background: #e5dfd5;
}

.progress-value {
  height: 100%;
  background: #9b6a44;
  transition: width 280ms ease;
}

.dev-navigation {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 22px;
  border: 1px dashed rgb(87 104 90 / 32%);
  border-radius: 12px;
  padding: 10px 12px;
  background: rgb(223 232 220 / 42%);
  color: #667064;
  font-size: 11px;
}

.dev-mode-label {
  border-radius: 999px;
  padding: 4px 7px;
  background: #dbe6d8;
  color: #435345;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.dev-previous-scene,
.dev-edit-text {
  border: 0;
  padding: 3px 0;
  background: transparent;
  color: #415646;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  text-decoration: underline;
  text-decoration-color: rgb(65 86 70 / 30%);
  text-underline-offset: 3px;
}

.dev-rewind-hint {
  margin-left: auto;
  color: #737c71;
  text-align: right;
}

.dev-rewind-hint.error {
  color: #9a3f32;
}

.dev-edit-text:disabled {
  cursor: default;
  opacity: 0.65;
  text-decoration: none;
}

.scene-copy {
  padding: clamp(44px, 8vw, 74px) 0 22px;
  font-family: "Newsreader", Georgia, serif;
  font-size: clamp(23px, 3.4vw, 29px);
  line-height: 1.55;
}

.dev-navigation + .scene-copy {
  padding-top: clamp(28px, 5vw, 44px);
}

.scene-copy p {
  margin: 0 0 1.05em;
}

.scene-image {
  margin-top: clamp(28px, 6vw, 52px);
  margin-bottom: 10px;
}

.scene-image img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 6px;
  background: #e9e3d9;
}

.scene-image + .scene-copy,
.scene-image + .translated-block .scene-copy {
  padding-top: clamp(24px, 4vw, 36px);
}

.authoring-scene-copy {
  display: grid;
  gap: 18px;
}

.authoring-field {
  display: grid;
  gap: 6px;
  color: #596359;
  font-family: Inter, system-ui, sans-serif;
  font-size: 11px;
  font-weight: 700;
}

.authoring-field input,
.authoring-field textarea {
  box-sizing: border-box;
  width: 100%;
  border: 1px solid #aab5a8;
  border-radius: 6px;
  padding: 12px;
  background: #fff;
  color: #272c28;
  font: inherit;
  font-size: 15px;
  font-weight: 400;
  line-height: 1.5;
}

.authoring-scene-field textarea {
  min-height: 150px;
  font-family: "Newsreader", Georgia, serif;
  font-size: 20px;
}

.authoring-field input:focus,
.authoring-field textarea:focus {
  border-color: #4f6955;
  outline: 3px solid rgb(79 105 85 / 18%);
}

.authoring-choice-list {
  display: grid;
  gap: 10px;
}

.authoring-choice {
  grid-template-columns: 34px 1fr;
  align-items: center;
}

.authoring-ending {
  display: grid;
  gap: 16px;
}

.authoring-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  width: min(680px, calc(100% - 48px));
  margin: 18px auto 36px;
}

.authoring-actions button:disabled {
  cursor: wait;
  opacity: 0.6;
}

.image-authoring-dialog {
  width: min(calc(100% - 32px), 620px);
}

.image-authoring-form {
  display: grid;
  gap: 16px;
}

.image-authoring-preview {
  display: grid;
  min-height: 150px;
  place-items: center;
  overflow: hidden;
  border: 1px dashed #b9b0a3;
  border-radius: 6px;
  background: #eee8de;
  color: #81796d;
  font-size: 12px;
}

.image-authoring-preview.has-image {
  border-style: solid;
  background: #ddd6cb;
}

.image-authoring-preview img {
  display: block;
  width: 100%;
  max-height: 300px;
  object-fit: contain;
}

.image-authoring-form input[type="file"] {
  border: 1px solid #b9b0a3;
  border-radius: 6px;
  padding: 10px;
  background: #fff;
  font-size: 13px;
  font-weight: 400;
}

.image-placement-field {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  border: 0;
  padding: 0;
}

.image-placement-field legend {
  margin-bottom: 6px;
  color: #596359;
  font-size: 11px;
  font-weight: 700;
}

.image-placement-field label {
  position: relative;
  cursor: pointer;
}

.image-placement-field input {
  position: absolute;
  opacity: 0;
}

.image-placement-field span {
  display: grid;
  min-height: 40px;
  place-items: center;
  border: 1px solid #aab5a8;
  background: #fff;
  color: #596359;
  font-size: 12px;
  font-weight: 600;
}

.image-placement-field label:first-of-type span {
  border-radius: 6px 0 0 6px;
}

.image-placement-field label:last-of-type span {
  border-left: 0;
  border-radius: 0 6px 6px 0;
}

.image-placement-field input:checked + span {
  background: #435345;
  color: #fff;
}

.image-placement-field input:focus-visible + span {
  outline: 3px solid rgb(79 105 85 / 22%);
  outline-offset: 2px;
}

.image-authoring-error {
  min-height: 18px;
  margin: 0;
  color: #9a3f32;
  font-size: 12px;
}

.image-authoring-primary-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}

.danger-text-button {
  border: 0;
  padding: 0;
  background: transparent;
  color: #9a3f32;
  cursor: pointer;
  font-size: 12px;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.scene-feedback {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  color: #827c70;
  font-size: 11px;
}

.feedback-actions {
  display: flex;
  gap: 5px;
}

.feedback-button,
.star-button {
  border: 1px solid rgb(65 62 54 / 13%);
  background: transparent;
  color: #817b6f;
  cursor: pointer;
}

.feedback-button {
  width: 31px;
  height: 31px;
  border-radius: 999px;
  line-height: 1;
}

.feedback-button:hover,
.feedback-button.selected,
.star-button:hover,
.star-button.selected {
  border-color: #967052;
  background: #e9ded0;
  color: #6e472c;
}

.choice-list {
  padding: 36px 0 56px;
}

.continue-reading {
  width: min(100% - 48px, 610px);
  margin-inline: auto;
  padding: 28px 0 56px;
  text-align: right;
}

.continue-reading-link {
  min-height: 48px;
  border: 0;
  padding: 0 4px;
  background: transparent;
  color: #75553e;
  cursor: pointer;
  font-weight: 600;
}

.continue-reading-link span {
  display: inline-block;
  margin-left: 8px;
  font-size: 18px;
  transition: transform 120ms ease;
}

.continue-reading-link:hover span {
  transform: translateX(3px);
}

.choice-prompt {
  margin: 0 0 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.choice-row {
  position: relative;
  margin-bottom: 10px;
}

.choice-button {
  display: grid;
  width: 100%;
  min-height: 66px;
  grid-template-columns: 34px 1fr 24px;
  align-items: center;
  gap: 12px;
  border: 1px solid #d8d0c4;
  border-radius: 16px;
  padding: 10px 14px;
  background: #fbf8f2;
  color: #302f2a;
  cursor: pointer;
  text-align: left;
  transition: transform 120ms ease, border-color 120ms ease, background 120ms ease;
}

.choice-button:hover {
  transform: translateY(-1px);
  border-color: #a99784;
  background: white;
}

.choice-number {
  color: #9d9588;
  font-size: 11px;
}

.choice-arrow {
  color: #8e6a4e;
  font-size: 20px;
}

.ending-copy {
  padding-bottom: 12px;
}

.ending-divider {
  width: min(100% - 48px, 610px);
  height: 1px;
  margin: 12px auto 38px;
  background: #ddd4c8;
}

.ending-summary h1 {
  font-size: clamp(42px, 7vw, 64px);
}

.ending-summary > p:last-child {
  margin: 18px 0 0;
  color: #5c574e;
  font-family: "Newsreader", Georgia, serif;
  font-size: 20px;
  line-height: 1.45;
}

.run-rating {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 38px;
  border-top: 1px solid #ded6ca;
  padding-top: 24px;
  color: #6e695f;
  font-size: 13px;
}

.run-more-feedback {
  margin-top: 12px;
  text-align: right;
}

.stars {
  display: flex;
  gap: 4px;
}

.star-button {
  border: 0;
  border-radius: 5px;
  padding: 3px;
  font-size: 21px;
}

.run-details {
  margin-top: 22px;
  color: #706a5f;
  font-size: 13px;
}

.run-details summary {
  cursor: pointer;
}

.run-details li {
  margin: 8px 0;
}

.ending-actions {
  width: min(100% - 48px, 610px);
  margin: 32px auto 52px;
}

.ending-actions .primary-button,
.ending-actions .secondary-button {
  margin: 10px 0 0;
  width: 100%;
}

.secondary-button {
  display: block;
  width: min(100% - 48px, 610px);
  margin: 32px auto 52px;
  border: 1px solid #c8beb0;
  background: transparent;
  color: #35332d;
}

.story-grid {
  display: grid;
  gap: 14px;
  margin-top: 34px;
}

.story-card {
  display: grid;
  gap: 10px;
  width: 100%;
  border: 1px solid #d8d0c4;
  border-radius: 18px;
  padding: 22px;
  background: #fbf8f2;
  color: #302f2a;
  cursor: pointer;
  text-align: left;
}

.story-card:hover {
  border-color: #a99784;
  background: white;
}

.story-card strong {
  font-family: "Newsreader", Georgia, serif;
  font-size: 28px;
  font-weight: 500;
}

.story-card-topline,
.story-card-footer,
.library-note {
  color: #817b6f;
  font-size: 12px;
}

.story-card-description {
  color: #59554c;
  line-height: 1.5;
}

.story-card-footer {
  display: flex;
  justify-content: space-between;
  margin-top: 5px;
}

.library-note {
  margin-top: 22px;
}

.story-card-progress {
  justify-self: start;
  border-radius: 20px;
  padding: 5px 10px;
  background: #e6ece4;
  color: #2f3c35;
  font-size: 12px;
  font-weight: 600;
}

.resume-reading {
  margin-top: 28px;
  border-top: 1px solid #d8d0c4;
  padding-top: 18px;
}

.resume-reading .primary-button {
  margin-top: 18px;
}

.restart-reading {
  margin-top: 20px;
  color: #59554c;
  font-size: 14px;
}

.restart-reading summary {
  width: fit-content;
  min-height: 44px;
  align-content: center;
  cursor: pointer;
}

.restart-reading .secondary-button {
  width: 100%;
  margin: 12px 0 0;
}

.reading-save-note {
  margin: 0 0 24px;
  color: #667363;
  font-size: 12px;
  line-height: 1.5;
}

.reading-save-note.save-unavailable {
  color: #855236;
}

.feedback-dialog {
  width: min(calc(100% - 32px), 520px);
  border: 1px solid #d0c6b8;
  border-radius: 20px;
  padding: 0;
  background: #f7f3eb;
  color: #302f2a;
  box-shadow: 0 28px 90px rgb(49 43 35 / 28%);
}

.feedback-dialog::backdrop {
  background: rgb(39 36 31 / 42%);
  backdrop-filter: blur(2px);
}

.feedback-form {
  padding: 24px;
}

.feedback-dialog-header,
.feedback-form-actions {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.feedback-dialog h2 {
  margin: 0;
  font-family: "Newsreader", Georgia, serif;
  font-size: 30px;
  font-weight: 500;
}

.dialog-close {
  border: 0;
  padding: 2px 7px;
  background: transparent;
  color: #756f64;
  cursor: pointer;
  font-size: 26px;
}

.feedback-context {
  color: #777166;
  font-size: 12px;
}

.feedback-dialog textarea {
  width: 100%;
  resize: vertical;
  border: 1px solid #d4cabd;
  border-radius: 12px;
  padding: 12px;
  background: #fffdf8;
  color: #302f2a;
  line-height: 1.45;
}

.feedback-form-actions {
  align-items: center;
  margin-top: 14px;
}

.loading-card,
.error-card {
  display: grid;
  align-content: center;
  padding: 48px;
}

.loading-card h1,
.error-card h1 {
  font-size: clamp(38px, 7vw, 64px);
}

.error-card p:last-child {
  max-width: 540px;
  color: #6d675c;
}

@media (max-width: 560px) {
  .app-shell {
    padding: 0;
  }

  .reader-card {
    min-height: 100vh;
    border: 0;
    border-radius: 0;
  }

  .brand-line,
  .reader-header {
    padding-inline: 20px;
  }

  .intro-copy,
  .library-copy,
  .scene-copy,
  .scene-image,
  .ending-summary,
  .run-details,
  .run-rating,
  .run-more-feedback,
  .dev-navigation,
  .scene-feedback,
  .choice-list,
  .ending-divider,
  .secondary-button,
  .ending-actions {
    width: calc(100% - 40px);
  }

  .scene-copy {
    font-size: 23px;
  }

  .dev-rewind-hint {
    flex-basis: 100%;
    margin-left: 0;
    text-align: left;
  }

  .header-home-link {
    max-width: 85px;
  }

  .reader-header-actions {
    gap: 10px;
  }
}

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