/* Mendil web panel: a radio station's running order. Public Sans is bundled (SIL OFL, fonts/). */
@font-face {
  font-family: "Public Sans";
  src: url(fonts/public-sans-latin-ext.woff2) format("woff2");
  font-weight: 300 900;
  font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Public Sans";
  src: url(fonts/public-sans-latin.woff2) format("woff2");
  font-weight: 300 900;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --ground: #e9edf1;       /* studio grey-blue */
  --panel: #ffffff;
  --panel-2: #f4f6f8;      /* row hover, next-up row */
  --ink: #1d2733;          /* navy ink */
  --ink-2: #4a596b;        /* secondary text, >= 6:1 on ground and panel */
  --rule: #cdd5de;
  --rule-strong: #9aa7b4;
  --bar: #1d2733;
  --bar-ink: #eef2f6;
  --bar-ink-2: #b4c0cc;
  --lamp: #d7332b;         /* reserved: on air, progress */
  --lamp-ink: #ffffff;
  --ok: #1f8a4c;
  --warn: #b26a00;
  --focus: #1d2733;
  --radius: 6px;
  --font: "Public Sans", ui-sans-serif, system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --ground: #18212b;     /* control room: deep blue-grey */
    --panel: #212d3a;
    --panel-2: #283646;
    --ink: #e6ebf0;
    --ink-2: #aab8c6;
    --rule: #33424f;
    --rule-strong: #4b5c6d;
    --bar: #111a23;
    --bar-ink: #e6ebf0;
    --bar-ink-2: #93a3b3;
    --lamp: #ff4b3e;
    --lamp-ink: #1a0503;
    --ok: #4cc283;
    --warn: #e0a243;
    --focus: #e6ebf0;
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font: 15px/1.45 var(--font);
  font-variant-numeric: tabular-nums;
  caret-color: var(--ink);
  scrollbar-color: var(--rule-strong) transparent;
}
::selection { background: var(--ink); color: var(--panel); }
[hidden] { display: none !important; }
a { color: inherit; text-underline-offset: .18em; text-decoration-thickness: 1.5px; }
button, input { font: inherit; color: inherit; }
h1, h2, p { margin: 0; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 3px; }
.sprite { position: absolute; width: 0; height: 0; }
.icon { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* --- controls ------------------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 14px;
  border: 1px solid var(--rule-strong); border-radius: var(--radius);
  background: var(--panel); color: var(--ink); font-weight: 600; cursor: pointer;
  transition: background-color .15s, border-color .15s;
}
.btn:hover:not(:disabled) { border-color: var(--ink); }
.btn:active:not(:disabled) { background: var(--panel-2); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.primary { background: var(--ink); border-color: var(--ink); color: var(--panel); }
.btn.primary:hover:not(:disabled) { background: color-mix(in srgb, var(--ink) 86%, var(--panel)); }
.btn.quiet { border-color: transparent; background: transparent; color: var(--ink-2); padding: 0 10px; }
.btn.quiet:hover:not(:disabled) { color: var(--ink); border-color: var(--rule); }
.btn.small { height: 30px; font-size: 13px; }
input[type="text"], input[type="password"] {
  width: 100%; height: 44px; padding: 0 12px;
  border: 1px solid var(--rule-strong); border-radius: var(--radius); background: var(--panel);
}
input::placeholder { color: var(--ink-2); opacity: 1; }
input[type="text"]:focus, input[type="password"]:focus { outline: 2px solid var(--focus); outline-offset: -1px; border-color: transparent; }
input[type="range"] { accent-color: var(--ink); }

/* --- login ---------------------------------------------------------------------------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.login-panel {
  width: min(380px, 100%); display: grid; gap: 12px;
  padding: 32px 28px; background: var(--panel); border: 1px solid var(--rule); border-radius: var(--radius);
}
.login-panel img { justify-self: center; }
.login-panel h1 { text-align: center; font-size: 30px; font-weight: 800; letter-spacing: -.02em; margin-bottom: 8px; }
.login-panel label { font-weight: 600; }
.login-panel .btn { height: 44px; }
.form-error { min-height: 1.4em; color: var(--lamp); font-weight: 600; }
.hint { color: var(--ink-2); font-size: 13px; }

/* --- top bar -------------------------------------------------------------------------- */
.bar {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  min-height: 52px; padding: 8px 28px; background: var(--bar); color: var(--bar-ink);
}
.bar-mark { width: 36px; height: 36px; }
.bar-name { font-size: 19px; font-weight: 800; letter-spacing: -.01em; }
.bar-status { display: flex; align-items: center; gap: 8px; color: var(--bar-ink); margin-left: 10px; }
.bar-status .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--warn); }
.bar-status.is-connected .dot { background: var(--ok); }
.bar-engine { color: var(--bar-ink-2); font-size: 13px; }
.bar-clock { margin-left: auto; font-weight: 700; font-size: 17px; letter-spacing: .02em; color: var(--bar-ink); }
.bar-signout {
  display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 10px;
  border: 1px solid transparent; border-radius: var(--radius); background: transparent; color: var(--bar-ink-2); cursor: pointer;
}
.bar-signout:hover { color: var(--bar-ink); border-color: var(--rule-strong); }
.bar :focus-visible { outline-color: var(--bar-ink); }

