/* Reset and base styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: "Arial", "Helvetica", sans-serif;
  line-height: 1.6;
  color: #333;
  background-color: #f3f4f6;
  min-height: 100vh;
  touch-action: manipulation;
}

body.theme-dark {
  background-color: #0b1220;
  color: #e5e7eb;
}

.container {
  max-width: 800px;
  margin: 0 auto;
  padding: 20px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header styles */
.header {
  text-align: center;
  margin-bottom: 40px;
  padding: 30px 0;
}

.header h1 {
  color: #1e3a8a;
  font-size: 2.5rem;
  margin-bottom: 10px;
  font-weight: 700;
}

.header-meta {
  margin-top: 6px;
}

.header-meta-row {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.header-link {
  color: #6b7280;
  font-size: 1rem;
  font-weight: 600;
  text-decoration: none;
}

.header-link:hover {
  color: #1e3a8a;
  text-decoration: underline;
}

.theme-toggle {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: 2px solid #e5e7eb;
  background: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  cursor: pointer;
  flex-shrink: 0;
}

.theme-toggle svg {
  width: 20px;
  height: 20px;
}

.theme-toggle .icon-sun,
.theme-toggle .icon-moon {
  fill: none;
  stroke: #6b7280;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.theme-toggle .icon-moon {
  display: none;
}

.theme-toggle.is-dark .icon-sun {
  display: none;
}

.theme-toggle.is-dark .icon-moon {
  display: inline;
}

.theme-toggle:active {
  transform: translateY(0);
}

.subtitle {
  color: #6b7280;
  font-size: 1.1rem;
  margin-bottom: 20px;
}

/* Form styles */
.main-content {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.home-page .main-content {
  align-items: flex-start;
  padding-top: 10px;
}

.story-form {
  background: white;
  padding: 40px;
  border-radius: 12px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  width: 100%;
  max-width: 600px;
}

body.theme-dark .header h1 {
  color: #93c5fd;
}

body.theme-dark .header-link {
  color: #cbd5e1;
}

body.theme-dark .header-link:hover {
  color: #93c5fd;
}

body.theme-dark .theme-toggle {
  background: #0f172a;
  border-color: #1f2937;
}

body.theme-dark .theme-toggle .icon-sun,
body.theme-dark .theme-toggle .icon-moon {
  stroke: #cbd5e1;
}

body.theme-dark .story-form,
body.theme-dark .home-tabs,
body.theme-dark .story-row,
body.theme-dark .story-display,
body.theme-dark .control-panel,
body.theme-dark .loading-content,
body.theme-dark .modal {
  background: #0f172a;
  border-color: #1f2937;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.35);
}

body.theme-dark .tab-btn {
  color: #cbd5e1;
}

body.theme-dark .tab-btn.is-active {
  background: #2563eb;
  color: #fff;
}

body.theme-dark .story-name {
  color: #f3f4f6;
}

body.theme-dark .story-sub,
body.theme-dark .story-list-empty,
body.theme-dark .subtitle {
  color: #9ca3af;
}

body.theme-dark .segment-item {
  border-color: #1f2937;
}

body.theme-dark .segment-item.active {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.18);
  background: rgba(37, 99, 235, 0.12);
}

body.theme-dark .japanese-text {
  color: #93c5fd;
}

body.theme-dark .english-text {
  color: #a3a3a3;
}

body.theme-dark .speed-control,
body.theme-dark .modal-desc,
body.theme-dark .modal-title {
  color: #e5e7eb;
}

body.theme-dark .player-progress {
  color: #93c5fd;
}

body.theme-dark #speedSlider,
body.theme-dark #delaySlider,
body.theme-dark #repeatCount {
  background: #0b1220;
  border-color: #1f2937;
  color: #e5e7eb;
}

body.theme-dark .favorite-btn {
  background: #0f172a;
  border-color: #1f2937;
}

body.theme-dark .favorite-btn svg {
  stroke: #cbd5e1;
}

.form-group {
  margin-bottom: 30px;
}

