/* ═══════════════════════════════════════════════════════════
   ATLAS JP — language.css
   Language Tab Specific Styles (Linen & Soft Beige Retheme)
   ═══════════════════════════════════════════════════════════ */

:root {
  --ink: #333537;
  --paper: #f5f3eb;
  --cream: #ffffff;
  --line: rgba(51, 53, 55, 0.12);
  --accent: #cf4a22;
  --accent-soft: #fcf1ed;
  --sage: #5e7d69;
  --sage-soft: #f0f5f2;
  --blue: #4a7a96;
  --gold: #c9933b;
  --love: #d65a7f;
  --love-soft: #fbf0f3;
  --text-light: var(--ink);
  --text-muted: rgba(51, 53, 55, 0.65);
  --shadow-sm: 0 1px 3px rgba(51, 53, 55, 0.05);
  --shadow-md: 0 6px 16px -2px rgba(51, 53, 55, 0.08), 0 2px 6px -2px rgba(51, 53, 55, 0.04);
  --shadow-lg: 0 16px 24px -4px rgba(51, 53, 55, 0.12), 0 4px 10px -2px rgba(51, 53, 55, 0.06);
  --radius: 16px;
  --radius-sm: 10px;
  --transition: all 0.22s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── 1. Hero ────────────────────────────────────────────── */
.language-hero {
  padding: 32px 4vw 16px;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}

.language-hero h1 {
  font-size: clamp(36px, 5vw, 56px);
  font-weight: 800;
  color: var(--ink);
  letter-spacing: -0.03em;
  margin: 0;
}

/* ── 2. Navigation Tabs (Linen Segmented Control) ───────── */
.language-nav {
  display: flex;
  margin: 24px 4vw;
  padding: 6px;
  background: #eae5da; /* Soft warm beige capsule container */
  border: 1px solid var(--line);
  border-radius: 999px;
  gap: 6px;
}

.language-tab {
  flex: 1;
  padding: 12px 16px;
  border: none;
  background: transparent;
  color: rgba(51, 53, 55, 0.65); /* Charcoal text on beige */
  font-size: 14px;
  font-weight: 600;
  border-radius: 999px;
  cursor: pointer;
  transition: var(--transition);
  text-align: center;
}

.language-tab:hover:not(.is-active) {
  background: rgba(51, 53, 55, 0.05);
  color: var(--ink);
}

.language-tab.is-active {
  background: var(--ink); /* Solid dark charcoal background */
  color: #ffffff; /* White text for contrast */
  border: none;
  box-shadow: var(--shadow-sm);
}

.language-tab strong {
  font-weight: 700;
}

/* ── 3. Content Area ────────────────────────────────────── */
.language-content {
  padding: 24px 4vw 48px;
  background: var(--paper);
}

.language-content > h2 {
  margin: 0 0 28px;
  font-size: 22px;
  font-weight: 800;
  color: var(--ink);
  letter-spacing: -0.01em;
}

/* ── 4. Voice Actor Panel ───────────────────────────────── */
.voice-actor-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 20px;
  margin-bottom: 24px;
  background: #eae5da; /* Soft warm beige container */
  border-radius: var(--radius);
  border: 1px solid var(--line);
}

.actor-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 8px;
}

.actor-btns {
  display: flex;
  gap: 8px;
}

.actor-btn {
  padding: 8px 16px;
  border: 1px solid var(--line);
  border-radius: 99px;
  background: #ffffff;
  color: var(--ink);
  font-size: 12px;
  font-weight: 600;
  transition: var(--transition);
  cursor: pointer;
}

.actor-btn.is-active {
  background: var(--ink);
  color: #ffffff;
  border-color: var(--ink);
}

.actor-btn:hover:not(.is-active) {
  background: rgba(51, 53, 55, 0.05);
  transform: translateY(-1px);
}

/* ── 5. Study Workspace ──────────────────────────────────── */
.study-workspace {
  width: min(820px, 100%);
  margin: 0 auto;
}

/* ── 6. Study Area Tabs (Situation Categories) ──────────── */
.study-area-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 6px;
  background: #eae5da; /* Soft beige capsule */
  border: 1px solid var(--line);
  border-radius: var(--radius);
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  margin-bottom: 20px;
}

.study-area-tabs::-webkit-scrollbar {
  display: none;
}

