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

:root {
  --bg: #0a0a0f;
  --surface: #111118;
  --surface2: #1a1a24;
  --border: rgba(255,255,255,0.08);
  --border-hover: rgba(255,255,255,0.16);
  --text: #f0f0f8;
  --text-muted: #8888aa;
  --text-dim: #4a4a66;
  --accent: #7c6af7;
  --accent2: #f7936a;
  --accent3: #6af7c8;
  --gold: #f7c46a;
  --radius: 16px;
  --radius-sm: 8px;
  --font-serif: 'Instrument Serif', Georgia, serif;
  --font-sans: 'DM Sans', system-ui, sans-serif;
}

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
}

/* ─── Background Orbs ─── */
.bg-orbs { position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden; }

.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.18;
  animation: drift 20s ease-in-out infinite;
}
.orb1 { width: 600px; height: 600px; background: var(--accent); top: -200px; left: -100px; animation-delay: 0s; }
.orb2 { width: 400px; height: 400px; background: var(--accent2); bottom: -100px; right: -100px; animation-delay: -7s; }
.orb3 { width: 300px; height: 300px; background: var(--accent3); top: 40%; left: 50%; animation-delay: -14s; }

@keyframes drift {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(30px, -30px) scale(1.05); }
  66% { transform: translate(-20px, 20px) scale(0.95); }
}

/* ─── Modal ─── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(0,0,0,0.85);
  backdrop-filter: blur(12px);
  display: flex; align-items: center; justify-content: center;
  padding: 1rem;
}
.modal-overlay.hidden { display: none; }

.modal-box {
  background: var(--surface);
  border: 1px solid var(--border-hover);
  border-radius: 24px;
  padding: 2.5rem;
  max-width: 460px;
  width: 100%;
  text-align: center;
  animation: modalIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.8) translateY(20px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-icon { font-size: 2.5rem; margin-bottom: 1rem; }

.modal-box h2 {
  font-family: var(--font-serif);
  font-size: 1.6rem;
  margin-bottom: 0.5rem;
  color: var(--text);
}

.modal-box p {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
  line-height: 1.6;
}

.modal-box input {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.85rem 1rem;
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
  outline: none;
  transition: border-color 0.2s;
}
.modal-box input:focus { border-color: var(--accent); }

.modal-hint {
  font-size: 0.78rem;
  color: var(--text-dim);
  margin-bottom: 1.5rem;
}
.modal-hint a { color: var(--accent); text-decoration: none; }
.modal-hint a:hover { text-decoration: underline; }

/* ─── Header ─── */
header {
  position: relative; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: 1.25rem 2rem;
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(20px);
  background: rgba(10,10,15,0.6);
  position: sticky; top: 0;
}

.logo { display: flex; align-items: center; gap: 0.5rem; }
.logo-icon { color: var(--accent); font-size: 1.2rem; }
.logo-text {
  font-family: var(--font-serif);
  font-size: 1.05rem;
  color: var(--text);
  letter-spacing: -0.02em;
}

.header-actions { display: flex; align-items: center; gap: 0.75rem; }

.model-badge {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--accent3);
  background: rgba(106,247,200,0.1);
  border: 1px solid rgba(106,247,200,0.2);
  padding: 0.3rem 0.75rem;
  border-radius: 999px;
}

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-size: 0.8rem;
  padding: 0.4rem 0.9rem;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-ghost:hover { border-color: var(--border-hover); color: var(--text); }

/* ─── Main ─── */
main {
  position: relative; z-index: 1;
  max-width: 860px;
  margin: 0 auto;
  padding: 3rem 1.5rem 6rem;
}

/* ─── Hero ─── */
.hero { text-align: center; margin-bottom: 3rem; }

.hero-label {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--gold);
  background: rgba(247,196,106,0.1);
  border: 1px solid rgba(247,196,106,0.2);
  padding: 0.35rem 1rem;
  border-radius: 999px;
  margin-bottom: 1.5rem;
  animation: fadeUp 0.6s ease both;
}