.form-note {
  margin-top: 8px;
  font-size: 0.95rem;
  color: #6b7280;
  line-height: 1.35;
}

body.theme-dark .form-note {
  color: #9ca3af;
}

.form-actions {
  display: flex;
  gap: 10px;
}

.home-shell {
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-items: center;
}

.home-tabs {
  width: 100%;
  max-width: 700px;
  display: flex;
  flex-wrap: nowrap;
  gap: 10px;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 8px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.06);
  position: sticky;
  top: 14px;
  z-index: 5;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.tab-btn {
  flex: 1 1 0;
  border: none;
  border-radius: 10px;
  padding: 12px 14px;
  font-weight: 700;
  font-size: 1rem;
  color: #374151;
  background: transparent;
  cursor: pointer;
  white-space: nowrap;
}

.tab-btn.is-active {
  background: #1e3a8a;
  color: #fff;
}

.tab-panel {
  width: 100%;
  display: none;
  justify-content: center;
}

.tab-panel.is-active {
  display: flex;
}

.story-list-card {
  width: 100%;
  max-width: 700px;
}

.story-list-title {
  font-weight: 800;
  color: #1e3a8a;
  font-size: 1.1rem;
  margin-bottom: 12px;
  text-align: center;
}

body.theme-dark .story-list-title {
  color: #4b7aff;
}

.story-list-empty {
  color: #6b7280;
}

.flash-msg {
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid #e5e7eb;
  text-align: center;
  font-weight: 700;
}

.flash-sub {
  margin-top: 6px;
  font-weight: 600;
  font-size: 0.95rem;
  opacity: 0.9;
}

.flash-success {
  background: rgba(22, 163, 74, 0.08);
  border-color: rgba(22, 163, 74, 0.35);
  color: #166534;
}

.flash-error {
  background: rgba(220, 38, 38, 0.08);
  border-color: rgba(220, 38, 38, 0.35);
  color: #991b1b;
}

body.theme-dark .flash-success {
  background: rgba(34, 197, 94, 0.14);
  border-color: rgba(34, 197, 94, 0.45);
  color: #bbf7d0;
}

body.theme-dark .flash-error {
  background: rgba(248, 113, 113, 0.14);
  border-color: rgba(248, 113, 113, 0.45);
  color: #fecaca;
}

.go-error {
  color: #dc2626;
  text-align: center;
  font-weight: 700;
  margin: 8px 0 10px;
}

body.theme-dark .go-error {
  color: #fca5a5;
}

.story-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.story-row {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 10px 12px;
}

.story-meta {
  min-width: 0;
  flex: 1;
}

.story-name {
  font-weight: 800;
  color: #111827;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.story-sub {
  font-size: 0.9rem;
  color: #6b7280;
}

.story-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-shrink: 0;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(17, 24, 39, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 2000;
}

.modal-overlay[hidden] {
  display: none;
}

.modal {
  width: 100%;
  max-width: 520px;
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
  border: 1px solid #e5e7eb;
  padding: 16px 18px;
}

.modal-title {
  font-weight: 800;
  color: #111827;
  font-size: 1.1rem;
}

.modal-desc {
  margin-top: 8px;
  color: #374151;
  line-height: 1.5;
}

