/* ==========================================================================
   Notion Design System - Chord Tone Ear Trainer
   Based strictly on Notion.md Design Guidelines
   ========================================================================== */

:root {
  /* Colors */
  --colors-primary: #0075de;
  --colors-primary-active: #005bab;
  --colors-secondary: #213183;
  --colors-on-primary: #ffffff;
  --colors-canvas: #ffffff;
  --colors-canvas-soft: #f6f5f4;
  --colors-surface: #ffffff;
  --colors-ink: #000000;
  --colors-ink-secondary: #31302e;
  --colors-ink-muted: #615d59;
  --colors-ink-faint: #a39e98;
  --colors-hairline: #e6e6e6;

  /* Sticker Accent Palette */
  --accent-sky: #62aef0;
  --accent-purple: #d6b6f6;
  --accent-purple-deep: #391c57;
  --accent-pink: #ff64c8;
  --accent-orange: #dd5b00;
  --accent-orange-deep: #793400;
  --accent-teal: #2a9d99;
  --accent-green: #1aae39;
  --accent-brown: #523410;

  /* Border Radii */
  --rounded-xs: 4px;
  --rounded-sm: 5px;
  --rounded-md: 8px;
  --rounded-lg: 12px;
  --rounded-xl: 16px;
  --rounded-full: 9999px;

  /* Spacing */
  --spacing-xxs: 4px;
  --spacing-xs: 8px;
  --spacing-sm: 12px;
  --spacing-md: 16px;
  --spacing-lg: 24px;
  --spacing-xl: 28px;
  --spacing-xxl: 32px;

  /* Elevation Shadows */
  --shadow-level-1: 0 1px 2px rgba(0, 0, 0, 0.04), 0 3px 8px rgba(0, 0, 0, 0.04);
  --shadow-level-2: 0 0 0 1px rgba(15, 15, 15, 0.05), 0 6px 16px rgba(15, 15, 15, 0.08), 0 16px 36px rgba(15, 15, 15, 0.12);
  --shadow-key: 0 2px 4px rgba(0, 0, 0, 0.08);

  /* Typography Font Stack */
  --font-family: "NotionInter", Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

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

body {
  font-family: var(--font-family);
  background-color: var(--colors-canvas-soft);
  color: var(--colors-ink);
  line-height: 1.5;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a {
  color: var(--colors-primary);
  text-decoration: none;
  transition: opacity 0.15s ease;
}

a:hover {
  text-decoration: underline;
  color: var(--colors-primary-active);
}

/* ==========================================================================
   Header (100% width, white background, app icon, title, version, producer)
   ========================================================================== */
.app-header {
  width: 100%;
  background-color: var(--colors-canvas);
  border-bottom: 1px solid var(--colors-hairline);
  position: sticky;
  top: 0;
  z-index: 100;
  padding: 12px 20px;
}

.header-container {
  max-width: 1120px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.app-icon-wrapper {
  width: 38px;
  height: 38px;
  border-radius: var(--rounded-md);
  background: linear-gradient(135deg, #f6f5f4 0%, #ebe9e7 100%);
  border: 1px solid var(--colors-hairline);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--colors-primary);
  flex-shrink: 0;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.app-icon-wrapper svg {
  width: 22px;
  height: 22px;
}

.header-title-group {
  display: flex;
  flex-direction: column;
}

.title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.app-title {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.25px;
  color: var(--colors-ink);
  line-height: 1.25;
}

.version-badge {
  font-size: 11px;
  font-weight: 600;
  color: var(--colors-ink-secondary);
  background-color: var(--colors-canvas-soft);
  border: 1px solid var(--colors-hairline);
  padding: 2px 8px;
  border-radius: var(--rounded-full);
  letter-spacing: 0.2px;
  display: inline-flex;
  align-items: center;
}

.header-producer {
  font-size: 12px;
  color: var(--colors-ink-muted);
  line-height: 1.3;
}

.header-producer a {
  color: var(--colors-primary);
  font-weight: 500;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ==========================================================================
   Notion Buttons
   ========================================================================== */
.button-primary {
  background-color: var(--colors-primary);
  color: var(--colors-on-primary);
  font-family: var(--font-family);
  font-size: 15px;
  font-weight: 600;
  border: none;
  border-radius: var(--rounded-full);
  padding: 10px 24px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background-color 0.15s ease, transform 0.1s ease;
  user-select: none;
  text-decoration: none;
}

.button-primary:hover {
  background-color: #0066c4;
}

.button-primary:active {
  background-color: var(--colors-primary-active);
  transform: scale(0.98);
}

.button-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.button-utility {
  background-color: var(--colors-surface);
  color: var(--colors-ink-secondary);
  font-family: var(--font-family);
  font-size: 14px;
  font-weight: 500;
  border: 1px solid var(--colors-hairline);
  border-radius: var(--rounded-md);
  padding: 6px 14px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
  user-select: none;
}

.button-utility:hover {
  background-color: var(--colors-canvas-soft);
  color: var(--colors-ink);
}

.button-utility:active {
  background-color: #edece9;
  transform: scale(0.98);
}

.button-utility:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.button-utility.active {
  background-color: var(--colors-canvas-soft);
  color: var(--colors-primary);
  border-color: #b8daf7;
  font-weight: 600;
}

.button-secondary {
  background-color: var(--colors-surface);
  color: var(--colors-ink);
  font-family: var(--font-family);
  font-size: 15px;
  font-weight: 500;
  border: 1px solid var(--colors-hairline);
  border-radius: var(--rounded-full);
  padding: 10px 22px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  transition: background-color 0.15s ease, transform 0.1s ease;
}

.button-secondary:hover {
  background-color: var(--colors-canvas-soft);
}

.button-secondary:active {
  transform: scale(0.98);
}

.btn-icon-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* ==========================================================================
   Main Content Layout
   ========================================================================== */
.main-wrapper {
  flex: 1;
  max-width: 980px;
  width: 100%;
  margin: 0 auto;
  padding: 24px 16px 48px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Cards */
.feature-card {
  background-color: var(--colors-surface);
  border: 1px solid var(--colors-hairline);
  border-radius: var(--rounded-lg);
  padding: 24px;
  box-shadow: var(--shadow-level-1);
}

/* Welcome / Intro Card */
.intro-banner {
  display: flex;
  flex-direction: column;
  gap: 12px;
  border-left: 4px solid var(--colors-primary);
  background: #ffffff;
}

.intro-title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.25px;
  color: var(--colors-ink);
}

.intro-desc {
  font-size: 14px;
  color: var(--colors-ink-muted);
  line-height: 1.6;
}

/* Controls Bar (Difficulty, Status, Timer) */
.controls-card {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.difficulty-section {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.section-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--colors-ink-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.segmented-control {
  display: inline-flex;
  background-color: var(--colors-canvas-soft);
  padding: 3px;
  border-radius: var(--rounded-md);
  border: 1px solid var(--colors-hairline);
  gap: 2px;
  flex-wrap: wrap;
}

.seg-btn {
  border: none;
  background: transparent;
  padding: 6px 14px;
  font-family: var(--font-family);
  font-size: 13px;
  font-weight: 500;
  color: var(--colors-ink-secondary);
  border-radius: var(--rounded-sm);
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  gap: 6px;
}

.seg-btn:hover {
  color: var(--colors-ink);
}

.seg-btn.active {
  background-color: var(--colors-surface);
  color: var(--colors-ink);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.badge-tag {
  font-size: 11px;
  padding: 1px 6px;
  border-radius: var(--rounded-full);
  font-weight: 600;
}

.badge-beginner {
  background-color: rgba(26, 174, 57, 0.12);
  color: var(--accent-green);
}

.badge-intermediate {
  background-color: rgba(0, 117, 222, 0.12);
  color: var(--colors-primary);
}

.badge-advanced {
  background-color: rgba(121, 52, 0, 0.12);
  color: var(--accent-orange);
}

/* Status Row */
.status-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--colors-hairline);
}

.stat-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.stat-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--colors-ink-faint);
}

.stat-val {
  font-size: 18px;
  font-weight: 700;
  color: var(--colors-ink);
  letter-spacing: -0.25px;
}

.stat-val.timer {
  font-variant-numeric: tabular-nums;
  color: var(--colors-primary);
}

/* Question Area Card */
.question-card {
  display: flex;
  flex-direction: column;
  gap: 20px;
  text-align: center;
}

.question-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.question-instruction {
  font-size: 16px;
  font-weight: 600;
  color: var(--colors-ink);
}

.question-hint {
  font-size: 13px;
  color: var(--colors-ink-muted);
}

.sound-play-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}

.btn-play-chord {
  padding: 12px 28px;
  font-size: 16px;
  box-shadow: 0 2px 8px rgba(0, 117, 222, 0.25);
}

.btn-play-chord svg {
  width: 20px;
  height: 20px;
}

/* Start Game Box */
.start-game-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 10px 0;
  gap: 8px;
}

.btn-game-start {
  box-shadow: 0 2px 10px rgba(0, 117, 222, 0.28);
}

/* ==========================================================================
   Piano Keyboard Component
   ========================================================================== */
.keyboard-container {
  display: flex;
  justify-content: center;
  padding: 12px 0 4px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.piano-keyboard {
  position: relative;
  display: flex;
  user-select: none;
  background: #333333;
  padding: 8px 8px 14px 8px;
  border-radius: 8px 8px 12px 12px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12), inset 0 2px 2px rgba(255, 255, 255, 0.15);
}

/* White Keys */
.key-white {
  position: relative;
  width: 48px;
  height: 170px;
  background: linear-gradient(180deg, #ffffff 0%, #fafafa 85%, #efefef 100%);
  border: 1px solid #c9c9c9;
  border-top: none;
  border-radius: 0 0 5px 5px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  padding-bottom: 10px;
  box-shadow: inset 0 1px 0 #ffffff, 0 2px 4px rgba(0, 0, 0, 0.08);
  transition: background-color 0.1s ease, box-shadow 0.1s ease, transform 0.08s ease;
  z-index: 1;
}

.key-white:hover {
  background: linear-gradient(180deg, #fafafa 0%, #f0f0f0 85%, #e8e8e8 100%);
}

.key-white:active, .key-white.pressed {
  background: #e6e6e6;
  box-shadow: inset 0 3px 5px rgba(0, 0, 0, 0.15);
  transform: translateY(2px);
}

.key-white.selected {
  background: #eaf4ff !important;
  border-color: var(--colors-primary) !important;
  box-shadow: inset 0 0 0 2px var(--colors-primary), 0 2px 6px rgba(0, 117, 222, 0.2) !important;
}

.key-white.selected::after {
  content: '';
  position: absolute;
  bottom: 34px;
  width: 8px;
  height: 8px;
  border-radius: var(--rounded-full);
  background-color: var(--colors-primary);
}

/* Black Keys */
.key-black {
  position: absolute;
  width: 28px;
  height: 105px;
  background: linear-gradient(180deg, #2b2b2b 0%, #151515 80%, #000000 100%);
  border-radius: 0 0 4px 4px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  padding-bottom: 8px;
  z-index: 10;
  box-shadow: 1px 3px 5px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.2);
  transition: background 0.1s ease, transform 0.08s ease;
}

.key-black:hover {
  background: linear-gradient(180deg, #3a3a3a 0%, #222222 80%, #0f0f0f 100%);
}

.key-black:active, .key-black.pressed {
  background: #111111;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.5);
  transform: translateY(2px);
}

.key-black.selected {
  background: linear-gradient(180deg, #005bab 0%, #004582 100%) !important;
  border: 1px solid #62aef0;
  box-shadow: 0 0 8px rgba(0, 117, 222, 0.5) !important;
}

.key-black.selected::after {
  content: '';
  position: absolute;
  bottom: 26px;
  width: 7px;
  height: 7px;
  border-radius: var(--rounded-full);
  background-color: #62aef0;
}

/* Key Text Labels */
.key-label {
  font-size: 12px;
  font-weight: 700;
  pointer-events: none;
}

.key-white .key-label {
  color: var(--colors-ink-secondary);
}

.key-black .key-label {
  color: #f0f0f0;
  font-size: 10px;
}

.key-sub-label {
  font-size: 10px;
  color: var(--colors-ink-faint);
  font-weight: 500;
  margin-top: 1px;
}

.key-black .key-sub-label {
  color: #aaaaaa;
  font-size: 9px;
}

/* Validation Highlights on Keys */
.key-white.correct-hit, .key-black.correct-hit {
  background: #d4f7dc !important;
  border-color: var(--accent-green) !important;
  box-shadow: inset 0 0 0 2px var(--accent-green) !important;
}

.key-black.correct-hit {
  background: #0f6e24 !important;
  border-color: #61d97c !important;
}

.key-white.wrong-hit, .key-black.wrong-hit {
  background: #fde8e4 !important;
  border-color: var(--accent-orange) !important;
  box-shadow: inset 0 0 0 2px var(--accent-orange) !important;
}

.key-black.wrong-hit {
  background: #872605 !important;
  border-color: #fca083 !important;
}

.key-white.missed-hit, .key-black.missed-hit {
  border: 2px dashed var(--accent-green) !important;
}

/* Keyboard Action Buttons */
.question-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  flex-wrap: wrap;
}

/* Result Feedback Card */
.feedback-box {
  display: none;
  background-color: var(--colors-surface);
  border: 1px solid var(--colors-hairline);
  border-radius: var(--rounded-lg);
  padding: 20px;
  animation: fadeIn 0.2s ease-out;
}

.feedback-box.active {
  display: block;
}

.feedback-box.correct {
  border-left: 5px solid var(--accent-green);
  background: linear-gradient(90deg, rgba(26, 174, 57, 0.04) 0%, #ffffff 100%);
}

.feedback-box.incorrect {
  border-left: 5px solid var(--accent-orange);
  background: linear-gradient(90deg, rgba(221, 91, 0, 0.04) 0%, #ffffff 100%);
}

.feedback-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  flex-wrap: wrap;
  gap: 8px;
}

.feedback-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 18px;
  font-weight: 700;
}

.feedback-title.correct {
  color: var(--accent-green);
}

.feedback-title.incorrect {
  color: var(--accent-orange);
}

.feedback-time {
  font-size: 13px;
  color: var(--colors-ink-muted);
  font-weight: 500;
}

.feedback-details {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  padding: 12px;
  background-color: var(--colors-canvas-soft);
  border-radius: var(--rounded-md);
  margin-bottom: 16px;
}

.feedback-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.feedback-item-label {
  font-size: 12px;
  color: var(--colors-ink-faint);
  font-weight: 500;
}

.feedback-item-value {
  font-size: 15px;
  font-weight: 600;
  color: var(--colors-ink);
}

.feedback-nav {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

/* ==========================================================================
   History & Results Card
   ========================================================================== */
.history-card {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.history-title {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.2px;
  color: var(--colors-ink);
}

.copy-status-tip {
  font-size: 12px;
  color: var(--colors-ink-faint);
}

/* History Table */
.history-table-container {
  max-height: 380px;
  overflow-y: auto;
  border: 1px solid var(--colors-hairline);
  border-radius: var(--rounded-md);
  background-color: var(--colors-surface);
}

.history-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 13px;
}

.history-table th {
  background-color: var(--colors-canvas-soft);
  color: var(--colors-ink-muted);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--colors-hairline);
  position: sticky;
  top: 0;
  z-index: 5;
}

.history-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--colors-hairline);
  color: var(--colors-ink-secondary);
}

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

.history-table tr:hover td {
  background-color: #faf9f8;
}

.history-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--rounded-full);
}

.history-badge.correct {
  background-color: rgba(26, 174, 57, 0.1);
  color: var(--accent-green);
}

.history-badge.incorrect {
  background-color: rgba(221, 91, 0, 0.1);
  color: var(--accent-orange);
}

.history-empty {
  padding: 32px 16px;
  text-align: center;
  color: var(--colors-ink-faint);
  font-size: 14px;
}

/* AI Export Modal Specifics */
#modal-ai-export {
  max-width: 480px;
}

