/* ==================== RESET & BASE ==================== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg: #faf7f2;
  --bg-card: #ffffff;
  --primary: #e07a5f;
  --primary-dark: #c4563d;
  --secondary: #3d405b;
  --accent: #81b29a;
  --text: #2d2d2d;
  --text-light: #6b6b6b;
  --border: #e8e4df;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  --radius: 12px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

.hidden {
  display: none !important;
}

/* ==================== LOGIN SCREEN ==================== */
#login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
}

.login-container {
  text-align: center;
  width: 100%;
  max-width: 320px;
}

.login-container h1 {
  font-size: 2.5rem;
  color: var(--primary);
  margin-bottom: 0.25rem;
}

.tagline {
  color: var(--text-light);
  margin-bottom: 2rem;
}

#login-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

#login-form input {
  padding: 14px 16px;
  font-size: 1rem;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  outline: none;
  transition: border-color 0.2s;
}

#login-form input:focus {
  border-color: var(--primary);
}

#login-form button {
  padding: 14px;
  font-size: 1rem;
  font-weight: 600;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.2s;
}

#login-form button:hover {
  background: var(--primary-dark);
}

.error {
  color: #d32f2f;
  margin-top: 12px;
  font-size: 0.9rem;
}

/* ==================== HEADER ==================== */
header {
  position: sticky;
  top: 0;
  background: var(--bg);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  z-index: 100;
}

header h1 {
  font-size: 1.25rem;
  color: var(--primary);
}

.icon-btn {
  background: none;
  border: none;
  padding: 8px;
  cursor: pointer;
  color: var(--text-light);
  border-radius: 8px;
  transition: background 0.2s;
}

.icon-btn:hover {
  background: var(--border);
}

/* ==================== TIMELINE ==================== */
#timeline {
  padding: 16px;
  padding-bottom: 100px;
  max-width: 600px;
  margin: 0 auto;
}

.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 16px;
  overflow: hidden;
}

.card-date {
  font-size: 0.75rem;
  color: var(--text-light);
  padding: 12px 16px 0;
}

.sentence-block, .translation-block {
  padding: 12px 16px;
}

.translation-block {
  background: rgba(129, 178, 154, 0.1);
  border-top: 1px dashed var(--border);
}

.language-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.75rem;
  color: var(--text-light);
  margin-bottom: 6px;
}

.sentence-text {
  font-size: 1.1rem;
  margin-bottom: 10px;
  line-height: 1.6;
}

.sentence-text .word {
  cursor: pointer;
  transition: background 0.2s;
  border-radius: 2px;
  padding: 0 2px;
  margin: 0 -2px;
}

.sentence-text .word:hover {
  background: rgba(224, 122, 95, 0.2);
}

.sentence-text .word.has-definition {
  border-bottom: 2px dotted var(--accent);
}

.audio-player {
  display: flex;
  align-items: center;
  gap: 8px;
}

.audio-player audio {
  height: 36px;
  width: 100%;
  max-width: 250px;
}

.add-translation-btn {
  display: block;
  width: 100%;
  padding: 14px;
  background: none;
  border: none;
  border-top: 1px dashed var(--border);
  color: var(--primary);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s;
}

.add-translation-btn:hover {
  background: rgba(224, 122, 95, 0.1);
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-light);
}

.empty-state p {
  margin-top: 12px;
}

/* ==================== FAB ==================== */
.fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  font-size: 2rem;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(224, 122, 95, 0.4);
  transition: transform 0.2s, background 0.2s;
  z-index: 200;
}

.fab:hover {
  background: var(--primary-dark);
  transform: scale(1.05);
}

.fab:active {
  transform: scale(0.95);
}

/* ==================== MODAL ==================== */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.modal-content {
  background: var(--bg-card);
  border-radius: var(--radius) var(--radius) 0 0;
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  animation: slideUp 0.3s ease;
}

@keyframes slideUp {
  from {
    transform: translateY(100%);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

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

.modal-header h2 {
  font-size: 1.1rem;
}

.close-btn {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--text-light);
  cursor: pointer;
  padding: 4px 8px;
}

.modal form {
  padding: 20px;
}

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-light);
  margin-bottom: 8px;
}

.form-group select,
.form-group textarea {
  width: 100%;
  padding: 12px;
  font-size: 1rem;
  border: 2px solid var(--border);
  border-radius: 8px;
  outline: none;
  transition: border-color 0.2s;
  font-family: inherit;
}

.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--primary);
}

.form-group textarea {
  resize: vertical;
  min-height: 80px;
}

.submit-btn {
  width: 100%;
  padding: 14px;
  font-size: 1rem;
  font-weight: 600;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.2s;
}

.submit-btn:hover {
  background: var(--primary-dark);
}

.submit-btn:disabled {
  background: var(--border);
  cursor: not-allowed;
}

.original-preview {
  padding: 16px 20px;
  background: rgba(61, 64, 91, 0.05);
  font-style: italic;
  color: var(--text-light);
  border-bottom: 1px solid var(--border);
}

/* ==================== AUDIO RECORDER ==================== */
.audio-recorder {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.recorder-controls {
  display: flex;
  align-items: center;
  gap: 12px;
}

.waveform {
  width: 100%;
  height: 60px;
  background: linear-gradient(to bottom, #fff5f3, #ffebe8);
  border-radius: 8px;
  border: 2px solid #ffcdd2;
}

.recording-time {
  text-align: center;
  font-size: 1.25rem;
  font-weight: 600;
  color: #c62828;
  font-variant-numeric: tabular-nums;
}

.record-btn, .stop-btn, .re-record-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  font-size: 0.9rem;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s;
}

.record-btn {
  background: #ffebee;
  color: #c62828;
}

.record-btn:hover {
  background: #ffcdd2;
}

.record-icon {
  width: 12px;
  height: 12px;
  background: #c62828;
  border-radius: 50%;
}

.record-btn.recording .record-icon {
  animation: pulse 1s infinite;
}

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

.stop-btn {
  background: var(--secondary);
  color: white;
}

.re-record-btn {
  background: var(--border);
  color: var(--text);
}

.audio-preview {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.audio-preview audio {
  flex: 1;
  min-width: 200px;
  height: 40px;
}

/* ==================== DEFINITION POPOVER ==================== */
.popover {
  position: fixed;
  z-index: 2000;
  background: var(--bg-card);
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  padding: 12px;
  min-width: 200px;
  max-width: 280px;
}

.popover-word {
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--secondary);
}

.definition-input {
  width: 100%;
  padding: 8px 10px;
  font-size: 0.9rem;
  border: 2px solid var(--border);
  border-radius: 6px;
  outline: none;
  margin-bottom: 8px;
}

.definition-input:focus {
  border-color: var(--primary);
}

.save-definition-btn {
  width: 100%;
  padding: 8px;
  font-size: 0.85rem;
  font-weight: 500;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
}

.save-definition-btn:hover {
  background: #6a9c84;
}

/* ==================== RESPONSIVE ==================== */
@media (min-width: 600px) {
  .modal {
    align-items: center;
  }

  .modal-content {
    border-radius: var(--radius);
  }
}
