:root {
  --ink: #0d1b2a;
  --accent: #0b84c6;
  --frost: rgba(255, 255, 255, .72);
  --line: rgba(13, 27, 42, .16);
  --shadow: 0 12px 34px rgba(13, 27, 42, .20), 0 2px 6px rgba(13, 27, 42, .10);
  --frost-blur: blur(14px) saturate(1.4);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  overflow: hidden;
  background: #0d1b2a;
  color: var(--ink);
  font-family: "Space Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior: none;
}

#stage {
  position: fixed;
  inset: 0;
  display: block;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  z-index: 0;
  background: #0b6fa8;
  touch-action: none;
  outline: none;
}

/* ---------- intro card ---------- */

.intro {
  position: fixed;
  top: calc(14px + env(safe-area-inset-top));
  left: calc(14px + env(safe-area-inset-left));
  z-index: 10;
  width: 320px;
  max-width: calc(100vw - 28px);
  padding: 14px 16px 13px;
  background: var(--frost);
  -webkit-backdrop-filter: var(--frost-blur);
  backdrop-filter: var(--frost-blur);
  border: 1px solid rgba(255, 255, 255, .55);
  border-radius: 18px;
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, .6);
  transition: opacity .18s ease, transform .18s ease;
}

.intro-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.intro h1 {
  margin: 0;
  font-family: Unbounded, system-ui, sans-serif;
  font-weight: 800;
  font-size: 25px;
  line-height: 1;
  letter-spacing: -.02em;
}

.fold {
  display: none;
  width: 28px;
  height: 28px;
  margin: -2px -4px 0 0;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(13, 27, 42, .07);
  color: var(--ink);
  cursor: pointer;
  align-items: center;
  justify-content: center;
}

.fold svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 2; transition: transform .2s ease; }
.intro.collapsed .fold svg { transform: rotate(180deg); }

.intro-body {
  max-height: 170px;
  overflow: hidden;
  opacity: 1;
  transition: max-height .28s ease, opacity .2s ease;
}

.intro.collapsed .intro-body { max-height: 0; opacity: 0; }

.intro .kr {
  margin: 10px 0 3px;
  font-family: "Space Mono", "Apple SD Gothic Neo", "Noto Sans KR", system-ui, sans-serif;
  font-size: 13px;
  line-height: 1.55;
}

.intro .en {
  margin: 0;
  font-size: 12px;
  line-height: 1.6;
  color: rgba(13, 27, 42, .68);
}

.intro .links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0 0;
  font-size: 10px;
  letter-spacing: .02em;
}

.intro .links a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid transparent;
}

.intro .links a:hover { border-bottom-color: currentColor; }
.intro .links .dot { opacity: .35; }

/* ---------- bottom dock ---------- */

.dock {
  position: fixed;
  left: 0;
  right: 0;
  bottom: calc(14px + env(safe-area-inset-bottom));
  z-index: 12;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 0 10px;
  pointer-events: none;
  transition: opacity .18s ease;
}

.dock > * { pointer-events: auto; }

.hint {
  padding: 9px 14px;
  border: 1px solid rgba(255, 255, 255, .18);
  border-radius: 999px;
  background: rgba(13, 27, 42, .62);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  box-shadow: 0 6px 18px rgba(13, 27, 42, .25);
  color: #fff;
  font-size: 11px;
  line-height: 1;
  letter-spacing: .01em;
  pointer-events: none !important;
  transition: opacity .55s ease, transform .55s ease;
}

.hint.off { opacity: 0; transform: translateY(5px); }

.toolbar {
  display: flex;
  align-items: center;
  gap: 3px;
  max-width: calc(100vw - 20px);
  padding: 6px;
  background: rgba(255, 255, 255, .78);
  -webkit-backdrop-filter: var(--frost-blur);
  backdrop-filter: var(--frost-blur);
  border: 1px solid rgba(255, 255, 255, .55);
  border-radius: 999px;
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, .65);
  color: var(--ink);
}

.toolbar button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-width: 44px;
  height: 44px;
  padding: 0 10px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 11px;
  letter-spacing: .01em;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background .15s ease, color .15s ease, opacity .15s ease, transform .1s ease;
}

