/* ============================================================================
 * Service mode — controls, report sheet, flagged lines
 *
 * Kept in its own file so the same rules drive the app and the design preview.
 * Everything here is scoped under .service-mode / .svc-* / .fs-* so it cannot
 * leak into the rest of the app. Tokens (--accent, --ui, --display, --mono, …)
 * come from styles.css; each has a fallback so this file also stands alone.
 * ========================================================================== */

.service-mode, .fs-backdrop {
  --svc-ink:    var(--text, #f5f3f0);
  --svc-ink-2:  var(--text-2, #b6b5bf);
  --svc-ink-3:  var(--text-dim, #76757f);
  --svc-accent: var(--accent, #ff4b32);
  --svc-accent-hi: var(--accent-bright, #ff6a52);
  --svc-accent-lo: var(--accent-deep, #d4321d);
  --svc-glow:   var(--accent-glow, rgba(255, 75, 50, 0.45));
  --svc-amber:  #ffb454;
  --svc-amber-glow: rgba(255, 180, 84, 0.42);
  --svc-ok:     #34d399;
}

/* ---- top stack: status + exit, then the dock ---------------------------- */
.svc-top {
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.svc-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.svc-wake {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 34px;
  padding: 0 14px 0 12px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
  color: var(--svc-ink-3);
  font: 600 12.5px/1 var(--ui, system-ui, sans-serif);
  letter-spacing: 0.02em;
  transition: color 0.25s, background 0.25s, border-color 0.25s;
}
.svc-wake::before {
  content: "";
  width: 8px; height: 8px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.22);
  transition: background 0.25s, box-shadow 0.25s;
}
.svc-wake.awake {
  color: #8ff0c4;
  border-color: rgba(52, 211, 153, 0.28);
  background: rgba(52, 211, 153, 0.08);
}
.svc-wake.awake::before {
  background: var(--svc-ok);
  box-shadow: 0 0 10px rgba(52, 211, 153, 0.75);
}

.svc-exit {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 34px;
  padding: 0 15px 0 12px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.06);
  color: var(--svc-ink);
  font: 700 13px/1 var(--ui, system-ui, sans-serif);
  cursor: pointer;
  touch-action: manipulation;
  transition: background 0.16s, border-color 0.16s, transform 0.16s;
}
.svc-exit svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 2.4; stroke-linecap: round; }
.svc-exit:hover { background: rgba(255, 255, 255, 0.11); border-color: rgba(255, 255, 255, 0.22); }
.svc-exit:active { transform: scale(0.95); }

/* ---- the dock: equal-width tiles, whatever number are showing ------------ */
.svc-dock {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  gap: 6px;
  padding: 6px;
  border-radius: 24px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.075), rgba(255, 255, 255, 0.025)),
    rgba(14, 14, 18, 0.72);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
          backdrop-filter: blur(16px) saturate(140%);
  box-shadow: 0 14px 34px -14px rgba(0, 0, 0, 0.85), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.svc-tile {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 72px;
  padding: 12px 4px 11px;
  border-radius: 18px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--svc-ink-2);
  font: 650 11.5px/1.1 var(--ui, system-ui, sans-serif);
  letter-spacing: 0.015em;
  white-space: nowrap;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: color 0.2s, background 0.25s, border-color 0.25s, box-shadow 0.25s, transform 0.14s;
  animation: svc-pop 0.32s cubic-bezier(0.2, 0.9, 0.3, 1.2) both;
}
.svc-tile .svc-ico {
  width: 23px; height: 23px;
  fill: none; stroke: currentColor;
  stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round;
  transition: transform 0.25s cubic-bezier(0.2, 0.9, 0.3, 1.3);
}
.svc-led {
  position: absolute;
  top: 9px; right: 10px;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.16);
  transition: background 0.25s, box-shadow 0.25s;
}
.svc-tile:hover { color: var(--svc-ink); background: rgba(255, 255, 255, 0.05); }
.svc-tile:active { transform: scale(0.95); }

.svc-tile[aria-pressed="true"] {
  color: #fff;
  border-color: color-mix(in srgb, var(--svc-accent) 55%, transparent);
  background: linear-gradient(165deg,
    color-mix(in srgb, var(--svc-accent) 38%, transparent),
    color-mix(in srgb, var(--svc-accent) 12%, transparent));
  box-shadow: 0 10px 24px -12px var(--svc-glow), inset 0 1px 0 rgba(255, 255, 255, 0.14);
}
.svc-tile[aria-pressed="true"] .svc-ico { transform: translateY(-1px) scale(1.06); }
.svc-tile[aria-pressed="true"] .svc-led {
  background: var(--svc-accent-hi);
  box-shadow: 0 0 9px var(--svc-glow);
}

/* Report mode reads differently from the other toggles: amber, not red. */
.svc-tile.svc-flag[aria-pressed="true"] {
  border-color: rgba(255, 180, 84, 0.6);
  background: linear-gradient(165deg, rgba(255, 180, 84, 0.34), rgba(255, 180, 84, 0.1));
  box-shadow: 0 10px 24px -12px var(--svc-amber-glow), inset 0 1px 0 rgba(255, 255, 255, 0.14);
}
.svc-tile.svc-flag[aria-pressed="true"] .svc-led { background: var(--svc-amber); box-shadow: 0 0 9px var(--svc-amber-glow); }

@keyframes svc-pop {
  from { opacity: 0; transform: scale(0.86); }
  to   { opacity: 1; transform: scale(1); }
}

.svc-hint {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 14px;
  border-radius: 14px;
  border: 1px dashed rgba(255, 180, 84, 0.5);
  background: rgba(255, 180, 84, 0.08);
  color: #ffd493;
  font: 600 13px/1.3 var(--ui, system-ui, sans-serif);
  text-align: center;
  animation: svc-pop 0.25s ease both;
}
.svc-hint svg { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---- progress + time --------------------------------------------------- */
.svc-progress {
  width: 100%;
  height: 5px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
}
.svc-progress > i {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--svc-accent-lo), var(--svc-accent-hi));
  box-shadow: 0 0 14px var(--svc-glow);
  transition: width 0.4s linear;
}

