/* style.css */
:root {
  --bg-primary: #0D0D0D;
  --bg-surface: #1A1A1A;
  --bg-surface-light: #242424;
  --border-subtle: rgba(255, 255, 255, 0.08);
  --accent: #F5A623;
  --accent-glow: rgba(245, 166, 35, 0.3);
  --text-primary: #F0EDE6;
  --text-secondary: #8A8A8A;
  --text-tertiary: #5A5A5A;
  --success: #4CAF7D;
  --error: #E05C5C;
  --font-ui: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-entry: 'Lora', Georgia, serif;
  --font-brand: 'Playfair Display', Georgia, serif;
  --max-width: 680px;
  --header-height: 100px;
  --nav-height: 72px;
  --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-ui);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  min-height: 100dvh;
}

.app-container {
  max-width: var(--max-width);
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  position: relative;
  padding: 0 20px;
}

/* Header */
.app-header {
  text-align: center;
  padding: 28px 0 20px;
  border-bottom: 1px solid var(--border-subtle);
}

.app-title {
  font-family: var(--font-brand);
  font-size: clamp(2.2rem, 8vw, 2.8rem);
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.app-tagline {
  font-size: 0.9rem;
  color: var(--text-secondary);
  font-style: italic;
  font-family: var(--font-entry);
}

/* Main Content */
.app-main {
  flex: 1;
  padding: 24px 0 20px;
}

.tab-content {
  display: none;
  animation: fadeIn 0.3s ease;
}

.tab-content.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Capture Tab */
.capture-container {
  display: flex;
  flex-direction: column;
  gap: 28px;
}

/* Language Selector */
.language-selector {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 4px;
}

.lang-label {
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.lang-toggle {
  display: flex;
  gap: 8px;
  background: var(--bg-surface);
  padding: 4px;
  border-radius: 24px;
  border: 1px solid var(--border-subtle);
}

.lang-btn {
  padding: 8px 16px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font-ui);
  font-size: 0.9rem;
  font-weight: 500;
  border-radius: 20px;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.lang-btn.active {
  background: var(--accent);
  color: var(--bg-primary);
}

/* Mic Section */
.mic-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px 0;
}

.mic-button-container {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.mic-button {
  width: clamp(96px, 30vw, 120px);
  height: clamp(96px, 30vw, 120px);
  border-radius: 50%;
  background: var(--bg-surface);
  border: 3px solid var(--border-subtle);
  color: var(--text-primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-smooth);
  position: relative;
  z-index: 2;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.mic-button::before {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid var(--accent);
  opacity: 0;
  transition: var(--transition-smooth);
  pointer-events: none;
}

.mic-button.recording {
  background: var(--accent);
  color: var(--bg-primary);
  transform: scale(1.05);
  border-color: var(--accent);
}

.mic-button.recording::before {
  opacity: 1;
  animation: pulse 1.5s ease-out infinite;
}

@keyframes pulse {
  0% { transform: scale(1); opacity: 0.8; }
  100% { transform: scale(1.4); opacity: 0; }
}

.mic-icon {
  width: 40%;
  height: 40%;
}

.waveform-canvas {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 200%;
  height: 200%;
  pointer-events: none;
  z-index: 1;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.waveform-canvas.active {
  opacity: 0.6;
}

.mic-hint {
  margin-top: 16px;
  font-size: 0.85rem;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* Transcript Section */
.transcript-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.section-label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.transcript-textarea {
  width: 100%;
  padding: 16px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 16px;
  color: var(--text-primary);
  font-family: var(--font-ui);
  font-size: 1rem;
  line-height: 1.6;
  resize: vertical;
  transition: var(--transition-smooth);
}

.transcript-textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.transcript-textarea::placeholder {
  color: var(--text-tertiary);
}

.transcript-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 4px;
}

.word-count {
  font-size: 0.8rem;
  color: var(--text-tertiary);
}

.icon-btn {
  background: transparent;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  padding: 8px;
  border-radius: 8px;
  transition: var(--transition-smooth);
  display: flex;
  align-items: center;
  justify-content: center;
}

.icon-btn:hover {
  color: var(--error);
  background: rgba(224, 92, 92, 0.1);
}

/* Tone Selector */
.tone-selector {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.tone-pills {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.tone-pill {
  padding: 8px 16px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 24px;
  color: var(--text-secondary);
  font-family: var(--font-ui);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition-smooth);
  flex: 0 1 auto;
}

.tone-pill:hover {
  border-color: var(--accent);
  color: var(--text-primary);
}

.tone-pill.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--bg-primary);
}

/* Buttons */
.primary-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 24px;
  background: var(--accent);
  border: none;
  border-radius: 40px;
  color: var(--bg-primary);
  font-family: var(--font-ui);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-smooth);
  width: 100%;
  box-shadow: 0 4px 12px var(--accent-glow);
}

.primary-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px var(--accent-glow);
}

