/* ==========================================================================
   THAI SONGWRITER — DESIGN SYSTEM & VARIABLES
   ========================================================================== */
:root {
  /* Core Colors — warm paper palette */
  --bg-color: #e7e4dc;
  --bg-alt: #dedad2;
  --panel-bg: rgba(250, 250, 247, 0.85);
  --panel-bg-solid: #fafaf7;
  --panel-hover: rgba(255, 255, 255, 0.98);
  --border-color: rgba(20, 17, 13, 0.12);
  --border-hover: rgba(255, 79, 0, 0.45);

  /* Text Colors */
  --text-main: #14110d;
  --text-dim: #4f4a40;
  --text-mute: #8c8678;

  /* Accent Colors */
  --amber: #ff4f00;
  --amber-bright: #ff6b2b;
  --amber-soft: rgba(255, 79, 0, 0.08);
  --amber-glow: rgba(255, 79, 0, 0.18);
  --green: #1a7a4a;
  --red: #c0392b;

  /* Layout Options */
  --max-width: 1200px;
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --nav-height: 72px;
  --transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);

  /* Typography */
  --font-mono: 'IBM Plex Mono', 'IBM Plex Sans Thai', monospace;
  --font-sans: 'IBM Plex Sans Thai', 'IBM Plex Sans', sans-serif;

  /* Shadows */
  --shadow-sm: 0 2px 8px rgba(20, 17, 13, 0.08);
  --shadow-md: 0 8px 24px rgba(20, 17, 13, 0.12);
  --shadow-lg: 0 16px 48px rgba(20, 17, 13, 0.16);
  --amber-shadow: 0 4px 16px rgba(255, 79, 0, 0.2);
}

/* ==========================================================================
   DARK THEME OVERRIDE
   ========================================================================== */
[data-theme="dark"] {
  --bg-color: hsl(206, 30%, 6%);
  --bg-alt: hsl(206, 30%, 9%);
  --panel-bg: hsla(206, 25%, 12%, 0.65);
  --panel-bg-solid: hsl(206, 25%, 12%);
  --panel-hover: hsla(206, 25%, 18%, 0.85);
  --border-color: rgba(255, 255, 255, 0.07);
  --border-hover: rgba(255, 169, 64, 0.35);
  --text-main: #e8ecf0;
  --text-dim: #909eb0;
  --text-mute: #54657a;
  --amber: hsl(32, 100%, 60%);
  --amber-bright: hsl(32, 100%, 70%);
  --amber-soft: hsla(32, 100%, 60%, 0.15);
  --amber-glow: hsla(32, 100%, 60%, 0.3);
  --green: #2ecc71;
  --red: #e74c3c;
  --shadow-sm: 0 4px 12px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 12px 36px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 24px 64px rgba(0, 0, 0, 0.7);
  --amber-shadow: 0 8px 24px hsla(32, 100%, 60%, 0.15);
  color-scheme: dark;
}
[data-theme="dark"] nav.top-nav {
  background: hsla(206, 30%, 6%, 0.85);
}
[data-theme="dark"] body::before {
  background-image:
    linear-gradient(0deg, transparent 49.9%, rgba(144, 158, 176, 0.03) 50%, transparent 50.1%),
    linear-gradient(90deg, transparent 49.9%, rgba(144, 158, 176, 0.03) 50%, transparent 50.1%);
}
[data-theme="dark"] .blob-2 { background: #e74c3c; }

/* Theme toggle button */
.btn-theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  background: var(--panel-bg-solid);
  border: 1px solid var(--border-color);
  color: var(--text-dim);
  cursor: pointer;
  transition: var(--transition);
  font-size: 16px;
  padding: 0;
}
.btn-theme-toggle:hover {
  border-color: var(--amber);
  color: var(--amber);
  background: var(--amber-soft);
}

