@import url('https://fonts.googleapis.com/css2?family=Space+Mono:wght@400;700&display=swap');

:root {
  /* Colors */
  /* Slightly lighter background so black-bordered icons are visible while keeping dark theme */
  --bg-color: #1c2637;
  --text-color: #e6eef8;
  --text-muted: #94a3b8;
  --accent-blue: #3b82f6;
  --accent-blue-hover: #2563eb;
  --accent-green: #22c55e;
  --accent-pink: #f472b6;
  --accent-purple: #7c3aed;
  /* Lighten input surfaces for better icon contrast */
  --input-bg: #2a3446;
  --input-border: #51617a;
  --border-subtle: #334155;
  
  /* unified button size handled directly in class rules */

  
  /* Layout */
  --font-main: 'Courier New', Courier, monospace;
  --font-head: 'Space Mono', monospace;
  --container-width: 720px;
  --label-col: 140px;
  --slider-col: minmax(120px, 200px);
}

/* Reset & Base */
body {
  font-family: var(--font-main);
  background: var(--bg-color);
  color: var(--text-color);
  display: flex;
  justify-content: center;
  min-height: 100vh;
  margin: 0;
  width: 100%;
}

main {
  width: var(--container-width);
  max-width: 94%;
  margin: 40px auto;
  padding: 28px;
  background: linear-gradient(180deg, rgba(255,255,255,0.03), rgba(255,255,255,0.01));
  border-radius: 12px;
  box-shadow: 0 6px 30px rgba(0,0,0,0.6);
}

h1 {
  margin-top: 0;
  font-family: var(--font-head);
  font-weight: 700;
  letter-spacing: 2px;
}

/* Top bar: Title | File | (spacer) | Record (right-aligned) */
.topbar {
  display: grid;
  grid-template-areas: 'title spacer file record';
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
  column-gap: 16px;
  row-gap: 8px;
  margin-bottom: 14px;
}
.topbar h1 { grid-area: title; margin: 0; }
.topbar .file-label { grid-area: file; justify-self: end; }
.topbar .record-stack { grid-area: record; justify-self: end; }

@media (max-width: 720px) {
  .topbar {
    grid-template-areas:
      'title title title'
      '.     file  record';
    grid-template-columns: 1fr auto auto;
  }
  .topbar .file-label { justify-self: end; }
}

/* Utilities */
.text-center { text-align: center; }
.center-row { display: flex; justify-content: center; align-items: center; gap: 12px; width: 100%; }
.stack-center { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.centered-block { width: max-content; margin-inline: auto; }
.btn-wide { width: 180px; }
.row { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
/* Ensure space below the Play button so the buttons below don't touch */
.play-row { margin-bottom: 16px; }
.actions-row { margin-top: 0; }

/* Action panes: Preset (left) and Render (right) */
.actions-two-col { display: none; }
.render-center { display: none; }

/* Dropdown styles */
#preset-select {
  background: var(--input-bg);
  color: var(--text-muted);
  border: 1px solid var(--input-border);
  border-radius: 8px;
  padding: 6px 8px;
  height: 34px;
  /* Center the selected value text */
  text-align: center;
  text-align-last: center;
  -moz-text-align-last: center;
  width: 180px;
  transition: transform 0.2s ease, box-shadow 0.4s ease, border-color 0.3s ease, background-position 0.6s ease;
  /* Match purchase CTA font styling */
  font-family: var(--font-main);
  font-weight: 700; /* bolden a bit */
  font-size: 13px;
  text-shadow: 0 1px 0 rgba(0,0,0,0.25);
}
#preset-select option { text-align: center; font-weight: 700; }
#preset-select:focus { outline: 2px solid var(--accent-blue); outline-offset: 2px; }

/* Enticing "Free Templates" state */
#preset-select.cta-glow {
  /* soft shimmering highlight + animated glow */
  background-image:
    linear-gradient(120deg, rgba(255,255,255,0.10) 25%, rgba(255,255,255,0.18) 50%, rgba(255,255,255,0.10) 75%);
  background-size: 220% 100%;
  animation: shimmer 3.2s ease-in-out infinite, glowShift 4.8s linear infinite;
  border-color: #60a5fa;
  box-shadow: 0 0 0 2px rgba(96,165,250,0.20) inset, 0 0 18px rgba(96,165,250,0.25);
}
#preset-select.cta-glow:hover { transform: translateY(-1px) scale(1.015); }

