:root {
  color-scheme: dark;
  font-family: Inter, "SF Pro Display", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  --ink: #eef7f7;
  --muted: #a8bcbe;
  --line: rgb(172 222 224 / 17%);
  --panel: rgb(7 20 25 / 78%);
  --cyan: #7acdd8;
  --amber: #d7a165;
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; background: #061014; }
button { font: inherit; color: inherit; cursor: pointer; }
button:focus-visible { outline: 2px solid #9ae7ea; outline-offset: 3px; }

#app {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  isolation: isolate;
  background:
    radial-gradient(circle at 48% 22%, rgb(228 255 249 / 28%), transparent 29%),
    linear-gradient(145deg, #3e626b, #172a31 62%, #0a161b);
}

#stage, .poster { position: absolute; inset: 0; width: 100%; height: 100%; }
#stage { z-index: 1; display: block; touch-action: none; }
.poster { z-index: 2; object-fit: cover; opacity: 1; filter: saturate(.93) contrast(1.06) brightness(.69); transition: opacity .42s ease; }
.poster.is-hidden { opacity: 0; pointer-events: none; }

.topbar, .intro, .mode-panel, .process-status, .step-rail, .focus-panel, .actions, .truth-bar { position: absolute; z-index: 10; }
.topbar { top: 0; right: 0; left: 0; height: 74px; display: flex; align-items: center; justify-content: space-between; padding: 0 30px; border-bottom: 1px solid var(--line); background: linear-gradient(180deg, rgb(5 17 21 / 82%), transparent); }
.brand { display: flex; align-items: center; gap: 11px; }
.brand-mark { display: grid; width: 36px; height: 36px; place-items: center; border: 1px solid rgb(172 235 237 / 46%); border-radius: 10px; background: #23434d; font-weight: 800; }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 13px; letter-spacing: .15em; }
.brand small { margin-top: 3px; color: #90a9ae; font-size: 8px; letter-spacing: .18em; }
.demo-status { display: flex; align-items: center; gap: 8px; color: #a3bec2; font-size: 9px; letter-spacing: .17em; }
.demo-status i { width: 7px; height: 7px; border-radius: 50%; background: #68c7a5; box-shadow: 0 0 11px #68c7a5; }

.intro, .mode-panel, .process-status, .focus-panel { border: 1px solid var(--line); background: var(--panel); box-shadow: 0 20px 52px rgb(0 0 0 / 24%); backdrop-filter: blur(14px); }
.intro { top: 102px; left: 30px; width: min(318px, 25vw); padding: 20px; border-radius: 16px; }
.eyebrow { margin: 0 0 8px; color: var(--cyan); font-size: 9px; font-weight: 700; letter-spacing: .17em; }
.intro h1 { margin: 0; font-size: clamp(25px, 2.2vw, 36px); line-height: 1.08; letter-spacing: -.045em; }
.intro > p:not(.eyebrow) { margin: 12px 0 0; color: var(--muted); font-size: 12px; line-height: 1.7; }
.intro-note { padding-top: 11px; border-top: 1px solid rgb(171 220 220 / 12%); font-size: 10px !important; }

.mode-panel { top: 102px; right: 30px; width: min(318px, 25vw); padding: 17px; border-radius: 15px; }
.mode-tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; padding: 4px; border-radius: 9px; background: rgb(0 9 12 / 38%); }
.mode-tabs button, .focus-controls button, .actions button, .step-rail button { border: 1px solid transparent; border-radius: 8px; background: rgb(255 255 255 / 4%); transition: background .18s ease, border-color .18s ease, color .18s ease; }
.mode-tabs button { min-height: 36px; padding: 0 5px; color: #9ab0b4; font-size: 10px; }
button[aria-pressed="true"] { border-color: rgb(113 211 220 / 47%); color: #f1faf9; background: linear-gradient(145deg, rgb(63 152 160 / 35%), rgb(18 60 67 / 32%)); }
.mode-panel > p { margin: 16px 0 5px; color: var(--cyan); font-size: 9px; font-weight: 700; letter-spacing: .18em; }
.mode-panel h2 { margin: 0 0 7px; font-size: 20px; }
.mode-panel > p:last-of-type { margin: 0; color: var(--muted); font-size: 12px; font-weight: 400; line-height: 1.6; letter-spacing: 0; }
.progress { height: 2px; margin-top: 15px; overflow: hidden; background: rgb(200 240 240 / 14%); }
.progress i { display: block; height: 100%; background: linear-gradient(90deg, #6bb9c5, #e1a264); transform: scaleX(0); transform-origin: left; }

.process-status { top: 354px; right: 30px; width: min(318px, 25vw); padding: 15px 17px; border-radius: 14px; }
.process-status > p, .focus-panel > p { margin: 0 0 10px; color: #87c9d2; font-size: 9px; font-weight: 700; letter-spacing: .18em; }
.process-status dl { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 0; }
.process-status dl div { padding: 7px 0; border-top: 1px solid rgb(174 220 220 / 10%); }
.process-status dt { color: #839ba0; font-size: 9px; }
.process-status dd { margin: 3px 0 0; color: #e4f0ef; font-size: 11px; line-height: 1.35; }

.focus-panel { bottom: 110px; left: 30px; width: min(318px, 25vw); padding: 15px; border-radius: 14px; }
.focus-controls { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; }
.focus-controls button { min-height: 32px; padding: 4px 3px; color: #a5babd; font-size: 10px; }
.step-rail { right: 30px; bottom: 110px; left: 370px; display: flex; gap: 6px; padding: 8px; overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; background: rgb(5 18 22 / 80%); box-shadow: 0 16px 44px rgb(0 0 0 / 18%); backdrop-filter: blur(13px); scrollbar-width: none; }
.step-rail::-webkit-scrollbar { display: none; }
.step-rail button { display: grid; min-width: 96px; min-height: 48px; padding: 7px 9px; text-align: left; color: #91a9ad; }
.step-rail b { color: #7ec8d1; font-size: 9px; letter-spacing: .12em; }
.step-rail span { margin-top: 3px; font-size: 10px; white-space: nowrap; }
.actions { right: 30px; bottom: 54px; display: flex; gap: 7px; }
.actions button { min-height: 36px; padding: 0 12px; border-color: var(--line); color: #d4e6e5; font-size: 11px; background: rgb(5 18 21 / 74%); }
.actions button:disabled { cursor: not-allowed; opacity: .45; }
#resetView { border-color: rgb(122 205 216 / 34%); }
.truth-bar { right: 30px; bottom: 16px; left: 30px; display: flex; justify-content: space-between; gap: 16px; color: #acc2c5; font-size: 9px; line-height: 1.4; }

.fallback { position: absolute; z-index: 20; inset: 0; display: grid; place-items: center; padding: 24px; background: rgb(4 13 16 / 45%); }
#fallback[hidden] { display: none; }
.fallback-card { width: min(530px, 92vw); padding: 30px; border: 1px solid rgb(170 222 220 / 25%); border-radius: 18px; background: rgb(8 25 30 / 92%); box-shadow: 0 28px 70px rgb(0 0 0 / 35%); }
.fallback-card h1 { margin: 6px 0 10px; font-size: 30px; }
.fallback-card p, .fallback-card li { color: #b5c7c8; font-size: 13px; line-height: 1.7; }
.fallback-card dl { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; margin: 18px 0; }
.fallback-card dl div { padding: 10px; border: 1px solid var(--line); border-radius: 9px; }
.fallback-card dt { color: #95abb0; font-size: 9px; }
.fallback-card dd { margin: 4px 0 0; color: #eef8f6; font-size: 12px; }
.truth-note { color: #d6e7e5 !important; }

.embed-mode .topbar, .embed-mode .intro { display: none; }
.embed-mode .mode-panel { top: 22px; }
.embed-mode .process-status { display: none; }
.bottom-ui { display: contents; }
.poster-mode .topbar, .poster-mode .intro, .poster-mode .mode-panel, .poster-mode .process-status, .poster-mode .focus-panel, .poster-mode .step-rail, .poster-mode .actions, .poster-mode .truth-bar, .poster-mode #stage, .poster-mode .fallback { display: none; }
.capture-mode .poster, .capture-mode .topbar, .capture-mode .intro, .capture-mode .mode-panel, .capture-mode .process-status, .capture-mode .focus-panel, .capture-mode .step-rail, .capture-mode .actions, .capture-mode .truth-bar, .capture-mode .fallback { display: none; }
.static-mode #stage { display: none; }
.static-mode .poster { opacity: 1; }
.static-mode .fallback { background: linear-gradient(90deg, rgb(4 12 15 / 84%), transparent); place-items: center start; }
.static-mode .topbar, .static-mode .intro, .static-mode .mode-panel, .static-mode .process-status, .static-mode .focus-panel, .static-mode .step-rail, .static-mode .actions, .static-mode .truth-bar,
#app[data-fallback="true"] .topbar, #app[data-fallback="true"] .intro, #app[data-fallback="true"] .mode-panel, #app[data-fallback="true"] .process-status, #app[data-fallback="true"] .focus-panel, #app[data-fallback="true"] .step-rail, #app[data-fallback="true"] .actions, #app[data-fallback="true"] .truth-bar { display: none; }

@media (max-width: 640px) {
  #app { min-height: 0; }
  .topbar { height: 58px; padding: 0 14px; }
  .brand-mark { width: 30px; height: 30px; }
  .demo-status { font-size: 7px; letter-spacing: .12em; }
  .intro, .process-status, .focus-panel { display: none; }
  .mode-panel { top: 68px; right: 12px; left: 12px; width: auto; padding: 10px 13px; }
  .mode-tabs button { min-height: 32px; font-size: 9px; }
  .mode-panel > p { margin: 9px 0 3px; }
  .mode-panel h2 { margin-bottom: 4px; font-size: 17px; }
  .mode-panel > p:last-of-type { display: none; }
  .mode-panel .progress { margin-top: 8px; }
  .step-rail { right: 12px; bottom: 91px; left: 12px; padding: 6px; border-radius: 10px; }
  .step-rail button { min-width: 88px; min-height: 42px; }
  .actions { right: 12px; bottom: 49px; left: 12px; justify-content: space-between; gap: 4px; }
  .actions button { min-height: 33px; padding: 0 7px; font-size: 10px; }
  .truth-bar { right: 12px; bottom: 9px; left: 12px; display: block; font-size: 8px; }
  .truth-bar span { display: block; }
  .fallback-card { padding: 22px; }
  .fallback-card dl { grid-template-columns: 1fr; }
  .embed-mode .mode-panel { top: 12px; }
}

@media (max-height: 620px) and (min-width: 641px) {
  .intro { top: 82px; transform: scale(.88); transform-origin: top left; }
  .mode-panel { top: 84px; transform: scale(.9); transform-origin: top right; }
  .process-status { top: 300px; transform: scale(.84); transform-origin: top right; }
  .focus-panel { display: none; }
}

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

@media (max-width: 640px), (max-height: 500px) {
  .bottom-ui {
    position: absolute;
    z-index: 10;
    right: 12px;
    bottom: max(9px, env(safe-area-inset-bottom));
    left: 12px;
    display: grid;
    gap: 8px;
    pointer-events: none;
  }

  .bottom-ui > .step-rail,
  .bottom-ui > .actions,
  .bottom-ui > .truth-bar {
    position: static;
    width: auto;
    margin: 0;
    transform: none;
  }

  .bottom-ui > .step-rail,
  .bottom-ui button {
    pointer-events: auto;
  }

  .bottom-ui > .actions {
    justify-content: space-between;
  }

  .bottom-ui .actions button {
    min-height: 44px;
  }

  .bottom-ui > .truth-bar {
    display: block;
    line-height: 1.4;
  }

  .truth-bar span { display: block; }
}

@media (min-width: 641px) and (max-height: 500px) {
  .topbar { height: 58px; padding: 0 14px; }
  .intro, .process-status, .focus-panel { display: none; }
  .mode-panel { top: 68px; right: 12px; left: 12px; width: auto; padding: 10px 13px; transform: none; }
  .mode-panel > p { margin: 9px 0 3px; }
  .mode-panel h2 { margin-bottom: 4px; font-size: 17px; }
  .mode-panel > p:last-of-type { display: none; }
  .mode-panel .progress { margin-top: 8px; }
}
