/* Plex Channel Builder, in Aster's look (astermediaplayer.com). Everything is served from this site: the
   content-security policy allows no outside fonts, styles or scripts. Fonts: SIL OFL, texts in fonts/. */
@font-face { font-family: 'Atkinson Hyperlegible'; font-style: normal; font-weight: 400; font-display: swap; src: url(fonts/AtkinsonHyperlegible-400.woff2) format('woff2'); }
@font-face { font-family: 'Atkinson Hyperlegible'; font-style: normal; font-weight: 700; font-display: swap; src: url(fonts/AtkinsonHyperlegible-700.woff2) format('woff2'); }
@font-face { font-family: 'Bricolage Grotesque'; font-style: normal; font-weight: 600 800; font-display: swap; src: url(fonts/BricolageGrotesque-600-800.woff2) format('woff2'); }
@font-face { font-family: 'IBM Plex Mono'; font-style: normal; font-weight: 400; font-display: swap; src: url(fonts/IBMPlexMono-400.woff2) format('woff2'); }
@font-face { font-family: 'IBM Plex Mono'; font-style: normal; font-weight: 600; font-display: swap; src: url(fonts/IBMPlexMono-600.woff2) format('woff2'); }

:root {
  color-scheme: light dark;
  --bg: #f6f4fb; --surface: #ffffff; --ink: #1d1830; --muted: #5d5873; --line: #e2ddef;
  --petal: #5b3fd0; --petal-soft: #ebe5ff; --gold: #e8a50c; --on-petal: #ffffff;
  --err: #b42318; --err-soft: #fdecea; --hint-soft: #fdf3dc; --hint-ink: #6e4a00;
  --font-display: "Bricolage Grotesque", "Avenir Next", "Segoe UI", system-ui, sans-serif;
  --font-body: "Atkinson Hyperlegible", "Helvetica Neue", Arial, system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #13101d; --surface: #1c1829; --ink: #efecf8; --muted: #a8a2bf; --line: #2e2945;
    --petal: #a995ff; --petal-soft: #2a2350; --gold: #f4b93a; --on-petal: #13101d;
    --err: #ff8a80; --err-soft: #3a1d1f; --hint-soft: #2e2412; --hint-ink: #f4d38a;
  }
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font-body); font-size: 1.0625rem; line-height: 1.55; -webkit-font-smoothing: antialiased; }
a { color: var(--petal); text-underline-offset: 3px; }
h1, h2, h3 { font-family: var(--font-display); line-height: 1.12; margin: 0; letter-spacing: -0.01em; text-wrap: balance; }
code { font-family: var(--font-mono); font-size: 0.86em; background: var(--petal-soft); border-radius: 5px; padding: 0.08em 0.35em; }
:focus-visible { outline: 3px solid var(--petal); outline-offset: 2px; border-radius: 6px; }
[hidden] { display: none !important; }
.wrap { max-width: 72rem; margin: 0 auto; padding-inline: 16px; }
@media (min-width: 40rem) { .wrap { padding-inline: 24px; } }

/* Header: "Channel Builder · by Aster" */
.site-header { padding-block: 18px; border-bottom: 1px solid var(--line); }
.site-header .wrap { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); font-family: var(--font-display); font-weight: 700; font-size: 1.15rem; }
.brand img { width: 30px; height: 30px; }
.by-dot { color: var(--muted); font-weight: 700; }
.by-aster { font-family: var(--font-display); font-weight: 700; font-size: 1.15rem; color: var(--petal); text-decoration: none; }
.by-aster:hover { text-decoration: underline; text-decoration-thickness: 2px; }

/* Intro */
.intro { padding-block: 28px 8px; }
.eyebrow { font-family: var(--font-mono); font-size: 0.78rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin: 0 0 8px; }
.intro h1 { font-size: clamp(1.9rem, 4.5vw, 2.8rem); font-weight: 800; letter-spacing: -0.02em; }
.intro h1 em { font-style: normal; color: var(--petal); }
.lede { color: var(--muted); font-size: 1.15rem; max-width: 46rem; margin: 12px 0 0; }
.how { margin: 18px 0 0; padding-left: 1.3rem; max-width: 46rem; display: grid; gap: 4px; }