h1 {
  font-family: var(--font-serif);
  font-size: clamp(2.2rem, 5vw, 3.6rem);
  line-height: 1.15;
  letter-spacing: -0.03em;
  color: var(--text);
  margin-bottom: 1rem;
  animation: fadeUp 0.6s 0.1s ease both;
}
h1 em { font-style: italic; color: var(--accent); }

.hero-sub {
  font-size: 1rem;
  color: var(--text-muted);
  max-width: 500px;
  margin: 0 auto;
  line-height: 1.7;
  animation: fadeUp 0.6s 0.2s ease both;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ─── Input Card ─── */
.input-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 1.75rem;
  margin-bottom: 2rem;
  animation: fadeUp 0.6s 0.3s ease both;
  transition: border-color 0.3s;
}
.input-card:focus-within { border-color: var(--border-hover); }

/* ─── Tabs ─── */
.tabs {
  display: flex; gap: 0.5rem;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 1rem;
}

.tab {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-size: 0.85rem;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s;
}
.tab:hover { color: var(--text); background: var(--surface2); }
.tab.active {
  color: var(--accent);
  background: rgba(124,106,247,0.1);
  border-color: rgba(124,106,247,0.3);
}

/* ─── Mode Panels ─── */
.mode-panel { display: none; }
.mode-panel.active { display: block; }

.main-input {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1rem 1.25rem;
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s;
  margin-bottom: 1rem;
}
.main-input:focus { border-color: var(--accent); }
.main-input::placeholder { color: var(--text-dim); }

.main-textarea {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1rem 1.25rem;
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 0.9rem;
  outline: none;
  resize: vertical;
  min-height: 180px;
  line-height: 1.7;
  transition: border-color 0.2s;
  margin-bottom: 1rem;
}
.main-textarea:focus { border-color: var(--accent); }
.main-textarea::placeholder { color: var(--text-dim); }

.options-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.option-group { display: flex; flex-direction: column; gap: 0.35rem; }
.option-group label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-dim); font-weight: 600; }

select {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.55rem 0.85rem;
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 0.85rem;
  outline: none;
  cursor: pointer;
  transition: border-color 0.2s;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%238888aa' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  padding-right: 2rem;
}
select:focus { border-color: var(--accent); }

/* PDF Drop Zone */
.pdf-drop {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 3rem 2rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  margin-bottom: 1rem;
}
.pdf-drop:hover { border-color: var(--accent); background: rgba(124,106,247,0.05); }
.pdf-icon { font-size: 2.5rem; margin-bottom: 0.75rem; }
.pdf-text { font-size: 1rem; color: var(--text); margin-bottom: 0.25rem; }
.pdf-sub { font-size: 0.8rem; color: var(--text-muted); }

.pdf-status {
  background: rgba(106,247,200,0.1);
  border: 1px solid rgba(106,247,200,0.2);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  font-size: 0.85rem;
  color: var(--accent3);
  margin-bottom: 1rem;
}

/* ─── Generate Button ─── */
.btn-generate {
  width: 100%;
  background: linear-gradient(135deg, var(--accent), #9f6af7);
  border: none;
  border-radius: var(--radius-sm);
  padding: 1rem;
  color: white;
  font-family: var(--font-sans);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 0.5rem;
  transition: all 0.2s;
  position: relative;
  overflow: hidden;
}
.btn-generate::before {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.1), transparent);
  opacity: 0;
  transition: opacity 0.2s;
}
.btn-generate:hover { transform: translateY(-1px); box-shadow: 0 8px 30px rgba(124,106,247,0.4); }
.btn-generate:hover::before { opacity: 1; }
.btn-generate:active { transform: translateY(0); }
.btn-generate:disabled {
  opacity: 0.6; cursor: not-allowed; transform: none;
  box-shadow: none;
}

.btn-icon { font-size: 1rem; }

.btn-generate.loading .btn-icon { animation: spin 1s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

.btn-primary {
  width: 100%;
  background: linear-gradient(135deg, var(--accent), #9f6af7);
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.9rem;
  color: white;
  font-family: var(--font-sans);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 24px rgba(124,106,247,0.4); }

/* ─── Output Section ─── */
.output-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 24px;
  overflow: hidden;
  margin-bottom: 2rem;
  animation: fadeUp 0.5s ease both;
}

.output-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  padding: 1.5rem 1.75rem;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  gap: 1rem;
}

