
  :root, :root[data-tone="dark"] {
    --stage: #000000;
    --ink: #f2f3f5;
    --muted: #a3a9b3;
    --chrome: rgba(24, 26, 30, 0.86);
    --chrome-line: rgba(255, 255, 255, 0.2);
    --field: #111316;
    --accent: #3b82f6;
    --accent-ink: #ffffff;
    --font-ui: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Helvetica Neue", "Segoe UI", Roboto, Arial, sans-serif;
    --composer-h: 54px;
    color-scheme: dark;
  }
  :root[data-tone="light"] {
    --ink: #15171a;
    --muted: #5b616b;
    --chrome: rgba(255, 255, 255, 0.86);
    --chrome-line: rgba(21, 23, 26, 0.16);
    --field: #ffffff;
    --accent: #2563eb;
    --accent-ink: #ffffff;
    color-scheme: light;
  }
  * { box-sizing: border-box; }
  html, body { height: 100%; }
  body {
    margin: 0;
    padding-block: 0;
    padding-left: max(16px, env(safe-area-inset-left, 0px));
    padding-right: max(16px, env(safe-area-inset-right, 0px));
    background: var(--stage);
    color: var(--ink);
    font: 500 14px/1.3 var(--font-ui);
    overflow: hidden;
    transition: background-color 0.35s ease;
  }
  #stage { position: fixed; inset: 0; width: 100%; height: 100%; display: block; z-index: 0; }

  .chrome {
    background: var(--chrome);
    border: 1px solid var(--chrome-line);
    border-radius: 10px;
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    color: var(--ink);
  }
  button, select, input { font: inherit; color: inherit; }
  button:focus-visible, select:focus-visible, input:focus-visible, a:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
  }

  #composer {
    position: fixed;
    z-index: 5;
    bottom: calc(env(safe-area-inset-bottom, 0px) + 12px);
    left: max(16px, env(safe-area-inset-left, 0px));
    right: max(16px, env(safe-area-inset-right, 0px));
    max-width: 820px;
    margin-inline: auto;
    padding: 8px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
  }
  #msg {
    flex: 1 1 170px;
    min-width: 0;
    height: 38px;
    padding: 0 12px;
    border: 1px solid var(--chrome-line);
    border-radius: 8px;
    background: var(--field);
  }
  #msg::placeholder { color: var(--muted); }
  #font {
    flex: 0 1 130px;
    min-width: 0;
    height: 38px;
    padding: 0 8px;
    border: 1px solid var(--chrome-line);
    border-radius: 8px;
    background: var(--field);
  }
  #color {
    width: 38px; height: 38px; padding: 0;
    border: 1px solid var(--chrome-line); border-radius: 8px; background: var(--field);
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
    overflow: hidden;
  }
  #color::-webkit-color-swatch-wrapper { padding: 0; }
  #color::-webkit-color-swatch { border: 0; border-radius: 7px; }
  #color::-moz-color-swatch { border: 0; border-radius: 7px; }
  #font:disabled, #color:disabled { opacity: 0.45; cursor: not-allowed; }
  #shuffle .icon-shuffle-off { display: none; }
  #shuffle[aria-pressed="false"] .icon-shuffle { display: none; }
  #shuffle[aria-pressed="false"] .icon-shuffle-off { display: block; }
  .ctl { display: flex; align-items: center; gap: 8px; }
  .ctl label { color: var(--muted); font-size: 12px; }
  #size { width: 90px; accent-color: var(--accent); }
  #sizeOut { font: 600 12px var(--font-ui); min-width: 3ch; text-align: right; font-variant-numeric: tabular-nums; }
  .btn {
    height: 38px; padding: 0 14px;
    border: 1px solid var(--chrome-line); border-radius: 8px;
    background: var(--field); cursor: pointer;
  }
  .btn:hover { border-color: var(--accent); }
  .btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 700; }
  .btn:disabled { opacity: 0.45; cursor: not-allowed; }
  .btn.icon-only { width: 38px; padding: 0; display: inline-flex; align-items: center; justify-content: center; }
  .btn.icon-only svg { width: 20px; height: 20px; display: block; }
  #add { border-radius: 8px; }
  #coffeeBtn {
    border-radius: 8px; padding: 0; text-decoration: none;
  }
  #coffeeBtn img { width: 30px; height: 30px; object-fit: contain; display: block; }
  #coffeeBtn .coffeeOnLight { display: none; }
  :root[data-tone="light"] #coffeeBtn .coffeeOnDark { display: none; }
  :root[data-tone="light"] #coffeeBtn .coffeeOnLight { display: block; }
  #pause .icon-play { display: none; }
  #pause[aria-pressed="true"] .icon-pause { display: none; }
  #pause[aria-pressed="true"] .icon-play { display: block; }
  .spacer { flex: 1 1 0; }

  #appIcon {
    position: fixed; z-index: 6;
    display: block;
    top: calc(env(safe-area-inset-top, 0px) + 12px);
    left: max(16px, env(safe-area-inset-left, 0px));
    width: 44px; height: 44px;
    border-radius: 10px;
    transition: transform 0.18s ease, opacity 0.18s ease;
  }
  #appIcon:hover { transform: scale(1.05); opacity: 0.9; }
  #appIcon img { width: 100%; height: 100%; display: block; object-fit: contain; border-radius: 10px; }

  #minimize {
    position: fixed; z-index: 6;
    top: calc(env(safe-area-inset-top, 0px) + 12px);
    right: max(16px, env(safe-area-inset-right, 0px));
    width: 28px; height: 28px; padding: 0; border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
  }
  #minimize svg { width: 14px; height: 14px; display: block; }
  #minimize .icon-restore { display: none; }
  body.minimized #minimize .icon-min { display: none; }
  body.minimized #minimize .icon-restore { display: block; }
  body.minimized #composer,
  body.minimized #soundDock,
  body.minimized #hits { display: none; }

  #hits {
    position: fixed; z-index: 5;
    left: max(16px, env(safe-area-inset-left, 0px));
    bottom: calc(env(safe-area-inset-bottom, 0px) + 16px);
    padding: 7px 10px;
    color: var(--ink);
    font-size: 12px; font-weight: 600;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
  }
  @media (max-width: 1040px) {
    #hits { bottom: calc(env(safe-area-inset-bottom, 0px) + var(--composer-h, 54px) + 20px); }
  }

  #soundDock {
    position: fixed; z-index: 5;
    right: max(16px, env(safe-area-inset-right, 0px));
    bottom: calc(env(safe-area-inset-bottom, 0px) + var(--composer-h, 54px) + 20px);
    display: flex; flex-direction: column; align-items: flex-end; gap: 8px;
    max-width: calc(100vw - 32px);
  }
  #soundBox {
    width: min(360px, calc(100vw - 32px));
    max-height: 45vh; overflow: auto; padding: 10px;
  }
  .boxHead { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
  .boxHead .btn { height: 30px; padding: 0 10px; font-size: 12px; }
  .boxActions { display: flex; gap: 6px; }
  #closeSounds { font-size: 16px; }
  .row { display: grid; grid-template-columns: 14px minmax(0, 1fr) auto auto auto; align-items: center; gap: 6px; padding: 4px 0; }
  .dot {
    width: 14px; height: 14px; padding: 0;
    border-radius: 50%; border: 1px solid var(--chrome-line);
    background: none; cursor: pointer; overflow: hidden;
    -webkit-appearance: none; appearance: none;
  }
  .dot::-webkit-color-swatch-wrapper { padding: 0; }
  .dot::-webkit-color-swatch { border: 0; border-radius: 50%; }
  .dot::-moz-color-swatch { border: 0; border-radius: 50%; }
  .lbl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .row select { height: 30px; max-width: 112px; border: 1px solid var(--chrome-line); border-radius: 6px; background: var(--field); padding: 0 4px; }
  .mini { width: 30px; height: 30px; border: 1px solid var(--chrome-line); border-radius: 6px; background: var(--field); cursor: pointer; padding: 0; line-height: 1; }
  .mini:hover { border-color: var(--accent); }
  .empty, #soundHint { color: var(--muted); font-size: 12px; }
  #soundHint { margin-top: 6px; min-height: 1em; }