/* ==========================================================================
   RESET & REBOOT
   ========================================================================== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  font-size: 17px;
  color-scheme: light;
}

body {
  background-color: var(--bg-color);
  color: var(--text-main);
  font-family: var(--font-sans);
  font-weight: 300;
  line-height: 1.5;
  overflow-x: hidden;
}

.mono {
  font-family: var(--font-mono);
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg-color);
}
::-webkit-scrollbar-thumb {
  background: var(--panel-bg-solid);
  border: 1px solid var(--border-color);
  border-radius: 99px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--amber);
}

/* Subtle paper grain background */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(0deg, transparent 49.9%, rgba(20, 17, 13, 0.025) 50%, transparent 50.1%),
    linear-gradient(90deg, transparent 49.9%, rgba(20, 17, 13, 0.025) 50%, transparent 50.1%);
  background-size: 40px 40px;
  pointer-events: none;
  z-index: 0;
}

.ambient-blob {
  position: fixed;
  border-radius: 50%;
  filter: blur(160px);
  opacity: 0.12;
  z-index: 0;
  pointer-events: none;
}
.blob-1 {
  top: -10%;
  left: 20%;
  width: 50vw;
  height: 50vw;
  background: var(--amber);
  animation: blob-float-1 25s ease-in-out infinite;
}
.blob-2 {
  bottom: 10%;
  right: 10%;
  width: 40vw;
  height: 40vw;
  background: #c7b89a;
  animation: blob-float-2 30s ease-in-out infinite;
}

@keyframes blob-float-1 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(4vw, 3vh) scale(1.08); }
}
@keyframes blob-float-2 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(-3vw, -4vh) scale(1.12); }
}

/* ==========================================================================
   NAVIGATION
   ========================================================================== */
nav.top-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--nav-height);
  background: rgba(231, 228, 220, 0.9);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border-color);
  padding: 0 32px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
}
.brand-logo {
  width: 38px;
  height: 38px;
  background: linear-gradient(135deg, var(--amber) 0%, hsl(32, 100%, 45%) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  box-shadow: 0 2px 10px var(--amber-soft);
  color: var(--bg-color);
  font-weight: bold;
}
.brand-text {
  font-family: var(--font-mono);
}
.brand-text .top {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-main);
}
.brand-text .top span {
  color: var(--amber);
}
.brand-text .sub {
  font-size: 12px;
  color: var(--text-dim);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  margin-top: 1px;
}

.nav-links {
  display: flex;
  gap: 28px;
  font-family: var(--font-mono);
  font-size: 15px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.nav-links a {
  color: var(--text-dim);
  text-decoration: none;
  transition: var(--transition);
}
.nav-links a:hover, .nav-links a.active {
  color: var(--amber);
}

.nav-right-group {
  display: flex;
  align-items: center;
  gap: 12px;
}
.nav-cta {
  display: flex;
  align-items: center;
  gap: 16px;
}
.nav-cta .btn-login {
  font-family: var(--font-mono);
  font-size: 15px;
  color: var(--text-dim);
  text-decoration: none;
  transition: var(--transition);
}
.nav-cta .btn-login:hover {
  color: var(--text-main);
}

.user-profile-badge {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--panel-bg);
  border: 1px solid var(--border-color);
  padding: 6px 12px;
  border-radius: 99px;
  font-size: 15px;
}
.user-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--amber-soft);
  color: var(--amber);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
}
.btn-signout {
  cursor: pointer;
  color: var(--text-dim);
  background: none;
  border: none;
  font-size: 14px;
  font-family: var(--font-mono);
  transition: var(--transition);
}
.btn-signout:hover {
  color: var(--red);
}

/* ==========================================================================
   BUTTONS
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-family: var(--font-mono);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  text-decoration: none;
  border: 1px solid transparent;
  cursor: pointer;
  transition: var(--transition);
}
.btn-primary {
  background: var(--amber);
  color: var(--bg-color);
  font-weight: 600;
  box-shadow: var(--amber-shadow);
}
.btn-primary:hover:not(:disabled) {
  background: var(--amber-bright);
  box-shadow: 0 4px 16px var(--amber-glow);
  transform: translateY(-1px);
}
.btn-secondary {
  background: transparent;
  border-color: var(--border-color);
  color: var(--text-main);
}
.btn-secondary:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.2);
}
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.btn-danger {
  background: transparent;
  border-color: rgba(231, 76, 60, 0.2);
  color: var(--red);
}
.btn-danger:hover {
  background: rgba(231, 76, 60, 0.1);
  border-color: var(--red);
}
.btn-ghost {
  background: transparent;
  color: var(--text-dim);
}
.btn-ghost:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.03);
}

/* ==========================================================================
   SECTIONS & LANDING PAGE
   ========================================================================== */