.study-area-tabs button {
  flex: 0 0 auto;
  min-height: 42px;
  padding: 8px 16px;
  border: 0;
  border-radius: calc(var(--radius) - 6px);
  background: transparent;
  font-weight: 700;
  font-size: 13.5px;
  color: var(--ink);
  cursor: pointer;
  white-space: nowrap;
  transition: var(--transition);
}

.study-area-tabs button.is-active {
  background: var(--ink);
  color: #ffffff;
  box-shadow: var(--shadow-sm);
}

.study-area-tabs button:hover:not(.is-active) {
  background: rgba(51, 53, 55, 0.05);
  color: var(--accent);
}

/* ── 7. Study Toolbar ────────────────────────────────────── */
.study-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.study-toolbar span {
  font-weight: 700;
  color: var(--ink);
  font-size: 14px;
}

/* ── 8. Study Card Outer & Star Button ───────────────────── */
.study-card-outer {
  position: relative;
  margin-bottom: 16px;
}

.card-star-btn {
  position: absolute;
  top: 16px;
  right: 20px;
  z-index: 50;
  border: 0;
  background: transparent;
  font-size: 26px;
  cursor: pointer;
  color: var(--gold);
  transition: var(--transition);
  filter: drop-shadow(0 1px 2px rgba(51, 53, 55, 0.1));
}

.card-star-btn:hover {
  transform: scale(1.2);
}

/* ── 9. Card Badges ──────────────────────────────────────── */
.card-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 99px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.badge-normal {
  background: var(--sage-soft);
  color: var(--sage);
}

.badge-love {
  background: var(--love-soft);
  color: var(--love);
}

/* ── 10. Study Card (White on Sand) ───────────────────────── */
.study-card {
  display: flex;
  width: 100%;
  min-height: 300px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 36px 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--cream); /* White background */
  color: var(--ink); /* Soft charcoal text */
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  box-shadow: var(--shadow-md);
  position: relative;
  overflow: hidden;
  box-sizing: border-box;
}

.study-card:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
}

.study-card::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--accent);
  opacity: 0;
  transform: scaleX(0);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease;
  transform-origin: center;
}

.study-card:hover::after {
  opacity: 1;
  transform: scaleX(1);
}

/* ── 11. Study Front ─────────────────────────────────────── */
.study-front {
  display: flex;
  max-width: 100%;
  align-items: stretch;
  justify-content: center;
  gap: 16px;
}

.study-front:has(.study-word) {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.study-word {
  display: block;
  font: 700 clamp(36px, 6vw, 60px) / 1.35 'Noto Sans JP', sans-serif;
  color: var(--ink);
  letter-spacing: -0.01em;
}

.study-reading {
  display: block;
  margin-top: 10px;
  color: var(--text-muted);
  font: 500 16px 'Noto Sans JP', sans-serif;
}

/* ── 12. Study Piece ─────────────────────────────────────── */
.study-piece {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 110px;
  padding: 12px 8px;
  border-right: 1px solid var(--line);
  position: relative;
}

.study-piece:last-child {
  border-right: 0;
}

.study-piece strong {
  display: block;
  font: 700 clamp(24px, 4vw, 36px) / 1.3 'Noto Sans JP', sans-serif;
  color: var(--ink);
  order: 2;
}

.study-piece small {
  display: block;
  margin-bottom: 8px;
  color: var(--text-muted);
  font: 500 13px 'Noto Sans JP', sans-serif;
  order: 1;
}

.study-piece em {
  display: block;
  margin-top: 16px;
  font-size: 14px;
  font-style: normal;
  font-weight: 600;
  color: var(--text-muted);
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.3s ease, transform 0.3s ease;
  order: 3;
}

.study-card.is-revealed .study-piece em {
  opacity: 1;
  transform: translateY(0);
}

/* ── 13. Study Answer ────────────────────────────────────── */
.study-answer {
  width: 100%;
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transform: translateY(12px);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.study-card.is-revealed .study-answer {
  max-height: 450px;
  margin-top: 20px;
  opacity: 1;
  transform: translateY(0);
}

.study-answer strong {
  display: block;
  font-size: 22px;
  font-weight: 800;
  color: var(--ink);
  margin-bottom: 12px;
}

.study-nuance {
  margin: 12px 0 16px;
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--paper); /* Linen background container inside white card */
  border: 1px solid var(--line);
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  text-align: left;
  display: inline-block;
  max-width: 100%;
  box-sizing: border-box;
}

.nuance-badge {
  display: inline-block;
  background: var(--accent);
  color: #ffffff;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 4px;
  margin-right: 8px;
  vertical-align: middle;
}

.study-answer em {
  display: block;
  margin-top: 12px;
  color: var(--text-muted);
  font-size: 13.5px;
  font-style: normal;
  line-height: 1.6;
}

/* ── 14. Study Controls ──────────────────────────────────── */
.study-controls {
  display: grid;
  grid-template-columns: 52px 1fr auto 52px;
  gap: 12px;
  margin-top: 16px;
}

.study-controls button {
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--ink);
  font-weight: 600;
  transition: var(--transition);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  justify-content: center;
}

