/* =============================================================================
   SONGWRITING TOOLS - "Analog Studio" Design System
   A warm, vintage recording studio aesthetic
   ============================================================================= */

/* -----------------------------------------------------------------------------
   CSS Variables & Design Tokens
   ----------------------------------------------------------------------------- */
:root {
  /* Color Palette - Warm Studio Tones (High Contrast) */
  --bg-deep: #0d0b09;
  --bg-primary: #141210;
  --bg-surface: #1e1a16;
  --bg-elevated: #282320;
  --bg-hover: #332d28;

  --accent-primary: #e8b885;
  --accent-secondary: #d4a06a;
  --accent-muted: #b8864d;
  --accent-glow: rgba(232, 184, 133, 0.12);

  --text-primary: #faf8f5;
  --text-secondary: #d9d4cc;
  --text-muted: #a09890;
  --text-faint: #6a635c;

  --border-subtle: rgba(232, 184, 133, 0.15);
  --border-medium: rgba(232, 184, 133, 0.30);

  /* Typography */
  --font-display: 'Playfair Display', Georgia, serif;
  --font-body: 'Source Sans 3', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

  /* Spacing Scale */
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2.5rem;
  --space-2xl: 4rem;

  /* Sizing */
  --max-width: 72rem;
  --nav-height: 4rem;

  /* Effects */
  --shadow-soft: 0 4px 20px rgba(0, 0, 0, 0.3);
  --shadow-glow: 0 0 30px rgba(212, 165, 116, 0.08);
  --shadow-inset: inset 0 1px 0 rgba(255, 255, 255, 0.03);

  /* Transitions */
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --duration-fast: 150ms;
  --duration-normal: 300ms;
  --duration-slow: 500ms;

  /* Border Radius */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 20px;
}

/* -----------------------------------------------------------------------------
   Reset & Base Styles
   ----------------------------------------------------------------------------- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.7;
  color: var(--text-primary);
  background: var(--bg-deep);
  min-height: 100vh;
  position: relative;
}

/* Subtle noise texture overlay */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0.018;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
  z-index: 9999;
}

/* Warm gradient ambient light effect */
body::after {
  content: '';
  position: fixed;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(ellipse at 30% 20%, rgba(212, 165, 116, 0.04) 0%, transparent 50%),
              radial-gradient(ellipse at 70% 80%, rgba(180, 140, 100, 0.03) 0%, transparent 40%);
  pointer-events: none;
  z-index: -1;
}

/* -----------------------------------------------------------------------------
   Typography
   ----------------------------------------------------------------------------- */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.2;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

h1 {
  font-size: clamp(2.5rem, 5vw, 3.5rem);
  font-weight: 700;
}

h2 {
  font-size: clamp(1.75rem, 3vw, 2.25rem);
}

h3 {
  font-size: clamp(1.25rem, 2vw, 1.5rem);
}

h4 {
  font-size: 1.125rem;
  font-family: var(--font-body);
  font-weight: 600;
  color: var(--text-secondary);
}

p {
  margin-bottom: var(--space-md);
  color: var(--text-secondary);
}

a {
  color: var(--accent-primary);
  text-decoration: none;
  transition: color var(--duration-fast) var(--ease-out);
}

a:hover {
  color: var(--text-primary);
}

strong {
  font-weight: 600;
  color: var(--text-primary);
}

cite {
  display: block;
  font-style: normal;
  color: var(--text-secondary);
  padding: var(--space-lg);
  background: var(--bg-surface);
  border-left: 3px solid var(--accent-muted);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  margin-bottom: var(--space-lg);
}

/* -----------------------------------------------------------------------------
   Layout Structure
   ----------------------------------------------------------------------------- */
.site-wrapper {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: linear-gradient(to bottom, var(--bg-deep) 0%, var(--bg-deep) 70%, transparent 100%);
  padding-bottom: var(--space-lg);
}

main {
  flex: 1;
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: var(--space-xl) var(--space-lg);
}

footer {
  margin-top: auto;
  padding: var(--space-2xl) var(--space-lg);
  background: var(--bg-surface);
  border-top: 1px solid var(--border-subtle);
  text-align: center;
}

footer p {
  color: var(--text-muted);
  font-size: 0.875rem;
  margin-bottom: var(--space-md);
}

footer .tool-bar {
  display: flex;
  justify-content: center;
  gap: var(--space-lg);
  margin-bottom: var(--space-lg);
}

