:root {
  color-scheme: dark;
  --page: #100e11;
  --stage: #0c0b0d;
  --text: #fff0dc;
  --muted: #b9acb4;
  --line: #332b35;
  --accent: #c69cf0;
  --gutter: clamp(14px, 2.7vw, 40px);
  font-family: "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  background: var(--page);
  color: var(--text);
}

a { color: inherit; text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: .24em; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

.quote-page {
  --flame-color: #bb260c;
  --flame-accent: color-mix(in srgb, var(--flame-color) 48%, #fff0fa);
  --control-line: color-mix(in srgb, var(--flame-color) 40%, #2e2632);
  --control-fill: color-mix(in srgb, var(--flame-color) 12%, #171319);
  flex: 1;
  display: flex;
  flex-direction: column;
}

.fire-controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  grid-template-areas: "settings next actions";
  align-items: center;
  gap: 10px;
  padding: 12px var(--gutter);
  border-bottom: 1px solid var(--control-line);
  background: linear-gradient(110deg, var(--control-fill), var(--page) 64%);
  color: var(--text);
  font-size: 12px;
}

.fire-controls[hidden],
.fire-controls button[hidden],
.quote-content [hidden] { display: none; }

.fire-settings,
.fire-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.fire-settings { grid-area: settings; }
.fire-actions { grid-area: actions; justify-content: flex-end; }

.fire-control,
.fire-controls button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 44px;
  padding: 5px 12px;
  background: var(--control-fill);
  border: 1px solid var(--control-line);
  border-radius: 11px;
  white-space: nowrap;
  transition: transform .18s ease-out;
}

.fire-controls button {
  color: var(--text);
  font: inherit;
  cursor: pointer;
}

.fire-control:hover,
.fire-controls button:enabled:hover,
.fire-controls button[data-active] {
  background-color: color-mix(in srgb, var(--flame-color) 25%, #171319);
  border-color: var(--flame-accent);
}

.fire-controls button:enabled:active { transform: translateY(1px); }
.fire-controls :focus-visible { outline-color: var(--flame-accent); }
.fire-controls input { cursor: pointer; margin: 0; }
.fire-control label { cursor: pointer; }
.fire-controls output { color: var(--flame-accent); font: 11px/1 ui-monospace, Consolas, monospace; }

.intensity input {
  appearance: none;
  width: clamp(70px, 7.7vw, 138px);
  height: 24px;
  background: transparent;
  --track: linear-gradient(to right, var(--flame-accent) 0 var(--burn-progress, 100%), var(--control-line) var(--burn-progress, 100%) 100%);
}

.intensity input::-webkit-slider-runnable-track { height: 4px; border-radius: 4px; background: var(--track); }
.intensity input::-moz-range-track { height: 4px; border-radius: 4px; background: var(--track); }
.intensity input::-webkit-slider-thumb {
  appearance: none;
  width: 14px;
  height: 14px;
  margin-top: -5px;
  border: 2px solid #fff3fc;
  border-radius: 50%;
  background: var(--flame-accent);
  box-shadow: 0 0 8px var(--flame-color);
}

.intensity input::-moz-range-thumb {
  width: 10px;
  height: 10px;
  border: 2px solid #fff3fc;
  border-radius: 50%;
  background: var(--flame-accent);
  box-shadow: 0 0 8px var(--flame-color);
}

.intensity output { min-width: 4ch; text-align: right; }
.flame-color input {
  inline-size: 28px;
  block-size: 24px;
  padding: 0;
  border: 0;
  background: transparent;
}

.flame-color input::-webkit-color-swatch-wrapper { padding: 1px; }
.flame-color input::-webkit-color-swatch { border: 1px solid var(--flame-accent); border-radius: 6px; }
.flame-color input::-moz-color-swatch { border: 1px solid var(--flame-accent); border-radius: 6px; }

.next-actions {
  position: relative;
  grid-area: next;
  justify-self: center;
}

.fire-controls .next-quote {
  gap: 14px;
  min-width: 150px;
  padding-inline: 19px;
  border-color: color-mix(in srgb, var(--flame-accent) 65%, var(--flame-color));
  background: linear-gradient(125deg, color-mix(in srgb, var(--flame-color) 35%, #211823), var(--control-fill));
  box-shadow: 0 0 20px color-mix(in srgb, var(--flame-color) 22%, transparent);
  font-size: 14px;
  font-weight: 600;
}

.next-quote span { color: var(--flame-accent); font-size: 17px; }
.fire-controls .next-quote:enabled:hover {
  background: color-mix(in srgb, var(--flame-color) 34%, #1b1320);
  border-color: var(--flame-accent);
  box-shadow: 0 0 24px color-mix(in srgb, var(--flame-color) 37%, transparent);
}

.fire-controls .save-note {
  position: absolute;
  inset: 0 auto 0 calc(100% + clamp(12px, 3vw, 44px));
  min-width: 68px;
  color: var(--flame-accent);
  font-weight: 600;
}

.fire-controls .save-note:disabled {
  color: var(--muted);
  cursor: default;
}

.quote-stage {
  position: relative;
  isolation: isolate;
  flex: 1;
  min-height: 240px;
  overflow: hidden;
  background: var(--stage);
}

.fire-glow,
.fire-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.fire-glow { filter: blur(9px); mix-blend-mode: screen; }
.fire-canvas { filter: drop-shadow(0 0 2px var(--flame-halo, transparent)); }

.quote-content {
  position: absolute;
  inset: 0 0 26%;
  display: grid;
  place-items: center;
  padding: 24px;
  background: radial-gradient(ellipse at center, #0c0b0df2 0%, #0c0b0dc2 21%, transparent 66%);
}

.quote-content[hidden] { display: none; }

blockquote { margin: 0; text-align: center; }

.quote-line {
  max-width: 13.25em;
  margin: 0;
  font: 400 clamp(26px, 4.1vw, 65px)/1.62 "Songti SC", "Noto Serif CJK SC", SimSun, serif;
  letter-spacing: .045em;
  text-wrap: balance;
  text-shadow: 0 2px 20px var(--stage);
}

.quote-line--long {
  max-width: 17em;
  font-size: clamp(22px, 3.4vw, 53px);
}

.quote-line--visitor {
  max-width: min(21em, calc(100vw - 48px));
  max-height: 55svh;
  overflow: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.quote-source {
  margin: clamp(12px, 2.4vh, 24px) 0 0;
  color: var(--muted);
  font-size: clamp(13px, 1.4vw, 17px);
  text-align: right;
}

.future-note {
  align-self: start;
  width: min(100%, 33rem);
  margin-top: clamp(12px, 5svh, 55px);
}

.future-note label {
  display: block;
  color: var(--text);
  font: 400 clamp(21px, 3.2vw, 40px)/1.5 "Songti SC", "Noto Serif CJK SC", SimSun, serif;
  text-shadow: 0 2px 20px var(--stage);
}

.note-editor { position: relative; margin-top: clamp(12px, 2vw, 28px); }

.note-editor textarea {
  display: block;
  width: 100%;
  padding: 0;
  resize: none;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--text);
  caret-color: var(--flame-accent);
  font: 400 clamp(22px, 3.1vw, 42px)/1.6 "Songti SC", "Noto Serif CJK SC", SimSun, serif;
  text-shadow: 0 2px 16px var(--stage);
}

.note-editor:has(textarea:placeholder-shown:not(:focus))::before {
  position: absolute;
  inset: 5px auto auto 0;
  width: 2px;
  height: clamp(23px, 3.1vw, 44px);
  background: var(--flame-accent);
  pointer-events: none;
  animation: note-caret 1.1s steps(1) infinite;
  content: "";
}

@keyframes note-caret { 50% { opacity: 0; } }
.note-status { margin: 8px 0 0; color: var(--flame-accent); font-size: 13px; }

@media (max-width: 1010px) {
  .fire-controls { grid-template-areas: "settings settings settings" ". next actions"; }
  .intensity input { width: clamp(75px, 18vw, 175px); }
}

@media (min-width: 576px) and (max-width: 720px) {
  .fire-controls:has(.save-note:not([hidden])) {
    grid-template-areas: "settings settings settings" ". next ." "actions actions actions";
  }
}

@media (max-width: 575px) {
  .quote-stage { min-height: 275px; }
  .quote-content {
    position: relative;
    inset: auto;
    place-items: start center;
    padding: clamp(23px, 5svh, 45px) clamp(15px, 5vw, 24px) 28px;
  }
  .quote-line { font-size: clamp(23px, 6.5vw, 28px); }
  .quote-line--long { font-size: clamp(19px, 5.6vw, 24px); }
  .quote-source { margin-top: 10px; font-size: 12px; text-align: center; }
  .future-note { margin-top: 0; }
  .fire-controls {
    order: 1;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "next actions" "settings settings";
    gap: 6px 7px;
    padding: 8px var(--gutter) max(8px, env(safe-area-inset-bottom));
    border-bottom: 0;
    border-top: 1px solid var(--control-line);
    font-size: 11px;
  }
  .fire-controls:has(.save-note:not([hidden])) {
    grid-template-areas: "next next" "actions actions" "settings settings";
  }
  .next-actions { display: flex; gap: 7px; justify-self: stretch; }
  .fire-controls button { min-height: 38px; padding-inline: 9px; border-radius: 9px; }
  .fire-controls .next-quote { flex: 1; min-width: 0; gap: 7px; font-size: 13px; }
  .next-quote span { font-size: 15px; }
  .fire-actions { justify-content: center; gap: 5px; }
  .fire-settings { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .fire-control {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 1px 6px;
    padding: 4px 8px;
  }
  .fire-controls output { font-size: 10px; }
  .fire-control input { grid-row: 2; }
  .intensity input { grid-column: 1 / -1; width: 100%; }
  .flame-color output { grid-row: 2; }
  .fire-controls .save-note { position: static; min-width: 54px; }
}

@media (prefers-reduced-motion: reduce) {
  .fire-control,
  .fire-controls button { transition: none; }
  .note-editor:has(textarea:placeholder-shown:not(:focus))::before { animation: none; }
}
