/* CatchTunes site. CSP allows only this stylesheet: no inline styles anywhere. */
@font-face { font-family: "Fredoka"; src: url("/static/fonts/fredoka-latin-600-normal.woff2") format("woff2"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Fredoka"; src: url("/static/fonts/fredoka-latin-700-normal.woff2") format("woff2"); font-weight: 700; font-display: swap; }

:root {
  --bg: #0E0E10;
  --surface: #18181B;
  --surface-2: #232328;
  --line: #2E2E35;
  --text: #F4F4F5;
  --muted: #A1A1AA;
  --orange: #FF6A13;
  --orange-hover: #FF8442;
  --on-orange: #0E0E10;
  --good: #3DDC97;
  --warn: #FFC22E;
  --bad: #FF5A5F;
  --radius: 14px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.6 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--orange); }
a:hover { color: var(--orange-hover); }
img { max-width: 100%; height: auto; }
code { background: var(--surface-2); padding: 0.1em 0.4em; border-radius: 6px; }
h1, h2, h3, .brand { font-family: "Fredoka", system-ui, sans-serif; line-height: 1.15; }
h1 { font-size: clamp(2rem, 5vw, 3rem); margin: 0 0 0.5rem; }
h2 { font-size: 1.4rem; margin: 2rem 0 0.75rem; }
.wrap { width: 100%; max-width: 1080px; margin: 0 auto; padding: 0 16px; }
.narrow { max-width: 760px; }
.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
.accent { color: var(--orange); }
.lead { font-size: 1.15rem; color: #D4D4D8; }

.skip { position: absolute; left: -999px; }
.skip:focus { left: 16px; top: 8px; background: var(--orange); color: var(--on-orange); padding: 8px 12px; border-radius: 8px; z-index: 10; }
:focus-visible { outline: 3px solid var(--orange); outline-offset: 2px; }

/* Header */
.top { border-bottom: 1px solid var(--line); background: rgba(14, 14, 16, 0.92); position: sticky; top: 0; z-index: 5; }
.top-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 64px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-size: 1.4rem; font-weight: 700; }
.brand b { color: var(--orange); font-weight: 700; }
nav { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
nav a { color: var(--text); text-decoration: none; font-weight: 600; }
nav a[aria-current="page"], nav a:hover { color: var(--orange); }
.inline { display: inline; margin: 0; }
.link-btn { background: none; border: 0; color: var(--text); font: inherit; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; gap: 8px; padding: 0; }
.link-btn:hover { color: var(--orange); }
.avatar { border-radius: 50%; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 20px; border-radius: 999px; border: 2px solid var(--orange);
  background: var(--orange); color: var(--on-orange); font: 700 1rem/1 "Fredoka", system-ui, sans-serif;
  text-decoration: none; cursor: pointer;
}
.btn:hover { background: var(--orange-hover); border-color: var(--orange-hover); color: var(--on-orange); }
.btn-ghost { background: transparent; color: var(--orange); }
.btn-ghost:hover { background: rgba(255, 106, 19, 0.12); color: var(--orange-hover); }
.btn-small { min-height: 36px; padding: 0 14px; font-size: 0.9rem; }
nav .btn-small { color: var(--on-orange); }
.btn-danger { background: var(--bad); border-color: var(--bad); color: var(--on-orange); }
.btn-danger:hover { background: #ff7b7f; border-color: #ff7b7f; color: var(--on-orange); }

/* Home */
.hero { padding: 56px 0 32px; }
.hero-row { display: flex; align-items: center; gap: 40px; flex-wrap: wrap; }
.hero-text { flex: 1 1 420px; }
.hero h1 { font-size: clamp(2.6rem, 8vw, 4.5rem); }
.hero-logo { flex: 0 1 320px; border-radius: 50%; }
.actions { display: flex; gap: 12px; flex-wrap: wrap; margin: 24px 0 12px; }
.features { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 16px; padding-bottom: 24px; }
.card, .panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.card h2 { margin-top: 0; font-size: 1.2rem; }
.band { padding: 8px 16px 48px; }
.steps { padding-left: 1.25rem; }
.steps li { margin: 8px 0; }

/* How-to guide */
.toc { margin: 24px 0 8px; }
.toc h2 { font-size: 1.1rem; margin: 0 0 8px; }
.toc ol { margin: 0; padding-left: 1.4rem; }
.toc li { margin: 4px 0; }
.guide section, .guide h3 { scroll-margin-top: 80px; }
.guide h3 { font-size: 1.1rem; margin: 1.5rem 0 0.5rem; }
.guide .notice { margin: 16px 0; }

/* Pages */
.page { padding: 40px 16px 64px; }
.crumbs { color: var(--muted); margin: 0 0 8px; }
.cmds div { display: grid; grid-template-columns: minmax(150px, 280px) 1fr; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.cmds dt { font-family: ui-monospace, Consolas, monospace; color: var(--orange); overflow-wrap: anywhere; }
.cmds dd { margin: 0; }
.legal h1 { margin-bottom: 0.25rem; }
.legal table { width: 100%; border-collapse: collapse; font-size: 0.95rem; display: block; overflow-x: auto; }
.legal th, .legal td, table th, table td { border: 1px solid var(--line); padding: 8px 10px; text-align: left; vertical-align: top; }
.legal th, table th { background: var(--surface-2); }
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; }

/* Dashboard */
.guilds { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.guild { display: flex; align-items: center; gap: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px; flex-wrap: wrap; }
.guild img, .guild-blank { width: 48px; height: 48px; border-radius: 50%; }
.guild-blank { display: inline-flex; align-items: center; justify-content: center; background: var(--surface-2); font-weight: 700; }
.guild-name { flex: 1 1 160px; font-weight: 600; }
.settings fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px 18px; margin: 0 0 18px; background: var(--surface); }
.settings legend { font-family: "Fredoka", system-ui, sans-serif; font-weight: 700; font-size: 1.1rem; padding: 0 6px; }
.settings label { display: block; font-weight: 600; margin: 12px 0 6px; }
.settings label.check, label.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 500; }
.settings select, .settings input[type="number"], .settings textarea {
  width: 100%; max-width: 480px; min-height: 44px; padding: 8px 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--bg); color: var(--text); font: inherit;
}
.settings textarea { max-width: 100%; resize: vertical; line-height: 1.5; }
input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--orange); margin-top: 3px; flex: none; }
.hint { color: var(--muted); font-size: 0.875rem; margin: 6px 0 0; }
.notice { border-radius: 10px; padding: 12px 14px; background: rgba(61, 220, 151, 0.12); border: 1px solid var(--good); }
.notice-warn { background: rgba(255, 194, 46, 0.1); border-color: var(--warn); }
.notice-bad { background: rgba(255, 90, 95, 0.1); border-color: var(--bad); }
.notice ul { margin: 0; padding-left: 1.2rem; }
.tabs { display: flex; gap: 8px; flex-wrap: wrap; margin: 16px 0; }
.tabs a { background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 6px 14px; text-decoration: none; color: var(--text); }
.tabs a:hover { border-color: var(--orange); }
.panel { margin: 0 0 16px; }
.panel h2 { margin-top: 0; }
.chart li { margin: 6px 0; }
.pill { display: inline-block; background: var(--surface-2); border-radius: 999px; padding: 0 10px; font-size: 0.85rem; color: var(--muted); }
.plain { list-style: none; padding: 0; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.danger { border-color: rgba(255, 90, 95, 0.5); }
.danger form { display: flex; flex-direction: column; gap: 12px; align-items: flex-start; }

/* Tunes player page: one column, the player frozen under the sticky site header */
[hidden] { display: none !important; }
.tunes-player { position: sticky; top: 64px; z-index: 4; background: var(--bg); padding: 12px 0 10px; margin: 0 0 6px; }
.np-box { background: var(--surface); border: 1px solid var(--orange); border-radius: var(--radius); padding: 14px; box-shadow: 0 6px 16px rgba(0, 0, 0, 0.5); }
.np { display: flex; gap: 12px; align-items: center; }
.np-art { width: 64px; height: 64px; border-radius: 10px; object-fit: cover; flex: none; background: var(--surface-2); }
.np-text { flex: 1 1 auto; min-width: 0; }
.np-title { margin: 0; font-family: "Fredoka", system-ui, sans-serif; font-weight: 700; font-size: 1.15rem; line-height: 1.25; overflow-wrap: anywhere; }
.np-meta { margin: 2px 0 0; overflow-wrap: anywhere; }
.np-save { flex: none; }
.np-progress { display: flex; align-items: center; gap: 10px; margin: 10px 0 8px; }
.np-progress input { flex: 1 1 auto; min-width: 0; }
input[type="range"] { accent-color: var(--orange); }
input[type="range"]:disabled { opacity: 0.5; }
.np-controls { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.np-vc { margin-left: auto; }
.np-notice { margin: 10px 0 0; padding: 8px 12px; }
.tunes-status { margin: 8px 0 0; min-height: 1.5em; color: var(--muted); }
.tunes-status.bad { color: var(--bad); }
.tunes-status em, .log em { color: var(--text); }
.vol { display: inline-flex; align-items: center; gap: 6px; }
.vol input { width: 110px; }
.ctl, .tbtn {
  min-height: 36px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface-2); color: var(--text); font: inherit; font-size: 0.9rem; cursor: pointer;
}
.ctl:hover:not(:disabled), .tbtn:hover:not(:disabled) { border-color: var(--orange); }
.ctl:disabled, .tbtn:disabled { opacity: 0.45; cursor: not-allowed; }
.ctl-main, .tbtn-o { background: var(--orange); border-color: var(--orange); color: var(--on-orange); font-weight: 600; }
.ctl-main:hover:not(:disabled), .tbtn-o:hover:not(:disabled) { background: var(--orange-hover); border-color: var(--orange-hover); }
.tbtn-bad { border-color: rgba(255, 90, 95, 0.6); color: var(--bad); }
.tunes .panel h2 { font-size: 1.2rem; margin-bottom: 10px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.panel-head h2 { margin: 0; }
.tunes input[type="search"], .tunes input[type="text"], .tunes input[type="url"], .tunes select {
  width: 100%; min-height: 44px; padding: 8px 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--bg); color: var(--text); font: inherit;
}
.tlist { list-style: none; padding: 0; margin: 8px 0 0; }
.trow { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-top: 1px solid var(--line); flex-wrap: wrap; }
.tnum { color: var(--muted); min-width: 2.2ch; }
.tmain { flex: 1 1 180px; min-width: 0; overflow-wrap: anywhere; }
.tby { flex: none; }
.ttag { flex: none; font-size: 0.75rem; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 0 6px; }
.tact { display: flex; gap: 6px; flex-wrap: wrap; }
.tlist .empty { padding: 8px 0; }
.log li { padding: 5px 0; border-top: 1px solid var(--line); color: var(--muted); font-size: 0.92rem; overflow-wrap: anywhere; }
.pl-bar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.pl-bar select { flex: 1 1 220px; width: auto; }
.pl-edit { margin: 10px 0 0; }
.pl-edit summary { cursor: pointer; color: var(--orange); font-weight: 600; }
.inline-form { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0; }
.tunes .inline-form input { flex: 1 1 200px; width: auto; }
.imp-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin: 10px 0 8px; }
.imp-tab[aria-selected="true"] { background: var(--orange); border-color: var(--orange); color: var(--on-orange); font-weight: 600; }
.imp-pane { margin: 0 0 4px; }
.tunes textarea {
  width: 100%; min-height: 120px; padding: 8px 12px; border-radius: 10px; resize: vertical;
  border: 1px solid var(--line); background: var(--bg); color: var(--text); font: inherit; line-height: 1.5;
}
.tunes input[type="file"] { max-width: 100%; color: var(--text); font: inherit; padding: 6px 0; }
.imp-steps { margin: 0 0 4px; padding-left: 1.4rem; }
.imp-steps > li { margin: 0 0 12px; }
.imp-steps p { margin: 0 0 6px; }
.imp-open-exportify { display: inline-flex; align-items: center; min-height: 44px; text-decoration: none; }
.imp-drop {
  position: relative;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 10px;
  padding: 18px 12px; border: 2px dashed var(--line); border-radius: 12px; text-align: center;
}
.imp-drop.over { border-color: var(--orange); background: var(--bg); }
.imp-drop-text { overflow-wrap: anywhere; }
.imp-drop-pick { display: inline-flex; align-items: center; min-height: 44px; cursor: pointer; }
.imp-drop input[type="file"] { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; }
.imp-drop:focus-within { outline: 2px solid var(--orange); outline-offset: 2px; }
.imp-progress { margin: 8px 0 0; }
.imp-status { margin: 0 0 6px; }
.imp-status.bad { color: var(--bad); }
.imp-progress progress { width: 100%; height: 10px; accent-color: var(--orange); }
.imp-progress details summary { cursor: pointer; color: var(--orange); font-weight: 600; }