footer .tool-bar a {
  color: var(--text-muted);
  font-size: 0.875rem;
  transition: color var(--duration-fast) var(--ease-out);
}

footer .tool-bar a:hover {
  color: var(--accent-primary);
}

footer .tool-bar hr {
  display: none;
}

/* -----------------------------------------------------------------------------
   Navigation & Branding
   ----------------------------------------------------------------------------- */
.brand-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-xs);
  padding: var(--space-lg) var(--space-lg) var(--space-md);
  border-bottom: none;
}

.brand-wrap a {
  text-decoration: none;
  display: flex;
  align-items: baseline;
}

.brand-wrap h3 {
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
  letter-spacing: 0.02em;
  transition: color var(--duration-normal) var(--ease-out);
}

.brand-wrap a:hover h3 {
  color: var(--accent-primary);
}

.brand-wrap > span {
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 400;
  color: var(--accent-primary);
}

.allcaps {
  text-transform: lowercase;
  font-variant: small-caps;
  letter-spacing: 0.05em;
}

nav {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--space-lg);
}

nav .tool-bar {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-xs);
  margin: 0;
}

nav a {
  position: relative;
  display: inline-flex;
  align-items: center;
  padding: var(--space-sm) var(--space-md);
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-muted);
  border-radius: var(--radius-md);
  transition: all var(--duration-normal) var(--ease-out);
  white-space: nowrap;
}

nav a::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--accent-glow);
  border-radius: var(--radius-md);
  opacity: 0;
  transition: opacity var(--duration-normal) var(--ease-out);
}

nav a:hover {
  color: var(--text-primary);
}

nav a:hover::before {
  opacity: 1;
}

nav a.active {
  color: var(--accent-primary);
  font-weight: 600;
}

nav a.active::before {
  opacity: 1;
  background: var(--accent-glow);
}

/* -----------------------------------------------------------------------------
   Cards & Containers
   ----------------------------------------------------------------------------- */
section {
  margin-bottom: var(--space-xl);
}

.box,
#tools .tool .box {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
  box-shadow: var(--shadow-soft), var(--shadow-inset);
  transition: all var(--duration-normal) var(--ease-out);
  overflow: hidden;
}

.box:hover,
#tools .tool .box:hover {
  border-color: var(--border-medium);
  box-shadow: var(--shadow-soft), var(--shadow-glow);
}

#tools .tool h3 {
  font-family: var(--font-display);
  font-size: 1.75rem;
  color: var(--accent-primary);
  margin-bottom: var(--space-lg);
  padding-bottom: var(--space-md);
  border-bottom: 1px solid var(--border-subtle);
}

/* Welcome section */
section > p {
  max-width: 65ch;
  font-size: 1.1rem;
  line-height: 1.8;
}

/* -----------------------------------------------------------------------------
   Forms & Inputs
   ----------------------------------------------------------------------------- */
.custom {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
}

.cell {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.cell label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

input[type="text"],
input[type="number"],
select,
textarea {
  font-family: var(--font-body);
  font-size: 1rem;
  color: var(--text-primary);
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: var(--space-sm) var(--space-md);
  transition: all var(--duration-fast) var(--ease-out);
  box-shadow: none;
}

input[type="text"]:focus,
input[type="number"]:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

input[type="text"]::placeholder {
  color: var(--text-faint);
}

input[type="number"] {
  width: 5rem;
}

select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23c9c2b8' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--space-sm) center;
  padding-right: var(--space-xl);
}

select option {
  background: var(--bg-surface);
  color: var(--text-primary);
}

input[type="checkbox"] {
  width: 1.25rem;
  height: 1.25rem;
  accent-color: var(--accent-primary);
  cursor: pointer;
}

textarea {
  min-height: 150px;
  resize: vertical;
  line-height: 1.6;
}

/* -----------------------------------------------------------------------------
   Buttons
   ----------------------------------------------------------------------------- */
button,
.btn,
button.big {
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--bg-deep);
  background: linear-gradient(135deg, var(--accent-primary) 0%, var(--accent-secondary) 100%);
  border: none;
  border-radius: var(--radius-md);
  padding: var(--space-sm) var(--space-lg);
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-out);
  box-shadow: 0 2px 8px rgba(212, 165, 116, 0.25);
  white-space: nowrap;
}

button:hover,
.btn:hover,
button.big:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(212, 165, 116, 0.35);
}