/* ---- lyric lines: report mode, badges ---------------------------------- */
.service-lyrics .sl-line { position: relative; -webkit-touch-callout: none; }
.service-lyrics .sl-list { touch-action: pan-y; }

.service-lyrics.flagging .sl-line {
  cursor: crosshair;
  outline: 1.5px dashed rgba(255, 180, 84, 0.42);
  outline-offset: -3px;
}
.service-lyrics.flagging .sl-line:active {
  background: rgba(255, 180, 84, 0.18);
}
.service-lyrics.flagging .sl-line.untimed { cursor: crosshair; }

/* A line somebody has reported. Solid = you reported it; hollow = others did. */
.sl-line.flagged::after {
  content: "⚑" attr(data-n);
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  font: 700 12px/1 var(--ui, system-ui, sans-serif);
  letter-spacing: 0;
  color: var(--svc-amber);
  padding: 5px 7px;
  border-radius: 999px;
  border: 1px solid rgba(255, 180, 84, 0.5);
  background: rgba(20, 16, 8, 0.55);
  opacity: 0.85;
  pointer-events: none;
}
.sl-line.flagged.mine::after {
  color: #1a1206;
  background: var(--svc-amber);
  border-color: var(--svc-amber);
  box-shadow: 0 0 12px var(--svc-amber-glow);
}

/* ---- the report sheet ------------------------------------------------------ */
.fs-backdrop {
  position: fixed;
  inset: 0;
  z-index: 450;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(3, 3, 6, 0.62);
  -webkit-backdrop-filter: blur(6px);
          backdrop-filter: blur(6px);
  animation: fs-fade 0.2s ease both;
}
.fs-backdrop.closing { animation: fs-fade 0.18s ease reverse both; }
.fs-backdrop.closing .fs-sheet { animation: fs-down 0.2s ease both; }

.fs-sheet {
  width: 100%;
  max-width: 560px;
  max-height: 92dvh;
  overflow-y: auto;
  box-sizing: border-box;
  padding: 10px 18px calc(env(safe-area-inset-bottom, 0px) + 18px);
  border-radius: 28px 28px 0 0;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-bottom: 0;
  background:
    radial-gradient(120% 60% at 50% -10%, rgba(255, 180, 84, 0.13), transparent 60%),
    #131318;
  color: var(--svc-ink);
  font-family: var(--ui, system-ui, sans-serif);
  box-shadow: 0 -24px 60px -20px rgba(0, 0, 0, 0.9);
  animation: fs-up 0.32s cubic-bezier(0.2, 0.9, 0.3, 1) both;
}
@media (min-width: 700px) {
  .fs-backdrop { align-items: center; }
  .fs-sheet { border-radius: 26px; border-bottom: 1px solid rgba(255, 255, 255, 0.1); padding-bottom: 22px; }
}
.fs-grab { width: 42px; height: 5px; border-radius: 99px; background: rgba(255, 255, 255, 0.2); margin: 0 auto 14px; }