.modal-actions {
  margin-top: 14px;
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.modal-actions .submit-btn {
  width: auto;
  padding: 10px 14px;
  box-shadow: none;
  transform: none;
}

.delete-form {
  margin: 0;
}

.btn-compact {
  width: auto;
  padding: 10px 14px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.story-actions .btn-compact {
  min-width: 96px;
}

.go-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.go-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 320px;
  overflow: auto;
  padding-right: 2px;
}

.go-row {
  cursor: pointer;
}

.go-checkbox {
  width: 18px;
  height: 18px;
  margin-right: 10px;
  flex-shrink: 0;
}

.go-row.is-checked {
  border-color: rgba(37, 99, 235, 0.55);
  background: rgba(37, 99, 235, 0.08);
}

body.theme-dark .go-row.is-checked {
  border-color: rgba(147, 197, 253, 0.55);
  background: rgba(147, 197, 253, 0.12);
}

.go-row.is-checked .story-name {
  color: #0b132b;
}

body.theme-dark .go-row.is-checked .story-name {
  color: #f3f4f6;
}

.go-options {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
}

.go-option label {
  display: block;
  margin-bottom: 8px;
  font-weight: 700;
  color: #374151;
  font-size: 0.95rem;
}

.go-option input,
.go-option select {
  width: 100%;
  padding: 10px 12px;
  border: 2px solid #e5e7eb;
  border-radius: 8px;
  font-size: 0.95rem;
  font-family: inherit;
  background: #fff;
}

body.theme-dark .go-option label {
  color: #e5e7eb;
}

body.theme-dark .go-option input,
body.theme-dark .go-option select {
  background: #0b1220;
  border-color: #1f2937;
  color: #e5e7eb;
}

.btn-danger {
  background: #dc2626;
}

.btn-danger:hover {
  background: #dc2626;
}

.btn-success {
  background: #16a34a;
}

.btn-success:hover {
  background: #16a34a;
}

.form-group label {
  display: block;
  margin-bottom: 10px;
  font-weight: 600;
  color: #374151;
  font-size: 1.1rem;
}

.form-group textarea {
  width: 100%;
  padding: 15px;
  border: 2px solid #e5e7eb;
  border-radius: 8px;
  font-size: 1rem;
  font-family: inherit;
  resize: vertical;
  min-height: 200px;
  transition: border-color 0.3s ease;
}

.form-group input[type="text"],
.form-group input[type="password"] {
  width: 100%;
  padding: 15px;
  border: 2px solid #e5e7eb;
  border-radius: 8px;
  font-size: 1rem;
  font-family: inherit;
  transition: border-color 0.3s ease;
}

.form-group textarea:focus {
  outline: none;
  border-color: #1e3a8a;
  box-shadow: 0 0 0 3px rgba(30, 58, 138, 0.1);
}

.form-group input[type="text"]:focus,
.form-group input[type="password"]:focus {
  outline: none;
  border-color: #1e3a8a;
  box-shadow: 0 0 0 3px rgba(30, 58, 138, 0.1);
}

.form-group textarea::placeholder {
  color: #9ca3af;
  font-style: italic;
}

.submit-btn {
  background-color: #1e3a8a;
  color: white;
  padding: 15px 30px;
  border: none;
  border-radius: 8px;
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  width: 100%;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.submit-btn:hover {
  background-color: #1e40af;
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.submit-btn.pressed,
.submit-btn.pressed:hover {
  background-color: #dc2626;
  transform: none;
}

.submit-btn:active {
  transform: translateY(0);
}

.submit-btn.btn-success {
  background-color: #16a34a;
}

.submit-btn.btn-success:hover {
  background-color: #15803d;
}

.submit-btn.btn-danger {
  background-color: #dc2626;
}

.submit-btn.btn-danger:hover {
  background-color: #b91c1c;
}

/* Playback page styles */
.playback-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 0 280px;
  gap: 14px;
}

.play-topbar {
  width: 100%;
  max-width: 700px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.play-topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.favorite-btn {
  width: 46px;
  height: 46px;
  border-radius: 10px;
  border: 2px solid #e5e7eb;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  cursor: pointer;
  flex-shrink: 0;
}

.favorite-btn svg {
  width: 22px;
  height: 22px;
  fill: transparent;
  stroke: #9ca3af;
  stroke-width: 2;
}

.favorite-btn.is-favorite {
  border-color: #f59e0b;
  background: rgba(245, 158, 11, 0.12);
}

.favorite-btn.is-favorite svg {
  fill: #f59e0b;
  stroke: #f59e0b;
}

.toast {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  background: #facc15;
  color: #111827;
  border: 1px solid rgba(17, 24, 39, 0.25);
  padding: 12px 14px;
  border-radius: 12px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
  z-index: 3000;
  max-width: calc(100% - 40px);
  width: max-content;
  opacity: 0;
  transition: opacity 140ms ease;
  pointer-events: none;
}

.toast.is-show {
  opacity: 1;
}

.story-display {
  background: white;
  padding: 60px 40px;
  border-radius: 12px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  text-align: center;
  width: 100%;
  max-width: 700px;
  max-height: calc(100vh - 220px);
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-width: none;
  -ms-overflow-style: none; /* IE & Edge (old) */
}

.story-display.is-playlist .segment-item {
  cursor: default;
  pointer-events: none;
}

.current-segment {
  margin-bottom: 30px;
}

.japanese-text {
  font-size: 1.8rem;
  color: #1e3a8a;
  margin-bottom: 20px;
  font-weight: 500;
  line-height: 1.8;
  min-height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.english-text {
  font-size: 1.4rem;
  color: #6b7280;
  font-style: italic;
  min-height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.progress-info {
  font-size: 1.1rem;
  color: #9ca3af;
  margin-top: 30px;
  font-weight: 500;
}

.segment-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.segment-item {
  padding: 12px 10px;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
  cursor: pointer;
}

.segment-item.active {
  border-color: #1e3a8a;
  box-shadow: 0 0 0 3px rgba(30, 58, 138, 0.08);
  background: rgba(30, 58, 138, 0.06);
}

/* Floating controls */
.floating-controls {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
}

.control-panel {
  background: #cdcdcd;
  padding: 20px;
  border-radius: 12px;
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 15px;
  border: 1px solid #e5e7eb;
}

.control-panel.is-mini {
  padding: 12px 14px;
  gap: 12px;
  flex-wrap: nowrap;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(10px);
}

.player-buttons.is-mini {
  width: auto;
  flex-wrap: nowrap;
}

.player-buttons.is-mini .control-btn {
  pointer-events: auto;
}

.player-progress.is-mini {
  font-weight: 700;
  color: #111827;
  padding: 0 6px;
  white-space: nowrap;
}

.control-btn.settings-trigger {
  background: #2563eb;
}

.control-btn.settings-trigger:hover {
  background: #2563eb;
}

.control-btn.settings-trigger svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

.settings-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 16px;
  background: rgba(17, 24, 39, 0.55);
  opacity: 0;
  transition: opacity 180ms ease;
  z-index: 2500;
  pointer-events: none;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.settings-overlay.is-open {
  opacity: 1;
  pointer-events: auto;
}

.settings-sheet {
  width: 100%;
  max-width: 640px;
  max-height: calc(100vh - 40px);
  overflow: auto;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 18px;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.28);
  transform: translateY(24px);
  transition: transform 180ms ease;
}

.settings-overlay.is-open .settings-sheet {
  transform: translateY(0);
}

.settings-sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 14px 10px;
  border-bottom: 1px solid #e5e7eb;
}

.settings-sheet-title {
  font-weight: 800;
  font-size: 1.05rem;
  color: #111827;
}

.settings-close {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: 1px solid #e5e7eb;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.settings-close svg {
  width: 20px;
  height: 20px;
  fill: #374151;
}

.settings-sheet-body {
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.settings-modes .control-btn {
  height: auto;
  min-height: 45px;
  padding: 12px 10px;
  line-height: 1.1;
  text-align: center;
  white-space: normal;
}

.settings-modes {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  align-items: stretch;
}

.settings-fields {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  align-items: stretch;
}

.settings-sheet .player-setting {
  border: 1px solid rgba(17, 24, 39, 0.12);
  background: rgba(255, 255, 255, 0.7);
  padding: 10px 12px;
  border-radius: 14px;
  width: 100%;
}

.settings-sheet .control-btn {
  border: 1px solid rgba(17, 24, 39, 0.18);
  width: 100%;
  min-width: 0;
  justify-content: center;
}

.settings-fields .player-setting:first-child {
  grid-column: 1 / -1;
}

.settings-sheet .player-setting .speed-control,
.settings-sheet .player-setting.speed-control {
  color: #111827;
}

.settings-sheet .player-setting label {
  color: inherit;
}

.settings-sheet .player-setting input[type="number"] {
  box-shadow: none;
}

.settings-sheet .step-btn {
  display: flex;
  border: 1px solid rgba(17, 24, 39, 0.18);
}

body.modal-open {
  overflow: hidden;
}

.settings-overlay[hidden] {
  display: none !important;
}

body.theme-dark .control-panel.is-mini {
  background: rgba(15, 23, 42, 0.86);
}

body.theme-dark .player-progress.is-mini {
  color: #e5e7eb;
}

body.theme-dark .settings-sheet {
  background: #0f172a;
  border-color: #1f2937;
}

body.theme-dark .settings-sheet-title {
  color: #e5e7eb;
}

body.theme-dark .settings-sheet-header {
  border-bottom-color: #1f2937;
}

body.theme-dark .settings-close {
  background: #0f172a;
  border-color: rgba(255, 255, 255, 0.65);
}

body.theme-dark .settings-close svg {
  fill: #cbd5e1;
}

body.theme-dark .settings-sheet .player-setting {
  border-color: rgba(255, 255, 255, 0.55);
  background: rgba(2, 6, 23, 0.35);
}

body.theme-dark .settings-sheet .control-btn {
  border-color: rgba(255, 255, 255, 0.65);
}

body.theme-dark .settings-sheet .step-btn {
  border-color: rgba(255, 255, 255, 0.65);
}

body.theme-dark .settings-sheet #speedSlider,
body.theme-dark .settings-sheet #delaySlider,
body.theme-dark .settings-sheet #repeatCount {
  border-color: rgba(255, 255, 255, 0.55);
}

body.theme-dark .settings-sheet .player-setting .speed-control,
body.theme-dark .settings-sheet .player-setting.speed-control {
  color: #e5e7eb;
}

.player-buttons {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 12px;
  width: 100%;
}

.player-settings {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 15px;
  width: 100%;
}

.control-btn {
  background: #1e3a8a;
  color: white;
  border: none;
  border-radius: 8px;
  padding: 12px;
  cursor: pointer;
  transition: none;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 45px;
  height: 45px;
}

.control-btn .btn-svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
}

.control-btn .icon-pause {
  display: none;
}

.control-btn.playing .icon-play {
  display: none;
}

.control-btn.playing .icon-pause {
  display: block;
}

.control-btn:hover {
  background: #1e3a8a;
}

.control-btn.pressed {
  background: #dc2626;
}

.control-btn.playing {
  animation: none;
  background: #dc2626;
}

.control-btn.pressed:hover,
.control-btn.playing:hover {
  background: #dc2626;
}

.control-btn:disabled,
button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  filter: grayscale(20%);
  pointer-events: none;
  animation: none !important;
  transform: none !important;
  box-shadow: none !important;
}

.control-btn.playing:disabled {
  animation: none !important;
}

.btn-icon {
  font-size: 1.2rem;
}

.speed-control {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.9rem;
  color: #374151;
}

.step-btn {
  display: none;
  background: #1e3a8a;
  color: #fff;
  border: none;
  border-radius: 8px;
  width: 32px;
  height: 38px;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  line-height: 1;
  touch-action: manipulation;
}

.step-btn:active {
  opacity: 0.92;
}

.mode-status {
  font-size: 0.9rem;
  color: #1e3a8a;
  font-weight: 600;
}

.player-progress {
  font-size: 0.9rem;
  color: #1e3a8a;
  font-weight: 700;
  min-width: 72px;
  text-align: center;
}

/* Loading overlay */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}

