/* ─── Reset & Base ──────────────────────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  /* Orchestrato UI -- Off-White Zen Theme */
  --color-bg: #F5F5EE;
  --color-surface: #F0F0F0;
  --color-border: #D0D0D0;
  --color-hover-surface: #E0E0D0;
  --color-text: #1A1A1A;
  --color-text-muted: #606060;
  --color-text-light: #A0A0A0;
  --color-accent: #E05A20;
  --color-accent-hover: #C04010;
  --color-category-header: #C0B070;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.06), 0 2px 4px -2px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.08);
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-mono: 'SF Mono', 'Fira Code', 'Fira Mono', 'Roboto Mono', monospace;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.6;
  min-height: 100vh;
}

/* ─── Header ────────────────────────────────────────────────────────────────── */
.header {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  padding: 2.5rem 1rem;
  text-align: center;
}

.header-inner {
  max-width: 600px;
  margin: 0 auto;
}

.logo {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 0.25rem;
  color: var(--color-text);
}

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

/* ─── Container ─────────────────────────────────────────────────────────────── */
.container {
  max-width: 800px;
  margin: 0 auto;
  padding: 1.5rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* ─── Cards ─────────────────────────────────────────────────────────────────── */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
}

.card-title {
  font-size: 1.125rem;
  font-weight: 600;
  margin-bottom: 1rem;
  color: var(--color-text);
}

/* ─── Upload Zone ───────────────────────────────────────────────────────────── */
.upload-zone {
  border: 2px dashed var(--color-border);
  border-radius: var(--radius-md);
  padding: 2rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-bottom: 0.75rem;
}

.upload-zone:hover,
.upload-zone-active {
  border-color: var(--color-accent);
  background: var(--color-hover-surface);
}

.upload-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.upload-icon {
  color: var(--color-text-light);
}

.upload-text {
  font-size: 0.95rem;
  color: var(--color-text);
}

.upload-hint {
  font-size: 0.8rem;
  color: var(--color-text-muted);
}

/* ─── File Info ─────────────────────────────────────────────────────────────── */
.file-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--color-hover-surface);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.75rem;
  margin-bottom: 0.75rem;
  font-size: 0.85rem;
}

.file-name {
  color: var(--color-accent);
  font-weight: 500;
}

/* ─── Textarea ──────────────────────────────────────────────────────────────── */
.textarea-wrapper {
  position: relative;
}

#text-input {
  width: 100%;
  min-height: 160px;
  padding: 0.875rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  font-size: 0.95rem;
  line-height: 1.6;
  resize: vertical;
  transition: border-color 0.2s, box-shadow 0.2s;
  color: var(--color-text);
  background: var(--color-bg);
}

#text-input:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(224, 90, 32, 0.1);
}

#text-input::placeholder {
  color: var(--color-text-light);
}

.textarea-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 0.5rem;
  padding: 0 0.25rem;
}

.char-count {
  font-size: 0.8rem;
  color: var(--color-text-muted);
}

.char-count-warning {
  color: var(--color-accent) !important;
  font-weight: 500;
}

.textarea-actions {
  display: flex;
  gap: 0.5rem;
}

/* ─── Chunk Preview ─────────────────────────────────────────────────────────── */
.chunk-preview {
  margin-top: 0.75rem;
  padding: 0.625rem 0.875rem;
  background: var(--color-hover-surface);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
}

.chunk-info {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.warning-text {
  color: var(--color-accent);
  font-weight: 500;
}

/* ─── Settings Grid ─────────────────────────────────────────────────────────── */
.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
}

@media (max-width: 600px) {
  .settings-grid {
    grid-template-columns: 1fr;
  }
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.form-group.full-width {
  grid-column: 1 / -1;
}

.form-group label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--color-text);
}

.form-group select,
.form-group input[type="text"] {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  color: var(--color-text);
  background: var(--color-bg);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group select:focus,
.form-group input[type="text"]:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(224, 90, 32, 0.1);
}

.form-group select optgroup {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--color-category-header);
  font-style: normal;
  letter-spacing: 0.05em;
}

.form-group select option {
  font-size: 0.9rem;
  font-weight: 400;
  color: var(--color-text);
  padding: 0.25rem 0;
}

.model-desc {
  font-size: 0.75rem;
  color: var(--color-text-muted);
}

.voice-meta {
  font-size: 0.75rem;
  color: var(--color-text-muted);
}

/* ─── Range Slider ──────────────────────────────────────────────────────────── */
input[type="range"] {
  width: 100%;
  height: 6px;
  -webkit-appearance: none;
  appearance: none;
  background: var(--color-border);
  border-radius: 3px;
  outline: none;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--color-accent);
  cursor: pointer;
  border: 2px solid var(--color-surface);
  box-shadow: var(--shadow-sm);
}