.study-controls button:hover:not(:disabled) {
  border-color: var(--ink);
  background: rgba(51, 53, 55, 0.05);
}

.study-controls button:disabled {
  opacity: 0.3;
  cursor: not-allowed;
  box-shadow: none;
}

#study-reveal {
  background: var(--ink) !important;
  color: #ffffff !important;
  border: none !important;
  font-size: 14.5px;
}

#study-reveal:hover {
  background: #444749 !important;
}

.speak-main-btn {
  background: var(--accent-soft) !important;
  color: var(--accent) !important;
  border-color: var(--accent) !important;
  padding: 0 20px;
}

.speak-main-btn:hover {
  background: var(--accent) !important;
  color: #ffffff !important;
}

/* ── 15. Song Workspace (J-POP) ─────────────────────────── */
.song-workspace {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 48px;
  align-items: start;
  width: 100%;
  max-width: 1680px;
  margin: 0 auto;
}

.song-library {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--cream);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

#song-new {
  width: 100%;
  padding: 16px 20px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: var(--ink);
  color: #ffffff;
  font-size: 13.5px;
  font-weight: 700;
  text-align: left;
  transition: var(--transition);
}

#song-new:hover {
  background: #444749;
}

.song-library-item {
  display: grid;
  grid-template-columns: 24px 1fr;
  width: 100%;
  padding: 16px 20px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  text-align: left;
  transition: var(--transition);
}

.song-library-item span {
  font: 700 10px 'IBM Plex Mono', monospace;
  color: rgba(51, 53, 55, 0.4);
}

.song-library-item strong {
  font-size: 13.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.song-library-item:hover {
  background: rgba(51, 53, 55, 0.04);
}

.song-library-item.is-active {
  background: var(--accent-soft);
  border-left: 4px solid var(--accent);
  padding-left: 16px;
  color: var(--accent);
}

.song-library-item.is-active span {
  color: var(--accent);
  opacity: 0.6;
}

.album-group {
  border-bottom: 1px solid var(--line);
}

.album-group summary {
  display: grid;
  grid-template-columns: 1fr auto;
  padding: 16px 20px;
  cursor: pointer;
  list-style: none;
  background: transparent;
  transition: var(--transition);
}

.album-group summary::-webkit-details-marker {
  display: none;
}

.album-group summary span {
  grid-column: 1;
  grid-row: 1;
  color: var(--accent);
  font: 700 9px 'IBM Plex Mono', monospace;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.album-group summary strong {
  grid-column: 1;
  grid-row: 2;
  margin-top: 4px;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--ink);
}

.album-group summary small {
  grid-column: 2;
  grid-row: 1 / 3;
  align-self: center;
  font: 700 11px 'IBM Plex Mono', monospace;
  color: rgba(51, 53, 55, 0.4);
}

.album-group .song-library-item {
  padding-left: 32px; /* Indent items inside accordion */
  background: rgba(255, 255, 255, 0.4);
}

.album-group[open] summary {
  background: rgba(51, 53, 55, 0.03);
  border-bottom: 1px solid var(--line);
}

.song-main {
  min-width: 0;
}

.now-playing {
  display: flex;
  flex-direction: column;
  margin-bottom: 24px;
}

.now-playing span {
  font: 700 10px 'IBM Plex Mono', monospace;
  color: var(--accent);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.now-playing strong {
  margin-top: 6px;
  font-size: clamp(24px, 3.5vw, 36px);
  font-weight: 800;
  color: var(--ink);
}

.song-practice-toolbar {
  display: flex;
  gap: 24px;
  margin-bottom: 24px;
  padding: 16px 24px;
  background: #eae5da;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
}

.song-practice-toolbar label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.song-practice-toolbar input[type="checkbox"] {
  accent-color: var(--accent);
  width: 18px;
  height: 18px;
  cursor: pointer;
}

.song-player-panel {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 24px;
  align-items: start;
  margin-bottom: 20px;
}

#song-player:empty {
  display: none;
}

#song-player:not(:empty) {
  grid-column: 1 / -1;
  width: 100%;
}