.output-label {
  font-size: 0.72rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--accent3);
  margin-bottom: 0.25rem;
}

.output-title {
  font-family: var(--font-serif);
  font-size: 1.3rem;
  color: var(--text);
}

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

.btn-action {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-size: 0.8rem;
  padding: 0.5rem 0.85rem;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-action:hover { border-color: var(--border-hover); color: var(--text); }

.btn-pdf {
  background: rgba(247,147,106,0.1);
  border-color: rgba(247,147,106,0.3);
  color: var(--accent2);
  font-weight: 600;
}
.btn-pdf:hover { background: rgba(247,147,106,0.2); color: var(--accent2); }

/* ─── Notes Content ─── */
.notes-content {
  padding: 2rem 1.75rem;
  line-height: 1.8;
  font-size: 0.95rem;
}

.notes-content h1 {
  font-family: var(--font-serif);
  font-size: 1.8rem;
  color: var(--text);
  margin: 0 0 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
  animation: none;
}

.notes-content h2 {
  font-family: var(--font-serif);
  font-size: 1.3rem;
  color: var(--accent);
  margin: 1.75rem 0 0.75rem;
  display: flex; align-items: center; gap: 0.5rem;
}
.notes-content h2::before {
  content: '▸';
  font-size: 0.8rem;
  color: var(--accent);
}

.notes-content h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--gold);
  margin: 1.25rem 0 0.5rem;
}

.notes-content p {
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

.notes-content ul, .notes-content ol {
  padding-left: 1.5rem;
  margin-bottom: 1rem;
}

.notes-content li {
  color: var(--text-muted);
  margin-bottom: 0.4rem;
}

.notes-content li::marker { color: var(--accent); }

.notes-content strong { color: var(--text); font-weight: 600; }

.notes-content em { color: var(--accent3); font-style: italic; }

.notes-content code {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.15em 0.4em;
  font-family: 'Courier New', monospace;
  font-size: 0.85em;
  color: var(--accent2);
}

.notes-content pre {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1rem;
  overflow-x: auto;
  margin: 1rem 0;
}

.notes-content pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: 0.85rem;
}

.notes-content blockquote {
  border-left: 3px solid var(--accent);
  padding: 0.5rem 1rem;
  margin: 1rem 0;
  background: rgba(124,106,247,0.05);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.notes-content hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1.5rem 0;
}

/* Typing animation */
.typing-cursor::after {
  content: '|';
  color: var(--accent);
  animation: blink 0.7s infinite;
}
@keyframes blink { 50% { opacity: 0; } }

/* ─── Examples ─── */
.examples-section { text-align: center; animation: fadeUp 0.6s 0.5s ease both; }

.examples-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  margin-bottom: 0.75rem;
}

.chips { display: flex; flex-wrap: wrap; gap: 0.5rem; justify-content: center; }

.chip {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-size: 0.8rem;
  padding: 0.45rem 1rem;
  cursor: pointer;
  transition: all 0.2s;
}
.chip:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(124,106,247,0.08);
}

/* ─── PDF hidden preview ─── */
.pdf-preview-hidden { position: absolute; left: -9999px; top: -9999px; }

/* ─── Toast ─── */
.toast {
  position: fixed; bottom: 2rem; left: 50%; transform: translateX(-50%) translateY(100px);
  background: var(--surface);
  border: 1px solid var(--border-hover);
  border-radius: 999px;
  padding: 0.65rem 1.25rem;
  font-size: 0.85rem;
  color: var(--text);
  z-index: 200;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  white-space: nowrap;
}
.toast.show { transform: translateX(-50%) translateY(0); }

/* ─── Responsive ─── */
@media (max-width: 600px) {
  header { padding: 1rem; }
  main { padding: 2rem 1rem 4rem; }
  .output-header { flex-direction: column; }
  .options-row { grid-template-columns: 1fr; }
  .tabs { flex-wrap: wrap; }
}
