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

:root {
  --primary: #2c3e50;
  --primary-hover: #34495e;
  --accent: #3498db;
  --bg: #f5f6f8;
  --card: #ffffff;
  --text: #333;
  --text-muted: #777;
  --border: #dde1e6;
  --success: #27ae60;
  --success-hover: #219a52;
  --error: #c0392b;
  --radius: 10px;
}

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

.container {
  max-width: 580px;
  margin: 0 auto;
  padding: 2rem 1rem;
}

header {
  text-align: center;
  margin-bottom: 1.5rem;
}

header h1 {
  color: var(--primary);
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

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

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
}

/* Tabs */

.tabs {
  display: flex;
  gap: 0;
  margin-bottom: 1rem;
  background: var(--card);
  border-radius: var(--radius);
  padding: 4px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
}

.tab {
  flex: 1;
  padding: 0.55rem 1rem;
  border: none;
  border-radius: 7px;
  background: transparent;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

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

.tab.active {
  background: var(--primary);
  color: #fff;
}

.tab-panel[hidden] {
  display: none;
}

/* File upload */

.file-upload {
  text-align: center;
  margin-bottom: 1.25rem;
}

.file-label {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  border: 2px dashed var(--border);
  border-radius: 8px;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 0.95rem;
  transition: border-color 0.15s, background 0.15s;
}

.file-label:hover,
.drop-active .file-label {
  border-color: var(--accent);
  background: rgba(52, 152, 219, 0.04);
}

.file-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.file-name {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 0.4rem;
}

/* Form */

.form-row {
  display: flex;
  gap: 1rem;
}

.form-row .form-group {
  flex: 1;
}

.form-group {
  margin-bottom: 1rem;
}

.form-group > label {
  display: block;
  font-weight: 500;
  font-size: 0.85rem;
  margin-bottom: 0.25rem;
}

.form-group input[type="text"],
.form-group input[type="date"] {
  width: 100%;
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.9rem;
  font-family: inherit;
  color: var(--text);
  background: var(--card);
}

.form-group input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.15);
}

.required {
  color: var(--error);
  font-weight: 600;
}

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

.advanced-toggle {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0;
  margin-bottom: 0.75rem;
  border: none;
  background: none;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.15s;
}

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

.advanced-toggle .chevron {
  transition: transform 0.2s;
}

.advanced-toggle[aria-expanded="true"] .chevron {
  transform: rotate(180deg);
}

.advanced-panel {
  padding: 0.75rem;
  margin-bottom: 1rem;
  background: var(--bg);
  border-radius: 8px;
}

.advanced-panel .form-group:last-child {
  margin-bottom: 0;
}

.form-group input[type="number"] {
  width: 100%;
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.9rem;
  font-family: inherit;
  color: var(--text);
  background: var(--card);
}

.form-group input[type="number"]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.15);
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

/* Buttons */

.btn-primary,
.btn-success {
  display: block;
  width: 100%;
  padding: 0.7rem;
  border: none;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  transition: background 0.15s;
}

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

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

.btn-primary:disabled {
  background: var(--border);
  color: var(--text-muted);
  cursor: not-allowed;
}

.btn-success {
  background: var(--success);
  color: #fff;
  display: inline-block;
  width: auto;
  padding: 0.7rem 2rem;
}

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

/* Progress */

.progress-meta {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.5rem;
}

#progress-step {
  font-weight: 600;
  font-size: 0.95rem;
}

#progress-pct {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.progress-track {
  height: 8px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 1rem;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), #5dade2);
  border-radius: 4px;
  transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.progress-fill::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent 0%, rgba(255, 255, 255, 0.3) 50%, transparent 100%);
  animation: shimmer 1.8s ease-in-out infinite;
}

.progress-fill.done {
  background: var(--success);
  transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1), background 0.5s;
}

.progress-fill.done::after {
  animation: none;
  opacity: 0;
}

.progress-fill.errored {
  background: var(--error);
}

.progress-fill.errored::after {
  animation: none;
  opacity: 0;
}

.progress-time {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
  font-variant-numeric: tabular-nums;
}

@keyframes shimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(200%); }
}

.log {
  background: var(--bg);
  border-radius: 6px;
  padding: 0.6rem 0.75rem;
  max-height: 220px;
  overflow-y: auto;
  font-family: "SF Mono", Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 0.78rem;
  line-height: 1.7;
}

.log-entry {
  color: var(--text-muted);
}

.log-entry.error {
  color: var(--error);
  font-weight: 500;
}

/* Result */

.result-section {
  text-align: center;
}

.result-section h2 {
  color: var(--success);
  font-size: 1.15rem;
  margin-bottom: 0.3rem;
}

.result-title {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

/* Usage meters */

.usage-meter {
  margin-bottom: 1.25rem;
}

.usage-label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.35rem;
  font-size: 0.88rem;
  font-weight: 500;
}

.usage-value {
  font-size: 0.8rem;
  font-weight: 400;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.meter-track {
  height: 10px;
  background: var(--border);
  border-radius: 5px;
  overflow: hidden;
}

.meter-fill {
  height: 100%;
  width: 0%;
  border-radius: 5px;
  background: var(--accent);
  transition: width 0.5s ease-out, background 0.3s;
}

.meter-fill.warn {
  background: #e67e22;
}

.meter-fill.critical {
  background: var(--error);
}

.usage-note {
  font-size: 0.78rem;
  color: var(--text-muted);
  text-align: center;
  margin-top: 0.5rem;
}

/* Library */

.library-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.library-header h2 {
  font-size: 1.05rem;
  color: var(--primary);
}

.btn-small {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--card);
  color: var(--text-muted);
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}

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

.library-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.transcript-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0.75rem;
  background: var(--bg);
  border-radius: 8px;
  transition: background 0.1s;
}

.transcript-item:hover {
  background: #eef0f3;
}

.transcript-info {
  flex: 1;
  min-width: 0;
}

.transcript-name {
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

.transcript-actions {
  display: flex;
  gap: 0.4rem;
  flex-shrink: 0;
}

.transcript-actions a,
.transcript-actions button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.35rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--card);
  color: var(--text-muted);
  font-size: 0.78rem;
  font-family: inherit;
  text-decoration: none;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}

.transcript-actions a:hover,
.transcript-actions button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.text-muted {
  color: var(--text-muted);
  font-size: 0.9rem;
  text-align: center;
  padding: 2rem 0;
}

/* Responsive */

@media (max-width: 480px) {
  .form-row {
    flex-direction: column;
    gap: 0;
  }
  .container {
    padding: 1rem 0.75rem;
  }
}