@keyframes shimmer {
  0% { background-position: 0% 0; }
  50% { background-position: 100% 0; }
  100% { background-position: 0% 0; }
}
@keyframes glowShift {
  0% { box-shadow: 0 0 0 2px rgba(96,165,250,0.20) inset, 0 0 18px rgba(96,165,250,0.25); }
  33% { box-shadow: 0 0 0 2px rgba(244,114,182,0.20) inset, 0 0 18px rgba(244,114,182,0.25); }
  66% { box-shadow: 0 0 0 2px rgba(124,58,237,0.20) inset, 0 0 18px rgba(124,58,237,0.25); }
  100% { box-shadow: 0 0 0 2px rgba(96,165,250,0.20) inset, 0 0 18px rgba(96,165,250,0.25); }
}

/* Render mode select is half-width and sits to the left of Render button */
#render-mode {
  background: var(--input-bg);
  color: var(--text-muted);
  border: 1px solid var(--input-border);
  border-radius: 6px;
  padding: 6px 8px;
  height: 34px;
  text-align: center;
  text-align-last: center;
  -moz-text-align-last: center;
  width: 90px;
}
#render-mode option { text-align: center; }
#render-mode:focus { outline: 2px solid var(--accent-blue); outline-offset: 2px; }

/* Loop toggle button next to Play */
.btn-loop {
  background: var(--input-border);
  color: #e2e8f0;
  padding: 8px 12px;
  border-radius: 8px;
  font-weight: 600;
  margin-left: 8px;
}
.btn-loop[aria-pressed="true"] {
  background: var(--accent-pink);
  color: var(--bg-color);
}

/* Components: Buttons */
button {
  font-family: var(--font-main);
  background: var(--accent-green);
  border: 0;
  padding: 10px 14px;
  border-radius: 8px;
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s;
}
button:disabled { opacity: 0.6; cursor: not-allowed; }
button:hover:not(:disabled) { opacity: 0.9; }
#start-again-btn:not(.media-btn) { background: #ef4444; }
#preview-btn:not(.media-btn) { background: var(--accent-blue); }
#preset-slow, #preset-nightcore, #preset-lofi { background: var(--accent-blue); padding: 6px 12px; border-radius: 6px; }
#preset-nightcore { background: var(--accent-purple); }
#preset-lofi { background: #d97706; }
.trial-btn {
  /* Minimalist solid style - Pink background, Black text */
  background: var(--accent-pink);
  color: #000000;
  font-weight: 700;
  height: 34px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  border: none;
  transition: all 0.2s ease;
}
.trial-btn:hover:not(:disabled) {
  opacity: 0.9;
  /* Slight transform for feedback without big shadows */
  transform: translateY(-1px);
}
.trial-btn:active:not(:disabled) {
  transform: translateY(0);
}

/* Render/Download primary action (minimalist) */
#process-btn {
  /* Dark leafy green background, White text */
  background: #15803d; /* green-700 */
  color: #ffffff;
  width: 180px; /* match template selector width */
  height: 34px; /* match selects */
  padding: 0 14px; /* vertical alignment */
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 6px;
  font-weight: 600;
  transition: all 0.2s ease;
}
#process-btn:hover:not(:disabled) {
  opacity: 0.9;
  /* Slight transform for feedback without big shadows */
  transform: translateY(-1px);
}
#process-btn:active:not(:disabled) {
  transform: translateY(0);
}
#process-btn:focus-visible { outline: 2px solid var(--accent-green); outline-offset: 2px; }

/* Media transport icon buttons */
.media-btn {
  width: 48px;
  height: 48px;
  min-width: 48px;
  min-height: 48px;
  border-radius: 8px;
  background: transparent; /* override any shorthand background */
  border: none;
  box-shadow: none;
  padding: 0;
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain; /* prevent squish, keep aspect */
  position: relative;
  z-index: 0;
}
.media-btn:hover { opacity: 0.9; }


/* Play/Pause combo shows next action */
.media-playpause[data-state="play"] { background-image: url('/static/img/media_play.png'); }
.media-playpause[data-state="pause"] { background-image: url('/static/img/media_pause.png'); }

/* Restart */
.media-restart { background-image: url('/static/img/media_restart.png'); }

/* Normalize icon scale to match Record button appearance */
.media-playpause,
.media-restart,
.reset-btn {
  background-size: contain;
}

/* Restart inherits base media button size */

/* Loop toggle */
.media-loop { background-image: url('/static/img/media_loop.png'); }
.media-loop[aria-pressed="false"] { filter: brightness(0.6) contrast(0.9) saturate(0.8); opacity: 0.7; }
.media-loop[aria-pressed="true"] { filter: none; opacity: 1; }