.toolbar button:hover { background: rgba(13, 27, 42, .07); }
.toolbar button:active { transform: scale(.97); }
.toolbar button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.toolbar button.active { background: var(--ink); color: #fff; }
.toolbar button.off { opacity: .4; }

.toolbar button svg {
  flex: none;
  width: 19px;
  height: 19px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.key {
  margin-left: 1px;
  padding: 0 3px;
  border: 1px solid currentColor;
  border-radius: 4px;
  font-size: 9px;
  line-height: 1.4;
  opacity: .45;
}

.toolbar button.active .key { opacity: .8; }

.brush {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 44px;
  padding: 0 8px 0 10px;
  border-radius: 999px;
}

.brush .label {
  font-size: 10px;
  letter-spacing: .05em;
  text-transform: uppercase;
  opacity: .55;
}

.brush input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 96px;
  height: 4px;
  margin: 0;
  border-radius: 999px;
  background: rgba(13, 27, 42, .18);
  outline: none;
  cursor: pointer;
}

.brush input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 1px 4px rgba(13, 27, 42, .35);
}

.brush input[type="range"]::-moz-range-track {
  height: 4px;
  border-radius: 999px;
  background: rgba(13, 27, 42, .18);
}

.brush input[type="range"]::-moz-range-thumb {
  width: 13px;
  height: 13px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 1px 4px rgba(13, 27, 42, .35);
}

.brush input:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; border-radius: 999px; }
.brush output { min-width: 18px; font-size: 10px; text-align: right; opacity: .55; font-variant-numeric: tabular-nums; }

.divider { flex: none; width: 1px; height: 22px; margin: 0 4px; background: var(--line); }

.row-break { display: none; }

.chip {
  padding: 0 13px;
  background: rgba(13, 27, 42, .06);
  font-size: 11px;
}

.chip:hover { background: rgba(13, 27, 42, .12); }

/* ---------- film mode extras ---------- */

.wordmark {
  display: none;
  position: fixed;
  top: calc(16px + env(safe-area-inset-top));
  left: calc(18px + env(safe-area-inset-left));
  z-index: 15;
  color: #fff;
  font-family: Unbounded, system-ui, sans-serif;
  font-weight: 700;
  font-size: 22px;
  line-height: 1;
  letter-spacing: -.02em;
  text-shadow: 0 1px 2px rgba(0, 0, 0, .28), 0 4px 22px rgba(0, 0, 0, .32);
  pointer-events: none;
  transition: opacity .18s ease;
}

#label {
  display: none;
  position: fixed;
  left: 50%;
  bottom: calc(26px + env(safe-area-inset-bottom));
  z-index: 15;
  max-width: min(80vw, 720px);
  padding: 9px 16px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(13, 27, 42, .58);
  -webkit-backdrop-filter: blur(10px) saturate(1.2);
  backdrop-filter: blur(10px) saturate(1.2);
  color: #fff;
  font-family: "Space Mono", ui-monospace, monospace;
  font-size: 15px;
  line-height: 1.4;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
  opacity: 0;
  transform: translateX(-50%);
  transition: opacity .25s ease;
  pointer-events: none;
}

body.film .intro,
body.film .dock { display: none !important; }
body.film .wordmark { display: block; }
body.film #label { display: block; }

/* ---------- clean-recording toggle ---------- */

body.ui-hidden .intro,
body.ui-hidden .dock,
body.ui-hidden .wordmark,
body.ui-hidden #label {
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
  transition: opacity .18s ease, visibility 0s linear .18s;
}

/* ---------- narrow screens ---------- */

@media (max-width: 640px) {
  .intro {
    top: calc(10px + env(safe-area-inset-top));
    left: calc(10px + env(safe-area-inset-left));
    width: min(300px, calc(100vw - 24px));
  }

  .intro .fold { display: inline-flex; }

  .dock {
    bottom: calc(10px + env(safe-area-inset-bottom));
    gap: 8px;
  }

  .toolbar {
    flex-wrap: wrap;
    justify-content: center;
    padding: 5px 8px;
    border-radius: 20px;
    row-gap: 2px;
    column-gap: 1px;
  }

  .row-break { display: block; flex-basis: 100%; width: 100%; height: 0; }

  .toolbar button { width: 44px; min-width: 44px; padding: 0; }
  .toolbar .label,
  .toolbar .key { display: none; }

  .brush { gap: 6px; padding: 0 6px; }
  .brush .label { display: none; }
  .brush input[type="range"] { width: 72px; }
  .brush output { display: none; }

  .divider { margin: 0 1px; }

  .chip { width: auto; min-width: 0; padding: 0 11px; font-size: 10px; }

  .hint { padding: 8px 12px; font-size: 10px; }
}

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