  :root {
    --bg: #f2f5f7;
    --surface: #ffffff;
    --ink: #13202b;
    --muted: #5d6b77;
    --line: #dbe2e8;
    --accent: #0e7c86;
    --accent-ink: #ffffff;
    --hot: #d9482b;
    --calm: #1f9d6b;
    --font-display: "Bricolage Grotesque", "Segoe UI", sans-serif;
    --font-body: "DM Sans", system-ui, sans-serif;
  }
  @media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
      --bg: #0f171d; --surface: #17222a; --ink: #e7eef3; --muted: #93a3af;
      --line: #263540; --accent: #3cc3cd; --accent-ink: #06222a; --hot: #ff7b5c; --calm: #4cd09b;
      color-scheme: dark;
    }
  }
  :root[data-theme="dark"] {
    --bg: #0f171d; --surface: #17222a; --ink: #e7eef3; --muted: #93a3af;
    --line: #263540; --accent: #3cc3cd; --accent-ink: #06222a; --hot: #ff7b5c; --calm: #4cd09b;
    color-scheme: dark;
  }
  * { box-sizing: border-box; }
  [hidden] { display: none !important; }
  body {
    background: var(--bg); color: var(--ink);
    font: 16px/1.5 var(--font-body);
    padding-block: 28px 48px;
    padding-left: max(16px, env(safe-area-inset-left, 0px));
    padding-right: max(16px, env(safe-area-inset-right, 0px));
  }
  main { max-width: 520px; margin: 0 auto; display: flex; flex-direction: column; gap: 20px; }
  header h1 { font: 700 2rem/1.1 var(--font-display); margin: 0; letter-spacing: -0.02em; }
  header h1 .tw { color: var(--accent); }
  header p { margin: 6px 0 0; color: var(--muted); }
  label, .label { font-size: 0.75rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); font-weight: 600; }

  .card { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
  .card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
  textarea {
    width: 100%; min-height: 110px; resize: vertical; border: 0; outline: 0; background: transparent;
    color: var(--ink); font: 1.0625rem/1.5 var(--font-body); padding: 0;
  }
  .card:focus-within { border-color: var(--accent); }

  .meter { display: flex; align-items: center; gap: 8px; font-size: 0.8125rem; color: var(--muted); font-variant-numeric: tabular-nums; }
  .meter-track { width: 72px; height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
  .meter-fill { height: 100%; width: 0; border-radius: 3px; transition: width .5s ease, background-color .5s ease; }

  .samples { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
  .chip {
    font: 500 0.8125rem var(--font-body); color: var(--muted); background: transparent;
    border: 1px dashed var(--line); border-radius: 999px; padding: 4px 10px; cursor: pointer;
  }
  .chip:hover { border-color: var(--accent); color: var(--ink); }
  button:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

  .tones { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; }
  .tone {
    font: 600 0.9375rem var(--font-body); color: var(--ink); background: var(--surface);
    border: 1.5px solid var(--line); border-radius: 12px; padding: 14px 8px; cursor: pointer;
    display: flex; flex-direction: column; align-items: center; gap: 2px;
  }
  .tone small { font-weight: 400; font-size: 0.75rem; color: var(--muted); }
  .tone[aria-pressed="true"] { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, var(--surface)); }

  .go {
    font: 700 1.375rem var(--font-display); background: var(--accent); color: var(--accent-ink);
    border: 0; border-radius: 16px; padding: 20px; cursor: pointer; letter-spacing: -0.01em;
    box-shadow: 0 6px 0 color-mix(in srgb, var(--accent) 55%, #000);
    transition: transform .08s ease, box-shadow .08s ease;
  }
  .go:disabled { opacity: .85; cursor: progress; }
  .dots i { font-style: normal; animation: bounce 1s infinite; display: inline-block; }
  .dots i:nth-child(2) { animation-delay: .15s; }
  .dots i:nth-child(3) { animation-delay: .3s; }
  @keyframes bounce { 0%, 60%, 100% { transform: translateY(0); } 30% { transform: translateY(-5px); } }
  .skel { display: flex; flex-direction: column; gap: 10px; }
  .skel i, .skel-notes i {
    display: block; height: 14px; border-radius: 7px;
    background: linear-gradient(90deg, var(--line) 25%, color-mix(in srgb, var(--line) 40%, var(--surface)) 50%, var(--line) 75%);
    background-size: 200% 100%; animation: shimmer 1.2s linear infinite;
  }
  .skel i:nth-child(1) { width: 96%; } .skel i:nth-child(2) { width: 88%; } .skel i:nth-child(3) { width: 54%; }
  .skel-notes { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; border-top: 1px solid var(--line); padding-top: 12px; }
  .skel-notes div { display: flex; flex-direction: column; gap: 8px; }
  .skel-notes i { height: 11px; }
  .skel-notes i:nth-child(1) { width: 40%; } .skel-notes i:nth-child(2) { width: 90%; } .skel-notes i:nth-child(3) { width: 75%; }
  @keyframes shimmer { to { background-position: -200% 0; } }

  .result { border-color: var(--accent); }
  .result-text { font-size: 1.125rem; line-height: 1.5; margin: 0; }
  .result-text.loading { color: var(--muted); animation: pulse 1.1s ease-in-out infinite; }
  @keyframes pulse { 50% { opacity: .4; } }
  .actions { display: flex; gap: 8px; flex-wrap: wrap; }
  .ghost {
    font: 600 0.9375rem var(--font-body); color: var(--accent); background: transparent;
    border: 1.5px solid var(--accent); border-radius: 10px; padding: 10px 20px; cursor: pointer;
  }
  .ghost:hover { border-color: var(--accent); }
  .ghost.done { color: var(--calm); border-color: var(--calm); }
  .empty { color: var(--muted); font-size: 0.9375rem; margin: 0; }
  .notes { display: flex; flex-direction: column; gap: 12px; border-top: 1px solid var(--line); padding-top: 12px; }
  .notes h3 { margin: 0 0 6px; font: 600 0.75rem var(--font-body); letter-spacing: 0.08em; text-transform: uppercase; }
  .notes ul { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 6px; font-size: 0.9375rem; }
  .notes li { padding-left: 22px; position: relative; }
  .notes li::before { position: absolute; left: 0; font-weight: 700; }
  .notes .good h3, .notes .good li::before { color: var(--calm); }
  .notes .good li::before { content: "+"; }
  .notes .watch h3, .notes .watch li::before { color: var(--hot); }
  .notes .watch li::before { content: "!"; }
  .notes .orig h3 { color: var(--muted); }
  .notes .orig li::before { content: "\2022"; color: var(--muted); }
  .notes-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
  .top { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
  .seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; padding: 3px; background: var(--surface); }
  .seg button { font: 600 0.75rem var(--font-body); color: var(--muted); background: transparent; border: 0; border-radius: 7px; padding: 4px 10px; cursor: pointer; }
  .seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
  main[data-mode="compact"] .adv, main[data-mode="compact"] .tone small { display: none !important; }
  main[data-mode="compact"] textarea { min-height: 80px; }
  main[data-mode="compact"] .tone { padding: 10px 8px; }
  .go:active:not(:disabled) { transform: translateY(4px); box-shadow: 0 2px 0 color-mix(in srgb, var(--accent) 55%, #000); }
  #again { border-color: transparent; color: var(--muted); font-weight: 500; text-decoration: underline; padding: 10px 8px; }
  #again:hover { color: var(--ink); border-color: transparent; }
  footer { color: var(--muted); font-size: 0.8125rem; text-align: center; }
  @media (prefers-reduced-motion: reduce) { .meter-fill { transition: none; } .skel i, .skel-notes i, .dots i { animation: none; } }
.tone-label { margin-bottom: 8px; }
.error { margin: 0; color: var(--hot); font-size: 0.9375rem; }
footer a { color: inherit; }