.primary-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.secondary-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  background: transparent;
  border: 1px solid var(--border-subtle);
  border-radius: 40px;
  color: var(--text-secondary);
  font-family: var(--font-ui);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.secondary-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* Refined Entry Card */
.refine-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 20px;
  padding: 24px;
  margin-top: 8px;
  animation: slideUp 0.4s ease;
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.entry-title {
  font-family: var(--font-brand);
  font-size: clamp(1.5rem, 5vw, 1.8rem);
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 12px;
  line-height: 1.3;
}

.entry-tags {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.tag {
  padding: 4px 12px;
  background: var(--bg-surface-light);
  border-radius: 16px;
  font-size: 0.8rem;
  color: var(--accent);
  border: 1px solid var(--border-subtle);
}

.entry-content {
  font-family: var(--font-entry);
  font-size: 1.05rem;
  line-height: 1.8;
  color: var(--text-primary);
  margin-bottom: 20px;
  white-space: pre-wrap;
}

.regenerate-btn {
  margin-top: 8px;
}

/* Loading Skeleton */
.loading-skeleton {
  padding: 24px;
}

.skeleton {
  background: linear-gradient(90deg, var(--bg-surface-light) 25%, var(--bg-surface) 50%, var(--bg-surface-light) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 8px;
}

.skeleton-title {
  height: 32px;
  width: 60%;
  margin-bottom: 16px;
}

.skeleton-tags {
  height: 28px;
  width: 40%;
  margin-bottom: 24px;
}

.skeleton-line {
  height: 16px;
  margin-bottom: 12px;
  width: 100%;
}

.skeleton-line-short {
  height: 16px;
  width: 70%;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Listen Section */
.listen-section {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 20px;
  padding: 20px;
}

.section-header {
  margin-bottom: 16px;
}

.voice-selector {
  margin-bottom: 16px;
}

.voice-select {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg-primary);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  color: var(--text-primary);
  font-family: var(--font-ui);
  font-size: 0.95rem;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.voice-select:focus {
  outline: none;
  border-color: var(--accent);
}

.playback-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.play-btn, .stop-btn {
  background: var(--bg-primary);
  border: 1px solid var(--border-subtle);
  border-radius: 40px;
  padding: 12px;
  color: var(--text-primary);
  cursor: pointer;
  transition: var(--transition-smooth);
  display: flex;
  align-items: center;
  justify-content: center;
}

.play-btn {
  width: 52px;
  height: 52px;
}

.stop-btn {
  width: 40px;
  height: 40px;
}

.play-btn:hover, .stop-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.play-btn.playing {
  background: var(--accent);
  color: var(--bg-primary);
  border-color: var(--accent);
}

.progress-container {
  flex: 1;
  height: 4px;
  background: var(--bg-surface-light);
  border-radius: 2px;
  overflow: hidden;
}

.playback-progress {
  height: 100%;
  background: var(--accent);
  width: 0%;
  transition: width 0.1s linear;
  border-radius: 2px;
}

.highlighted-text-container {
  padding: 16px;
  background: var(--bg-primary);
  border-radius: 12px;
  font-family: var(--font-entry);
  font-size: 1rem;
  line-height: 1.8;
  max-height: 200px;
  overflow-y: auto;
}

.highlighted-text-container mark {
  background: var(--accent);
  color: var(--bg-primary);
  padding: 2px 0;
}

/* Export Section */
.export-section {
  display: flex;
  gap: 8px;
  padding: 8px 0 16px;
}

.export-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  color: var(--text-secondary);
  font-family: var(--font-ui);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.export-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(245, 166, 35, 0.05);
}

/* Library Tab */
.library-container {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.upload-area {
  background: var(--bg-surface);
  border: 2px dashed var(--border-subtle);
  border-radius: 24px;
  padding: 48px 24px;
  text-align: center;
  cursor: pointer;
  transition: var(--transition-smooth);
  position: relative;
}

.upload-area:hover {
  border-color: var(--accent);
  background: rgba(245, 166, 35, 0.02);
}

.upload-area.dragover {
  border-color: var(--accent);
  background: rgba(245, 166, 35, 0.05);
}

.upload-area svg {
  color: var(--text-tertiary);
  margin-bottom: 16px;
}

.upload-text {
  font-size: 1.1rem;
  font-weight: 500;
  margin-bottom: 8px;
}

.upload-subtext {
  font-size: 0.9rem;
  color: var(--text-tertiary);
}

.file-input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}

.extracted-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 20px;
  padding: 20px;
}

.extracted-text {
  font-family: var(--font-entry);
  font-size: 1rem;
  line-height: 1.8;
  color: var(--text-primary);
  max-height: 300px;
  overflow-y: auto;
  padding: 12px;
  background: var(--bg-primary);
  border-radius: 12px;
  white-space: pre-wrap;
}

/* Bottom Navigation */
.bottom-nav {
  display: flex;
  justify-content: center;
  gap: 20px;
  padding: 12px 20px 20px;
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-primary);
  position: sticky;
  bottom: 0;
  margin-top: auto;
}

