:root {
      --bg: #0b0d13;
      --card-bg: rgba(21, 25, 36, 0.75);
      --card-border: rgba(255, 255, 255, 0.08);
      --text: #f1f5f9;
      --text-muted: #94a3b8;
      --accent: #3b82f6;
      --accent-hover: #2563eb;
      --emerald: #10b981;
      --amber: #f59e0b;
      --rose: #ef4444;
      --purple: #8b5cf6;
      --radius: 14px;
      --radius-sm: 8px;
      --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
      --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    }

    * {
      box-sizing: border-box;
      margin: 0;
      padding: 0;
      -webkit-tap-highlight-color: transparent;
    }

    body {
      background: var(--bg);
      color: var(--text);
      font-family: var(--font-sans);
      min-height: 100vh;
      min-height: 100dvh;
      padding: env(safe-area-inset-top, 16px) 16px env(safe-area-inset-bottom, 24px) 16px;
      line-height: 1.5;
    }

    .container {
      max-width: 720px;
      margin: 0 auto;
      display: flex;
      flex-direction: column;
      gap: 16px;
    }

    /* Header */
    header {
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 8px 0;
      border-bottom: 1px solid var(--card-border);
    }
    .header-left {
      display: flex;
      align-items: center;
      gap: 10px;
    }
    .back-btn {
      display: inline-flex;
      align-items: center;
      gap: 6px;
      color: var(--text-muted);
      text-decoration: none;
      font-size: 0.88rem;
      padding: 6px 10px;
      background: rgba(255, 255, 255, 0.04);
      border: 1px solid var(--card-border);
      border-radius: var(--radius-sm);
      transition: all 0.2s ease;
    }
    .back-btn:hover {
      color: var(--text);
      background: rgba(255, 255, 255, 0.08);
    }
    .brand-title {
      font-size: 1.05rem;
      font-weight: 700;
      letter-spacing: -0.01em;
      display: flex;
      align-items: center;
      gap: 8px;
    }
    .badge {
      font-size: 0.68rem;
      font-weight: 600;
      padding: 3px 8px;
      border-radius: 999px;
      text-transform: uppercase;
      letter-spacing: 0.05em;
      background: rgba(59, 130, 246, 0.18);
      color: #60a5fa;
      border: 1px solid rgba(59, 130, 246, 0.3);
    }

    /* Cards */
    .card {
      background: var(--card-bg);
      border: 1px solid var(--card-border);
      border-radius: var(--radius);
      padding: 18px;
      backdrop-filter: blur(16px);
      -webkit-backdrop-filter: blur(16px);
      box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
    }
    .card-title {
      font-size: 0.85rem;
      font-weight: 600;
      text-transform: uppercase;
      letter-spacing: 0.06em;
      color: var(--text-muted);
      margin-bottom: 12px;
      display: flex;
      align-items: center;
      justify-content: space-between;
    }

    /* Track display */
    .track-info {
      margin-bottom: 14px;
    }
    .track-index {
      font-size: 0.75rem;
      font-weight: 600;
      color: var(--accent);
      text-transform: uppercase;
      letter-spacing: 0.05em;
      margin-bottom: 2px;
    }
    .track-title {
      font-size: 1.25rem;
      font-weight: 700;
      line-height: 1.3;
      margin-bottom: 2px;
      word-break: break-word;
    }
    .track-artist {
      font-size: 0.92rem;
      color: var(--text-muted);
    }

    /* Progress & Scrubber */
    .progress-wrap {
      display: flex;
      flex-direction: column;
      gap: 6px;
      margin-bottom: 16px;
    }
    .seek-slider {
      -webkit-appearance: none;
      appearance: none;
      width: 100%;
      height: 6px;
      background: rgba(255, 255, 255, 0.12);
      border-radius: 999px;
      outline: none;
      cursor: pointer;
    }
    .seek-slider::-webkit-slider-thumb {
      -webkit-appearance: none;
      appearance: none;
      width: 16px;
      height: 16px;
      border-radius: 50%;
      background: var(--accent);
      box-shadow: 0 0 10px rgba(59, 130, 246, 0.6);
      cursor: pointer;
    }
    .seek-slider::-moz-range-thumb {
      width: 16px;
      height: 16px;
      border-radius: 50%;
      background: var(--accent);
      border: none;
      cursor: pointer;
    }
    .time-row {
      display: flex;
      justify-content: space-between;
      font-family: var(--font-mono);
      font-size: 0.78rem;
      color: var(--text-muted);
    }

    /* Controls */
    .controls-row {
      display: flex;
      align-items: center;
      justify-content: center;
      gap: 16px;
      margin-bottom: 16px;
    }
    .btn-ctrl {
      background: rgba(255, 255, 255, 0.06);
      border: 1px solid var(--card-border);
      color: var(--text);
      width: 48px;
      height: 48px;
      border-radius: 50%;
      display: flex;
      align-items: center;
      justify-content: center;
      cursor: pointer;
      transition: all 0.2s ease;
    }
    .btn-ctrl:hover {
      background: rgba(255, 255, 255, 0.12);
      border-color: rgba(255, 255, 255, 0.2);
    }
    .btn-ctrl:active {
      transform: scale(0.94);
    }
    .btn-ctrl-primary {
      width: 62px;
      height: 62px;
      background: var(--accent);
      border-color: var(--accent);
      box-shadow: 0 4px 18px rgba(59, 130, 246, 0.4);
    }
    .btn-ctrl-primary:hover {
      background: var(--accent-hover);
      border-color: var(--accent-hover);
    }
    .btn-ctrl svg {
      width: 22px;
      height: 22px;
      fill: currentColor;
    }
    .btn-ctrl-primary svg {
      width: 26px;
      height: 26px;
    }

    .speed-row {
      display: flex;
      align-items: center;
      justify-content: center;
      gap: 8px;
      margin-bottom: 16px;
    }
    .speed-btn {
      font-family: var(--font-mono);
      font-size: 0.76rem;
      font-weight: 600;
      padding: 4px 10px;
      border-radius: 6px;
      background: rgba(255, 255, 255, 0.05);
      border: 1px solid var(--card-border);
      color: var(--text-muted);
      cursor: pointer;
      transition: all 0.15s ease;
    }
    .speed-btn.active, .speed-btn:hover {
      background: rgba(59, 130, 246, 0.2);
      border-color: var(--accent);
      color: #93c5fd;
    }

    /* URL Box */
    .stream-url-box {
      background: rgba(0, 0, 0, 0.35);
      border: 1px solid var(--card-border);
      border-radius: var(--radius-sm);
      padding: 10px 12px;
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 8px;
    }
    .stream-url-text {
      font-family: var(--font-mono);
      font-size: 0.74rem;
      color: #cbd5e1;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
      flex: 1;
    }
    .btn-copy {
      background: rgba(255, 255, 255, 0.08);
      border: 1px solid var(--card-border);
      color: var(--text);
      font-size: 0.75rem;
      font-weight: 500;
      padding: 6px 10px;
      border-radius: 6px;
      cursor: pointer;
      display: inline-flex;
      align-items: center;
      gap: 6px;
      white-space: nowrap;
      transition: all 0.15s ease;
    }
    .btn-copy:hover {
      background: rgba(255, 255, 255, 0.15);
      border-color: rgba(255, 255, 255, 0.3);
    }
    .btn-copy:active {
      transform: scale(0.96);
    }

    /* Toggles Grid */
    .toggles-grid {
      display: grid;
      grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
      gap: 12px;
    }
    .toggle-card {
      background: rgba(255, 255, 255, 0.03);
      border: 1px solid var(--card-border);
      border-radius: var(--radius-sm);
      padding: 12px;
      display: flex;
      flex-direction: column;
      justify-content: space-between;
      gap: 10px;
    }
    .toggle-header {
      display: flex;
      align-items: flex-start;
      justify-content: space-between;
      gap: 8px;
    }
    .toggle-label-text {
      font-size: 0.85rem;
      font-weight: 600;
    }
    .toggle-desc {
      font-size: 0.74rem;
      color: var(--text-muted);
      line-height: 1.35;
    }

    /* Switch Component */
    .switch {
      position: relative;
      display: inline-block;
      width: 44px;
      height: 24px;
      flex-shrink: 0;
    }
    .switch input {
      opacity: 0;
      width: 0;
      height: 0;
    }
    .slider {
      position: absolute;
      cursor: pointer;
      top: 0; left: 0; right: 0; bottom: 0;
      background-color: rgba(255, 255, 255, 0.15);
      transition: .25s ease;
      border-radius: 24px;
    }
    .slider:before {
      position: absolute;
      content: "";
      height: 18px;
      width: 18px;
      left: 3px;
      bottom: 3px;
      background-color: white;
      transition: .25s ease;
      border-radius: 50%;
    }
    input:checked + .slider {
      background-color: var(--accent);
    }
    input:checked + .slider:before {
      transform: translateX(20px);
    }

    /* Metrics Grid */
    .metrics-grid {
      display: grid;
      grid-template-columns: repeat(2, 1fr);
      gap: 10px;
    }
    @media (min-width: 600px) {
      .metrics-grid {
        grid-template-columns: repeat(4, 1fr);
      }
    }
    .metric-pill {
      background: rgba(0, 0, 0, 0.35);
      border: 1px solid var(--card-border);
      border-radius: var(--radius-sm);
      padding: 10px;
      display: flex;
      flex-direction: column;
      gap: 4px;
    }
    .metric-name {
      font-size: 0.7rem;
      font-weight: 600;
      text-transform: uppercase;
      letter-spacing: 0.05em;
      color: var(--text-muted);
    }
    .metric-val {
      font-family: var(--font-mono);
      font-size: 0.88rem;
      font-weight: 700;
      color: var(--text);
      display: flex;
      align-items: center;
      gap: 6px;
    }
    .status-dot {
      width: 8px;
      height: 8px;
      border-radius: 50%;
      display: inline-block;
      flex-shrink: 0;
    }
    .dot-green { background: var(--emerald); box-shadow: 0 0 8px var(--emerald); }
    .dot-amber { background: var(--amber); box-shadow: 0 0 8px var(--amber); }
    .dot-red { background: var(--rose); box-shadow: 0 0 8px var(--rose); }
    .dot-blue { background: var(--accent); box-shadow: 0 0 8px var(--accent); }

    /* Diagnostic Log Section */
    .log-header-actions {
      display: flex;
      align-items: center;
      gap: 8px;
    }
    .log-console {
      background: #06070a;
      border: 1px solid var(--card-border);
      border-radius: var(--radius-sm);
      height: 260px;
      overflow-y: auto;
      padding: 10px;
      font-family: var(--font-mono);
      font-size: 0.72rem;
      display: flex;
      flex-direction: column;
      gap: 4px;
      scroll-behavior: smooth;
    }
    .log-entry {
      line-height: 1.4;
      display: flex;
      align-items: flex-start;
      gap: 6px;
      word-break: break-all;
    }
    .log-ts {
      color: #64748b;
      flex-shrink: 0;
    }
    .log-tag {
      font-weight: 700;
      padding: 0 4px;
      border-radius: 3px;
      font-size: 0.65rem;
      flex-shrink: 0;
    }
    .tag-fg { background: rgba(59, 130, 246, 0.2); color: #93c5fd; }
    .tag-bg { background: rgba(245, 158, 11, 0.2); color: #fcd34d; }
    .tag-event { background: rgba(16, 185, 129, 0.2); color: #6ee7b7; }
    .tag-error { background: rgba(239, 68, 68, 0.25); color: #fca5a5; }
    .tag-wait { background: rgba(217, 119, 6, 0.25); color: #fde68a; }
    .log-msg {
      color: #cbd5e1;
    }

    .log-footer-bar {
      display: flex;
      align-items: center;
      justify-content: space-between;
      margin-top: 10px;
      font-size: 0.75rem;
      color: var(--text-muted);
    }
    .log-autoscroll-label {
      display: inline-flex;
      align-items: center;
      gap: 6px;
      cursor: pointer;
      user-select: none;
    }

    /* Feed & Soak Controls */
    .feed-controls-grid {
      display: grid;
      grid-template-columns: 1fr auto auto;
      gap: 10px;
      align-items: center;
      margin-bottom: 12px;
    }
    .feed-input {
      background: #06070a;
      border: 1px solid var(--card-border);
      border-radius: var(--radius-sm);
      color: #e2e8f0;
      font-family: var(--font-mono);
      font-size: 0.82rem;
      padding: 8px 10px;
      width: 100%;
    }
    .feed-num-input {
      background: #06070a;
      border: 1px solid var(--card-border);
      border-radius: var(--radius-sm);
      color: #e2e8f0;
      font-family: var(--font-mono);
      font-size: 0.82rem;
      padding: 8px 10px;
      width: 80px;
      text-align: center;
    }
    .soak-settings-grid {
      display: grid;
      grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
      gap: 10px;
      margin-top: 10px;
    }
    .soak-setting-item {
      display: flex;
      flex-direction: column;
      gap: 4px;
      background: rgba(255, 255, 255, 0.02);
      border: 1px solid var(--card-border);
      border-radius: var(--radius-sm);
      padding: 8px 10px;
    }
    .soak-setting-label {
      font-size: 0.72rem;
      font-weight: 600;
      color: var(--text-muted);
      text-transform: uppercase;
      letter-spacing: 0.04em;
    }
    .soak-setting-input {
      background: #06070a;
      border: 1px solid var(--card-border);
      border-radius: 4px;
      color: #e2e8f0;
      font-family: var(--font-mono);
      font-size: 0.8rem;
      padding: 4px 6px;
    }

    /* Playlist Items */
    .playlist-list {
      display: flex;
      flex-direction: column;
      gap: 8px;
      max-height: 420px;
      overflow-y: auto;
      padding-right: 4px;
    }
    .playlist-item {
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 10px 14px;
      background: rgba(255, 255, 255, 0.03);
      border: 1px solid var(--card-border);
      border-radius: var(--radius-sm);
      cursor: pointer;
      transition: all 0.15s ease;
    }
    .playlist-item:hover {
      background: rgba(255, 255, 255, 0.07);
      border-color: rgba(255, 255, 255, 0.15);
    }
    .playlist-item.active {
      background: rgba(59, 130, 246, 0.15);
      border-color: var(--accent);
    }
    .item-meta {
      display: flex;
      align-items: center;
      gap: 12px;
      overflow: hidden;
    }
    .item-idx {
      font-family: var(--font-mono);
      font-size: 0.82rem;
      font-weight: 700;
      color: var(--text-muted);
      width: 20px;
    }
    .playlist-item.active .item-idx {
      color: var(--accent);
    }
    .item-texts {
      overflow: hidden;
    }
    .item-title {
      font-size: 0.88rem;
      font-weight: 600;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }
    .item-artist {
      font-size: 0.75rem;
      color: var(--text-muted);
    }
    .item-badge {
      font-size: 0.68rem;
      font-weight: 700;
      color: var(--accent);
      background: rgba(59, 130, 246, 0.2);
      padding: 2px 8px;
      border-radius: 999px;
      white-space: nowrap;
    }

    /* Collapsible JSON Editor */
    details.editor-details {
      margin-top: 10px;
    }
    details.editor-details summary {
      cursor: pointer;
      font-size: 0.78rem;
      font-weight: 600;
      color: var(--text-muted);
      padding: 6px 0;
      user-select: none;
    }
    details.editor-details summary:hover {
      color: var(--text);
    }
    .editor-body {
      padding-top: 8px;
      display: flex;
      flex-direction: column;
      gap: 8px;
    }
    .json-textarea {
      width: 100%;
      height: 140px;
      background: #06070a;
      border: 1px solid var(--card-border);
      border-radius: var(--radius-sm);
      color: #e2e8f0;
      font-family: var(--font-mono);
      font-size: 0.75rem;
      padding: 8px;
      resize: vertical;
    }
    .editor-btn-row {
      display: flex;
      gap: 8px;
    }

    /* Toast */
    .toast {
      position: fixed;
      bottom: 24px;
      left: 50%;
      transform: translateX(-50%) translateY(30px);
      background: rgba(15, 23, 42, 0.95);
      border: 1px solid rgba(255, 255, 255, 0.2);
      color: white;
      padding: 10px 18px;
      border-radius: 999px;
      font-size: 0.84rem;
      font-weight: 500;
      box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
      pointer-events: none;
      opacity: 0;
      transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
      z-index: 9999;
    }
    .toast.show {
      transform: translateX(-50%) translateY(0);
      opacity: 1;
    }