#modal-ai-export .modal-header {
  padding: 10px 18px;
}

#modal-ai-export .modal-title {
  font-size: 15px;
  font-weight: 700;
}

#modal-ai-export .modal-body {
  padding: 10px 16px 6px 16px;
  gap: 8px;
  max-height: calc(90vh - 75px);
  overflow-y: auto;
}

#modal-ai-export .modal-footer {
  padding: 8px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

#modal-ai-export .button-primary {
  padding: 6px 20px;
  font-size: 13px;
}

#modal-ai-export .button-utility {
  padding: 6px 12px;
  font-size: 12px;
  color: var(--colors-ink-secondary);
}

.ai-modal-compact-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 4px;
}

.ai-modal-stats-pill {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  color: var(--colors-ink);
  background-color: rgba(0, 117, 222, 0.08);
  padding: 3px 12px;
  border-radius: var(--rounded-full);
  border: 1px solid rgba(0, 117, 222, 0.2);
}

.ai-modal-lead-text {
  font-size: 11px;
  color: var(--colors-ink-muted);
  margin: 0;
  line-height: 1.4;
}

/* Horizontal 1-Row AI Links */
.ai-modal-links-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  width: 100%;
}

.ai-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 6px;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  border-radius: var(--rounded-md);
  border: 1px solid var(--colors-hairline);
  background-color: var(--colors-surface);
  color: var(--colors-ink);
  transition: all 0.15s ease;
  box-shadow: 0 1px 2px rgba(0,0,0,0.03);
  white-space: nowrap;
}