.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 24px;
  position: relative;
  z-index: 1;
}

.hero {
  padding: 100px 0 60px;
  text-align: center;
}
.section-label {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--amber);
  letter-spacing: 0.25em;
  text-transform: uppercase;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.section-label::before, .section-label::after {
  content: '';
  width: 24px;
  height: 1px;
  background: var(--amber-soft);
}
.hero .section-label {
  opacity: 0;
  animation: fadeInUp 0.8s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
.hero h1 {
  font-size: clamp(32px, 5vw, 56px);
  font-weight: 700;
  line-height: 1.45;
  letter-spacing: -0.01em;
  margin-bottom: 24px;
  opacity: 0;
  animation: fadeInUp 0.8s cubic-bezier(0.16, 1, 0.3, 1) 0.15s forwards;
}
.hero h1 span {
  background: linear-gradient(90deg, var(--amber) 0%, #e03000 50%, var(--amber) 100%);
  background-size: 200% auto;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: shimmer-text 6s linear infinite;
  display: inline-block;
}
[data-theme="dark"] .hero h1 span {
  background: linear-gradient(90deg, var(--amber) 0%, #ffc670 50%, var(--amber) 100%);
  background-size: 200% auto;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.hero p {
  font-size: 18px;
  color: var(--text-dim);
  max-width: 680px;
  margin: 0 auto 40px;
  opacity: 0;
  animation: fadeInUp 0.8s cubic-bezier(0.16, 1, 0.3, 1) 0.3s forwards;
}
.hero-ctas {
  display: flex;
  justify-content: center;
  gap: 16px;
  flex-wrap: wrap;
  opacity: 0;
  animation: fadeInUp 0.8s cubic-bezier(0.16, 1, 0.3, 1) 0.45s forwards;
}

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

@keyframes shimmer-text {
  to {
    background-position: 200% center;
  }
}

/* Features Grid */
.features-section {
  padding: 80px 0;
  border-top: 1px solid var(--border-color);
}
.section-title {
  text-align: center;
  font-size: clamp(24px, 3.5vw, 36px);
  font-weight: 600;
  margin-bottom: 48px;
}
.features-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 24px;
}
.feature-card {
  background: var(--panel-bg);
  border: 1px solid var(--border-color);
  padding: 32px;
  border-radius: var(--radius-md);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition: var(--transition);
}
.feature-card:hover {
  border-color: var(--border-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}
.feature-icon {
  font-size: 28px;
  color: var(--amber);
  margin-bottom: 18px;
}
.feature-card h3 {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 12px;
}
.feature-card p {
  font-size: 15px;
  color: var(--text-dim);
}

/* ==========================================================================
   STUDIO INTERFACE
   ========================================================================== */
.studio-container {
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: calc(100vh - var(--nav-height));
  position: relative;
  z-index: 1;
}

/* Sidebar Library */
.sidebar {
  background: var(--bg-alt);
  border-right: 1px solid var(--border-color);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  overflow-y: auto;
}
.sidebar-title {
  font-family: var(--font-mono);
  font-size: 14px;
  text-transform: uppercase;
  color: var(--text-dim);
  letter-spacing: 0.1em;
}
.history-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.history-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
}
.history-item:hover, .history-item.active {
  background: var(--panel-bg);
  border-color: var(--border-hover);
}
.history-item .song-title {
  font-size: 15px;
  font-weight: 500;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.history-item .song-meta {
  font-size: 12px;
  font-family: var(--font-mono);
  color: var(--text-mute);
}

/* Studio Workbench */
.workbench {
  padding: 40px;
  overflow-y: auto;
}

.studio-header {
  margin-bottom: 32px;
}
.studio-header h1 {
  font-size: 28px;
  font-weight: 600;
  margin-bottom: 8px;
}
.studio-header p {
  color: var(--text-dim);
  font-size: 15px;
}

/* Wizard Wrap */
.wizard-card {
  background: var(--panel-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  overflow: hidden;
  box-shadow: var(--shadow-md);
}

/* Wizard Header / Steps */
.wizard-nav {
  display: flex;
  background: rgba(0, 0, 0, 0.2);
  border-bottom: 1px solid var(--border-color);
  padding: 0 24px;
  position: relative;
}
.wizard-progress-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 2px;
  background: var(--amber);
  transition: width 0.3s ease;
}
.wizard-tab {
  flex: 1;
  padding: 20px 12px;
  background: none;
  border: none;
  color: var(--text-mute);
  font-family: var(--font-mono);
  font-size: 13px;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.wizard-tab.active {
  color: var(--amber);
}
.wizard-tab.completed {
  color: var(--text-dim);
}
.wizard-tab-num {
  font-size: 11px;
  opacity: 0.6;
}
.wizard-tab-title {
  font-weight: 600;
  font-family: var(--font-sans);
}

/* Wizard Body & Panels */
.wizard-content {
  padding: 32px;
}
.wizard-panel {
  display: none;
  animation: fadeIn 0.3s ease forwards;
}
.wizard-panel.active {
  display: block;
}

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

.wizard-panel h3 {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text-main);
}
.wizard-panel > p {
  font-size: 15px;
  color: var(--text-dim);
  margin-bottom: 24px;
}

/* Fields & Grid */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
  margin-bottom: 20px;
}
.form-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 20px;
}
.form-field label {
  font-family: var(--font-mono);
  font-size: 13px;
  text-transform: uppercase;
  color: var(--text-dim);
  letter-spacing: 0.05em;
}

/* Form Inputs styling */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="search"],
select,
textarea {
  background: hsla(var(--hue), 25%, 8%, 0.6);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-weight: 300;
  font-size: 15px;
  width: 100%;
  transition: var(--transition);
}
input:focus, select:focus, textarea:focus {
  border-color: var(--amber);
  box-shadow: 0 0 0 2px var(--amber-soft);
  background: hsla(var(--hue), 25%, 10%, 0.8);
}
textarea {
  resize: vertical;
  min-height: 120px;
}

/* Options/Toggle Toggles */
.toggle-group {
  display: flex;
  gap: 10px;
}
.toggle-btn {
  flex: 1;
  padding: 12px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--text-dim);
  transition: var(--transition);
}
.toggle-btn:hover {
  background: rgba(255, 255, 255, 0.05);
}
.toggle-btn.active {
  background: var(--amber-soft);
  border-color: var(--amber);
  color: var(--amber);
}