.loading-content {
  background: #fff;
  padding: 24px 28px;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  display: flex;
  align-items: center;
  gap: 14px;
  border: 1px solid #e5e7eb;
}

.loading-spinner {
  width: 28px;
  height: 28px;
  border: 3px solid #e5e7eb;
  border-top-color: #1e3a8a;
  border-radius: 50%;
  animation: loading-spin 0.8s linear infinite;
}

.loading-text {
  color: #1e3a8a;
  font-weight: 600;
}

@keyframes loading-spin {
  to {
    transform: rotate(360deg);
  }
}

.speed-control label {
  font-weight: 600;
}

#speedSlider {
  width: 70px;
  padding: 8px 10px;
  border: 2px solid #e5e7eb;
  border-radius: 8px;
  font-size: 0.95rem;
  font-family: inherit;
  text-align: center;
}

#delaySlider {
  width: 70px;
  padding: 8px 10px;
  border: 2px solid #e5e7eb;
  border-radius: 8px;
  font-size: 0.95rem;
  font-family: inherit;
  text-align: center;
}

#speedSlider:focus,
#delaySlider:focus {
  outline: none;
  border-color: #1e3a8a;
  box-shadow: 0 0 0 3px rgba(30, 58, 138, 0.1);
}

#repeatCount {
  width: 60px;
  padding: 8px 10px;
  border: 2px solid #e5e7eb;
  border-radius: 8px;
  font-size: 0.95rem;
  font-family: inherit;
  text-align: center;
}

