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

:root {
  --bg: #0f0f0f;
  --surface: #1a1a1a;
  --border: #2a2a2a;
  --text: #e5e5e5;
  --text-dim: #888;
  --accent: #6366f1;
  --accent-glow: rgba(99, 102, 241, 0.3);
  --success: #22c55e;
  --error: #ef4444;
  --radius: 12px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.screen { display: none; width: 100%; max-width: 520px; padding: 20px; }
.screen.active { display: flex; flex-direction: column; align-items: center; }
.hidden { display: none !important; }

/* Login */
.login-container { text-align: center; margin-top: 20vh; }
.login-title { font-size: 2rem; font-weight: 700; letter-spacing: -0.02em; }
.login-subtitle { color: var(--text-dim); margin-top: 4px; font-size: 0.9rem; }

.pin-display {
  display: flex; gap: 12px; justify-content: center;
  margin: 32px 0 8px;
}
.pin-dot {
  width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid var(--border); transition: all 0.15s;
}
.pin-dot.filled { background: var(--accent); border-color: var(--accent); }
.pin-error { color: var(--error); font-size: 0.85rem; min-height: 20px; margin-bottom: 8px; }

.pin-pad {
  display: grid; grid-template-columns: repeat(3, 72px);
  gap: 10px; justify-content: center; margin-top: 16px;
}
.pin-key {
  width: 72px; height: 52px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface);
  color: var(--text); font-size: 1.2rem; cursor: pointer;
  transition: all 0.1s;
}
.pin-key:active { background: var(--accent); border-color: var(--accent); transform: scale(0.95); }

/* Header */
header { width: 100%; text-align: center; padding: 24px 0 16px; }
header h1 { font-size: 1.5rem; font-weight: 700; }
.header-sub { font-size: 0.75rem; color: var(--text-dim); margin-top: 2px; }

/* Upload area */
.upload-area {
  width: 100%; padding: 48px 24px; border: 2px dashed var(--border);
  border-radius: var(--radius); text-align: center; cursor: pointer;
  transition: all 0.2s;
}
.upload-area:hover, .upload-area.dragover {
  border-color: var(--accent); background: rgba(99,102,241,0.05);
}
.upload-icon { color: var(--text-dim); margin-bottom: 12px; }
.upload-text { font-size: 1rem; margin-bottom: 6px; }
.upload-formats { font-size: 0.8rem; color: var(--text-dim); }

/* Progress */
.progress-section { width: 100%; margin-top: 24px; }
.file-info { display: flex; justify-content: space-between; margin-bottom: 12px; }
.file-name { font-weight: 500; font-size: 0.9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 70%; }
.file-size { color: var(--text-dim); font-size: 0.85rem; }

.progress-bar-container {
  width: 100%; height: 8px; background: var(--surface);
  border-radius: 4px; overflow: hidden;
}
.progress-bar {
  height: 100%; width: 0%; background: var(--accent);
  border-radius: 4px; transition: width 0.5s ease;
}

.progress-info { display: flex; justify-content: space-between; margin-top: 8px; }
.progress-status { font-size: 0.85rem; color: var(--text-dim); }
.progress-eta { font-size: 0.85rem; color: var(--text-dim); }

/* Actions section */
.actions-section { width: 100%; margin-top: 24px; }

.topic-line {
  text-align: center; margin-bottom: 20px;
}
.topic-text {
  font-size: 1.1rem; font-weight: 600;
  color: var(--text);
}

.action-cards {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 12px; margin-bottom: 20px;
}

.action-card {
  display: flex; flex-direction: column; align-items: center;
  padding: 20px 12px; border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--surface);
  color: var(--text); cursor: pointer; text-decoration: none;
  transition: all 0.15s; font-family: inherit;
}
.action-card:hover {
  border-color: var(--accent); background: rgba(99,102,241,0.08);
}
.action-card.done {
  border-color: var(--success); background: rgba(34,197,94,0.08);
}
.action-card.generating {
  border-color: var(--accent); opacity: 0.6; pointer-events: none;
}

.action-icon {
  font-size: 1.3rem; font-weight: 700; letter-spacing: 0.05em;
  margin-bottom: 8px; color: var(--accent);
}
.action-card.done .action-icon { color: var(--success); }

.action-label { font-size: 0.9rem; font-weight: 600; margin-bottom: 2px; }
.action-desc { font-size: 0.75rem; color: var(--text-dim); }

/* Generation progress */
.gen-progress {
  display: flex; align-items: center; justify-content: center;
  gap: 10px; padding: 12px; margin-bottom: 16px;
}
.gen-spinner {
  width: 18px; height: 18px; border: 2px solid var(--border);
  border-top-color: var(--accent); border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.gen-status { font-size: 0.85rem; color: var(--text-dim); }

/* Downloads */
.downloads { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }

.download-link {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 16px; border-radius: 8px;
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text); text-decoration: none; font-size: 0.85rem;
  transition: all 0.15s;
}
.download-link:hover { border-color: var(--accent); }
.download-link svg { flex-shrink: 0; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 12px 20px; border-radius: var(--radius); font-size: 0.9rem;
  font-weight: 500; text-decoration: none; cursor: pointer; border: none;
  transition: all 0.15s; font-family: inherit;
}
.btn-new {
  width: 100%; justify-content: center;
  background: var(--accent); color: white;
}
.btn-new:hover { filter: brightness(1.1); }

/* History */
.history-section { width: 100%; margin-top: 24px; }
.history-title {
  font-size: 0.85rem; font-weight: 600; color: var(--text-dim);
  text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 10px;
}
.history-list { display: flex; flex-direction: column; gap: 6px; }

.history-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; border-radius: 10px;
  background: var(--surface); border: 1px solid var(--border);
  cursor: pointer; transition: all 0.15s;
}
.history-item:hover { border-color: var(--accent); }

.history-topic {
  flex: 1; font-size: 0.85rem; font-weight: 500;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.history-date { font-size: 0.75rem; color: var(--text-dim); white-space: nowrap; }
.history-badges { display: flex; gap: 4px; }
.history-badge {
  font-size: 0.65rem; font-weight: 600; padding: 2px 5px;
  border-radius: 4px; background: var(--border); color: var(--text-dim);
}
.history-badge.active { background: rgba(34,197,94,0.15); color: var(--success); }

/* Error */
.error-section { width: 100%; margin-top: 24px; text-align: center; }
.error-message { color: var(--error); margin-bottom: 16px; font-size: 0.9rem; }