input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--color-accent);
  cursor: pointer;
  border: 2px solid var(--color-surface);
  box-shadow: var(--shadow-sm);
}

.range-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.7rem;
  color: var(--color-text-light);
}

/* ─── Capability Info ───────────────────────────────────────────────────────── */
.capability-info {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--color-border);
}

.cap-formats {
  font-size: 0.75rem;
  color: var(--color-text-muted);
}

/* ─── Buttons ───────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.625rem 1.25rem;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: var(--font-sans);
  white-space: nowrap;
}

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

.btn-primary {
  background: var(--color-accent);
  color: #fff;
  border-color: var(--color-accent);
}

.btn-primary:hover:not(:disabled) {
  background: var(--color-accent-hover);
  border-color: var(--color-accent-hover);
}

.btn-secondary {
  background: var(--color-surface);
  color: var(--color-text);
  border-color: var(--color-border);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--color-hover-surface);
}

.btn-ghost {
  background: transparent;
  color: var(--color-text-muted);
  border-color: transparent;
}

.btn-ghost:hover:not(:disabled) {
  background: var(--color-hover-surface);
  color: var(--color-text);
}

.btn-sm {
  padding: 0.375rem 0.75rem;
  font-size: 0.8rem;
}

.btn-lg {
  padding: 0.875rem 2rem;
  font-size: 1rem;
}

/* ─── Action Bar ────────────────────────────────────────────────────────────── */
.action-bar {
  display: flex;
  align-items: center;
  gap: 1rem;
}

/* ─── Progress ──────────────────────────────────────────────────────────────── */
.progress-container {
  margin-top: 1rem;
}

.progress-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.5rem;
  font-size: 0.85rem;
}

.progress-bar {
  height: 8px;
  background: var(--color-border);
  border-radius: 4px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--color-accent);
  border-radius: 4px;
  transition: width 0.3s ease;
  width: 0%;
}

.progress-detail {
  margin-top: 0.375rem;
  font-size: 0.8rem;
  color: var(--color-text-muted);
}

/* ─── Audio Player ──────────────────────────────────────────────────────────── */
.audio-player {
  background: var(--color-bg);
  border-radius: var(--radius-md);
  padding: 1rem;
  margin-bottom: 1rem;
}

.player-controls {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.player-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: var(--color-accent);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s;
}

.player-btn:hover {
  background: var(--color-accent-hover);
}

.player-progress {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.player-time {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  font-family: var(--font-mono);
  min-width: 36px;
}

.player-progress input[type="range"] {
  flex: 1;
}

.player-volume {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  color: var(--color-text-muted);
}

.player-volume input[type="range"] {
  width: 80px;
}

.download-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

/* ─── History ───────────────────────────────────────────────────────────────── */
.history-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.history-empty {
  color: var(--color-text-muted);
  font-size: 0.9rem;
  text-align: center;
  padding: 1rem;
}

.history-item {
  padding: 0.75rem;
  background: var(--color-bg);
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
}

.history-info {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 0.375rem;
  font-size: 0.8rem;
}

.history-model {
  font-weight: 600;
  color: var(--color-accent);
}

.history-voice {
  color: var(--color-text-muted);
}

.history-date {
  color: var(--color-text-light);
  margin-left: auto;
}

.history-text {
  font-size: 0.85rem;
  color: var(--color-text);
  line-height: 1.4;
}

/* ─── Toast Notifications ───────────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: toast-in 0.3s ease;
  max-width: 320px;
}

.toast-success {
  background: var(--color-text);
  color: #fff;
}

.toast-error {
  background: var(--color-accent);
  color: #fff;
}

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

.toast-exit {
  animation: toast-out 0.3s ease forwards;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateX(100%); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes toast-out {
  from { opacity: 1; transform: translateX(0); }
  to { opacity: 0; transform: translateX(100%); }
}

/* ─── Spinner ───────────────────────────────────────────────────────────────── */
.spinner {
  animation: spin 1s linear infinite;
}

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

/* ─── Utility ───────────────────────────────────────────────────────────────── */
.hidden {
  display: none !important;
}

/* ─── Footer ────────────────────────────────────────────────────────────────── */
.footer {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--color-text-light);
  font-size: 0.8rem;
}

/* ─── Responsive ────────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  .header {
    padding: 1.5rem 1rem;
  }

  .logo {
    font-size: 1.5rem;
  }

  .tagline {
    font-size: 0.875rem;
  }

  .container {
    padding: 1rem 0.75rem;
  }

  .card {
    padding: 1.25rem;
  }

  .action-bar {
    flex-direction: column;
  }

  .action-bar .btn {
    width: 100%;
  }

  .player-controls {
    flex-wrap: wrap;
  }

  .player-volume {
    width: 100%;
    justify-content: center;
  }

  .download-actions {
    flex-direction: column;
  }

  .download-actions .btn {
    width: 100%;
  }
}
