:root {
  color-scheme: dark;
  --ink: #091117;
  --ink-soft: #111c23;
  --paper: #efe7d8;
  --paper-dim: #bdb4a5;
  --line: rgba(239, 231, 216, 0.16);
  --amber: #e9a86b;
  --amber-dark: #7f4b2d;
  --shadow: rgba(0, 0, 0, 0.42);
  --serif: "Songti SC", "STSong", "Noto Serif CJK SC", Georgia, serif;
  --sans: "Avenir Next Condensed", "DIN Condensed", "PingFang SC", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--ink);
}

body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  color: var(--paper);
  background:
    radial-gradient(circle at 14% 10%, rgba(47, 79, 91, 0.24), transparent 34rem),
    linear-gradient(160deg, #0d1920 0%, var(--ink) 48%, #070c10 100%);
  font-family: var(--serif);
}

body::after {
  position: fixed;
  inset: 0;
  z-index: -1;
  content: "";
  opacity: 0.11;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.84' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.48'/%3E%3C/svg%3E");
}

.sky {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
}

.moon {
  position: absolute;
  top: 7vh;
  right: -2.8rem;
  width: 9.5rem;
  aspect-ratio: 1;
  border: 1px solid rgba(239, 231, 216, 0.32);
  border-radius: 50%;
  box-shadow: 0 0 5rem rgba(233, 168, 107, 0.08);
}

.moon::after {
  position: absolute;
  inset: 1.2rem 1.7rem 1.7rem 1.2rem;
  content: "";
  border: 1px solid rgba(239, 231, 216, 0.11);
  border-radius: 50%;
}

.star {
  position: absolute;
  width: 2px;
  height: 2px;
  border-radius: 50%;
  background: var(--paper);
  box-shadow: 0 0 0.8rem var(--paper);
  animation: glint 4s ease-in-out infinite;
}

.star-a { top: 17%; left: 9%; }
.star-b { top: 28%; right: 18%; animation-delay: 1.3s; }
.star-c { top: 8%; left: 61%; animation-delay: 2.5s; }

.shell {
  width: min(100%, 42rem);
  min-height: 100vh;
  margin: 0 auto;
  padding: max(3.5rem, env(safe-area-inset-top)) 1.4rem max(2rem, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
}

.masthead {
  position: relative;
  padding: 1rem 0 2.4rem;
  border-bottom: 1px solid var(--line);
  animation: enter 0.8s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.masthead::after {
  position: absolute;
  right: 0;
  bottom: -1px;
  width: 4.2rem;
  height: 1px;
  content: "";
  background: var(--amber);
}

.eyebrow {
  margin: 0 0 1.1rem;
  color: var(--amber);
  font: 600 0.69rem/1 var(--sans);
  letter-spacing: 0.18em;
}

h1 {
  margin: 0;
  font-size: clamp(3.5rem, 16vw, 6.4rem);
  font-weight: 500;
  line-height: 0.92;
  letter-spacing: -0.08em;
}

.subtitle {
  margin: 1rem 0 0 0.2rem;
  color: var(--paper-dim);
  font-size: 0.94rem;
  letter-spacing: 0.12em;
}

.screen {
  flex: 1;
  padding: 2.2rem 0;
  animation: enter 0.8s 0.12s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.panel {
  padding: 1.4rem;
  border: 1px solid var(--line);
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.045), rgba(255, 255, 255, 0.015));
  box-shadow: 0 1.8rem 4rem var(--shadow);
  backdrop-filter: blur(16px);
}

.panel + .panel {
  margin-top: 1rem;
}

.panel-label {
  margin: 0 0 0.8rem;
  color: var(--amber);
  font: 600 0.67rem/1 var(--sans);
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.panel h2 {
  margin: 0;
  font-size: 1.55rem;
  font-weight: 500;
  line-height: 1.35;
}

.panel p {
  color: var(--paper-dim);
  line-height: 1.75;
}

.install-note {
  border-left: 2px solid var(--amber);
  padding: 0.2rem 0 0.2rem 1rem;
  margin: 1.2rem 0;
}

.install-note strong {
  display: block;
  margin-bottom: 0.3rem;
  color: var(--paper);
  font-weight: 500;
}

.actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
  margin-top: 1.2rem;
}

button {
  min-height: 3.2rem;
  padding: 0.75rem 1rem;
  border: 1px solid var(--amber-dark);
  border-radius: 0;
  color: var(--paper);
  background: transparent;
  font: 600 0.8rem/1.2 var(--sans);
  letter-spacing: 0.08em;
  cursor: pointer;
  transition: background 180ms ease, color 180ms ease, transform 180ms ease;
}

button.primary {
  color: var(--ink);
  border-color: var(--amber);
  background: var(--amber);
}

button:active {
  transform: translateY(2px);
}

button:disabled {
  opacity: 0.45;
  cursor: wait;
}

textarea {
  width: 100%;
  min-height: 9rem;
  margin-top: 1rem;
  padding: 1rem;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 0;
  outline: none;
  color: var(--paper);
  background: rgba(0, 0, 0, 0.18);
  font: 1rem/1.75 var(--serif);
}

textarea:focus {
  border-color: var(--amber);
}

.status {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.65rem 1rem;
  margin: 1.2rem 0 0;
}

.status dt {
  color: var(--paper-dim);
  font: 600 0.68rem/1.5 var(--sans);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.status dd {
  margin: 0;
  text-align: right;
  line-height: 1.5;
}

.state-word {
  color: var(--amber);
}

.message-card {
  position: relative;
  min-height: 18rem;
  display: grid;
  place-items: center;
  padding: 3.3rem 1.8rem;
  border: 1px solid rgba(239, 231, 216, 0.22);
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 2rem 5rem var(--shadow);
}

.message-card::before,
.message-card::after {
  position: absolute;
  content: "✦";
  color: var(--amber-dark);
  font-size: 0.8rem;
}

.message-card::before { top: 1rem; left: 1rem; }
.message-card::after { right: 1rem; bottom: 1rem; }

.message-text {
  margin: 0;
  font-size: clamp(1.55rem, 6vw, 2.3rem);
  line-height: 1.65;
  text-align: center;
  white-space: pre-wrap;
}

.message-meta {
  margin-top: 1rem;
  color: var(--paper-dim);
  text-align: center;
  font: 600 0.68rem/1.4 var(--sans);
  letter-spacing: 0.12em;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: max(1.4rem, env(safe-area-inset-bottom));
  z-index: 5;
  max-width: calc(100vw - 2rem);
  padding: 0.85rem 1.1rem;
  opacity: 0;
  color: var(--ink);
  background: var(--paper);
  box-shadow: 0 1rem 3rem var(--shadow);
  transform: translate(-50%, 1rem);
  transition: opacity 180ms ease, transform 180ms ease;
  pointer-events: none;
  font: 600 0.78rem/1.3 var(--sans);
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

footer {
  padding-top: 1rem;
  color: rgba(239, 231, 216, 0.34);
  font: 600 0.6rem/1 var(--sans);
  letter-spacing: 0.22em;
  text-align: center;
}

@keyframes enter {
  from { opacity: 0; transform: translateY(1.4rem); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes glint {
  0%, 100% { opacity: 0.25; transform: scale(0.8); }
  50% { opacity: 1; transform: scale(1.4); }
}

@media (hover: hover) {
  button:hover {
    color: var(--ink);
    background: var(--amber);
  }
}

@media (max-width: 27rem) {
  .actions { grid-template-columns: 1fr; }
  .shell { padding-inline: 1rem; }
}

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