/* Loop inherits base media button size */

/* Ensure preview icon button keeps neutral background color */
#preview-btn.media-btn { background-color: transparent; }

/* Play/Pause and Reset inherit base media button size */

/* Transport container: single big box around all media buttons */
.transport {
  display: inline-flex;
  align-items: center;
  gap: 8px; /* revert to original spacing between playback buttons */
  padding: 0;
  border-radius: 12px;
  background: transparent;
  border: none;
  box-shadow: none;
}

/* (cleanup) removed radial underlay effects */

/* Start Again reset icon */
.reset-btn { background-image: url('/static/img/reset.png'); }

/* Components: File Upload */
.file-label {
  background: var(--input-bg);
  border: 1px dashed var(--input-border);
  padding: 0 14px;
  border-radius: 8px;
  cursor: pointer;
  width: 234px; /* ~30% wider than Render button */
  max-width: 100%;
  height: 34px; /* match Render button height */
  box-sizing: border-box; /* include padding/border in fixed height */
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  color: var(--text-muted);
  transition: all 0.2s;
  margin: 0; /* keep row centering on the flex container so the record button can sit beside */
}
.file-label:hover, .file-label.drag-over { border-color: #60a5fa; color: #e2e8f0; }
.file-label:focus-within { outline: 2px solid #60a5fa; outline-offset: 2px; }
.file-label input[type="file"] {
  position: absolute; inset: 0; opacity: 0; cursor: pointer; font-size: 0; width: 100%; height: 100%;
}
#file-display { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
#file-row { justify-content: center; flex-wrap: nowrap; gap: 12px; }

.record-stack { position: relative; display: flex; flex-direction: column; align-items: center; margin-left: 0; height: 48px; z-index: 2; }
.record-btn {
  /* inherits 72px square from .media-btn */
  border-radius: 8px;
  background: transparent;
  background-image: url('/static/img/record_micoff.png');
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
  display: inline-flex; align-items: center; justify-content: center;
  box-shadow: none; /* no box appearance */
  border: none;
  position: relative; z-index: 2;
}
.record-btn:disabled { opacity: 0.6; cursor: not-allowed; }
.record-timer { position: absolute; top: calc(100% + 4px); left: 50%; transform: translateX(-50%); font-size: 12px; color: var(--text-muted); min-height: 14px; text-align: center; }

/* Minimal recording state indication */
.record-btn.recording {
  /* Show only the icon; remove square pulse on the button itself */
  background-image: url('/static/img/record_micon.png');
  animation: none;
}
/* Circular, more noticeable pulse ring */
.record-btn.recording::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  /* Slightly larger highlight circle */
  width: 40px;
  height: 40px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  box-shadow: 0 0 0 0 rgba(239,68,68,0.65);
  animation: recPulseSmall 1.15s infinite;
  pointer-events: none;
  z-index: 1;
}
@keyframes recPulse {
  0%   { box-shadow: 0 0 0 0 rgba(239,68,68,0.55); }
  70%  { box-shadow: 0 0 0 6px rgba(239,68,68,0); }
  100% { box-shadow: 0 0 0 0 rgba(239,68,68,0); }
}

/* Pulse used for the recording indicator circle */
@keyframes recPulseSmall {
  0%   { box-shadow: 0 0 0 0 rgba(239,68,68,0.65); }
  70%  { box-shadow: 0 0 0 8px rgba(239,68,68,0); }
  100% { box-shadow: 0 0 0 0 rgba(239,68,68,0); }
}

/* Playbar layout: center transport, loop aligned right */
.playbar {
  display: grid;
  grid-template-columns: 1fr auto 1fr; /* left group, centered transport, right group */
  grid-template-areas: 'left center right';
  column-gap: 24px; /* push left/right groups further from the centered transport */
  align-items: center;
  width: 100%;
}
.playbar .left-controls { grid-area: left; justify-self: start; display: inline-flex; align-items: center; gap: 8px; }
.playbar .transport { grid-area: center; justify-self: center; }
.playbar .right-controls { grid-area: right; justify-self: end; display: inline-flex; align-items: center; gap: 8px; }

/* When space is tight: keep transport centered with right group; drop left group below, centered */
@media (max-width: 720px) {
  .playbar {
    grid-template-columns: 1fr auto 1fr;
    grid-template-areas:
      '.      center right'
      'left   left   left';
    row-gap: 8px;
  }
  .playbar .left-controls { justify-self: center; }
}

/* On very narrow screens: stack right group below transport, left group at the bottom */
@media (max-width: 520px) {
  .playbar {
    grid-template-columns: 1fr;
    grid-template-areas:
      'center'
      'right'
      'left';
    row-gap: 8px;
  }
  .playbar .transport { justify-self: center; }
  .playbar .right-controls { justify-self: center; }
  .playbar .left-controls { justify-self: center; }
}

/* Components: Inputs & Sliders */
input[type="range"] {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 3px; border-radius: 2px;
  background: linear-gradient(to right, #60a5fa 0%, #60a5fa 50%, #334155 50%, #334155 100%);
  outline: none; cursor: pointer; min-width: 0;
  touch-action: none; /* Prevent scroll while dragging */
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 16px; height: 16px; border-radius: 50%;
  background: #60a5fa; cursor: pointer; box-shadow: 0 1px 3px rgba(0,0,0,0.28); margin-top: -6px; transition: background 0.2s, transform 0.1s;
}
input[type="range"]::-webkit-slider-thumb:active { transform: scale(1.1); }
input[type="range"]::-webkit-slider-thumb:hover { background: #3b82f6; }
input[type="range"]::-webkit-slider-runnable-track { background: transparent; height: 3px; border-radius: 2px; }
input[type="range"]::-moz-range-thumb {
  width: 16px; height: 16px; border-radius: 50%; background: #60a5fa; border: none; cursor: pointer; transition: background 0.2s, transform 0.1s;
}
input[type="range"]::-moz-range-thumb:active { transform: scale(1.1); }
input[type="range"]::-moz-range-track { background: #334155; border-radius: 2px; border: none; height: 3px; }
input[type="range"]::-moz-range-progress { background: #60a5fa; border-radius: 2px; height: 3px; }

input[type="number"] {
  width: 7ch; height: 28px;
  background: var(--input-bg); border: 1px solid var(--input-border);
  color: var(--text-color); border-radius: 6px; padding: 4px 8px;
  font-family: inherit; font-size: 12px;
  -moz-appearance: textfield;
  appearance: textfield;
}
input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
input[type="number"]:hover { border-color: #60a5fa; background: #334155; }
input[type="number"]:focus { outline: none; border-color: #3b82f6; background: #334155; }

input[type="checkbox"] { width: 18px; height: 18px; accent-color: #60a5fa; cursor: pointer; margin: 0; }

select {
  width: 100%; max-width: 200px; height: 28px;
  background: var(--input-bg); border: 1px solid var(--input-border);
  color: var(--text-color); border-radius: 6px; padding: 4px 8px;
  font-family: inherit; font-size: 12px; cursor: pointer;
  appearance: none;
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="12" height="8" viewBox="0 0 12 8"><path fill="%2360a5fa" d="M1 1l5 5 5-5"/></svg>');
  background-repeat: no-repeat; background-position: right 8px center; padding-right: 28px;
}
select:hover { border-color: #60a5fa; background-color: #334155; }

/* Sections */
#visualizer-wrap { position: relative; }
#loop-handle-overlay { position: absolute; left: 0; right: 0; top: -15px; height: 15px; z-index: 3; pointer-events: auto; background: transparent; }
#visualizer { width: 100%; height: 100px; background: #000; border-radius: 8px; border: 1px solid var(--border-subtle); margin-bottom: 6px; position: relative; z-index: 1; }
#status-text { margin-top: 10px; color: var(--text-muted); font-style: italic; min-height: 24px; }
.presets-container { margin-top: 16px; display: flex; gap: 8px; align-items: center; justify-content: center; }
.presets-label { font-weight: 600; color: var(--text-muted); }

/* Pro Section */
#pro-section {
  display: flex; flex-direction: column; align-items: center;
  margin: 20px 0; border-top: 1px solid var(--border-subtle); padding-top: 15px;
  gap: 12px;
}
.pro-mode #pro-header { cursor: pointer; }
#pro-header { display: flex; align-items: center; justify-content: center; gap: 12px; flex-wrap: wrap; margin-bottom: 0; position: relative; }
.pro-mode #pro-header::after {
  content: '▾';
  color: var(--text-muted);
  margin-left: 6px;
}
.pro-mode.collapsed #pro-header::after {
  content: '▸';
}
.pro-title { font-size: 22px; font-weight: 700; color: var(--accent-pink); display: flex; align-items: center; gap: 8px; }

.cassette-button {
  background: transparent;
  border: none;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px;
  margin: 2px auto 8px;
  position: relative;
  z-index: 0;
  isolation: isolate; /* keep inner glow self-contained */
}
.cassette-button::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 10px;
  transform: translateX(-50%);
  width: clamp(160px, 28vw, 220px);
  height: clamp(60px, 10vw, 90px);
  border-radius: 16px;
  background:
    radial-gradient(60% 60% at 50% 35%, rgba(124,58,237,0.22) 0%, rgba(244,114,182,0.18) 45%, rgba(59,130,246,0.16) 80%, transparent 100%);
  filter: blur(12px);
  z-index: -1;
  pointer-events: none;
}
.cassette-image {
  width: clamp(100px, 22vw, 150px);
  filter: drop-shadow(0 4px 10px rgba(0,0,0,0.45));
  transition: transform 0.18s ease, filter 0.18s ease;
}
.cassette-button:hover .cassette-image { transform: translateY(-1px) scale(1.04); filter: drop-shadow(0 6px 14px rgba(0,0,0,0.55)); }
.cassette-cta {
  /* Minimalist text only */
  color: var(--text-muted);
  font-size: 13px;
  padding: 2px 4px;
  border-radius: 4px;
  display: inline-block;
  border: 1px solid transparent;
  background: transparent;
  box-shadow: none;
  text-shadow: none;
  transition: color 0.2s ease;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.cassette-button:hover .cassette-cta {
  color: var(--text-color);
  transform: none;
  box-shadow: none;
  border-color: transparent;
}
.cassette-button:active .cassette-cta {
  transform: translateY(0);
  box-shadow: none;
}

/* Pro Controls Layout */
#pro-controls {
  width: 100%; max-width: 600px;
  opacity: 0.5; pointer-events: none; transition: opacity 0.3s;
  display: flex; flex-direction: column; align-items: center;
  margin-top: 10px;
  overflow-x: hidden;
  container-type: inline-size;
}
#pro-controls.enabled, #pro-controls[data-enabled="true"] { opacity: 1; pointer-events: auto; }

.effect-group { width: 100%; margin-top: 15px; box-sizing: border-box; display: flex; flex-direction: column; }

/* Ensure the container that holds Format and Sample Rate rows stretches full width
  so those rows share the exact same left alignment as the other effect rows */
.pro-control-formats { width: 100%; }

/* When Pro/Trial is not enabled, additionally dim the Format/Sample Rate rows
  so it's obvious they cannot be adjusted. Also show a not-allowed cursor. */
#pro-controls[data-enabled="false"] .pro-control-formats .row span,
#pro-controls[data-enabled="false"] .pro-control-formats .row select {
  opacity: 0.65;
  cursor: not-allowed;
}
#pro-controls[data-enabled="false"] .pro-control-formats .row span { color: var(--text-muted); }

/* Grid for Controls */
/* Apply grid to label.row (sub rows, format rows), .pro-heading, and .pro-sub */
label.row, .pro-heading, .pro-sub {
  display: grid;
  grid-template-columns: var(--label-col) var(--slider-col) auto;
  align-items: center;
  column-gap: 8px;
  width: 100%;
  margin: 0 auto 5px;
  padding: 0 1rem;
  box-sizing: border-box;
}
label.row span { width: auto; }

/* Align the left text column (labels like Rate:, Mix:, etc.) with the
   section headings (Speed, Reverb, etc.) which have a bullet and 18px inset. */
.pro-sub span { padding-left: 18px; }
/* Keep the format/sample-rate rows aligned with the same left column as well */
.row.format-select-row span,
.row.sample-rate-row span { padding-left: 18px; }

/* Ensure selects align with the slider column start */
.format-select-row select,
.sample-rate-row select { justify-self: start; width: 100%; }

.pro-heading strong { position: relative; padding-left: 18px; grid-column: 1; }
.pro-heading strong::before {
  content: ""; position: absolute; left: 0; top: 50%; transform: translateY(-50%);
  width: 10px; height: 10px; border-radius: 50%; background: #60a5fa;
}
.pro-heading input[type="checkbox"] { position: absolute; opacity: 0; pointer-events: none; }
.pro-heading input[type="checkbox"]:not(:checked) + strong { opacity: 0.65; }
.pro-heading input[type="checkbox"]:not(:checked) + strong::before { background: var(--input-border); }

/* Dim effect group when unchecked */
.effect-group:has(> .pro-heading input:not(:checked)) .pro-sub { opacity: 0.5; pointer-events: none; }


/* Right-side container in each row to allow easy extension with more columns (e.g., extra controls) */
.pro-sub-right { display: inline-flex; gap: 8px; align-items: center; justify-self: start; padding-left: 18px; }
.pro-sub-right select { justify-self: start; width: 100%; }
/* Placeholder to preserve grid three columns for select rows */
.pro-sub-placeholder { display: block; }

/* Text-style controls used for Automation + / - */
.pro-text-btn {
  background: transparent;
  border: none;
  color: var(--text-color);
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px; /* fixed square for perfect centering */
  height: 28px; /* match number input height */
  padding: 0; /* avoid visual shift from side padding */
  cursor: pointer;
  user-select: none;
  border-radius: 4px; /* invisible, but improves focus outline shape */
  text-align: center; /* hard-center fallback */
}
.pro-text-btn:hover { color: #60a5fa; }
.pro-text-btn:focus { outline: 1px dashed #60a5fa; outline-offset: 2px; }

/* Ensure automation row right controls align like number boxes */
.automation-row .pro-sub-right { justify-self: start; gap: 4px; flex-wrap: nowrap; white-space: nowrap; overflow: hidden; }

/* Token & Trial */
.token-row { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
#pro-token-input { background: #0b1220; border: 1px solid var(--border-subtle); color: var(--text-color); padding: 8px; border-radius: 6px; min-width: 220px; text-align: center; }
#save-token-btn { background: var(--input-border); color: #e2e8f0; }
.pro-divider { width: 100%; height: 1px; background: var(--border-subtle); margin: 10px 0; }
.pro-trial-block { display: flex; flex-direction: column; align-items: center; gap: 4px; margin-top: 4px; }
.trial-controls { display: flex; align-items: center; gap: 10px; }
.trial-hint, #pro-upload-hint, #token-uses-left { display: none; text-align: center; color: var(--text-muted); font-size: 12px; margin-top: 4px; }
#pro-upload-hint { font-weight: 600; }
.trial-timer { color: var(--accent-pink); font-weight: bold; display: none; }

/* Collapse the purchase/ads area when in Pro mode */
#pro-section.collapsed .pro-cta-row,
#pro-section.collapsed .token-row,
#pro-section.collapsed .pro-divider,
#pro-section.collapsed .pro-trial-block,
#pro-section.collapsed #pro-upload-hint,
#pro-section.collapsed #token-uses-left {
  display: none !important;
}

/* Restore purchase dropdown (text-style, not a button) */
.restore-toggle {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 0;
  margin: 0;
  height: auto;
  width: auto;
  border-radius: 0;
  appearance: none;
  box-shadow: none;
  opacity: 1;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-weight: 600;
}
.restore-toggle::after { content: '▾'; color: var(--text-muted); transition: transform 0.2s ease; }
.restore-toggle[aria-expanded="false"]::after { content: '▸'; }
.restore-toggle:hover { color: #e2e8f0; text-decoration: underline; opacity: 1; }
.restore-panel { gap: 8px; margin-top: 6px; }
.restore-panel[hidden] { display: none !important; }

/* Match render button dimensions for token input and restore button */
#pro-token-input {
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  color: var(--text-color);
  border-radius: 8px;
  width: 90px; /* match #render-mode width */
  min-width: 90px;
  height: 34px;
  padding: 6px 8px; /* match #render-mode padding */
  text-align: center;
  box-sizing: border-box; /* ensure total height equals 34px including padding/border */
}
#save-token-btn {
  background: var(--input-border);
  color: #e2e8f0;
  width: 180px;
  height: 34px;
  padding: 0 14px;
}

/* Token row: allow buttons to wrap if needed while centered */
.token-row { flex-wrap: wrap; }

/* Keep Trial button visually normal even if disabled (e.g., expired) */
.trial-btn:disabled { opacity: 1; }

/* Compare Features table */
.compare-content table {
  border-collapse: collapse;
  width: 100%;
  background: transparent;
}
.compare-content th, .compare-content td {
  border: 1px solid var(--border-subtle);
  padding: 6px 8px;
  text-align: left;
}
.compare-content th {
  color: var(--text-color);
}

/* Media Queries */
@media (max-width: 640px) {
  :root { --label-col: 110px; }
}
@container (max-width: 520px) {
  label.row, .pro-heading, .pro-sub { grid-template-columns: var(--label-col) 1fr; }
  .pro-sub input[type="number"] { display: none; }
  /* Hide + / - on Automation lane when cramped, mirroring number box behavior */
  .automation-row .pro-text-btn { display: none; }
}