.nav-tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 24px;
  background: transparent;
  border: none;
  color: var(--text-tertiary);
  font-family: var(--font-ui);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition-smooth);
  border-radius: 40px;
}

.nav-tab:hover {
  color: var(--text-secondary);
}

.nav-tab.active {
  color: var(--accent);
  background: rgba(245, 166, 35, 0.08);
}

.nav-tab svg {
  width: 20px;
  height: 20px;
}

/* Toast */
.toast-container {
  position: fixed;
  bottom: 100px;
  right: 20px;
  left: 20px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  pointer-events: none;
  z-index: 1000;
}

.toast {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 12px 20px;
  color: var(--text-primary);
  font-size: 0.9rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
  pointer-events: auto;
  animation: slideInRight 0.3s ease;
  max-width: 320px;
}

.toast.success {
  border-left: 4px solid var(--success);
}

.toast.error {
  border-left: 4px solid var(--error);
}

@keyframes slideInRight {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}

/* Utilities */
.hidden {
  display: none !important;
}

/* Mobile Adjustments */
@media (max-width: 480px) {
  .app-container {
    padding: 0 16px;
  }
  
  .app-header {
    padding: 20px 0 16px;
  }
  
  .capture-container {
    gap: 20px;
  }
  
  .tone-pills {
    justify-content: center;
  }
  
  .tone-pill {
    padding: 6px 14px;
    font-size: 0.85rem;
  }
  
  .export-section {
    flex-wrap: wrap;
  }
  
  .export-btn {
    flex: 1 1 calc(50% - 4px);
  }
  
  .bottom-nav {
    padding: 8px 16px 16px;
  }
}

/* Error Message */
.error-message {
  background: rgba(224, 92, 92, 0.1);
  border: 1px solid var(--error);
  border-radius: 12px;
  padding: 12px 16px;
  color: var(--error);
  font-size: 0.9rem;
  text-align: center;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: var(--bg-surface);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb {
  background: var(--text-tertiary);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-secondary);
}