#repeatCount:focus {
  outline: none;
  border-color: #1e3a8a;
  box-shadow: 0 0 0 3px rgba(30, 58, 138, 0.1);
}

#speedValue {
  font-weight: 600;
  color: #1e3a8a;
  min-width: 35px;
}

.play-topbar a.submit-btn {
  font-size: 16px;
  background-color: #7c30a3;
}

/* Responsive design */
@media (max-width: 768px) {
  .container {
    padding: 15px;
  }

  .header {
    margin-bottom: 16px;
    padding: 16px 0;
  }

  .main-content {
    align-items: flex-start;
    padding-top: 10px;
  }

  .header h1 {
    font-size: 2rem;
  }

  .subtitle {
    font-size: 1rem;
  }

  .story-form {
    padding: 25px;
  }

  .home-tabs {
    max-width: none;
  }

  .tab-btn {
    padding: 10px 10px;
    font-size: 0.95rem;
  }

  .go-options {
    grid-template-columns: 1fr;
  }

  .story-list-card {
    max-width: none;
  }

  .story-row {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .story-row.go-row {
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    gap: 12px;
  }

  .story-row.go-row .story-meta {
    width: auto;
  }

  .story-actions {
    justify-content: flex-end;
  }

  .story-display {
    padding: 40px 25px;
  }

  .japanese-text {
    font-size: 1.5rem;
  }

  .english-text {
    font-size: 1.2rem;
  }

  .floating-controls {
    bottom: 20px;
    left: 20px;
    transform: none;
    width: calc(100% - 40px);
    max-width: none;
  }

  .playback-content {
    padding-bottom: 340px;
  }

  .control-panel {
    flex-wrap: wrap;
    justify-content: center;
    padding: 15px;
    width: 100%;
  }

  .player-settings {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px 14px;
    align-items: center;
    justify-items: center;
  }

  .player-setting label.mobile-show {
    display: inline;
  }

  #speedValue,
  #delayValue {
    display: inline;
    font-weight: 700;
    color: #1e3a8a;
    min-width: 38px;
    text-align: left;
  }

  .speed-control {
    width: 100%;
    justify-content: center;
    gap: 5px;
    margin-top: 0;
  }

  .step-btn {
    display: inline-flex;
  }

  .player-progress {
    justify-self: center;
    min-width: 0;
    text-align: center;
  }
}

/* Loading and transition effects */
.japanese-text,
.english-text {
  transition:
    opacity 0.3s ease,
    transform 0.3s ease;
}

.japanese-text.playing {
  color: #059669;
  font-weight: 600;
}

.english-text.playing {
  color: #dc2626;
  font-weight: 500;
}

/* Animation for control buttons */
/* removed pulse animation */

/* Accessibility improvements */
.control-btn:focus,
.submit-btn:focus,
#speedSlider:focus {
  outline: 2px solid #1e3a8a;
  outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .header h1 {
    color: #000;
  }

  .subtitle,
  .english-text {
    color: #333;
  }

  .control-btn,
  .submit-btn {
    background: #000;
    color: #fff;
  }
}