button:active,
.btn:active,
button.big:active {
  transform: translateY(0);
}

button.ok,
a.ok {
  background: linear-gradient(135deg, #5a9a6e 0%, #4a8a5e 100%);
  color: white;
  padding: var(--space-xs) var(--space-sm);
  font-size: 0.85rem;
  border-radius: var(--radius-sm);
  box-shadow: none;
}

/* Secondary/ghost buttons */
button[type="button"],
.btn-secondary {
  background: transparent;
  color: var(--accent-primary);
  border: 1px solid var(--accent-muted);
  box-shadow: none;
}

button[type="button"]:hover,
.btn-secondary:hover {
  background: var(--accent-glow);
  border-color: var(--accent-primary);
  transform: none;
}

/* -----------------------------------------------------------------------------
   Chord Tables
   ----------------------------------------------------------------------------- */
table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

table.chords {
  margin: var(--space-md) 0;
  overflow: hidden;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-soft);
}

table.chords td {
  background: var(--bg-elevated);
  color: var(--text-primary);
  padding: var(--space-md) var(--space-lg);
  text-align: center;
  border: none;
  border-right: 1px solid var(--border-subtle);
  border-bottom: 1px solid var(--border-subtle);
  font-family: var(--font-mono);
  font-size: 1rem;
  transition: background var(--duration-fast) var(--ease-out);
}

table.chords td:last-child {
  border-right: none;
}

table.chords tr:last-child td {
  border-bottom: none;
}

table.chords tr:first-child td {
  background: var(--bg-surface);
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 600;
  font-family: var(--font-body);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

table.chords tr:last-child td {
  font-weight: 700;
  color: var(--accent-primary);
  font-size: 1.1rem;
}

table.chords tr:first-child td:first-child { border-top-left-radius: var(--radius-md); }
table.chords tr:first-child td:last-child { border-top-right-radius: var(--radius-md); }
table.chords tr:last-child td:first-child { border-bottom-left-radius: var(--radius-md); }
table.chords tr:last-child td:last-child { border-bottom-right-radius: var(--radius-md); }

tbody {
  border: none;
}

/* -----------------------------------------------------------------------------
   Rhyme Dictionary Results
   ----------------------------------------------------------------------------- */
.rhyme-group-lists {
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
}

.rhyme-group {
  padding-bottom: var(--space-lg);
  border-bottom: 1px solid var(--border-subtle);
}

.rhyme-group:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

ul.word-list {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  margin-top: var(--space-md);
}

ul.word-list li {
  display: inline-block;
  margin: 0;
}

/* Chips/Tags */
chip,
.chip {
  display: inline-flex;
  align-items: center;
  padding: var(--space-xs) var(--space-md);
  font-size: 0.9rem;
  font-weight: 500;
  background: var(--bg-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  transition: all var(--duration-fast) var(--ease-out);
  box-shadow: none;
}

chip:hover,
.chip:hover {
  background: var(--bg-hover);
  border-color: var(--border-medium);
}

chip.ok {
  background: linear-gradient(135deg, var(--accent-muted) 0%, var(--accent-secondary) 100%);
  color: var(--bg-deep);
  border: none;
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

chip.warn {
  background: var(--bg-surface);
  color: var(--text-secondary);
  cursor: default;
}

chip.warn:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

/* -----------------------------------------------------------------------------
   Word Ladder
   ----------------------------------------------------------------------------- */
.verb-noun-pair > p {
  margin-bottom: var(--space-md);
}

.verb-noun-pair > p:last-of-type {
  margin-bottom: var(--space-lg);
}

.work-area {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-xl);
  margin-top: var(--space-lg);
  overflow: hidden;
}

#verb-noun-pair {
  min-height: 200px;
  min-width: 0;
  overflow-x: auto;
}

table.word-list {
  width: 100%;
  min-width: 0;
}

table.word-list tr {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-sm) 0;
  border-bottom: 1px dashed var(--border-subtle);
}

table.word-list tr:last-child {
  border-bottom: none;
}

table.word-list chip {
  text-wrap: nowrap;
}

table.word-list .divider {
  display: flex;
  align-items: center;
  padding: 0 var(--space-md);
}

table.word-list .divider .line {
  width: 40px;
  height: 1px;
  background: var(--border-medium);
}

/* Scratchpad */
.scratchpad {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  min-width: 0;
}