#song-player audio {
  width: 100%;
  border-radius: 99px;
  background: #eae5da;
  outline: none;
}

.youtube-embed {
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--line);
}

.youtube-embed:has(iframe) {
  aspect-ratio: 16 / 9;
  background: #000000;
}

.youtube-embed iframe {
  width: 100%;
  height: 100%;
  border: 0;
}

.focus-line {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 140px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--cream);
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}

.focus-line::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--accent), var(--gold));
}

.focus-count {
  font: 700 10px 'IBM Plex Mono', monospace;
  color: var(--accent);
}

.focus-line > strong {
  display: block;
  margin-top: 12px;
  max-width: 100%;
  font: 700 clamp(17px, 1.8vw, 27px) / 1.35 'Noto Sans JP', sans-serif;
  color: var(--ink);
  overflow-wrap: anywhere;
  white-space: normal;
}

.focus-line > small {
  display: block;
  margin-top: 8px;
  color: var(--text-muted);
  font: 500 14px/1.5 'Noto Sans JP', sans-serif;
  overflow-wrap: anywhere;
  white-space: normal;
}

.focus-line > em {
  display: block;
  margin-top: 20px;
  font-size: 15px;
  font-style: normal;
  font-weight: 700;
  color: var(--ink);
  overflow-wrap: anywhere;
  white-space: normal;
}

.focus-controls {
  display: grid;
  grid-template-columns: 48px 1fr 48px;
  gap: 10px;
  margin-top: 20px;
}

.focus-controls button {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--ink);
  font-weight: 600;
  transition: var(--transition);
  cursor: pointer;
}

.focus-controls button:hover:not(:disabled) {
  border-color: var(--ink);
  background: rgba(51, 53, 55, 0.05);
}

.focus-controls button:disabled {
  opacity: 0.3;
}

#line-speak {
  white-space: nowrap;
  background: var(--accent-soft) !important;
  color: var(--accent) !important;
  border-color: var(--accent) !important;
}

#line-speak:hover {
  background: var(--accent) !important;
  color: #ffffff !important;
}

.song-editor {
  margin: 32px 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--cream);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.song-editor summary {
  padding: 18px 24px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
  outline: none;
  user-select: none;
  transition: var(--transition);
}

.song-editor summary:hover {
  background: rgba(51, 53, 55, 0.03);
}

.song-inputs {
  padding: 8px 24px 30px;
  display: grid;
  gap: 20px;
}

.song-inputs label {
  display: grid;
  gap: 8px;
  font-size: 12px;
  font-weight: 700;
  color: var(--ink);
}

.song-inputs input,
.song-inputs textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--paper);
  outline: none;
  font-size: 14px;
  transition: var(--transition);
}

.song-inputs input:focus,
.song-inputs textarea:focus {
  border-color: var(--accent);
  background: #ffffff;
}

.parallel-fields {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.parallel-fields textarea {
  min-height: 260px;
  font-family: 'Noto Sans JP', sans-serif;
  line-height: 1.8;
}

.song-meta-fields {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.song-actions {
  display: flex;
  gap: 12px;
  margin-top: 10px;
}

.song-save {
  padding: 12px 28px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--ink);
  color: #ffffff;
  font-weight: 700;
  font-size: 14px;
  transition: var(--transition);
}

.song-save:hover {
  background: #444749;
}

.song-delete {
  padding: 12px 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--ink);
  font-weight: 600;
  transition: var(--transition);
}

.song-delete:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}

.lyrics-sheet {
  border-top: 1px solid var(--line);
  margin-top: 32px;
}

.lyrics-sheet h3 {
  margin: 0;
  padding: 24px 20px;
  border-bottom: 1px solid var(--line);
  font-size: 20px;
  font-weight: 800;
}

