:root {
  color-scheme: dark;
  --panel: #101820;
  --panel-2: #18232d;
  --line: rgba(255,255,255,.11);
  --text: #f2f5f7;
  --muted: #9facb7;
  --accent: #65d1d0;
  --accent-2: #f0b568;
  --danger: #ff8d82;
  font-family: Inter, "Noto Sans TC", "Microsoft JhengHei", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body, #app { width: 100%; height: 100%; margin: 0; overflow: hidden; }
body { background: #0b1117; color: var(--text); }
button, input { font: inherit; }
button { cursor: pointer; }
#app { display: grid; grid-template-columns: 320px minmax(0, 1fr); }
.panel {
  position: relative; z-index: 3; overflow-y: auto; padding: 24px 20px 18px;
  background: linear-gradient(180deg, #13202a, var(--panel)); border-right: 1px solid var(--line);
  box-shadow: 12px 0 32px rgba(0,0,0,.18);
}
.brand { padding-bottom: 18px; border-bottom: 1px solid var(--line); }
.eyebrow { color: var(--accent); font-size: 12px; letter-spacing: .12em; text-transform: uppercase; }
h1 { margin: 6px 0 5px; font-size: 24px; line-height: 1.2; }
.brand p, footer p { margin: 0; color: var(--muted); font-size: 12px; }
.status-card { margin: 16px 0 8px; padding: 13px; border: 1px solid var(--line); border-radius: 12px; background: rgba(255,255,255,.035); }
.status-row { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px rgba(101,209,208,.12); }
.dot.loading { animation: pulse 1.2s infinite; }
.dot.error { background: var(--danger); box-shadow: 0 0 0 4px rgba(255,141,130,.12); }
.progress-track { height: 4px; margin-top: 11px; overflow: hidden; border-radius: 99px; background: rgba(255,255,255,.08); }
.progress-bar { width: 0%; height: 100%; background: linear-gradient(90deg,var(--accent),#8fe7bd); transition: width .2s ease; }
.status-card small { display: block; margin-top: 5px; color: var(--muted); text-align: right; }
section h2 { margin: 18px 0 9px; font-size: 13px; letter-spacing: .04em; color: #dbe4e9; }
.button-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
button {
  min-height: 38px; padding: 8px 10px; color: var(--text); background: #1c2a35;
  border: 1px solid rgba(255,255,255,.12); border-radius: 9px; transition: background .16s, border-color .16s, transform .08s;
}
button:hover { background: #263745; border-color: rgba(101,209,208,.45); }
button:active { transform: translateY(1px); }
button[aria-pressed="true"] { color: #071416; background: var(--accent); border-color: var(--accent); }
.section-title-row { display: flex; align-items: center; justify-content: space-between; }
.text-button { min-height: 26px; padding: 2px 7px; color: var(--accent); border: 0; background: transparent; font-size: 12px; }
.layer-controls { display: grid; grid-template-columns: 1fr 1fr; gap: 7px 10px; }
.layer-controls label { display: flex; align-items: center; gap: 6px; color: #d7e0e5; font-size: 13px; }
input[type="checkbox"] { width: 15px; height: 15px; accent-color: var(--accent); }
.solo-row { display: flex; align-items: center; gap: 6px; margin-top: 12px; color: var(--muted); font-size: 12px; }
.solo-row button { min-height: 29px; padding: 4px 9px; font-size: 12px; }
.slider-label { display: flex; justify-content: space-between; margin-top: 15px; color: #d7e0e5; font-size: 12px; }
.slider-label output { color: var(--accent); }
input[type="range"] { width: 100%; margin: 8px 0 0; accent-color: var(--accent); }
footer { margin-top: 22px; padding-top: 13px; border-top: 1px solid var(--line); line-height: 1.8; }
.viewer { position: relative; min-width: 0; min-height: 0; overflow: hidden; background: #17212a; touch-action: none; }
.viewer canvas { display: block; width: 100%; height: 100%; outline: none; }
.viewport-label {
  position: absolute; z-index: 2; top: 16px; left: 18px; display: flex; gap: 8px; pointer-events: none;
}
.viewport-label span { padding: 5px 9px; border: 1px solid rgba(255,255,255,.12); border-radius: 99px; background: rgba(10,16,22,.72); color: #d8e2e7; font-size: 12px; backdrop-filter: blur(8px); }
.loading-overlay { position: absolute; z-index: 5; inset: 0; display: grid; place-content: center; justify-items: center; gap: 12px; background: rgba(13,20,26,.86); transition: opacity .35s; }
.loading-overlay.hidden { opacity: 0; pointer-events: none; }
.loading-overlay span { color: var(--accent); }
.loader-ring { width: 44px; height: 44px; border: 3px solid rgba(255,255,255,.1); border-top-color: var(--accent); border-radius: 50%; animation: spin .9s linear infinite; }
.error-panel { position: absolute; z-index: 6; left: 50%; top: 50%; transform: translate(-50%,-50%); width: min(520px, calc(100% - 34px)); padding: 20px; border: 1px solid rgba(255,141,130,.4); border-radius: 14px; background: rgba(42,23,25,.94); box-shadow: 0 22px 70px rgba(0,0,0,.4); }
.error-panel strong { color: var(--danger); font-size: 18px; }
.error-panel p { margin: 9px 0 0; color: #ecd9d8; line-height: 1.55; font-size: 13px; }
code { color: #fff; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 50% { opacity: .4; } }
@media (max-width: 760px) {
  html, body, #app { overflow: hidden; }
  #app { grid-template-columns: 1fr; grid-template-rows: minmax(55vh, 1fr) minmax(245px, 41vh); }
  .viewer { grid-row: 1; }
  .panel { grid-row: 2; padding: 14px 14px calc(15px + env(safe-area-inset-bottom)); border-right: 0; border-top: 1px solid var(--line); box-shadow: 0 -10px 28px rgba(0,0,0,.25); }
  .brand { display: flex; align-items: baseline; gap: 9px; padding-bottom: 10px; }
  .eyebrow { display: none; }
  h1 { margin: 0; font-size: 18px; }
  .brand p { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .status-card { margin: 10px 0; padding: 9px 11px; }
  section h2 { margin: 10px 0 7px; }
  .button-grid { grid-template-columns: repeat(3, 1fr); }
  button { min-height: 34px; padding: 6px; font-size: 12px; }
  footer { display: none; }
  .viewport-label { top: 10px; left: 10px; }
}
@media (max-width: 430px) {
  .button-grid { grid-template-columns: 1fr 1fr; }
  .layer-controls { grid-template-columns: 1fr 1fr; }
}