.ai-chip:hover {
  transform: translateY(-1px);
  box-shadow: 0 3px 6px rgba(0,0,0,0.06);
}

.ai-chip .ai-logo {
  flex-shrink: 0;
}

.ai-chip .external-icon {
  opacity: 0.45;
  flex-shrink: 0;
}

.ai-chip-gemini:hover {
  border-color: #a8c7fa;
  background-color: #f6f9fe;
  color: #1a73e8;
}

.ai-chip-chatgpt:hover {
  border-color: #a3e6d8;
  background-color: #f2fbf9;
  color: #10a37f;
}

.ai-chip-claude:hover {
  border-color: #fed7aa;
  background-color: #fffaf5;
  color: #c2410c;
}

.ai-modal-banner-section {
  border-top: 1px solid var(--colors-hairline);
  padding-top: 6px;
  margin-top: 2px;
  text-align: center;
}

.ai-modal-banner-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--colors-ink-muted);
  margin-bottom: 2px;
}

.ai-modal-banner-section .amazon-banner-container {
  margin: 0 auto;
  min-height: 380px;
}

@media (max-width: 380px) {
  .ai-chip {
    font-size: 11px;
    gap: 3px;
    padding: 6px 4px;
  }
  .ai-chip .ai-logo {
    width: 14px;
    height: 14px;
  }
}