.scratchpad h4 {
  color: var(--accent-primary);
  font-family: var(--font-display);
}

.scratchpad textarea {
  flex: 1;
  min-height: 300px;
  width: 100%;
  max-width: 100%;
  font-family: var(--font-mono);
  font-size: 0.95rem;
  line-height: 1.8;
  box-sizing: border-box;
}

.scratchpad-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-md);
}

.scratchpad-head h4 {
  margin: 0;
}

/* -----------------------------------------------------------------------------
   Loading States
   ----------------------------------------------------------------------------- */
.htmx-indicator {
  opacity: 0;
  height: 0;
  overflow: hidden;
  transition: all var(--duration-normal) var(--ease-out);
  color: var(--accent-primary);
  font-style: italic;
}

.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
  opacity: 1;
  height: auto;
  padding: var(--space-md) 0;
}

/* Animated loading dots */
.htmx-indicator::after {
  content: '';
  animation: loadingDots 1.5s infinite;
}

@keyframes loadingDots {
  0%, 20% { content: '.'; }
  40% { content: '..'; }
  60%, 100% { content: '...'; }
}

/* -----------------------------------------------------------------------------
   Horizontal Rules
   ----------------------------------------------------------------------------- */
hr {
  border: none;
  height: 1px;
  background: linear-gradient(to right, transparent, var(--border-medium), transparent);
  margin: var(--space-lg) 0;
}

/* -----------------------------------------------------------------------------
   Sense Writing
   ----------------------------------------------------------------------------- */
.sense-writing cite {
  font-size: 1rem;
  line-height: 1.8;
}

.sense-writing cite a {
  font-weight: 600;
}

/* -----------------------------------------------------------------------------
   Chord Progression
   ----------------------------------------------------------------------------- */
.chord-progression {
  overflow: visible;
}

.chord-progression h4 {
  color: var(--text-secondary);
  margin: var(--space-lg) 0 var(--space-md);
  font-family: var(--font-display);
  font-size: 1.25rem;
}

.chord-progression h4:first-of-type {
  margin-top: 0;
}

/* -----------------------------------------------------------------------------
   Page Entrance Animation
   ----------------------------------------------------------------------------- */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

main > section,
#tools {
  animation: fadeInUp var(--duration-slow) var(--ease-out) both;
}

#tools {
  animation-delay: 100ms;
}

/* Staggered animation for nav items */
nav a {
  animation: fadeInUp var(--duration-normal) var(--ease-out) both;
}

nav a:nth-child(1) { animation-delay: 50ms; }
nav a:nth-child(2) { animation-delay: 100ms; }
nav a:nth-child(3) { animation-delay: 150ms; }
nav a:nth-child(4) { animation-delay: 200ms; }
nav a:nth-child(5) { animation-delay: 250ms; }
nav a:nth-child(6) { animation-delay: 300ms; }

/* -----------------------------------------------------------------------------
   Responsive Design
   ----------------------------------------------------------------------------- */
@media (max-width: 768px) {
  :root {
    --space-xl: 1.5rem;
    --space-2xl: 2.5rem;
  }

  main {
    padding: var(--space-lg) var(--space-md);
  }

  .brand-wrap h3,
  .brand-wrap > span {
    font-size: 1.35rem;
  }

  nav .tool-bar {
    gap: var(--space-xs);
  }

  nav a {
    padding: var(--space-xs) var(--space-sm);
    font-size: 0.85rem;
  }

  .work-area {
    grid-template-columns: 1fr;
    overflow: visible;
  }

  .scratchpad {
    order: 2;
  }

  #verb-noun-pair {
    order: 1;
    overflow-x: auto;
  }

  .scratchpad textarea {
    min-height: 200px;
  }

  .custom {
    flex-direction: column;
    align-items: stretch;
  }

  .cell {
    width: 100%;
  }

  input[type="number"] {
    width: 100%;
  }

  button.big {
    width: 100%;
  }

  table.chords td {
    padding: var(--space-sm);
    font-size: 0.9rem;
  }

  footer .tool-bar {
    flex-direction: column;
    gap: var(--space-sm);
  }
}

@media (max-width: 480px) {
  .brand-wrap {
    flex-direction: column;
    gap: 0;
  }

  .brand-wrap > span {
    font-size: 1rem;
  }

  #tools .tool h3 {
    font-size: 1.35rem;
  }

  .box,
  #tools .tool .box {
    padding: var(--space-lg);
  }
}