.lyric-line {
  display: grid;
  grid-template-columns: 48px 1fr auto;
  width: 100%;
  min-height: 84px;
  padding: 0;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  text-align: left;
  cursor: pointer;
  transition: var(--transition);
}

.lyric-line:hover {
  background: var(--accent-soft);
}

.lyric-line.is-active {
  position: relative;
  z-index: 10;
  background: var(--love-soft);
  box-shadow: inset 4px 0 var(--love);
}

.lyric-line > span {
  display: flex;
  align-items: center;
  justify-content: center;
  border-right: 1px solid var(--line);
  font: 700 10px 'IBM Plex Mono', monospace;
  color: rgba(51, 53, 55, 0.4);
}

.line-text {
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
}

.line-text strong {
  font: 700 clamp(12px, .9vw, 15px)/1.45 'Noto Sans JP', sans-serif;
  color: var(--ink);
  overflow-wrap: anywhere;
  white-space: normal;
}

.line-text small {
  margin-top: 4px;
  color: var(--text-muted);
  font: 500 12px 'Noto Sans JP', sans-serif;
  overflow-wrap: anywhere;
  white-space: normal;
}

.line-text em {
  margin-top: 6px;
  font-size: 13.5px;
  font-style: normal;
  font-weight: 600;
  color: var(--ink);
  overflow-wrap: anywhere;
  white-space: normal;
}

.lyric-buttons {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 16px;
  flex-shrink: 0;
}

.lyric-buttons button {
  border: 0;
  background: transparent;
  font-size: 18px;
  padding: 8px;
  border-radius: 50%;
  transition: var(--transition);
  color: var(--ink);
}

.lyric-buttons button:hover {
  background: rgba(51, 53, 55, 0.08);
}

.speak-line-btn:hover {
  color: var(--accent) !important;
}

.star-line-btn {
  color: var(--gold) !important;
}

.song-empty {
  padding: 48px 24px;
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 500;
}

/* ── 16. My Words ───────────────────────────────────────── */
.mywords-workspace {
  width: min(900px, 100%);
  margin: 0 auto;
}

.mywords-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}

.stat-card {
  padding: 16px 20px;
  text-align: center;
  border-radius: var(--radius);
}

.stat-card span {
  display: block;
  font-size: 11px;
  font-weight: 700;
  color: rgba(51, 53, 55, 0.5) !important;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
}

.stat-card strong {
  display: block;
  font-size: 26px;
  font-weight: 800;
}

.stat-card button {
  margin-top: 10px;
  padding: 10px 24px;
  border: none;
  border-radius: 99px;
  background: var(--accent);
  color: #ffffff !important;
  font-weight: 700;
  font-size: 13px;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}

.stat-card button:hover:not(:disabled) {
  background: #c34b31;
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.stat-card button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  box-shadow: none;
}

.add-custom-panel {
  padding: 16px 20px;
  background: var(--cream);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}

.add-custom-panel h4 {
  margin: 0 0 18px;
  font-size: 15px;
  font-weight: 800;
}

.custom-inputs {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr auto;
  gap: 12px;
  align-items: end;
}

.custom-inputs input {
  padding: 12px 0;
  border: 0;
  border-bottom: 1.5px solid var(--line);
  background: transparent;
  outline: none;
  font-size: 14px;
  color: var(--ink);
  transition: var(--transition);
}

.custom-inputs input:focus {
  border-color: var(--accent);
}

#custom-add-btn {
  padding: 10px 24px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--ink);
  color: #ffffff;
  font-weight: 700;
  font-size: 13.5px;
  white-space: nowrap;
  transition: var(--transition);
}

#custom-add-btn:hover {
  background: #444749;
}

.words-title {
  margin: 0 0 16px;
  font-size: 18px;
  font-weight: 800;
}

.no-words-fallback {
  padding: 36px 24px;
  text-align: center;
  background: var(--cream);
  border: 1.5px dashed var(--line);
  border-radius: var(--radius);
}

.no-words-fallback p {
  margin: 0;
  font-size: 15.5px;
  font-weight: 600;
  color: rgba(51, 53, 55, 0.65) !important;
}

.no-words-fallback small {
  display: block;
  margin-top: 8px;
  color: rgba(51, 53, 55, 0.4) !important;
  font-size: 12.5px;
}

.words-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}

.word-card-inner {
  padding: 16px;
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 140px;
  background: #ffffff;
  border: 1px solid var(--line);
}