/* ==========================================================================
   Modals (<dialog> element with Notion aesthetics)
   ========================================================================== */
dialog {
  border: 1px solid var(--colors-hairline);
  border-radius: var(--rounded-xl);
  padding: 0;
  max-width: 560px;
  width: calc(100% - 32px);
  margin: auto;
  box-shadow: var(--shadow-level-2);
  background-color: var(--colors-surface);
  color: var(--colors-ink);
}

dialog::backdrop {
  background: rgba(15, 15, 15, 0.45);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.modal-content {
  display: flex;
  flex-direction: column;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid var(--colors-hairline);
}

.modal-title {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.2px;
  color: var(--colors-ink);
}

.btn-modal-close {
  background: transparent;
  border: none;
  font-size: 20px;
  color: var(--colors-ink-muted);
  cursor: pointer;
  width: 32px;
  height: 32px;
  border-radius: var(--rounded-md);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.15s ease;
}

.btn-modal-close:hover {
  background-color: var(--colors-canvas-soft);
  color: var(--colors-ink);
}

.modal-body {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  max-height: 70vh;
  overflow-y: auto;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--colors-hairline);
  display: flex;
  justify-content: flex-end;
  background-color: var(--colors-canvas-soft);
  border-radius: 0 0 var(--rounded-xl) var(--rounded-xl);
}

