@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,400&display=swap');

* {
  box-sizing: border-box;
}

:root {
  --bg: #f8fafc;
  --bg-card: #fff;
  --text: #1e293b;
  --text-muted: #64748b;
  --accent: #0d9488;
  --accent-hover: #0f766e;
  --border: #e2e8f0;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
  --shadow-hover: 0 4px 12px rgba(15, 23, 42, 0.08);
  --success: #059669;
  --success-bg: #d1fae5;
  --error-bg: #fee2e2;
  --error-text: #b91c1c;
}

body {
  font-family: 'DM Sans', system-ui, sans-serif;
  font-size: 1rem;
  line-height: 1.6;
  max-width: 56rem;
  margin: 0 auto;
  padding: 2rem;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
}

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1.25rem;
  margin-bottom: 1.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
  position: relative;
  z-index: 1;
}

.header__row {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.header__select-label {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-muted);
}

.header__select {
  flex: 1;
  max-width: 28rem;
  min-height: 2.5rem;
  padding: 0.5rem 0.75rem;
  font-size: 0.95rem;
  font-family: inherit;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-card);
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
  position: relative;
  z-index: 2;
  cursor: pointer;
}

.header__select:hover {
  border-color: var(--accent);
}

.header__select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.15);
}

.header__select--narrow {
  max-width: 12rem;
}

.header__search {
  flex: 1;
  max-width: 28rem;
  min-height: 2.5rem;
  padding: 0.5rem 0.75rem;
  font-size: 0.95rem;
  font-family: inherit;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-card);
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
}

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

.header__search:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.15);
}

.header__search-count {
  font-size: 0.85rem;
  color: var(--text-muted);
  white-space: nowrap;
}

#fileSelect,
#voiceSelect {
  pointer-events: auto;
}

.header__source {
  width: 100%;
  margin: 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}

h1 {
  font-size: 1.75rem;
  font-weight: 600;
  margin: 0;
  color: var(--text);
  letter-spacing: -0.02em;
}

.toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  cursor: pointer;
  color: var(--text-muted);
  transition: color 0.15s;
}

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

.toggle input {
  cursor: pointer;
  accent-color: var(--accent);
}

.entry {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem 1.5rem;
  padding-right: 9.5rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
  transition: box-shadow 0.2s, border-color 0.2s;
}

.entry:hover {
  box-shadow: var(--shadow-hover);
  border-color: #cbd5e1;
}

.entry--learned {
  opacity: 0.85;
  background: linear-gradient(135deg, #f0fdfa 0%, var(--bg-card) 100%);
}

.entry__copy {
  position: absolute;
  top: 1rem;
  right: 7.5rem;
  width: 2rem;
  height: 2rem;
  padding: 0.25rem;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s, background 0.2s;
}

.entry__copy:hover {
  color: var(--accent);
  background: rgba(13, 148, 136, 0.1);
}

.entry__copy--copied {
  color: var(--success);
}

.entry__copy svg {
  display: block;
}

.entry__play {
  position: absolute;
  top: 1rem;
  right: 5.5rem;
  width: 2rem;
  height: 2rem;
  padding: 0.25rem;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s, background 0.2s;
}

.entry__play:hover:not(:disabled) {
  color: var(--accent);
  background: rgba(13, 148, 136, 0.1);
}

.entry__play:disabled {
  cursor: wait;
  opacity: 0.6;
}

.entry__play svg {
  display: block;
}

.entry__spinner {
  animation: entry-spin 0.8s linear infinite;
}

@keyframes entry-spin {
  to { transform: rotate(360deg); }
}

.entry__learned {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: 2px solid var(--border);
  border-radius: 8px;
  background: var(--bg-card);
  color: var(--text-muted);
  font-size: 1rem;
  cursor: pointer;
  line-height: 1;
  transition: all 0.2s;
}

.entry__learned:hover {
  background: var(--success-bg);
  border-color: var(--success);
  color: var(--success);
  transform: scale(1.05);
}

.entry--learned .entry__learned {
  background: var(--success-bg);
  border-color: var(--success);
  color: var(--success);
}

.entry__head {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.875rem;
}

.entry__word {
  font-size: 1.3rem;
  font-weight: 600;
  margin: 0;
  color: var(--text);
  letter-spacing: -0.01em;
}

.entry__badge {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.2rem 0.6rem;
  border-radius: 6px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.entry__badge--literary { background: #ede9fe; color: #5b21b6; }
.entry__badge--formal-official { background: #dbeafe; color: #1d4ed8; }
.entry__badge--colloquial { background: #ffedd5; color: #c2410c; }
.entry__badge--regional { background: #d1fae5; color: #047857; }
.entry__badge--other { background: #e2e8f0; color: #475569; }

.entry__gender {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-style: italic;
}

.entry__row {
  margin-bottom: 0.6rem;
}

.entry__row:last-child {
  margin-bottom: 0;
}

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

.entry__row strong {
  font-weight: 700;
  color: var(--accent);
  background: rgba(13, 148, 136, 0.12);
  padding: 0.08em 0.2em;
  border-radius: 3px;
}

.error {
  padding: 1.25rem;
  background: var(--error-bg);
  border: 1px solid #fecaca;
  border-radius: 12px;
  color: var(--error-text);
  font-weight: 500;
}

.loading {
  color: var(--text-muted);
  font-size: 1rem;
}

.sentinel {
  height: 1px;
  visibility: hidden;
  pointer-events: none;
}

.empty {
  color: var(--text-muted);
  font-size: 1rem;
}