/* --- on air strip --------------------------------------------------------------------- */
.onair {
  display: grid; grid-template-columns: auto auto minmax(0, 1fr) auto; align-items: center; gap: 22px;
  padding: 20px 28px; background: var(--panel); border-bottom: 1px solid var(--rule);
}
/* The studio's lit sign: square-cornered and taller than any button, so it never reads as one. */
.lamp {
  display: grid; place-items: center; min-width: 112px; min-height: 60px; padding: 12px 16px;
  border-radius: 2px; font-weight: 800; font-size: 14px; letter-spacing: .14em; white-space: nowrap;
  background: var(--panel-2); color: var(--ink-2); border: 1px solid var(--rule);
  transition: background-color .3s, color .3s, box-shadow .3s;
}
.lamp[data-state="on"] {
  background: var(--lamp); color: var(--lamp-ink); border-color: var(--lamp);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .28), 0 6px 18px -4px color-mix(in srgb, var(--lamp) 55%, transparent);
}
/* Paused: the same lamp, unlit. */
.lamp[data-state="paused"] {
  background: color-mix(in srgb, var(--lamp) 14%, var(--panel)); color: var(--ink-2);
  border-color: color-mix(in srgb, var(--lamp) 40%, var(--panel));
}
.lamp[data-state="offline"] { color: var(--warn); border-color: var(--warn); background: transparent; }
.thumb { width: 128px; height: 72px; object-fit: cover; border-radius: 4px; background: var(--panel-2); }
.now { min-width: 0; }
.now-title {
  font-size: clamp(26px, 3vw, 44px); font-weight: 800; line-height: 1.08; letter-spacing: -.02em;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere;
}
.now-title a { text-decoration: none; }
.now-title a:hover { text-decoration: underline; }
.now-title.is-entering { animation: title-in .5s cubic-bezier(.16, 1, .3, 1); }
@keyframes title-in { from { clip-path: inset(0 100% 0 0); opacity: .35; } to { clip-path: inset(0 0 0 0); opacity: 1; } }
#now-empty { color: var(--ink-2); font-weight: 700; }
.now-meta { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 6px; color: var(--ink-2); }
.now-time { font-weight: 600; }
.now-left { font-weight: 700; color: var(--ink); }
.progress { height: 4px; margin-top: 12px; border-radius: 2px; background: var(--rule); overflow: hidden; }
.progress span { display: block; height: 100%; width: 0; background: var(--lamp); transition: width .95s linear, background-color .3s; }
.onair[data-state="paused"] .progress span { background: color-mix(in srgb, var(--lamp) 40%, var(--rule)); }
.onair[data-state="off"] .progress, .onair[data-state="offline"]:not(.has-track) .progress { visibility: hidden; }
.transport { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.transport .btn { height: 44px; }
.transport .primary { min-width: 132px; }
.volume { display: flex; align-items: center; gap: 8px; margin-left: 10px; color: var(--ink-2); }
.volume input { width: 120px; }
.volume output { min-width: 3ch; text-align: right; font-weight: 600; color: var(--ink); }

/* --- desk: running order + side ------------------------------------------------------- */
.desk {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(320px, 400px); gap: 24px; align-items: start;
  padding: 24px 28px 32px;
}
.schedule, .panel { background: var(--panel); border: 1px solid var(--rule); border-radius: var(--radius); }
.schedule { overflow: hidden; }
.schedule-head { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; padding: 14px 16px 14px 20px; border-bottom: 1px solid var(--rule); }
.schedule-head h2 { font-size: 18px; font-weight: 800; letter-spacing: -.01em; }
.schedule-summary { display: flex; gap: 14px; color: var(--ink-2); }
.schedule-summary b { color: var(--ink); font-weight: 700; }
.schedule-actions { display: flex; gap: 2px; margin-left: auto; }

.order { width: 100%; border-collapse: collapse; }
.order th {
  text-align: left; font-size: 13px; font-weight: 600; color: var(--ink-2);
  padding: 10px 16px; border-bottom: 1px solid var(--rule); white-space: nowrap;
}
.order td { padding: 12px 16px; border-bottom: 1px solid var(--rule); vertical-align: baseline; }
.order tr:last-child td { border-bottom: 0; }
.order tbody tr:hover { background: var(--panel-2); }
.c-time { width: 88px; }
.order td.c-time { font-weight: 800; font-size: 17px; }
.order td.c-time.is-unknown { color: var(--ink-2); font-weight: 600; }
.c-len { width: 80px; } .order td.c-len { color: var(--ink-2); }
.c-by { width: 22%; } .order td.c-by { color: var(--ink-2); overflow-wrap: anywhere; }
.c-x { width: 52px; } .order td.c-x { padding: 6px 10px; text-align: right; vertical-align: middle; }
.order .title { font-weight: 600; text-decoration: none; overflow-wrap: anywhere; }
.order .title:hover { text-decoration: underline; }
.order tbody tr:first-child td { background: var(--panel-2); }
.order tbody tr:first-child .title { font-weight: 800; }
.remove {
  width: 32px; height: 32px; display: inline-grid; place-items: center; border: 0; border-radius: var(--radius);
  background: transparent; color: var(--ink-2); cursor: pointer;
}
.remove:hover { color: var(--ink); background: var(--panel-2); }
.order-empty { padding: 28px 20px; color: var(--ink-2); }

.side { display: grid; gap: 16px; }
.panel { padding: 16px 18px; }
.panel h2 { font-size: 15px; font-weight: 700; margin-bottom: 10px; }
.request-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.request-actions .primary { flex: 1 1 100%; }
.request-actions .btn:not(.primary) { flex: 1; }
.request-result { margin-top: 10px; color: var(--ink-2); }
.request-result:empty { display: none; }
.request-result.is-error { color: var(--lamp); font-weight: 600; }
.request-result.is-working { color: var(--ink); }
.results { list-style: none; margin: 10px 0 0; padding: 0; border-top: 1px solid var(--rule); }
.results li { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--rule); }
.results .title { overflow-wrap: anywhere; }
.results .len { color: var(--ink-2); }

