:root {
  --bg: #0f0f12;
  --surface: #18181c;
  --surface-hover: #1f1f24;
  --border: #2a2a32;
  --text: #e8e8ed;
  --text-muted: #8c8c96;
  --accent: #5b7cfa;
  --accent-hover: #4a6bef;
  --success: #22c55e;
  --error: #ef4444;
  --czech-blue: #11457e;
  --czech-red: #d7141a;
  --radius: 14px;
  --radius-sm: 8px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: 'DM Sans', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.app {
  max-width: 640px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: 1.5rem;
  padding-top: max(1.5rem, env(safe-area-inset-top));
  padding-left: max(1.5rem, env(safe-area-inset-left));
  padding-right: max(1.5rem, env(safe-area-inset-right));
  padding-bottom: max(1.5rem, env(safe-area-inset-bottom));
}

.header {
  position: relative;
  text-align: center;
  margin-bottom: 2rem;
}

.settings-btn {
  position: absolute;
  top: 0;
  right: 0;
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0.25rem;
  opacity: 0.7;
  -webkit-tap-highlight-color: transparent;
}

.settings-btn:hover {
  opacity: 1;
}

.settings-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s, visibility 0.2s;
  z-index: 100;
}

.settings-overlay.open {
  opacity: 1;
  visibility: visible;
}

.settings-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(320px, 100%);
  background: var(--surface);
  border-left: 1px solid var(--border);
  transform: translateX(100%);
  transition: transform 0.25s ease;
  z-index: 101;
  display: flex;
  flex-direction: column;
}

.settings-panel.open {
  transform: translateX(0);
}

.settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
}

.settings-header h2 {
  font-size: 1.25rem;
  font-weight: 600;
}

.settings-close {
  background: none;
  border: none;
  font-size: 1.25rem;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.25rem;
  -webkit-tap-highlight-color: transparent;
}

.settings-close:hover {
  color: var(--text);
}

.settings-content {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  overflow-y: auto;
}

.settings-row {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  font-size: 0.95rem;
}

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

.settings-row select {
  padding: 0.5rem 0.75rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: inherit;
  font-size: 0.95rem;
}

.settings-row-check {
  flex-direction: row;
  align-items: center;
}

.settings-row-check input {
  accent-color: var(--accent);
}

.title {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 0.25rem;
  background: linear-gradient(135deg, var(--text) 0%, var(--text-muted) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.subtitle {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
}

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.subtitle-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  min-height: 140px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.subtitle-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.play-btn,
.pause-btn {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 1rem;
  background: var(--accent);
  border: none;
  border-radius: var(--radius-sm);
  color: white;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: opacity 0.2s;
}

.play-btn:hover:not(:disabled),
.pause-btn:hover:not(:disabled) {
  opacity: 0.9;
}

.play-btn:disabled,
.pause-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.play-btn .play-label,
.pause-btn .pause-label {
  color: inherit;
}

.play-btn {
  background: var(--accent);
  border: none;
}

.pause-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
}

.pause-btn.active {
  background: var(--error);
  border-color: var(--error);
  color: white;
}

.subtitle-text {
  font-size: 1.25rem;
  line-height: 1.6;
  min-height: 2.5em;
}

.subtitle-text.listening {
  color: var(--text-muted);
  font-style: italic;
}

.voice-options {
  display: flex;
  gap: 1rem;
}

.voice-option {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.9rem;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.voice-option input {
  accent-color: var(--accent);
}

.controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}

.ctrl-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 1rem 2rem;
  min-height: 56px;
  min-width: 200px;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.listen-btn {
  background: linear-gradient(135deg, var(--czech-blue) 0%, var(--czech-red) 100%);
  color: white;
}

.listen-btn:hover {
  transform: scale(1.02);
  box-shadow: 0 4px 20px rgba(91, 124, 250, 0.3);
}

.listen-btn.listening {
  background: var(--error);
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.85; }
}

.ctrl-icon {
  font-size: 1.2rem;
}

.status {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-family: 'JetBrains Mono', monospace;
}

.history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 0.5rem;
}

.history-title {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.clear-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.85rem;
  padding: 0.35rem 0.75rem;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: color 0.2s, border-color 0.2s;
}

.clear-btn:hover {
  color: var(--text);
  border-color: var(--text-muted);
}

.history {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-height: 200px;
  overflow-y: auto;
}

.history-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  font-size: 0.9rem;
}

.history-item .orig {
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.history-item .trans {
  color: var(--text);
}

.footer {
  text-align: center;
  padding-top: 1.5rem;
  padding-bottom: env(safe-area-inset-bottom);
  font-size: 0.8rem;
  color: var(--text-muted);
}

@media (max-width: 480px) {
  .app { padding: 1rem; }
  .title { font-size: 1.5rem; }
  .subtitle-panel { min-height: 120px; padding: 1.25rem; }
  .subtitle-text { font-size: 1.1rem; }
  .ctrl-btn { min-width: 100%; max-width: 280px; }
  .history { max-height: 160px; }
}

.hidden {
  display: none !important;
}