/* Layout: one column; form left and output right on wide screens */
.builder { display: grid; gap: 24px; padding-block: 20px 56px; }
@media (min-width: 60rem) {
  .builder { grid-template-columns: minmax(0, 1fr) minmax(0, 26rem); align-items: start; }
  .output-panel { position: sticky; top: 16px; }
}

/* Form sections */
.form { display: grid; gap: 18px; min-width: 0; }
fieldset { margin: 0; padding: 20px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); min-width: 0; display: grid; gap: 16px; }
legend { font-family: var(--font-display); font-weight: 700; font-size: 1.3rem; padding: 0 6px; margin-left: -6px; }
.section-note { margin: -6px 0 0; color: var(--muted); font-size: 0.95rem; }
.field { display: grid; gap: 6px; min-width: 0; }
.field > label, .field > .label { font-weight: 700; font-size: 0.95rem; }
.help { color: var(--muted); font-size: 0.88rem; margin: 0; }
.row2 { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr)); }
.pair { display: flex; align-items: center; gap: 8px; }
.pair span { color: var(--muted); }
input[type="text"], input[type="number"], select, textarea {
  font: inherit; font-size: 1rem; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 10px;
  padding: 0 12px; height: 2.6rem; width: 100%; min-width: 0;
}
textarea { height: auto; min-height: 5.5rem; padding: 10px 12px; resize: vertical; }
input:hover, select:hover, textarea:hover { border-color: var(--muted); }
.field.bad input, .field.bad textarea, .field.bad .tags { border-color: var(--err); }
.err { color: var(--err); font-size: 0.88rem; font-weight: 700; margin: 0; }
.hint { background: var(--hint-soft); color: var(--hint-ink); border-radius: 10px; padding: 8px 12px; font-size: 0.9rem; margin: 0; }

/* Tag lists */
.tags { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 6px; min-height: 2.6rem; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); cursor: text; }
.tags:focus-within { outline: 3px solid var(--petal); outline-offset: 2px; }
.tag { display: inline-flex; align-items: center; gap: 4px; max-width: 100%; background: var(--petal-soft); color: var(--ink); border-radius: 999px; padding: 3px 4px 3px 10px; font-size: 0.92rem; }
.tag span { overflow-wrap: anywhere; }
.tag button { border: 0; background: transparent; color: var(--muted); font: inherit; font-size: 1rem; line-height: 1; cursor: pointer; padding: 2px 6px; border-radius: 999px; }
.tag button:hover { color: var(--ink); background: var(--line); }
.tags input { border: 0; background: transparent; height: 1.9rem; padding: 0 4px; flex: 1 1 8rem; width: auto; outline: none; }

/* Toggles */
.toggle { display: flex; align-items: center; gap: 12px; cursor: pointer; font-weight: 700; font-size: 0.95rem; }
.toggle input { appearance: none; -webkit-appearance: none; flex: none; width: 44px; height: 26px; border-radius: 999px; background: var(--line); position: relative; cursor: pointer; transition: background 0.15s; margin: 0; }
.toggle input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: transform 0.15s; }
.toggle input:checked { background: var(--petal); }
.toggle input:checked::after { transform: translateX(18px); }
.bug-details { display: grid; gap: 16px; padding-left: 14px; border-left: 3px solid var(--petal-soft); }
.slider { display: flex; align-items: center; gap: 10px; }
.slider input { flex: 1; accent-color: var(--petal); }
.slider output { font-family: var(--font-mono); font-size: 0.9rem; min-width: 3.5em; text-align: right; }

/* Show weights */
.weights { display: grid; gap: 8px; }
.weight-row { display: grid; grid-template-columns: minmax(0, 1fr) 5rem auto; gap: 8px; align-items: center; }
.weight-row .err { grid-column: 1 / -1; }