#modal-settings .modal-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

#btn-share-settings {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  padding: 8px 14px;
  color: var(--colors-primary);
  border-color: #cce4f7;
  transition: all 0.15s ease;
}

#btn-share-settings:hover {
  background-color: var(--colors-canvas-soft);
  border-color: #a3cff5;
}

#btn-share-settings.copied {
  color: #137333;
  background-color: #e6f4ea;
  border-color: #ceead6;
}

@media (max-width: 480px) {
  #modal-settings .modal-footer {
    flex-direction: column-reverse;
  }
  #modal-settings .modal-footer button {
    width: 100%;
  }
}

/* Modal Form Controls */
.setting-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.setting-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--colors-ink);
}

.setting-desc {
  font-size: 12px;
  color: var(--colors-ink-muted);
}

.setting-select {
  padding: 8px 12px;
  border: 1px solid var(--colors-hairline);
  border-radius: var(--rounded-sm);
  background-color: var(--colors-surface);
  font-family: var(--font-family);
  font-size: 14px;
  color: var(--colors-ink);
  outline: none;
  transition: border-color 0.15s ease;
}

.setting-select:focus {
  border-color: var(--colors-primary);
  box-shadow: 0 0 0 2px rgba(0, 117, 222, 0.15);
}

.setting-range {
  accent-color: var(--colors-primary);
}

