@layer reset, base, scene, controls;

@layer reset {
  *, *::before, *::after { box-sizing: border-box; }
  html, body { width: 100%; height: 100%; margin: 0; }
  button, input { font: inherit; }
  button { cursor: pointer; }
}

@layer base {
  :root { color-scheme: dark; --ink: #f1f3f0; --dim: #9da69c; --line: #ffffff24; --accent: #9dff3a; --glass: #080a08d9; }
  body { overflow: hidden; background: #000; color: var(--ink); font: 400 13px/1.45 "Share Tech Mono", ui-monospace, monospace; }
  .topbar { position: fixed; z-index: 4; inset: 0 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 18px; min-height: 64px; padding: 10px clamp(14px, 3vw, 36px); border-bottom: 1px solid #fff2; background: linear-gradient(#050706db, #05070686, transparent); }
  .brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; }
  .brand-mark { width: 34px; height: 34px; display: grid; place-items: center; border: 1px solid #00eaff80; border-radius: 8px; color: #ffe15a; font: 800 12px/1 "Share Tech Mono", monospace; }
  .brand strong, .brand small { display: block; }
  .brand strong { font: 700 12px/1.2 system-ui, sans-serif; letter-spacing: .12em; }
  .brand small { margin-top: 3px; color: #9dff3a; font-size: 9px; letter-spacing: .12em; }
  .privacy-note, .home-link { color: #c5cdc1; font-size: 10px; letter-spacing: .1em; }
  .privacy-dot { display: inline-block; width: 7px; height: 7px; margin-right: 7px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 10px #9dff3a88; }
  .home-link { color: var(--accent); text-decoration: none; white-space: nowrap; }
  .home-link:hover { color: white; }
  main { position: relative; width: 100%; height: 100%; }
  @media (max-width: 560px) { .topbar { min-height: 56px; } .privacy-note { display: none; } }
}

@layer scene {
  #out { position: fixed; inset: 0; display: block; width: 100%; height: 100%; background: #000; }
  #vid { position: fixed; top: 0; left: 0; width: 2px; height: 2px; opacity: 0; pointer-events: none; }
  #hint { position: fixed; z-index: 2; top: 84px; left: 50%; width: min(94vw, 760px); padding: 0 14px; transform: translateX(-50%); color: #d7ddd2b8; font-size: 12px; text-align: center; pointer-events: none; transition: opacity .35s ease; }
  #hint.off { opacity: 0; }
  #toast { position: fixed; z-index: 6; top: 72px; left: 50%; max-width: calc(100vw - 28px); padding: 9px 14px; transform: translateX(-50%); border: 1px solid #ffffff36; background: #eef4e9; color: #080a08; opacity: 0; pointer-events: none; transition: opacity .2s ease; }
  #toast.show { opacity: 1; }
}

@layer controls {
  #dock { position: fixed; z-index: 5; left: 50%; bottom: max(12px, env(safe-area-inset-bottom)); width: min(980px, calc(100vw - 20px)); max-height: min(70vh, 590px); overflow: auto; transform: translateX(-50%); border: 1px solid var(--line); background: var(--glass); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); box-shadow: 0 14px 45px #0008; }
  #dock.collapsed { display: none; }
  .bar { display: flex; align-items: stretch; justify-content: space-between; gap: 8px; border-bottom: 1px solid var(--line); }
  .tabs, .tools { display: flex; align-items: stretch; }
  .tab, .tool-button { min-height: 44px; padding: 10px 15px; border: 0; border-bottom: 2px solid transparent; background: transparent; color: var(--dim); font: 600 10px/1.2 "Share Tech Mono", monospace; letter-spacing: .1em; white-space: nowrap; }
  .tab:hover, .tool-button:hover { color: var(--ink); }
  .tab[aria-selected="true"] { border-bottom-color: var(--accent); color: var(--ink); }
  .tool-button { padding-inline: 9px; font-size: 9px; }
  .tool-button.on { color: #ff6868; }
  .tool-button.on::before { content: "● "; }
  .format-control { display: flex; align-items: center; }
  .format-control select { min-height: 32px; padding: 5px 7px; border: 1px solid var(--line); background: #080a08; color: var(--ink); font: 600 9px/1 "Share Tech Mono", monospace; }
  .format-control select:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
  .format-control select:disabled { color: var(--dim); }
  .format-status { color: var(--dim); font-size: 8px; white-space: nowrap; }
  .sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
  .pane { display: none; grid-template-columns: repeat(auto-fit, minmax(min(100%, 190px), 1fr)); align-items: end; gap: 14px 20px; padding: 15px; }
  .pane.active { display: grid; }
  .wide { grid-column: 1 / -1; }
  .actions, .url-row { display: flex; flex-wrap: wrap; gap: 8px; }
  .field { display: grid; gap: 7px; min-width: 0; }
  .field-label, .field > label { display: flex; justify-content: space-between; gap: 8px; color: var(--dim); font-size: 11px; }
  .field-label b { color: var(--ink); font-weight: 500; font-variant-numeric: tabular-nums; }
  .optional, .note { color: var(--dim); font-size: 10px; }
  .note { margin: 6px 0 0; line-height: 1.45; }
  .url-row input { flex: 1 1 220px; min-width: 0; }
  .button, input[type="text"], input[type="url"] { min-height: 40px; padding: 8px 11px; border: 1px solid var(--line); border-radius: 2px; background: #ffffff0a; color: var(--ink); font: 500 12px/1.2 "Share Tech Mono", monospace; }
  .button:hover { border-color: #e6eee0; }
  .button:disabled { cursor: not-allowed; opacity: .45; }
  .button.primary { border-color: var(--accent); background: var(--accent); color: #080a06; font-weight: 700; }
  input::placeholder { color: #f2f2f259; }
  input[type="color"] { width: 100%; height: 36px; border: 1px solid var(--line); background: transparent; padding: 2px; }
  input[type="range"] { width: 100%; height: 22px; margin: 0; accent-color: var(--accent); }
  .check { display: flex; align-items: center; gap: 9px; min-height: 36px; color: var(--ink); cursor: pointer; }
  .check input { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); }
  button:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
  #pill { position: fixed; z-index: 5; left: 50%; bottom: max(12px, env(safe-area-inset-bottom)); display: none; min-height: 42px; padding: 9px 18px; transform: translateX(-50%); border: 1px solid var(--line); background: var(--glass); color: var(--ink); font: 600 10px/1 "Share Tech Mono", monospace; letter-spacing: .1em; -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); }
  #dock.collapsed + #pill { display: block; }
  @media (max-width: 620px) { #dock { bottom: max(8px, env(safe-area-inset-bottom)); width: calc(100vw - 12px); max-height: 58vh; } .bar { flex-direction: column; } .tabs { overflow-x: auto; } .tab { flex: 1 0 auto; padding-inline: 12px; } .tools { justify-content: flex-end; flex-wrap: wrap; border-top: 1px solid var(--line); } .format-status { display: none; } .pane { gap: 12px; padding: 12px; } }
  @media (prefers-reduced-motion: reduce) { #hint, #toast { transition: none; } }
}