/* -----------------------------------------------------------------------------
   Utility Classes
   ----------------------------------------------------------------------------- */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.text-muted {
  color: var(--text-muted);
}

.text-accent {
  color: var(--accent-primary);
}

/* Focus visible for accessibility */
:focus-visible {
  outline: 2px solid var(--accent-primary);
  outline-offset: 2px;
}

/* Selection styling */
::selection {
  background: var(--accent-primary);
  color: var(--bg-deep);
}

/* -----------------------------------------------------------------------------
   Additional Chip Variants
   ----------------------------------------------------------------------------- */
chip.verb {
  background: linear-gradient(135deg, #6b8cae 0%, #5a7a9a 100%);
  color: white;
  border: none;
  font-weight: 500;
}

chip.noun {
  background: linear-gradient(135deg, var(--accent-primary) 0%, var(--accent-secondary) 100%);
  color: var(--bg-deep);
  border: none;
  font-weight: 600;
}

chip.info {
  background: var(--bg-elevated);
  color: var(--text-secondary);
  border: 1px solid var(--border-medium);
}

chip.prompt-highlight {
  background: linear-gradient(135deg, var(--accent-primary) 0%, var(--accent-secondary) 100%);
  color: var(--bg-deep);
  border: none;
  font-weight: 700;
  font-size: 1.1rem;
  padding: var(--space-sm) var(--space-lg);
}

chip.sense {
  background: var(--bg-elevated);
  color: var(--accent-primary);
  border: 1px solid var(--accent-muted);
  font-size: 0.85rem;
}

.sense-chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  margin-top: var(--space-sm);
}

/* -----------------------------------------------------------------------------
   Timer
   ----------------------------------------------------------------------------- */
.timer {
  font-family: var(--font-mono);
  font-size: 1.5rem;
  font-weight: 500;
  color: var(--accent-primary);
  padding: var(--space-xs) var(--space-md);
  background: var(--bg-elevated);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  min-width: 5rem;
  text-align: center;
}

.timer.timer-done {
  color: #e57373;
  border-color: #e57373;
  animation: timerPulse 1s ease-in-out infinite;
}

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

/* -----------------------------------------------------------------------------
   Fretboard / Scale Explorer
   ----------------------------------------------------------------------------- */
.scales-explorer p {
  margin-bottom: var(--space-lg);
}

/* Scales layout with wheel and controls side by side */
.scales-layout {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: var(--space-xl);
  align-items: start;
  margin-bottom: var(--space-lg);
}

.wheel-section {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.wheel-container {
  width: 320px;
  height: 320px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-soft);
}

#wheel-canvas {
  display: block;
}

.wheel-hint {
  margin-top: var(--space-sm);
  font-size: 0.75rem;
  color: var(--text-muted);
  font-style: italic;
}

.controls-section {
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
}

@media (max-width: 768px) {
  .scales-layout {
    grid-template-columns: 1fr;
    justify-items: center;
  }

  .wheel-container {
    width: 280px;
    height: 280px;
  }

  .controls-section {
    width: 100%;
  }
}

.scale-controls {
  margin-bottom: var(--space-lg);
}

.scale-notes-display {
  margin-bottom: var(--space-md);
}

.scale-notes-display label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: var(--space-xs);
}

.scale-notes-chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
}

.scale-notes-chips chip.root-note {
  background: linear-gradient(135deg, var(--accent-primary) 0%, var(--accent-secondary) 100%);
  color: var(--bg-deep);
  border: none;
  font-weight: 700;
}

.scale-notes-chips chip.scale-note {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
}

/* Fretboard header with toggle */
.fretboard-header {
  display: flex;
  justify-content: flex-end;
  margin-bottom: var(--space-md);
}

/* Toggle switch */
.toggle-switch {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  cursor: pointer;
  user-select: none;
}

.toggle-switch input {
  display: none;
}

.toggle-slider {
  position: relative;
  width: 44px;
  height: 24px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  transition: all var(--duration-fast) var(--ease-out);
}

.toggle-slider::before {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  background: var(--text-muted);
  border-radius: 50%;
  transition: all var(--duration-fast) var(--ease-out);
}

.toggle-switch input:checked + .toggle-slider {
  background: var(--accent-muted);
  border-color: var(--accent-secondary);
}

.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(20px);
  background: var(--accent-primary);
}