/* Support tickets (owner only) */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.owner-links { margin: 0 0 8px; }
.tickets { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.ticket-link { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px; color: var(--text); text-decoration: none; }
.ticket-link:hover { border-color: var(--orange); color: var(--text); }
.ticket-num { font-weight: 700; min-width: 4.5ch; display: inline-flex; align-items: center; gap: 6px; }
.ticket-main { flex: 1 1 220px; min-width: 0; overflow-wrap: anywhere; }
.ticket-when { flex: none; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--orange); flex: none; }
.status-pill { display: inline-block; border-radius: 999px; padding: 0 10px; font-size: 0.85rem; border: 1px solid var(--line); background: var(--surface-2); white-space: nowrap; }
.status-open { border-color: var(--good); color: var(--good); }
.status-waiting { border-color: var(--warn); color: var(--warn); }
.status-closed { color: var(--muted); }
.ticket-who { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.ticket-who > div { flex: 1 1 160px; min-width: 0; overflow-wrap: anywhere; }
.ticket-facts { display: flex; flex-wrap: wrap; gap: 4px 24px; margin: 12px 0 0; }
.ticket-facts dt { color: var(--muted); font-size: 0.8rem; }
.ticket-facts dd { margin: 0; }
.convo { list-style: none; padding: 0; margin: 0 0 18px; display: flex; flex-direction: column; gap: 10px; }
.bubble { max-width: 85%; border-radius: var(--radius); padding: 10px 14px; border: 1px solid var(--line); background: var(--surface); }
.bubble.from-owner { align-self: flex-end; border-color: rgba(255, 106, 19, 0.6); background: rgba(255, 106, 19, 0.08); }
.bubble.from-member { align-self: flex-start; }
.bubble-body { white-space: pre-wrap; overflow-wrap: anywhere; }
.dm-mark { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.dm-sent { color: var(--good); }
.dm-failed { color: var(--bad); font-weight: 600; }
.ticket-closed { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.ticket-closed p { margin: 0; }
.ticket-controls { display: flex; flex-direction: column; gap: 12px; }
.ctl-form { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 0; }
.ctl-form label { font-weight: 600; min-width: 4.5em; }
.ctl-form select { min-height: 36px; padding: 4px 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--text); font: inherit; }
.notes { list-style: none; padding: 0; margin: 12px 0 0; }
.notes li { padding: 8px 0; border-top: 1px solid var(--line); }
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { padding: 6px 0; border-top: 1px solid var(--line); font-size: 0.92rem; overflow-wrap: anywhere; }

/* Footer */
.foot { border-top: 1px solid var(--line); padding: 20px 0 28px; }
.foot p { margin: 4px 0; }

/* Phones (375-414 px and up to 600): no sideways scrolling, 44 px tap targets, 16 px inputs (no iOS zoom).
   Everything below only applies at this width; the desktop layout above is untouched. */
@media (max-width: 600px) {
  .cmds div { grid-template-columns: 1fr; gap: 2px; }
  .hero-logo { flex-basis: 200px; margin: 0 auto; }
  h1 { overflow-wrap: anywhere; }
  .page { padding: 24px 16px 48px; }
  input, select, textarea { font-size: 16px; }
  fieldset { min-width: 0; } /* a fieldset is min-content wide by default: long option text would overflow */

  /* Header: brand on one row, the links on the next, each a full-height tap target */
  .top-row { gap: 0 16px; min-height: 56px; }
  nav { gap: 0 16px; }
  nav a, .link-btn { display: inline-flex; align-items: center; min-height: 44px; }
  .brand { min-height: 44px; }
  .btn-small { min-height: 44px; }
  .crumbs a, .foot a { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; min-width: 44px; }
  .foot p { margin: 0; }
  summary { display: flex; align-items: center; min-height: 44px; }
  /* The header wraps to two rows on phones: let it scroll away and freeze the player at the very top instead. */
  body:has(.tunes-player) .top { position: static; }

  /* Dashboard server list: the buttons share the row under the name */
  .guild { gap: 10px; }
  .guild-name { overflow-wrap: anywhere; }
  .guild .btn { flex: 1 1 auto; }

  /* Server settings */
  .page-links { display: flex; flex-wrap: wrap; align-items: center; gap: 0 8px; }
  .page-links a { display: inline-flex; align-items: center; min-height: 44px; }
  .hint a { display: inline-block; padding: 12px 0; margin: -12px 0; } /* a 44 px tap area without moving the text */
  .settings fieldset { padding: 12px 14px 14px; }
  .settings select, .settings input[type="number"] { max-width: 100%; }

  /* Tunes: a compact sticky player */
  .tunes-player { top: 0; padding: 6px 0; }
  .np-box { padding: 10px; }
  .np { gap: 10px; }
  .np-art { width: 48px; height: 48px; border-radius: 8px; }
  .np-title, .np-meta { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; overflow-wrap: normal; }
  .np-title { font-size: 1rem; }
  .np-save { padding: 0 10px; }
  .np-progress { margin: 4px 0; gap: 8px; }
  .tunes input[type="range"] { height: 44px; margin: 0; }
  /* Controls in a tidy grid: Previous, Play, Skip / Repeat, Shuffle, volume / the voice channel line */
  .np-controls { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px; }
  .np-controls > .ctl, .np-controls > .vol { grid-column: span 2; }
  .ctl { min-width: 0; padding: 0 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .vol { display: flex; min-width: 0; }
  .vol input { width: auto; flex: 1 1 auto; min-width: 0; }
  .np-vc { grid-column: 1 / -1; margin-left: 0; font-size: 0.8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .np-notice { margin: 6px 0 0; padding: 6px 10px; }
  .tunes-status { margin: 4px 0 0; min-height: 0; }
  .tunes-status:empty { display: none; }
  .ctl, .tbtn { min-height: 44px; }
  .tbtn { min-width: 44px; }

  /* Lists: the title on one line (cut with …), who queued it and the buttons on the line below */
  .panel { padding: 14px; }
  .trow { gap: 4px 8px; }
  .tmain { flex: 1 1 calc(100% - 2.2ch - 8px); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; overflow-wrap: normal; }
  .trow:not(:has(.tnum)) .tmain { flex-basis: 100%; }
  .tby { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .tact { margin-left: auto; }

  /* Playlist and import panels stack */
  .pl-bar > select, .pl-bar > .tbtn { flex: 1 1 100%; }
  .tunes .inline-form input { flex: 1 1 100%; }
  .inline-form .tbtn, .panel-head .tact .tbtn, .imp-tab { flex: 1 1 auto; }
  .panel-head .tact { margin-left: 0; width: 100%; }
  .tunes input[type="file"] { min-height: 44px; }
  .imp-drop, .imp-open-exportify { width: 100%; box-sizing: border-box; justify-content: center; }
  .imp-drop-pick { flex: 1 1 100%; justify-content: center; }
  #imp-open a { display: inline-flex; align-items: center; min-height: 44px; }

  /* Tickets: bubbles full width and stacked, controls wrap to full-width rows */
  .ticket-link { gap: 4px 10px; min-height: 44px; }
  .ticket-main { flex-basis: calc(100% - 6ch); }
  .bubble { max-width: 100%; align-self: stretch; }
  .ctl-form select { flex: 1 1 100%; min-height: 44px; }
  .ctl-form .tbtn { flex: 1 1 auto; }
  .ticket-closed .btn { flex: 1 1 100%; }
  .tabs a { display: inline-flex; align-items: center; min-height: 44px; }

  /* Guide: table-of-contents links are full-height tap targets; anchors clear the taller header */
  .toc li { margin: 0; }
  .toc a { display: inline-flex; align-items: center; min-height: 44px; }
  .guide section, .guide h3 { scroll-margin-top: 128px; } /* the header wraps to two rows here */
}