/* Range input styling */
.range-wrap {
  background: rgba(0, 0, 0, 0.15);
  border: 1px solid var(--border-color);
  padding: 16px 20px;
  border-radius: var(--radius-sm);
  margin-top: 10px;
}
.range-header {
  display: flex;
  justify-content: space-between;
  font-size: 15px;
  margin-bottom: 10px;
}
.range-header span:first-child {
  color: var(--text-dim);
}
.range-header span:last-child {
  font-family: var(--font-mono);
  color: var(--amber);
  font-weight: 500;
}
input[type="range"] {
  width: 100%;
  accent-color: var(--amber);
  background: var(--bg-color);
  height: 6px;
  border-radius: 99px;
  cursor: pointer;
}

/* Emotions Selector Grid */
.emotions-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}
.emotion-card {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  padding: 16px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 16px;
}
.emotion-card:hover {
  background: rgba(255, 255, 255, 0.05);
}
.emotion-card.primary {
  background: var(--amber-soft);
  border-color: var(--amber);
}
.emotion-card.secondary {
  background: rgba(231, 76, 60, 0.15);
  border-color: var(--red);
}
.emotion-icon {
  font-size: 24px;
}
.emotion-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.emotion-name {
  font-size: 15px;
  font-weight: 500;
  color: var(--text-main);
}
.emotion-desc {
  font-size: 12px;
  color: var(--text-dim);
}

