:root {
  color-scheme: dark;
  --bg: #07070d;
  --panel: rgba(14, 13, 25, 0.82);
  --line: rgba(200, 186, 255, 0.2);
  --text: #f6f3ff;
  --muted: #a8a1bb;
  --violet: #9b74ff;
  --cyan: #70ebff;
}

* { box-sizing: border-box; }

html, body { width: 100%; min-height: 100%; margin: 0; }

body {
  background:
    radial-gradient(circle at 74% 18%, rgba(103, 58, 174, 0.22), transparent 34%),
    radial-gradient(circle at 23% 74%, rgba(32, 141, 177, 0.13), transparent 31%),
    var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  overflow: hidden;
}

button { font: inherit; }

.viewer-shell {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  width: 100vw;
  height: 100svh;
  min-height: 620px;
  padding: 22px 28px 16px;
  isolation: isolate;
}

.viewer-shell::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.42;
  background-image:
    linear-gradient(rgba(255,255,255,0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.025) 1px, transparent 1px);
  background-size: 40px 40px;
  mask-image: linear-gradient(to bottom, black, transparent 90%);
}

.topbar, footer, .control-panel {
  position: relative;
  z-index: 4;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
}

.eyebrow {
  display: block;
  margin-bottom: 7px;
  color: var(--cyan);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.22em;
}

h1 {
  margin: 0;
  font-family: "Times New Roman", "Noto Serif TC", serif;
  font-size: clamp(32px, 4vw, 58px);
  font-weight: 400;
  letter-spacing: 0.06em;
  line-height: 0.92;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding-top: 5px;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.12em;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #d2b368;
  box-shadow: 0 0 14px currentColor;
}

.status.is-ready .status-dot { background: #72f6c0; }
.status.is-error .status-dot { background: #ff6e8d; }

.stage {
  position: relative;
  min-height: 0;
  margin: 10px 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 18px;
  background:
    radial-gradient(ellipse at center, rgba(83, 65, 126, 0.22), transparent 55%),
    linear-gradient(160deg, rgba(24, 22, 38, 0.88), rgba(8, 8, 14, 0.94));
  box-shadow: inset 0 0 80px rgba(0,0,0,0.45), 0 24px 80px rgba(0,0,0,0.32);
}

model-viewer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  --poster-color: transparent;
  --progress-bar-color: var(--cyan);
}

.time-ring {
  position: absolute;
  z-index: 0;
  left: 50%;
  top: 52%;
  border: 1px solid rgba(137, 225, 255, 0.16);
  border-radius: 50%;
  pointer-events: none;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 48px rgba(116, 92, 255, 0.08);
}

.ring-one { width: min(62vw, 700px); aspect-ratio: 1; }
.ring-two { width: min(46vw, 520px); aspect-ratio: 1; border-style: dashed; }

.progress {
  position: absolute;
  left: 50%;
  bottom: 30px;
  width: min(320px, 70%);
  height: 2px;
  overflow: hidden;
  transform: translateX(-50%);
  background: rgba(255,255,255,0.1);
}

.progress-fill {
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, var(--violet), var(--cyan));
  box-shadow: 0 0 12px var(--cyan);
  transition: width 120ms linear;
}

.ar-button {
  position: absolute;
  right: 18px;
  bottom: 18px;
  padding: 9px 14px;
  border: 1px solid var(--line);
  border-radius: 99px;
  background: rgba(10, 9, 18, 0.78);
  color: var(--text);
  cursor: pointer;
}

.model-meta {
  position: absolute;
  z-index: 3;
  left: 16px;
  bottom: 14px;
  display: flex;
  gap: 16px;
  color: rgba(224, 218, 239, 0.55);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 9px;
  letter-spacing: 0.1em;
  pointer-events: none;
}

.control-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 6px 0 12px;
}

.instruction {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.instruction strong { color: var(--text); font-weight: 600; }

.actions { display: flex; flex-wrap: wrap; gap: 8px; }

.actions button {
  min-height: 38px;
  padding: 8px 15px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(20, 18, 33, 0.72);
  color: var(--text);
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}

.actions button:hover {
  border-color: rgba(112, 235, 255, 0.58);
  background: rgba(48, 39, 78, 0.82);
  transform: translateY(-1px);
}

.actions button:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }
.actions button[aria-pressed="true"] { border-color: var(--violet); color: #d9cbff; }

footer {
  display: flex;
  justify-content: space-between;
  color: rgba(207, 200, 223, 0.42);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 9px;
  letter-spacing: 0.09em;
}

@media (max-width: 720px) {
  body { overflow: auto; }
  .viewer-shell { min-height: 720px; padding: 16px; }
  .topbar { align-items: flex-start; }
  .eyebrow { max-width: 250px; line-height: 1.5; }
  .control-panel { align-items: flex-start; flex-direction: column; }
  .actions { width: 100%; }
  .actions button { flex: 1; }
  .model-meta { display: none; }
  footer { gap: 16px; flex-direction: column; }
}

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