/* Help Steps */
.help-step-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.help-step {
  display: flex;
  gap: 12px;
}

.help-step-num {
  width: 24px;
  height: 24px;
  border-radius: var(--rounded-full);
  background-color: var(--colors-primary);
  color: #ffffff;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
}

.help-step-content h4 {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 2px;
}

.help-step-content p {
  font-size: 13px;
  color: var(--colors-ink-muted);
  line-height: 1.5;
}

/* ==========================================================================
   Toast Notification
   ========================================================================== */
.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background-color: var(--colors-ink-secondary);
  color: #ffffff;
  padding: 10px 20px;
  border-radius: var(--rounded-md);
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
  display: flex;
  align-items: center;
  gap: 8px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  z-index: 1000;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ==========================================================================
   Amazon Milestone Dialog & Banner Styles
   ========================================================================== */
#modal-amazon-milestone {
  max-width: 440px;
  width: calc(100% - 24px);
}

.milestone-message-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.milestone-text {
  font-size: 16px;
  font-weight: 700;
  color: var(--colors-ink);
}

.milestone-stats-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background-color: var(--colors-canvas-soft);
  border: 1px solid var(--colors-hairline);
  padding: 6px 14px;
  border-radius: var(--rounded-full);
  font-size: 13px;
  font-weight: 600;
  color: var(--colors-ink-secondary);
  font-variant-numeric: tabular-nums;
}

.milestone-subtext {
  font-size: 12px;
  color: var(--colors-ink-muted);
  line-height: 1.4;
}

.amazon-banner-container {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  margin: 12px auto;
  border-radius: var(--rounded-lg);
  overflow: hidden;
}

.amazon-banner-container iframe {
  border: none;
  max-width: 100%;
  border-radius: var(--rounded-md);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.04);
}

/* ==========================================================================
   Footer (100% width, white background, single line: Title · Version · produce by flamenquito)
   ========================================================================== */
.app-footer {
  width: 100%;
  background-color: var(--colors-canvas);
  border-top: 1px solid var(--colors-hairline);
  padding: 16px 20px;
  margin-top: auto;
}

.footer-content {
  max-width: 1120px;
  margin: 0 auto;
  text-align: center;
  font-size: 13px;
  color: var(--colors-ink-secondary);
  white-space: nowrap;
  overflow-x: auto;
}

.footer-version {
  font-weight: 600;
  background-color: var(--colors-canvas-soft);
  border: 1px solid var(--colors-hairline);
  padding: 1px 6px;
  border-radius: var(--rounded-full);
  font-size: 11px;
}

.footer-content a {
  color: var(--colors-primary);
  font-weight: 500;
}

/* Animations */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Responsive adjustments */
@media (max-width: 680px) {
  .header-container {
    flex-wrap: wrap;
  }
  .app-header {
    padding: 10px 14px;
  }
  .main-wrapper {
    padding: 14px 10px 32px;
  }
  .feature-card {
    padding: 16px;
  }
  .key-white {
    width: 36px;
    height: 140px;
  }
  .key-black {
    width: 22px;
    height: 90px;
  }
  .key-label {
    font-size: 10px;
  }
  .key-black .key-label {
    font-size: 9px;
  }
}