.emotion-summary {
  display: flex;
  gap: 24px;
  background: rgba(0, 0, 0, 0.15);
  border: 1px solid var(--border-color);
  padding: 16px 20px;
  border-radius: var(--radius-sm);
  margin-top: 24px;
}
.emotion-summary-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.emotion-summary-item span:first-child {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-mute);
  text-transform: uppercase;
}
.emotion-summary-item span:last-child {
  font-size: 15px;
  color: var(--text-main);
}

/* Rhyme Controls Dashboard */
.rhyme-dashboard {
  background: rgba(0, 0, 0, 0.1);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 24px;
  margin-top: 24px;
}
.rhyme-dashboard-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}
.rhyme-dashboard-head h4 {
  font-size: 16px;
  font-weight: 600;
}
.rhyme-dashboard-badge {
  font-family: var(--font-mono);
  font-size: 12px;
  background: rgba(255, 255, 255, 0.05);
  padding: 4px 8px;
  border-radius: 4px;
  color: var(--amber);
}
.rhyme-presets {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}
.rhyme-preset-btn {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  padding: 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-align: left;
  transition: var(--transition);
}
.rhyme-preset-btn:hover {
  background: rgba(255, 255, 255, 0.05);
}
.rhyme-preset-btn.active {
  background: var(--amber-soft);
  border-color: var(--amber);
}
.rhyme-preset-btn strong {
  display: block;
  font-size: 15px;
  color: var(--text-main);
}
.rhyme-preset-btn span {
  display: block;
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 2px;
}

.rhyme-sections-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}
.rhyme-card {
  background: rgba(0, 0, 0, 0.15);
  border: 1px solid var(--border-color);
  padding: 16px;
  border-radius: var(--radius-sm);
}
.rhyme-card h5 {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--text-main);
  border-left: 2px solid var(--amber);
  padding-left: 8px;
}
.rhyme-card select {
  font-size: 14px;
  padding: 8px 12px;
  margin-bottom: 12px;
}
.rhyme-card label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--text-dim);
  cursor: pointer;
  margin-top: 4px;
}
.rhyme-card input[type="checkbox"] {
  accent-color: var(--amber);
}

.rhyme-detail-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 16px;
}

.rhyme-note {
  font-size: 13px;
  color: var(--text-mute);
  margin-top: 12px;
  line-height: 1.4;
}
.rhyme-summary {
  font-size: 14px;
  color: var(--amber-bright);
  background: var(--amber-soft);
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  margin-top: 16px;
}

/* Song Structure Builder */
.structure-container {
  background: rgba(0, 0, 0, 0.1);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 24px;
  margin-top: 24px;
}
.structure-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 20px;
}
.structure-head h4 {
  font-size: 16px;
  font-weight: 600;
}
.structure-presets {
  display: flex;
  gap: 8px;
}
.structure-presets button {
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 6px 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  cursor: pointer;
  transition: var(--transition);
}
.structure-presets button:hover {
  color: var(--text-main);
  border-color: rgba(255, 255, 255, 0.2);
}

.structure-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 16px;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  min-height: 72px;
  align-items: center;
}
.structure-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--panel-bg-solid);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  font-size: 14px;
  font-weight: 500;
}
.sect-rhyme-select {
  margin-left: auto;
  background: rgba(255, 255, 255, 0.05);
  border: none;
  border-radius: 3px;
  color: var(--text-dim);
  font-size: 13px;
  font-family: var(--font-sans);
  padding: 2px 6px;
  cursor: pointer;
  outline: none;
  transition: var(--transition);
}
.sect-rhyme-select:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-main);
}
.sect-rhyme-select option {
  background: var(--panel-bg-solid);
  color: var(--text-main);
}
.structure-item button {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-mute);
  font-size: 15px;
  display: flex;
  align-items: center;
  transition: var(--transition);
}
.structure-item button:hover {
  color: var(--red);
}
.structure-item .reorder-btn {
  color: var(--text-mute);
  cursor: grab;
}
.structure-item .reorder-btn:hover {
  color: var(--text-dim);
}

.structure-add-row {
  display: flex;
  gap: 12px;
  margin-top: 16px;
  max-width: 320px;
}
.structure-add-row select {
  font-size: 14px;
  padding: 8px 12px;
}