/* Buttons */
.btn { font: inherit; font-weight: 700; font-size: 0.95rem; border-radius: 999px; padding: 9px 18px; cursor: pointer; border: 2px solid var(--ink); background: var(--ink); color: var(--bg); }
.btn:hover { background: var(--petal); border-color: var(--petal); color: #fff; }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn.ghost:hover { border-color: var(--petal); color: var(--ink); }
.btn.small { padding: 5px 12px; font-size: 0.85rem; }
.icon-btn { font: inherit; border: 1px solid var(--line); background: transparent; color: var(--muted); border-radius: 10px; height: 2.6rem; padding: 0 12px; cursor: pointer; }
.icon-btn:hover { color: var(--ink); border-color: var(--muted); }

/* Output panel */
.output-panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; display: grid; gap: 12px; min-width: 0; }
.output-panel h2 { font-size: 1.3rem; }
.problems { margin: 0; padding: 10px 12px 10px 30px; background: var(--err-soft); color: var(--err); border-radius: 10px; font-size: 0.9rem; font-weight: 700; }
#output { font-family: var(--font-mono); font-size: 0.86rem; line-height: 1.55; min-height: 9rem; background: var(--bg); white-space: pre-wrap; overflow-wrap: anywhere; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.paste-note { color: var(--muted); font-size: 0.88rem; margin: 0; }

/* Footer */
.site-footer { border-top: 1px solid var(--line); padding-block: 22px 32px; color: var(--muted); font-size: 0.88rem; }
.site-footer p { margin: 0 0 6px; max-width: 52rem; }

/* Your Plex library (optional sign-in) */
.plex { border-style: dashed; }
.optional { font-family: var(--font-mono); font-size: 0.68rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--petal); background: var(--petal-soft); border-radius: 999px; padding: 3px 8px; vertical-align: middle; margin-left: 4px; }
.signed-in { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.plex-status { margin: 0; font-size: 0.9rem; color: var(--muted); }
.plex-status.bad { color: var(--err); font-weight: 700; }

/* New channel, search results, and the confirm step */
.new-channel { display: grid; gap: 16px; padding: 16px; border-radius: 12px; background: var(--bg); border: 1px solid var(--line); }
.results, .picked { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.results { max-height: 16rem; overflow-y: auto; border: 1px solid var(--line); border-radius: 10px; padding: 6px; background: var(--surface); }
.results li, .picked li { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-width: 0; }
.results li span, .picked li span { min-width: 0; overflow-wrap: anywhere; }
.results small, .picked small { color: var(--muted); }
.picked li { background: var(--petal-soft); border-radius: 10px; padding: 6px 6px 6px 12px; }
.confirm { display: grid; gap: 10px; padding: 16px; border-radius: 12px; border: 2px solid var(--gold); background: var(--hint-soft); }
.confirm h3 { font-size: 1.15rem; }
.confirm p { margin: 0; }
.confirm .label { font-weight: 700; font-size: 0.9rem; }
.confirm pre { margin: 0; padding: 10px 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; font-family: var(--font-mono); font-size: 0.82rem; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 14rem; overflow-y: auto; }

/* What's in a playlist */
.contents { display: grid; gap: 12px; padding: 16px; border-radius: 12px; background: var(--bg); border: 1px solid var(--line); }
.contents h3 { font-size: 1.1rem; }
.content-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; max-height: 24rem; overflow-y: auto; }
.content-list .group { font-family: var(--font-mono); font-size: 0.72rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); margin-top: 6px; }
.content-list .item { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-width: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 6px 6px 6px 12px; }
.content-list .item span { min-width: 0; overflow-wrap: anywhere; }
.content-list .item small { color: var(--muted); }
.content-list .item.removing span { text-decoration: line-through; color: var(--muted); }
.content-list .item.adding { border-style: dashed; border-color: var(--petal); }
.content-list .tag-note { font-family: var(--font-mono); font-size: 0.68rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--petal); margin-left: 6px; }
