/* ── AzuraStreamer Design System ────────────────────────────────────────────── */

:root {
  /* Colors */
  --bg-main: #0a0a0c;
  --bg-panel: rgba(18, 18, 22, 0.7);
  --bg-card: rgba(30, 30, 35, 0.6);
  --bg-input: rgba(0, 0, 0, 0.3);
  
  --primary: #7c3aed;
  --primary-hover: #8b5cf6;
  --secondary: #2563eb;
  
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  
  --border: rgba(255, 255, 255, 0.08);
  --border-focus: rgba(124, 58, 237, 0.5);
  
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #3b82f6;
  
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;
  
  --shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
  --glass: blur(12px) saturate(180%);
}

/* ── Reset & Base ─────────────────────────────────────────────────────────── */

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: var(--bg-main);
  background-image: 
    radial-gradient(circle at 0% 0%, rgba(124, 58, 237, 0.1) 0%, transparent 40%),
    radial-gradient(circle at 100% 100%, rgba(37, 99, 235, 0.1) 0%, transparent 40%);
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

button, input, select { font-family: inherit; color: inherit; }

/* ── Layout ───────────────────────────────────────────────────────────────── */

.site-header {
  height: 56px;
  border-bottom: 1px solid var(--border);
  backdrop-filter: var(--glass);
  background: rgba(10, 10, 12, 0.8);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  height: 100%;
  padding: 0 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  /* Defensive: if all our mobile rules fail, at least let actions wrap rather
     than overflow the viewport. */
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;            /* allow the brand block to shrink inside the flex */
}

.brand > div:last-child {  /* the name+sub wrapper */
  min-width: 0;
  overflow: hidden;
}