.segmented { display: grid; grid-template-columns: repeat(3, 1fr); gap: 3px; padding: 3px; border: 1px solid var(--rule-strong); border-radius: var(--radius); }
.segmented button { height: 34px; border: 0; border-radius: 4px; background: transparent; color: var(--ink); font-weight: 600; cursor: pointer; }
.segmented button:hover { background: var(--panel-2); }
.segmented button[aria-checked="true"] { background: var(--ink); color: var(--panel); }

.log-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.log-head h2 { margin: 0; }
.log-lines {
  list-style: none; margin: 0; padding: 0; max-height: 9.5em; overflow: hidden;
  font: 12.5px/1.6 var(--mono); color: var(--ink-2);
}
.log:not(.is-open) .log-lines { mask-image: linear-gradient(to bottom, transparent 0, #000 2.4em); }
.log.is-open .log-lines { max-height: 420px; overflow: auto; }
.log-lines li { white-space: pre-wrap; overflow-wrap: anywhere; }
.log-lines time { color: var(--ink); }
.log-lines .warn { color: var(--warn); }
.log-lines .error { color: var(--lamp); }

/* --- narrower screens ----------------------------------------------------------------- */
@media (max-width: 1180px) {
  .onair { grid-template-columns: auto minmax(0, 1fr); }
  .thumb { display: none; }
  .transport { grid-column: 1 / -1; justify-content: flex-start; }
}
@media (max-width: 900px) {
  .bar { padding: 8px 16px; gap: 10px; }
  .bar-status { margin-left: 0; }
  .bar-engine { display: none; }
  .onair { padding: 16px; gap: 14px; }
  .lamp { min-width: 0; min-height: 32px; padding: 6px 10px; font-size: 12px; }
  .transport { display: grid; grid-template-columns: 1.4fr 1fr 1fr; }
  .transport .primary { min-width: 0; }
  .volume { grid-column: 1 / -1; margin: 4px 0 0; }
  .volume input { flex: 1; width: auto; }
  .desk { grid-template-columns: 1fr; padding: 16px; gap: 16px; }
  .side { display: contents; }
  .request { order: -1; }
  .order thead { display: none; }
  .order, .order tbody { display: block; }
  .order tr { display: grid; grid-template-columns: 68px minmax(0, 1fr) 44px; align-items: baseline; border-bottom: 1px solid var(--rule); }
  .order tr:last-child { border-bottom: 0; }
  .order tbody tr:first-child { background: var(--panel-2); }
  .order tbody tr:first-child td { background: transparent; }
  .order td { border: 0; padding: 10px 6px; }
  .order td.c-time { padding-left: 16px; font-size: 15px; }
  .order td.c-len { display: none; }
  .order td.c-by { grid-column: 2; padding-top: 0; width: auto; font-size: 13px; }
  .order td.c-x { grid-row: 1 / span 2; grid-column: 3; align-self: center; padding: 0 8px 0 0; }
  .schedule-head { padding: 12px 12px 12px 16px; }
  .remove { width: 44px; height: 44px; }
  .results .btn.small, #log-toggle { height: 44px; }
  .bar-clock { font-size: 15px; }
  .bar-signout { width: 40px; height: 40px; padding: 0; justify-content: center; }
  .bar-signout span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
}
@media (max-width: 480px) {
  .bar { gap: 8px; }
  .bar-name { font-size: 17px; }
  /* Requester on its own line, then the times side by side. */
  .now-meta { gap: 2px 12px; font-size: 14px; }
  #now-by { flex-basis: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  .now-title.is-entering { animation: none; }
  .progress span, .lamp, .btn { transition: none; }
}
