:root {
  color-scheme: light;
  --ink: #111713;
  --muted: #657068;
  --paper: #fffdf8;
  --surface: #f1eee5;
  --line: #d9d4c8;
  --accent: #315f49;
  --accent-dark: #234534;
  --shadow: 0 18px 60px rgba(32, 38, 33, 0.10);
  font-family: Inter, "Noto Sans SC", "Microsoft YaHei", system-ui, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 9% 8%, rgba(102, 132, 112, .13), transparent 28rem),
    linear-gradient(145deg, #e8e4d9, #f7f4ed 50%, #e4e7df);
}

button, input, select { font: inherit; }

button { cursor: pointer; }

.shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 46px 0 28px;
}

.hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 28px;
}

.hero > div:first-child { flex: 1 1 auto; min-width: 0; }

.eyebrow, .section-label {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .18em;
}

h1 {
  margin: 0;
  max-width: 960px;
  font-family: "Noto Serif SC", "Songti SC", SimSun, serif;
  font-size: clamp(32px, 5.4vw, 66px);
  font-weight: 650;
  letter-spacing: -.03em;
  line-height: 1.13;
}

.subtitle { margin: 14px 0 0; color: var(--muted); }

.runtime-badge {
  flex: 0 0 auto;
  padding: 9px 13px;
  border: 1px solid rgba(49, 95, 73, .28);
  border-radius: 999px;
  color: var(--accent-dark);
  background: rgba(255, 255, 255, .58);
  font-size: 13px;
}

.search-panel, .player-card, .info-card {
  border: 1px solid rgba(119, 116, 105, .23);
  background: rgba(255, 253, 248, .88);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.search-panel {
  padding: 22px;
  border-radius: 20px;
  margin-bottom: 22px;
}

.search-form label { display: block; margin-bottom: 9px; font-weight: 700; }

.search-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; }

input {
  min-width: 0;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--ink);
  background: #fff;
  font-size: 20px;
  outline: none;
}

input:focus, select:focus, button:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(49, 95, 73, .16);
  outline: none;
}

button, select {
  min-height: 44px;
  padding: 9px 14px;
  border: 1px solid var(--line);
  border-radius: 11px;
  color: var(--ink);
  background: #fffdf9;
}

button:hover { border-color: #aaa69b; background: #fff; }

button.primary {
  border-color: var(--accent);
  color: #fff;
  background: var(--accent);
}

button.primary:hover { background: var(--accent-dark); }

#search-help { margin: 9px 0 0; color: var(--muted); font-size: 13px; }

.examples { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-top: 15px; }
.examples span { margin-right: 4px; color: var(--muted); font-size: 13px; }
.examples button { min-height: 36px; padding: 5px 11px; }

.player-layout { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(270px, .8fr); gap: 22px; }
.player-card, .info-card { border-radius: 22px; }
.player-card { padding: 20px; }
.stage-strip { display: flex; justify-content: space-between; gap: 16px; margin-bottom: 14px; font-weight: 700; }
#frame-label { color: var(--muted); font-variant-numeric: tabular-nums; }

.canvas-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 18px;
  background:
    linear-gradient(rgba(140, 133, 119, .08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(140, 133, 119, .08) 1px, transparent 1px),
    var(--paper);
  background-size: 50% 50%;
}

#glyph-canvas { display: block; width: 100%; height: 100%; padding: 7%; }
#glyph-path { shape-rendering: geometricPrecision; }
#static-glyph { font-family: "Noto Serif SC", "Songti SC", SimSun, serif; }

.loading {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--accent-dark);
  background: rgba(255, 253, 248, .82);
  font-weight: 700;
}

.loading[hidden] { display: none; }

.controls { display: flex; align-items: center; flex-wrap: wrap; gap: 9px; margin-top: 15px; }
.controls label { margin-left: auto; color: var(--muted); font-size: 13px; }

.info-card { padding: 24px; }
.character-heading { display: flex; align-items: center; gap: 18px; padding-bottom: 20px; border-bottom: 1px solid var(--line); }
#character-display { font-family: "Noto Serif SC", "Songti SC", SimSun, serif; font-size: 76px; line-height: 1; }
.character-heading div { display: grid; gap: 5px; }
.character-heading strong { font-size: 17px; }
.character-heading span:last-child { color: var(--muted); font-size: 13px; }
dl { margin: 4px 0 0; }
dl div { padding: 15px 0; border-bottom: 1px solid var(--line); }
dt { margin-bottom: 6px; color: var(--muted); font-size: 12px; }
dd { margin: 0; line-height: 1.55; overflow-wrap: anywhere; }
.status-message { min-height: 48px; color: var(--muted); line-height: 1.6; }
.status-message.error { color: #a6372c; }
.share-button { width: 100%; }

footer { display: flex; justify-content: space-between; gap: 24px; margin-top: 22px; color: var(--muted); font-size: 12px; }
footer a { color: inherit; text-underline-offset: 3px; }

@media (max-width: 820px) {
  .shell { width: min(100% - 20px, 680px); padding-top: 24px; }
  .hero { align-items: flex-start; flex-direction: column; }
  .player-layout { grid-template-columns: 1fr; }
  .runtime-badge { align-self: flex-start; }
  footer { flex-direction: column; gap: 2px; }
}

@media (max-width: 480px) {
  .search-row { grid-template-columns: 1fr; }
  .player-card, .info-card, .search-panel { padding: 15px; border-radius: 16px; }
  .controls { display: grid; grid-template-columns: repeat(2, 1fr); }
  .controls label { margin-left: 0; align-self: center; }
  .controls select { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; }
}