.word-card-inner:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.word-tag {
  display: inline-block;
  align-self: flex-start;
  padding: 3px 10px;
  border-radius: 99px;
  font-size: 9px;
  font-weight: 700;
  background: var(--sage-soft);
  color: var(--sage);
}

.word-main-content {
  margin: 12px 0;
}

.word-main-content strong {
  display: block;
  font: 700 24px 'Noto Sans JP', sans-serif;
}

.word-main-content small {
  display: block;
  margin-top: 4px;
  font: 500 13px 'Noto Sans JP', sans-serif;
}

.word-reveal-box {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
}

.word-reveal-box:hover {
  border-color: var(--accent);
}

.revealed-ko {
  font-size: 14px;
  font-weight: 700;
}

.word-card-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 10px;
}

.word-card-actions button {
  border: 0;
  background: transparent;
  font-size: 18px;
  padding: 6px;
  border-radius: 50%;
  transition: var(--transition);
  color: var(--ink);
}

.word-card-actions button:hover {
  background: rgba(51, 53, 55, 0.06);
}

.word-speaker-btn:hover {
  color: var(--accent) !important;
}

.word-unstar-btn:hover {
  color: var(--love) !important;
}

/* ── 17. Quiz Mode ──────────────────────────────────────── */
.quiz-container {
  width: min(640px, 100%);
  margin: 0 auto;
}

.quiz-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding: 12px 20px;
  background: #ffffff;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
}

.quiz-header span {
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
}

#quiz-exit-btn {
  padding: 6px 16px;
  border: 1px solid var(--line);
  border-radius: 99px;
  background: transparent;
  color: rgba(30, 32, 34, 0.65);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

#quiz-exit-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.quiz-card-outer {
  perspective: 1000px;
  margin-bottom: 20px;
}

.quiz-card {
  display: flex;
  width: 100%;
  min-height: 280px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 24px;
  border-radius: var(--radius);
  background: #ffffff;
  border: 1px solid var(--line);
  box-shadow: var(--shadow-md);
  box-sizing: border-box;
  position: relative;
  overflow: hidden;
}

.quiz-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--gold), var(--accent));
}

.quiz-front {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.quiz-badge {
  padding: 4px 12px;
  border-radius: 99px;
  font-size: 10px;
  font-weight: 700;
  background: var(--sage-soft);
  color: var(--sage);
  margin-bottom: 12px;
}

.quiz-front strong {
  font: 700 clamp(32px, 5vw, 52px) / 1.3 'Noto Sans JP', sans-serif;
  color: var(--ink);
}

.quiz-front small {
  color: rgba(30, 32, 34, 0.65);
  font-size: 14px;
  font-weight: 500;
  margin-top: 8px;
}

.speak-btn {
  margin-top: 16px;
  padding: 8px 20px;
  border: 1.5px solid var(--accent);
  border-radius: 99px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.speak-btn:hover {
  background: var(--accent);
  color: #ffffff;
}

.quiz-back {
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transition: all 0.3s ease;
  width: 100%;
}

.quiz-card.is-revealed .quiz-back {
  max-height: 100px;
  margin-top: 12px;
  opacity: 1;
}

.quiz-back strong {
  font-size: 26px;
  font-weight: 800;
  color: var(--ink);
  text-align: center;
}

.quiz-controls-panel {
  width: 100%;
}

#quiz-reveal-btn {
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--ink);
  color: #ffffff;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  transition: var(--transition);
}

#quiz-reveal-btn:hover {
  background: #444749;
}

.quiz-choice-btns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.incorrect-btn {
  padding: 14px;
  border: 1.5px solid var(--love);
  border-radius: var(--radius-sm);
  background: var(--love-soft);
  color: var(--love);
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  transition: var(--transition);
}

.incorrect-btn:hover {
  background: var(--love);
  color: #ffffff;
}

.correct-btn {
  padding: 14px;
  border: 1.5px solid var(--sage);
  border-radius: var(--radius-sm);
  background: var(--sage-soft);
  color: var(--sage);
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  transition: var(--transition);
}

.correct-btn:hover {
  background: var(--sage);
  color: #ffffff;
}

.quiz-complete-card {
  padding: 32px 24px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  text-align: center;
  color: var(--ink);
}

.quiz-complete-card h3 {
  margin: 0 0 12px;
  font-size: 24px;
  font-weight: 800;
  color: var(--ink);
}