.fs-title { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.fs-title .fs-badge {
  width: 38px; height: 38px; flex: none;
  display: grid; place-items: center;
  border-radius: 12px;
  background: rgba(255, 180, 84, 0.16);
  color: var(--svc-amber);
}
.fs-badge svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.fs-title h2 { margin: 0; font: 800 19px/1.15 var(--display, var(--ui, system-ui)); letter-spacing: -0.01em; }
.fs-title small { display: block; margin-top: 2px; font: 500 12.5px/1.3 var(--ui, system-ui); color: var(--svc-ink-3); }
.fs-x {
  margin-left: auto; width: 36px; height: 36px; flex: none;
  border-radius: 50%; border: 0;
  background: rgba(255, 255, 255, 0.07); color: var(--svc-ink-2);
  font-size: 18px; line-height: 1; cursor: pointer;
}
.fs-x:hover { background: rgba(255, 255, 255, 0.13); }

.fs-quote {
  margin: 0 0 16px;
  padding: 14px 16px 14px 18px;
  border-radius: 16px;
  border-left: 4px solid var(--svc-amber);
  background: rgba(255, 255, 255, 0.05);
  font: 800 clamp(20px, 5.2vw, 26px)/1.25 var(--display, var(--ui, system-ui));
  letter-spacing: -0.01em;
  overflow-wrap: anywhere;
}

.fs-notice {
  margin: 0 0 14px;
  padding: 10px 12px;
  border-radius: 12px;
  font: 500 13px/1.4 var(--ui, system-ui);
  color: #ffd493;
  background: rgba(255, 180, 84, 0.1);
  border: 1px solid rgba(255, 180, 84, 0.28);
}
.fs-notice.info { color: var(--svc-ink-2); background: rgba(255, 255, 255, 0.05); border-color: rgba(255, 255, 255, 0.1); }
.fs-notice.err  { color: #ffb3a8; background: rgba(255, 75, 50, 0.1); border-color: rgba(255, 75, 50, 0.35); }

.fs-label { display: flex; align-items: baseline; justify-content: space-between; margin: 0 2px 8px; font: 700 12px/1 var(--ui, system-ui); letter-spacing: 0.08em; text-transform: uppercase; color: var(--svc-ink-3); }
.fs-label em { font-style: normal; font-weight: 500; letter-spacing: 0.02em; text-transform: none; }

.fs-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.fs-chip {
  height: 38px; padding: 0 15px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.04);
  color: var(--svc-ink-2);
  font: 600 13.5px/1 var(--ui, system-ui);
  cursor: pointer;
  touch-action: manipulation;
  transition: background 0.15s, border-color 0.15s, color 0.15s, transform 0.12s;
}
.fs-chip:active { transform: scale(0.95); }
.fs-chip[aria-pressed="true"] {
  color: #1a1206;
  background: var(--svc-amber);
  border-color: var(--svc-amber);
}

.fs-note {
  display: block;
  width: 100%;
  min-height: 92px;
  box-sizing: border-box;
  resize: vertical;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(0, 0, 0, 0.3);
  color: var(--svc-ink);
  font: 500 16px/1.4 var(--ui, system-ui);   /* 16px: iOS zooms inputs below it */
}
.fs-note::placeholder { color: var(--svc-ink-3); }
.fs-note:focus { outline: 2px solid rgba(255, 180, 84, 0.55); outline-offset: 1px; border-color: transparent; }
.fs-count { margin: 6px 4px 0; text-align: right; font: 500 11.5px/1 var(--mono, ui-monospace, monospace); color: var(--svc-ink-3); }

.fs-actions { display: grid; grid-template-columns: 1fr 1.6fr; gap: 10px; margin-top: 16px; }
.fs-actions.three { grid-template-columns: 1fr 1fr 1.6fr; }
.fs-btn {
  height: 52px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.06);
  color: var(--svc-ink);
  font: 700 15px/1 var(--ui, system-ui);
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 0.12s, filter 0.15s, opacity 0.15s;
}
.fs-btn:active { transform: scale(0.97); }
.fs-btn.danger { color: #ff9a8b; border-color: rgba(255, 75, 50, 0.35); background: rgba(255, 75, 50, 0.08); }
.fs-btn.primary {
  border: 0;
  color: #1a1206;
  background: linear-gradient(160deg, #ffc978, #ffa62e);
  box-shadow: 0 12px 26px -10px var(--svc-amber-glow), inset 0 1px 0 rgba(255, 255, 255, 0.45);
}
.fs-btn[disabled] { opacity: 0.45; pointer-events: none; }

@keyframes fs-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes fs-up   { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes fs-down { from { transform: none; opacity: 1; } to { transform: translateY(40px); opacity: 0; } }

/* ---- narrow phones ------------------------------------------------------ */
@media (max-width: 380px) {
  .svc-tile { min-height: 66px; font-size: 11px; }
  .svc-tile .svc-ico { width: 21px; height: 21px; }
}
@media (max-height: 520px) {
  /* Landscape phone: keep the dock but flatten the tiles into icon + label rows. */
  .svc-tile { flex-direction: row; min-height: 44px; gap: 8px; padding: 8px 10px; }
  .svc-led { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .svc-tile, .svc-hint, .fs-backdrop, .fs-sheet { animation: none !important; }
  .svc-tile, .svc-tile .svc-ico, .svc-progress > i { transition: none !important; }
}

/* ---- one view button + text-size box (all themes) ---- */
.svc-dock { display: flex; }
.svc-dock > .svc-tile { flex: 1 1 0; min-width: 0; }
.svc-dock > .svc-tile.hidden { display: none; }
.svc-font {
  flex: 0 0 auto; align-self: center;
  display: flex; align-items: center; gap: 2px;
  height: 40px; padding: 2px; border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04);
}
.svc-font button {
  width: 32px; height: 34px; padding: 0; border: 0; border-radius: 9px;
  background: transparent; color: var(--svc-ink-2, #ccc);
  font: 800 13px/1 var(--ui, system-ui, sans-serif); cursor: pointer;
  touch-action: manipulation; -webkit-tap-highlight-color: transparent;
}
.svc-font button:hover:not(:disabled) { color: var(--svc-ink, #fff); background: rgba(255, 255, 255, 0.07); }
.svc-font button:disabled { opacity: 0.3; cursor: default; }
.svc-font span { min-width: 22px; text-align: center; font: 700 12px/1 var(--mono, ui-monospace, monospace); color: var(--svc-ink, #fff); }

/* text size scales lyrics, title and channel */
#serviceMode .service-title { font-size: calc(clamp(28px, 5.5vw, 56px) * var(--svc-fs, 1)); }
#serviceMode .service-channel { font-size: calc(1em * var(--svc-fs, 1)); }
#serviceMode .service-lyrics .sl-line { font-size: calc(max(22px, calc(var(--fit, 40px) * 0.48)) * var(--svc-fs, 1)); }
#serviceMode .service-lyrics .sl-line.near { font-size: calc(max(26px, calc(var(--fit, 40px) * 0.6)) * var(--svc-fs, 1)); }
#serviceMode .service-lyrics .sl-line.active { font-size: calc(max(30px, var(--fit, 40px)) * var(--svc-fs, 1)); }
#serviceMode .service-lyrics .sl-list.plain .sl-line { font-size: calc(max(30px, var(--fit, 40px)) * var(--svc-fs, 1)); }

/* album art / visualizer stage */
.service-visual {
  position: relative; width: min(78vw, 52vh, 460px); aspect-ratio: 1;
  margin: 0 auto 22px; border-radius: 26px; overflow: hidden; flex: none;
  box-shadow: 0 30px 60px -24px rgba(0, 0, 0, 0.9);
}
.service-visual::before {
  content: ""; position: absolute; inset: -20%;
  background: var(--art, none) center / cover; filter: blur(34px) saturate(140%); opacity: 0.55;
}
.service-visual .svc-art { position: relative; width: 100%; height: 100%; object-fit: cover; display: block; }
.service-visual .svc-viz { position: absolute; left: 6%; right: 6%; bottom: 6%; width: 88%; height: 58%; display: none; }
.service-visual[data-view="visual"] .svc-art { opacity: 0.28; filter: blur(2px); }
.service-visual[data-view="visual"] .svc-viz { display: block; }
.service-mode.visual-on .service-title { font-size: calc(clamp(24px, 4.4vw, 44px) * var(--svc-fs, 1)); }
.service-visual .svc-art.yt-art { transform: scale(1.34); }