.brand-icon { width: 36px; height: 36px; flex-shrink: 0; }
.brand-name { font-size: 20px; font-weight: 800; letter-spacing: -0.5px; background: linear-gradient(135deg, #a78bfa, #60a5fa); -webkit-background-clip: text; -webkit-text-fill-color: transparent; white-space: nowrap; }
.brand-sub { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 1px; color: var(--text-dim); }

.header-actions { display: flex; align-items: center; gap: 8px; min-width: 0; flex-wrap: wrap; justify-content: flex-end; }

/* The connection badge has no .badge rule in CSS — it relies on inheritance.
   Define a minimal one so it doesn't sprawl and so we can compact it on
   mobile (drop the text, keep the colored dot). */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  white-space: nowrap;
}
.badge--connecting { color: var(--text-muted); }
.badge--connected  { color: var(--success); border-color: rgba(16, 185, 129, 0.3); background: rgba(16, 185, 129, 0.08); }
.badge--error      { color: var(--danger);  border-color: rgba(239, 68, 68, 0.3);  background: rgba(239, 68, 68, 0.08); }

.layout {
  max-width: 1200px;
  margin: 16px auto;
  padding: 0 12px;
}

/* ── Dashboard Layout ── */
.dashboard {
  /* Mobile-first: single column by default */
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

@media (min-width: 900px) {
  .dashboard { grid-template-columns: 1fr 380px; gap: 24px; }
}

.dashboard-primary {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* ── Station Hero ── */
.station-hero {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  border-bottom: 1px solid var(--border);
  padding-bottom: 16px;
}

.hero-title {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.hero-badges {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 8px;
}

/* ── Media Viewport ── */
.media-viewport {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.viewport-main {
  display: grid;
  grid-template-columns: 1fr;
  min-height: 260px;
}

@media (min-width: 900px) {
  .viewport-main { grid-template-columns: 1.5fr 1fr; min-height: 360px; }
}

.preview-container {
  position: relative;
  background: #000;
  aspect-ratio: 16/9;
}

.art-img-bg {
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.3;
  filter: blur(20px);
}

.preview-overlay-text {
  position: absolute;
  top: 12px;
  right: 12px;
  background: rgba(0, 0, 0, 0.6);
  padding: 4px 8px;
  font-size: 10px;
  font-weight: 800;
  border-radius: 4px;
  z-index: 10;
}

.now-playing-hero {
  padding: 16px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  background: linear-gradient(to right, rgba(0,0,0,0.3), transparent);
}

.np-title-large { font-size: 18px; font-weight: 700; margin-bottom: 6px; }
.np-artist-large { font-size: 14px; color: var(--primary-hover); font-weight: 500; margin-bottom: 12px; }

/* ── Stats Bar ── */
.stream-stats-bar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  background: var(--border);
  border-top: 1px solid var(--border);
}

.stream-stats-bar .stat-box {
  background: var(--bg-panel);
  padding: 16px;
  border-radius: 0;
  border: none;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* ── Sidebar ── */
.dashboard-sidebar {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.control-card .card-body {
  padding: 24px;
}

/* ── Previous Components (Keep for compatibility) ── */
.station-card {
  display: none; /* Hide old cards if any remain */
}

.station-card:hover {
  border-color: var(--border-focus);
  transform: translateY(-4px);
  background: rgba(40, 40, 45, 0.8);
}

.station-card__art {
  position: relative;
  aspect-ratio: 16/9;
  overflow: hidden;
  background: #111;
  border-bottom: 1px solid var(--border);
}

.art-img, .preview-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.5s, opacity 0.3s;
}

.stream-preview {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 2;
  background: #000;
}

.live-badge {
  position: absolute;
  top: 12px;
  left: 12px;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 10px;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 6px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot--red { background: var(--danger); box-shadow: 0 0 10px var(--danger); animation: pulse 2s infinite; }

@keyframes pulse {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7); }
  70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(239, 68, 68, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

.station-card__body {
  padding: 20px;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.station-name { font-size: 18px; font-weight: 700; margin-bottom: 4px; }
.station-desc { font-size: 13px; color: var(--text-muted); margin-bottom: 16px; height: 2.4em; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }

.now-playing {
  background: var(--bg-input);
  padding: 12px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
}

.np-label { font-size: 9px; font-weight: 800; color: var(--text-dim); margin-bottom: 6px; letter-spacing: 0.5px; }
.np-artist { font-size: 12px; font-weight: 600; color: var(--primary-hover); }
.np-title { font-size: 14px; font-weight: 700; color: #fff; margin-bottom: 8px; }

.np-progress-wrap { display: flex; align-items: center; gap: 10px; }
.np-progress-bar { flex: 1; height: 4px; background: rgba(255, 255, 255, 0.1); border-radius: 2px; overflow: hidden; }
.np-progress-fill { height: 100%; background: linear-gradient(90deg, var(--primary), var(--secondary)); width: 0%; transition: width 1s linear; }
.np-time { font-size: 10px; font-family: 'JetBrains Mono', monospace; color: var(--text-dim); }

/* ── Stream Stats ── */

.stream-stats {
  background: rgba(0, 0, 0, 0.4);
  padding: 16px;
  border-radius: var(--radius-sm);
  margin-top: auto;
  border: 1px solid rgba(124, 58, 237, 0.2);
  animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.stream-info-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.stat-box {
  background: rgba(255, 255, 255, 0.03);
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.stat-label { font-size: 8px; font-weight: 700; color: var(--text-dim); margin-bottom: 2px; text-transform: uppercase; }
.stat-value { font-size: 11px; font-weight: 600; font-family: 'JetBrains Mono', monospace; color: var(--text-main); }

.station-footer {
  margin-top: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.listener-count { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: var(--text-muted); }


/* ── Buttons ──────────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  border: none;
  text-decoration: none;
}

.btn--primary { background: var(--primary); color: #fff; box-shadow: 0 4px 15px -5px var(--primary); }
.btn--primary:hover { background: var(--primary-hover); transform: translateY(-1px); }

.btn--danger { background: rgba(239, 68, 68, 0.1); color: var(--danger); border: 1px solid rgba(239, 68, 68, 0.2); }
.btn--danger:hover { background: var(--danger); color: #fff; }

.btn--ghost { background: transparent; color: var(--text-muted); border: 1px solid var(--border); }
.btn--ghost:hover { background: rgba(255, 255, 255, 0.05); color: #fff; }

.btn--sm { padding: 6px 12px; font-size: 12px; border-radius: 6px; }
.btn--full { width: 100%; }

.btn--yt { background: #ff0000; color: #fff; }
.btn--tw { background: #9146ff; color: #fff; }

/* Loading state for buttons */
.btn--loading { position: relative; pointer-events: none; opacity: 0.9; }
.btn--loading::after {
  content: '';
  position: absolute;
  right: 12px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.2);
  border-top-color: #fff;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Form Elements ─────────────────────────────────────────────────────────── */

.form-group { margin-bottom: 20px; }
.form-label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 8px; color: var(--text-muted); }

.form-input, .form-select {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 14px;
  transition: all 0.2s;
}

.form-input:focus, .form-select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.2);
}

.platform-picker {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.platform-btn {
  border: 1px solid var(--border);
  padding: 12px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
  transition: all 0.2s;
  background: rgba(255, 255, 255, 0.03);
}

.platform-btn input { display: none; }
.platform-btn:has(input:checked) { border-color: var(--primary); background: rgba(124, 58, 237, 0.1); color: var(--primary-hover); }

/* ── Modals / Overlays ─────────────────────────────────────────────────────── */

.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}

.modal-overlay.active { opacity: 1; pointer-events: all; }

.modal {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 500px;
  padding: 32px;
  box-shadow: var(--shadow);
  transform: translateY(20px);
  transition: transform 0.3s;
}

.modal-overlay.active .modal { transform: translateY(0); }

/* ── Mobile modal ───────────────────────────────────────────────────────────
   The settings form has 30+ fields, so on a phone in portrait the modal
   exceeds the viewport. Without these rules the overlay (display:flex,
   align-items:center) clips the modal at top and bottom — the user can see
   the first few fields but can never reach the Save button. Cap the modal
   height to the dynamic viewport (100dvh handles iOS Safari's URL-bar
   reflow), make the modal itself the scroll container, and pin the overlay
   to the top of the screen so the modal's scroll origin is visible. The
   inline-styled refresh-token rows stack via a class added below.
*/
@media (max-width: 899px) {
  .modal-overlay {
    align-items: flex-start;
    padding: 16px;
  }
  .modal {
    /* 100dvh = dynamic viewport height; falls back to 100vh in older browsers
       via the second value. Subtract the overlay's 16px top+bottom padding. */
    max-height: calc(100dvh - 32px);
    max-height: calc(100vh - 32px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 20px;
  }
  /* iOS Safari zooms in on focused inputs with font-size < 16px. Bump inputs
     on small screens so focusing a field doesn't re-zoom the whole modal. */
  .form-input,
  .form-select {
    font-size: 16px;
  }
  /* The refresh-token field has three flex children (input + Test + Connect
     Account). On a 360px-wide phone the input collapses to <120px and the
     "Connect Account" label wraps. Stack: input full-width on top, then the
     two buttons in a row beneath. */
  .connect-row {
    flex-direction: column !important;
    align-items: stretch !important;
  }
  .connect-row .form-input { width: 100%; }
  .connect-row .btn-connect-row {
    display: flex;
    gap: 8px;
    margin-top: 8px;
  }
  .connect-row .btn-connect-row > * { flex: 1; }
  /* The setup-guide boxes (YouTube / Twitch instructions) are wrapped in
     inline-styled divs; they stack fine but their inline padding eats space.
     Leave them alone; only fix the form-group margin so 30+ groups don't
     compound. */
  .form-group { margin-bottom: 16px; }
}

/* ── Mobile top-nav ─────────────────────────────────────────────────────────
   The desktop header has 6 action items in a single flex row (badge +
   settings + refresh + logout + privacy + terms). On a 360px-wide phone that
   exceeds the viewport and breaks the layout at the top. Compact strategy:
     • drop the brand subtitle ("Premium Live Bridge")
     • shrink the connection badge to a colored dot only (the .badge-text is
       hidden on mobile; status conveyed by color)
     • push the least-used actions (privacy/terms) into an "overflow" menu
       that's revealed by a small "···" button on the far right
     • make sure the header itself doesn't grow taller than 52px
   Result: 4 visible items on mobile (brand + dot + settings + refresh + menu)
   instead of 6, all of which fit in 360px.
*/
@media (max-width: 600px) {
  .site-header { height: 52px; }
  .header-inner { padding: 0 8px; gap: 6px; }
  .brand-icon { width: 30px; height: 30px; }
  .brand-name { font-size: 16px; }
  .brand-sub { display: none; }
  .header-actions { gap: 4px; }

  /* Compact badge: keep the dot, drop the text. The dot color tells the
     user the status (gray=connecting, green=connected, red=error). */
  .badge {
    padding: 0;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    justify-content: center;
    gap: 0;
    border-width: 1.5px;
  }
  .badge .badge-text { display: none; }
  .badge .dot { width: 10px; height: 10px; }

  /* Settings + refresh stay as visible icon buttons; their SVGs are
     important and frequently used. */
  #btn-settings, #btn-refresh { padding: 6px 8px; }

  /* Hide the low-priority icon buttons (logout, privacy, terms) by default;
     they're reachable via the "···" overflow menu. */
  #btn-logout, .header-actions a[href="/privacy.html"], .header-actions a[href="/terms.html"] {
    display: none;
  }

  /* The overflow menu button (added by app.js) is hidden on desktop, visible
     on mobile. */
  #btn-overflow { display: inline-flex; }

  /* The overflow popover is positioned absolutely relative to its trigger.
     The trigger is the last item in .header-actions. */
  .overflow-menu {
    position: absolute;
    top: 52px;
    right: 8px;
    min-width: 180px;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow);
    padding: 6px;
    z-index: 110;
  }
  .overflow-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 12px;
    background: transparent;
    border: 0;
    color: var(--text);
    text-align: left;
    font-size: 13px;
    border-radius: 6px;
    cursor: pointer;
  }
  .overflow-menu-item:hover { background: rgba(255, 255, 255, 0.05); }
  .overflow-menu-item svg { flex-shrink: 0; }

  /* ── Mobile layout for stream-active elements ──────────────────────────
     When a stream starts, three blocks become visible that were hidden on
     initial load: the .stream-stats-bar (4-column stat grid), the
     .preview-overlay (live feed), and the .stream-status-banner (LIVE/ERROR
     pill). None of these had a mobile override, so on a 360px phone they
     kept their desktop sizes — the 4-column stats grid crammed four ~80px
     columns into the available 336px, the station hero tried to fit the
     title and a status pill side-by-side, and the LIVE feed image broke
     out of the 16:9 aspect-ratio container.

     Below: make all three play nicely on mobile.
  */

  /* 4-column stats grid → 2×2 on phones. Each stat is wider, the
     labels/values have more breathing room. */
  .stream-stats-bar {
    grid-template-columns: repeat(2, 1fr);
  }
  .stream-stats-bar .stat-box {
    padding: 10px 8px;
  }
  .stream-stats-bar .stat-label { font-size: 9px; }
  .stream-stats-bar .stat-value { font-size: 11px; }

  /* The station hero (title + ONLINE/LIVE badge + listener count) is
     flex-row with space-between on desktop. On mobile the title can get
     squeezed by the badges row; stack them so the title gets the full
     width and the badges wrap onto a second row. */
  .station-hero {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
  .hero-badges {
    flex-wrap: wrap;
  }
  .hero-title { font-size: 18px; }

  /* The preview container's 16:9 aspect ratio is fine, but the embedded
     .stream-preview (when live) had no max-width, so on a 360px phone the
     1280×720 mjpeg could try to display at full natural size inside the
     360px container. .preview-img already has width:100% (line 267), so
     the only thing left is to ensure the container doesn't get a hard
     height from anywhere and to keep the LIVE FEED pill readable. */
  .preview-overlay-text { font-size: 9px; padding: 3px 6px; top: 8px; right: 8px; }

  /* Now-playing hero: trim padding so the progress bar and time text fit
     comfortably without squeezing the title. */
  .now-playing-hero { padding: 12px 14px; }
  .np-title-large { font-size: 16px; }
  .np-artist-large { font-size: 13px; }

  /* The stream-status-banner is a full-width pill; on mobile make it a
     bit smaller and less padded so it doesn't dominate the screen. */
  .stream-status-label { padding: 4px 10px; font-size: 10px; }
}
@media (min-width: 601px) {
  /* Overflow menu is desktop-only hidden — on desktop all 6 items fit. */
  #btn-overflow { display: none; }
}

/* Sticky save bar at the bottom of the modal so the primary action is always
   one tap away regardless of scroll position. Mirrors the modal's background
   with a slight blur so content scrolling under it stays readable. */
.settings-save-bar {
  position: sticky;
  bottom: -20px;        /* offset matches the modal's mobile padding */
  margin: 24px -20px -20px;
  padding: 16px 20px;
  background: var(--bg-panel);
  border-top: 1px solid var(--border);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 2;
}
@media (min-width: 900px) {
  .settings-save-bar {
    bottom: -32px;
    margin: 24px -32px -32px;
    padding: 16px 32px;
  }
}

/* ── Utility ──────────────────────────────────────────────────────────────── */

.chip {
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 800;
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-muted);
}

.chip--live { background: rgba(239, 68, 68, 0.1); color: var(--danger); border: 1px solid rgba(239, 68, 68, 0.2); }
.chip--online { background: rgba(16, 185, 129, 0.1); color: var(--success); border: 1px solid rgba(16, 185, 129, 0.2); }

.skeleton-card {
  height: 400px;
  background: linear-gradient(90deg, var(--bg-card) 25%, rgba(255,255,255,0.05) 50%, var(--bg-card) 75%);
  background-size: 200% 100%;
  animation: skeleton 1.5s infinite;
  border-radius: var(--radius-md);
}

@keyframes skeleton {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── Stream Status Labels ── */
.stream-status-label {
  font-size: 11px;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: 6px;
  margin-bottom: 16px;
  text-align: center;
  border: 1px solid transparent;
}

.status--live {
  background: rgba(16, 185, 129, 0.1);
  color: var(--success);
  border-color: rgba(16, 185, 129, 0.2);
}

.status--reconnecting {
  background: rgba(245, 158, 11, 0.1);
  color: var(--warning);
  border-color: rgba(245, 158, 11, 0.2);
  animation: blink 1.5s infinite;
}

.status--error {
  background: rgba(239, 68, 68, 0.1);
  color: var(--danger);
  border-color: rgba(239, 68, 68, 0.2);
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

/* ── Toast System ── */
#toasts {
  position: fixed;
  top: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 12px;
  pointer-events: none;
}

.toast {
  pointer-events: all;
  min-width: 320px;
  max-width: 420px;
  background: rgba(18, 18, 22, 0.9);
  backdrop-filter: blur(12px) saturate(180%);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  box-shadow: 0 20px 40px -10px rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: flex-start;
  gap: 16px;
  animation: toastIn 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

.toast .toast-close {
  position: absolute;
  top: 8px;
  right: 8px;
  background: transparent;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 12px;
  padding: 6px;
}
.toast .toast-close:hover { color: #fff; }

.toast--success { border-left: 4px solid var(--success); }
.toast--error { border-left: 4px solid var(--danger); }
.toast--info { border-left: 4px solid var(--info); }
.toast--warning { border-left: 4px solid var(--warning); }

.toast.removing {
  animation: toastOut 0.3s ease forwards;
}

.toast-icon {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.toast-content {
  flex: 1;
}

.toast-title {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 2px;
  color: #fff;
}

.toast-message {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.4;
}

@keyframes toastIn {
  from { transform: translateX(40px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

@keyframes toastOut {
  from { transform: translateX(0) scale(1); opacity: 1; }
  to { transform: translateX(20px) scale(0.95); opacity: 0; }
}

/* ── Log Area ── */
.log-card {
  margin-top: 0;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--border);
}

.log-viewport {
  height: 200px;
  overflow-y: auto;
  padding: 12px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  line-height: 1.6;
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: #050505;
}

.log-line {
  display: flex;
  gap: 12px;
  opacity: 0.85;
}

.log-line::before {
  content: '[' attr(data-time) ']';
  color: var(--text-dim);
  flex-shrink: 0;
}

.log-line--info { color: #818cf8; }
.log-line--error { color: #f87171; }
.log-line--stream { color: #34d399; }
.log-line--system { color: #fbbf24; }

.log-viewport::-webkit-scrollbar { width: 6px; }
.log-viewport::-webkit-scrollbar-track { background: transparent; }
.log-viewport::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.1); border-radius: 3px; }
.log-viewport::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.2); }