.quiz-complete-card p {
  color: rgba(30, 32, 34, 0.65);
  font-size: 14px;
  font-weight: 500;
}

.quiz-stats-result {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 24px 0;
}

.result-box {
  padding: 12px 8px;
  border-radius: var(--radius-sm);
  text-align: center;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--line);
}

.result-box span {
  display: block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  margin-bottom: 6px;
}

.result-box strong {
  font-size: 24px;
  font-weight: 800;
}

.result-box.correct {
  background: var(--sage-soft);
  color: var(--sage);
}

.result-box.incorrect {
  background: var(--love-soft);
  color: var(--love);
}

#quiz-finish-btn {
  padding: 12px 32px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--ink);
  color: var(--ink);
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  transition: var(--transition);
}

#quiz-finish-btn:hover {
  background: #444749;
  color: #ffffff;
}

/* ── 18. Responsive Queries ────────────────────────────── */
@media (max-width: 1024px) {
  .song-workspace {
    grid-template-columns: 1fr;
    gap: 24px;
  }
  .words-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .mywords-stats {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 600px) {
  /* iOS zooms the page when a focused input's font-size is below 16px */
  .song-inputs input,
  .song-inputs textarea,
  .custom-inputs input,
  .sync-input {
    font-size: 16px;
  }
  /* 44px touch targets for small icon buttons */
  .lyric-buttons button,
  .word-card-actions button,
  #quiz-exit-btn {
    min-width: 44px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
  .lyric-buttons {
    padding: 0 8px;
  }
  .lyric-line {
    grid-template-columns: 32px 1fr auto; /* was 48px — give text more room */
  }
  .line-text {
    padding: 12px 12px;
  }
  /* study card: sentence pieces overflow horizontally without wrapping */
  .study-front {
    flex-wrap: wrap;
  }
  .study-piece {
    border-right: 0;
    border-bottom: 1px dashed var(--line);
  }
  /* J-POP: cap the library list so it doesn't push the player off-screen */
  #song-library-list {
    max-height: 40vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  .song-workspace {
    gap: 20px;
  }
  .study-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
  .study-toolbar > div {
    display: flex;
    overflow-x: auto;
    gap: 8px;
    padding-bottom: 6px;
    -webkit-overflow-scrolling: touch;
  }
  .study-toolbar > div::-webkit-scrollbar {
    display: none;
  }
  .study-toolbar > div button {
    flex-shrink: 0;
    white-space: nowrap;
  }
  .language-hero {
    padding: 44px 20px 20px;
  }
  .language-nav {
    margin: 16px 20px;
    padding: 4px;
  }
  .language-tab {
    padding: 10px;
    font-size: 13px;
  }
  .language-content {
    padding: 30px 20px 60px;
  }
  .voice-actor-card {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 8px;
  }
  .study-area-tabs {
    margin-bottom: 16px;
  }
  .study-area-tabs button {
    font-size: 12.5px;
    padding: 6px 12px;
  }
  .study-card {
    min-height: 320px;
    padding: 40px 20px;
  }
  .study-piece {
    min-width: 100px;
    padding: 12px 8px;
  }
  .study-controls {
    grid-template-columns: 48px 1fr 48px;
  }
  .speak-main-btn {
    padding: 0 12px;
  }
  .song-practice-toolbar {
    flex-direction: column;
    gap: 12px;
    padding: 12px 8px;
  }
  .song-player-panel {
    grid-template-columns: 1fr;
  }
  .focus-line {
    min-height: 220px;
    padding: 16px 20px;
  }
  .parallel-fields {
    grid-template-columns: 1fr;
  }
  .song-meta-fields {
    grid-template-columns: 1fr;
  }
  .custom-inputs {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  #custom-add-btn {
    width: 100%;
  }
  .words-grid {
    grid-template-columns: 1fr;
  }
  .quiz-card {
    min-height: 300px;
    padding: 36px 20px;
  }
  .quiz-choice-btns {
    grid-template-columns: 1fr;
  }
}

/* ── 19. Situation & Type Grouped Study Cards ───────────── */
.study-sections-container {
  display: flex;
  flex-direction: column;
  gap: 36px;
  margin-top: 24px;
}

.study-type-section {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.study-type-section h3 {
  font-size: 15px;
  font-weight: 800;
  margin: 0;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 2px solid var(--line);
  padding-bottom: 8px;
}

.study-type-section h3 span {
  font-size: 11px;
  background: rgba(51, 53, 55, 0.08);
  color: var(--ink);
  padding: 2px 8px;
  border-radius: 99px;
  font-weight: 700;
}

.study-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}

.study-item-card {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 120px;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
  cursor: pointer;
  position: relative;
  overflow: hidden;
  box-sizing: border-box;
}

.study-item-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--accent);
}