.toggle-label {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.toggle-switch:hover .toggle-slider {
  border-color: var(--accent-muted);
}

.fretboard-container {
  overflow-x: auto;
  padding: var(--space-sm) 0;
}

.fretboard {
  min-width: fit-content;
}

.hfb-fretboard {
  display: flex;
  flex-direction: column;
  min-width: fit-content;
}

.hfb-main-row {
  display: flex;
}

.hfb-labels {
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  width: 28px;
  flex-shrink: 0;
}

.hfb-string-label {
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  padding-right: var(--space-xs);
  font-family: var(--font-mono);
}

.hfb-frets-container {
  display: flex;
  flex: 1;
  background: linear-gradient(180deg, var(--bg-elevated) 0%, var(--bg-surface) 50%, var(--bg-elevated) 100%);
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border-subtle);
}

.hfb-fret {
  display: flex;
  flex-direction: column;
  position: relative;
}

.hfb-nut {
  width: 24px;
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.02);
}

.hfb-fret:not(.hfb-nut) > .hfb-cell {
  border-right: 1px solid var(--border-subtle);
}

.hfb-nut > .hfb-cell {
  border-right: 2px solid var(--border-medium);
}

.hfb-fret:not(.hfb-nut) {
  flex: 1;
  min-width: 36px;
}

.hfb-cell {
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.hfb-string-line {
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  background: linear-gradient(90deg,
    rgba(255, 255, 255, 0.25) 0%,
    rgba(255, 255, 255, 0.35) 50%,
    rgba(255, 255, 255, 0.25) 100%);
  pointer-events: none;
}

/* Fret position markers (dots) */
.hfb-marker::before {
  content: '';
  position: absolute;
  width: 8px;
  height: 8px;
  background: var(--border-subtle);
  border-radius: 50%;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
}

.hfb-double-marker::before {
  top: 30%;
}

.hfb-double-marker::after {
  content: '';
  position: absolute;
  width: 8px;
  height: 8px;
  background: var(--border-subtle);
  border-radius: 50%;
  left: 50%;
  top: 70%;
  transform: translate(-50%, -50%);
}

/* Scale notes on fretboard */
.hfb-note {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.6rem;
  font-weight: 600;
  font-family: var(--font-mono);
  color: var(--bg-deep);
  background: var(--accent-muted);
  position: relative;
  z-index: 2;
  transition: transform var(--duration-fast) var(--ease-out);
}

.hfb-note:hover {
  transform: scale(1.15);
}

.hfb-note.hfb-root {
  width: 26px;
  height: 26px;
  font-size: 0.7rem;
  background: var(--accent-primary);
  color: var(--bg-deep);
  box-shadow: 0 0 0 2px var(--bg-surface), 0 0 0 4px var(--accent-primary);
}

/* Fret numbers */
.hfb-fret-number {
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-family: var(--font-mono);
  color: var(--text-faint);
  border-top: 1px solid var(--border-subtle);
}

/* Left-handed fretboard */
.hfb-fretboard.hfb-left-handed .hfb-main-row {
  flex-direction: row-reverse;
}

.hfb-fretboard.hfb-left-handed .hfb-frets-container {
  flex-direction: row-reverse;
}

.hfb-fretboard.hfb-left-handed .hfb-labels {
  order: 1;
}

.hfb-fretboard.hfb-left-handed .hfb-string-label {
  justify-content: flex-start;
  padding-left: var(--space-sm);
  padding-right: 0;
}

/* Responsive fretboard */
@media (min-width: 768px) {
  .hfb-labels {
    width: 32px;
  }

  .hfb-string-label {
    height: 38px;
    font-size: 0.85rem;
  }

  .hfb-cell {
    height: 38px;
  }

  .hfb-nut {
    width: 28px;
  }

  .hfb-fret:not(.hfb-nut) {
    min-width: 52px;
  }

  .hfb-note {
    width: 26px;
    height: 26px;
    font-size: 0.7rem;
  }

  .hfb-note.hfb-root {
    width: 30px;
    height: 30px;
    font-size: 0.75rem;
  }

  .hfb-fret-number {
    font-size: 0.75rem;
  }
}

/* -----------------------------------------------------------------------------
   Word List Table Header
   ----------------------------------------------------------------------------- */
table.word-list th {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding-bottom: var(--space-sm);
}

table.word-list thead tr {
  border-bottom: 1px solid var(--border-medium);
}