/* Wizard Summary (Review Step) */
.wizard-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}
.summary-card {
  background: rgba(0, 0, 0, 0.15);
  border: 1px solid var(--border-color);
  padding: 16px;
  border-radius: var(--radius-sm);
}
.summary-card span:first-child {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-mute);
  text-transform: uppercase;
  display: block;
  margin-bottom: 4px;
}
.summary-card span:last-child {
  font-size: 15px;
  color: var(--text-main);
}

/* Loading/Status states */
.status-msg {
  padding: 16px 20px;
  border-radius: var(--radius-sm);
  margin-top: 24px;
  font-size: 15px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.status-msg.error {
  background: rgba(231, 76, 60, 0.15);
  border: 1px solid var(--red);
  color: hsl(0, 100%, 80%);
}
.status-msg.success {
  background: rgba(46, 204, 113, 0.15);
  border: 1px solid var(--green);
  color: hsl(120, 100%, 80%);
}
.status-msg.loading {
  background: rgba(255, 169, 64, 0.1);
  border: 1px solid var(--amber);
  color: var(--amber-bright);
}

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid transparent;
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Generated Output Panel */
.output-card {
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border-hover);
  border-radius: var(--radius-lg);
  padding: 32px;
  margin-top: 32px;
}
.output-kicker {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--amber);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 8px;
}
.output-title {
  font-size: 24px;
  font-weight: 600;
  margin-bottom: 4px;
}
.output-meta {
  font-size: 14px;
  color: var(--text-dim);
  margin-bottom: 24px;
}

.output-box {
  background: var(--bg-alt);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 20px;
  margin-bottom: 20px;
}
.output-box h4 {
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--amber-bright);
  margin-bottom: 12px;
}
.output-lyrics {
  white-space: pre-wrap;
  font-size: 16px;
  line-height: 1.8;
  color: var(--text-main);
  letter-spacing: 0.02em;
}
.output-content {
  font-size: 15px;
  color: var(--text-dim);
  line-height: 1.6;
}

/* Navigation Buttons at the footer of wizard */
.wizard-footer {
  display: flex;
  justify-content: space-between;
  border-top: 1px solid var(--border-color);
  padding: 24px 32px;
  background: rgba(0, 0, 0, 0.1);
}

/* ==========================================================================
   MODAL OVERLAYS (DIALOGS)
   ========================================================================== */
dialog {
  margin: auto;
  border: 1px solid var(--border-color);
  background: var(--panel-bg-solid);
  color: var(--text-main);
  padding: 32px;
  border-radius: var(--radius-lg);
  max-width: 440px;
  width: 90%;
  box-shadow: var(--shadow-lg);
  overflow: visible;
}
dialog::backdrop {
  background-color: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.dialog-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}
.dialog-head h2 {
  font-size: 20px;
  font-weight: 600;
}
.dialog-close {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.05);
  color: var(--text-dim);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
}
.dialog-close:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.15);
  color: var(--text-main);
  transform: rotate(90deg);
}
.dialog-close svg {
  width: 14px;
  height: 14px;
  display: block;
}

.dialog-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ==========================================================================
   SETTINGS PANEL (DEVELOPER OPTIONS)
   ========================================================================== */
.settings-panel {
  background: var(--bg-alt);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 24px;
  margin-top: 32px;
}
.settings-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}
.settings-head i {
  color: var(--amber);
}
.settings-head h3 {
  font-size: 16px;
  font-weight: 600;
}

/* ==========================================================================
   RESPONSIVENESS / MEDIA QUERIES
   ========================================================================== */
@media (max-width: 900px) {
  .studio-container {
    grid-template-columns: 1fr;
  }
  .sidebar {
    border-right: none;
    border-bottom: 1px solid var(--border-color);
    max-height: 240px;
  }
  .workbench {
    padding: 24px 16px;
  }
  .wizard-nav {
    overflow-x: auto;
  }
  .wizard-tab {
    min-width: 120px;
  }
  .wizard-content {
    padding: 24px 16px;
  }
}