.study-item-card.is-revealed {
  border-color: var(--accent);
}

.card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.card-star-btn {
  border: 0;
  background: transparent;
  font-size: 20px;
  color: var(--gold);
  cursor: pointer;
  padding: 0;
  transition: var(--transition);
}

.card-star-btn:hover {
  transform: scale(1.2);
}

.card-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex-grow: 1;
}

.card-body strong {
  font-size: 20px;
  font-weight: 700;
  color: var(--ink);
}

.card-kana {
  font-size: 13.5px;
  color: var(--text-muted);
  font-weight: 500;
}

/* Inline segment pieces style for sentences */
.study-pieces-inline {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.piece-inline {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  border-right: 1px solid var(--line);
  padding-right: 10px;
}

.piece-inline:last-child {
  border-right: 0;
  padding-right: 0;
}

.piece-inline strong {
  font: 700 18px 'Noto Sans JP', sans-serif !important;
  order: 2;
}

.piece-inline small {
  font: 500 11px 'Noto Sans JP', sans-serif !important;
  color: var(--text-muted) !important;
  order: 1;
  margin-bottom: 2px;
}

/* Card details (hidden by default, expands on click/reveal) */
.card-detail {
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.study-item-card.is-revealed .card-detail {
  max-height: 450px;
  opacity: 1;
  margin-top: 14px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.card-ko {
  display: block;
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 8px;
}

.card-nuance {
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--paper);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  margin-bottom: 10px;
  border: 1px solid var(--line);
  text-align: left;
}

.card-example {
  display: block;
  font-size: 12.5px;
  color: var(--text-muted);
  font-style: normal;
  line-height: 1.45;
  text-align: left;
}

.card-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
  border-top: 1px dashed var(--line);
  padding-top: 12px;
}

.card-actions button {
  flex: 1;
  min-height: 34px;
  font-size: 12px;
  font-weight: 700;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
}

.card-actions button:hover {
  background: rgba(51, 53, 55, 0.05);
  border-color: var(--ink);
}

.card-actions .card-speak-btn {
  flex: 0 0 74px;
  white-space: nowrap;
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--accent);
}

.card-actions .card-speak-btn:hover {
  background: var(--accent);
  color: #ffffff;
}

@media (max-width: 600px) {
  .study-grid {
    grid-template-columns: 1fr;
  }
}

/* ── Sync & Backup Panel Styles ────────────────────────── */
.sync-panel {
  padding: 20px;
  margin-bottom: 24px;
  background: var(--cream);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.sync-panel h4 {
  margin: 0 0 10px 0;
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
}

.sync-panel p {
  margin: 0 0 16px 0;
  font-size: 12px;
  color: rgba(51, 53, 55, 0.6);
  line-height: 1.6;
}

.sync-layout {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 20px;
}

.sync-group {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  padding: 16px;
  background: var(--paper);
  border-radius: var(--radius-sm);
  border: 1px solid rgba(51, 53, 55, 0.05);
}

.sync-group h5 {
  margin: 0 0 12px 0;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
}

.sync-btns button {
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 12px;
}

.sync-btns button:hover:not(:disabled) {
  opacity: 0.9;
  transform: translateY(-1px);
}

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

.sync-input:focus {
  border-color: var(--accent) !important;
}

@media (max-width: 850px) {
  .sync-layout {
    grid-template-columns: 1fr;
    gap: 16px;
  }
}

/* Touch devices: hover-lift effects stick after tap — disable them */
@media (hover: none) {
  .study-card:hover,
  .study-item-card:hover,
  .word-card-inner:hover,
  .actor-btn:hover:not(.is-active),
  .stat-card button:hover:not(:disabled),
  .sync-btns button:hover:not(:disabled) {
    transform: none;
  }
  .study-card:hover::after {
    opacity: 0;
    transform: scaleX(0);
  }
}
