/* ============ AIVARA STYLESHEET ============ */
:root {
  --bg: #0a0a14;
  --bg-2: #0f0f1f;
  --surface: #14142b;
  --surface-2: #1a1a35;
  --surface-3: #22224a;
  --border: #2a2a52;
  --border-2: #383866;
  --primary: #7B6BFF;
  --primary-dark: #5B4FE0;
  --primary-light: #9B8BFF;
  --primary-glow: rgba(123, 107, 255, 0.4);
  --text: #F0F0FF;
  --text-2: #C0C0E0;
  --muted: #7A7AA5;
  --success: #4ade80;
  --warning: #fbbf24;
  --danger: #f87171;
  --gradient: linear-gradient(135deg, #7B6BFF 0%, #5B4FE0 100%);
  --gradient-text: linear-gradient(135deg, #9B8BFF 0%, #5B4FE0 50%, #7B6BFF 100%);
  --gradient-bg: radial-gradient(ellipse at top, #1a1a3a 0%, #0a0a14 60%);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 20px 50px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 40px rgba(123, 107, 255, 0.3);
  --r-sm: 8px; --r-md: 12px; --r-lg: 16px; --r-xl: 24px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: var(--bg); }
*::-webkit-scrollbar-thumb { background: var(--border); border-radius: 5px; }
*::-webkit-scrollbar-thumb:hover { background: var(--border-2); }
html, body { height: 100%; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg); color: var(--text); line-height: 1.6;
  -webkit-font-smoothing: antialiased; overflow-x: hidden;
}
#root { min-height: 100vh; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.mono { font-family: 'SF Mono', Menlo, monospace; }
.gradient-text {
  background: var(--gradient-text);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}
.full-loader {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; background: var(--bg);
}
.full-loader .spinner { width: 40px; height: 40px; border-width: 4px; }

/* BUTTONS */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 0.5rem; padding: 0.65rem 1.25rem;
  border: none; border-radius: var(--r-sm);
  font-family: inherit; font-size: 0.95rem; font-weight: 600;
  cursor: pointer; transition: all 0.2s ease;
  white-space: nowrap; text-decoration: none; color: var(--text);
}
.btn-lg { padding: 0.9rem 1.75rem; font-size: 1rem; }
.btn-sm { padding: 0.4rem 0.85rem; font-size: 0.85rem; }
.btn-block { width: 100%; }
.btn-primary {
  background: var(--gradient); color: white;
  box-shadow: 0 4px 20px var(--primary-glow);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 25px var(--primary-glow); }
.btn-secondary { background: var(--surface-2); border: 1px solid var(--border); color: var(--text); }
.btn-secondary:hover { background: var(--surface-3); border-color: var(--border-2); }
.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #ef4444; transform: translateY(-1px); box-shadow: 0 4px 16px rgba(248,113,113,0.35); }
.btn-google {
  background: white; color: #1a1a1a; width: 100%;
  padding: 0.75rem; font-weight: 600;
}
.btn-google:hover { background: #f5f5f5; }
.btn-google .g-icon {
  display: inline-flex; width: 20px; height: 20px;
  background: linear-gradient(135deg, #4285F4, #EA4335 50%, #FBBC04);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
  font-weight: 900; font-size: 18px; align-items: center; justify-content: center;
}
.btn[disabled] { opacity: 0.6; cursor: not-allowed; }

.spinner {
  display: inline-block; width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: white; border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* LANDING */
.landing-view {
  background: var(--gradient-bg);
  position: relative; overflow: hidden; min-height: 100vh;
}
.landing-bg { position: absolute; inset: 0; pointer-events: none; overflow: hidden; z-index: 0; }
.orb {
  position: absolute; border-radius: 50%;
  filter: blur(80px); opacity: 0.5;
  animation: float 20s infinite ease-in-out;
}
.orb-1 { width: 500px; height: 500px; background: #7B6BFF; top: -100px; left: -100px; }
.orb-2 { width: 400px; height: 400px; background: #5B4FE0; top: 30%; right: -100px; animation-delay: -7s; }
.orb-3 { width: 350px; height: 350px; background: #4F46E5; bottom: -100px; left: 30%; animation-delay: -14s; }
@keyframes float {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(30px, -30px) scale(1.05); }
  66% { transform: translate(-20px, 20px) scale(0.95); }
}
.landing-nav {
  position: relative; z-index: 10;
  display: flex; justify-content: space-between; align-items: center;
  padding: 1.5rem 4rem; max-width: 1400px; margin: 0 auto;
}
.brand {
  display: flex; align-items: center; gap: 0.6rem;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.4rem; font-weight: 700; letter-spacing: -0.5px;
  cursor: pointer;
}
.brand-mark { width: 32px; height: 32px; }
.brand-name {
  background: var(--gradient-text);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}
.nav-links { display: flex; align-items: center; gap: 1.5rem; }
.nav-links a {
  color: var(--text-2); text-decoration: none;
  font-weight: 500; font-size: 0.95rem; transition: color 0.2s;
}
.nav-links a:hover { color: var(--text); }

.hero {
  position: relative; z-index: 1;
  display: grid; grid-template-columns: 1.1fr 1fr;
  gap: 4rem; align-items: center;
  max-width: 1400px; margin: 0 auto;
  padding: 4rem 4rem 6rem;
}
.hero-pill {
  display: inline-flex; align-items: center; gap: 0.5rem;
  padding: 0.4rem 1rem;
  background: rgba(123, 107, 255, 0.1);
  border: 1px solid rgba(123, 107, 255, 0.3);
  border-radius: 100px;
  font-size: 0.85rem; color: var(--primary-light); font-weight: 500;
  margin-bottom: 1.5rem;
}
.pill-dot {
  width: 6px; height: 6px;
  background: var(--primary-light);
  border-radius: 50%;
  box-shadow: 0 0 8px var(--primary-light);
  animation: pulse 2s infinite;
}
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }
.hero-title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: clamp(2.5rem, 6vw, 4.5rem);
  font-weight: 700; line-height: 1.05;
  letter-spacing: -2px; margin-bottom: 1.5rem;
}
.hero-sub {
  font-size: 1.15rem; color: var(--text-2);
  max-width: 540px; margin-bottom: 2.5rem; line-height: 1.6;
}
.hero-cta { display: flex; gap: 1rem; margin-bottom: 2.5rem; flex-wrap: wrap; }
.hero-trust { display: flex; gap: 2rem; flex-wrap: wrap; }
.trust-item { display: flex; align-items: center; gap: 0.5rem; color: var(--text-2); font-size: 0.9rem; }
.check { color: var(--success); font-weight: 700; }

.hero-art { position: relative; height: 500px; }
.floating-card {
  position: absolute;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(20px);
  animation: float-card 6s ease-in-out infinite;
}
.card-1 { top: 0; left: 0; width: 280px; height: 360px; z-index: 3; }
.card-2 { top: 50%; right: 0; width: 240px; z-index: 2; animation-delay: -2s; }
.card-3 { bottom: 0; left: 25%; width: 220px; z-index: 1; animation-delay: -4s; }
@keyframes float-card {
  0%, 100% { transform: translateY(0) rotate(-1deg); }
  50% { transform: translateY(-12px) rotate(1deg); }
}
.mini-doc { display: flex; flex-direction: column; gap: 0.6rem; height: 100%; }
.mini-doc-header { height: 20px; background: var(--gradient); border-radius: 4px; width: 60%; }
.mini-doc-line { height: 8px; background: var(--border); border-radius: 4px; }
.mini-doc-line.short { width: 60%; }
.mini-doc-stamp {
  margin-top: auto; padding: 0.5rem 1rem;
  background: rgba(74, 222, 128, 0.15);
  color: var(--success);
  border: 1px dashed var(--success);
  border-radius: 6px;
  font-weight: 700; font-size: 0.85rem; letter-spacing: 2px;
  text-align: center; align-self: flex-start;
}
.ai-bubble { display: flex; flex-direction: column; gap: 0.75rem; }
.ai-typing { display: flex; gap: 4px; }
.ai-typing span {
  width: 8px; height: 8px;
  background: var(--primary-light);
  border-radius: 50%;
  animation: typing 1.4s infinite;
}
.ai-typing span:nth-child(2) { animation-delay: 0.2s; }
.ai-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typing {
  0%, 60%, 100% { opacity: 0.3; transform: scale(1); }
  30% { opacity: 1; transform: scale(1.2); }
}
.ai-text { color: var(--text-2); font-size: 0.9rem; }
.pdf-preview { display: flex; flex-direction: column; gap: 0.75rem; }
.pdf-tag {
  align-self: flex-start; padding: 0.25rem 0.6rem;
  background: var(--danger); color: white;
  border-radius: 4px; font-size: 0.75rem; font-weight: 700;
}
.pdf-fields { display: flex; flex-direction: column; gap: 0.5rem; }
.pdf-field {
  height: 28px; border: 1px solid var(--border);
  border-radius: 4px; background: var(--surface-2);
}
.pdf-field.filled {
  background: linear-gradient(90deg, var(--surface-2) 30%, var(--primary) 30%, var(--primary) 80%, var(--surface-2) 80%);
}

.section-title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: clamp(2rem, 4vw, 3rem);
  font-weight: 700; text-align: center;
  margin-bottom: 3rem; letter-spacing: -1px;
}
.features { position: relative; z-index: 1; max-width: 1400px; margin: 0 auto; padding: 6rem 4rem; }
.feature-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1.5rem; }
.feature-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 2rem;
  transition: all 0.3s ease;
}
.feature-card:hover { transform: translateY(-4px); border-color: var(--primary); box-shadow: var(--shadow-glow); }
.feature-icon {
  width: 56px; height: 56px;
  background: var(--gradient);
  border-radius: var(--r-md);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem;
  color: white; margin-bottom: 1.25rem;
}
.feature-card h3 { font-size: 1.2rem; margin-bottom: 0.5rem; font-weight: 600; }
.feature-card p { color: var(--text-2); font-size: 0.95rem; }

.how { position: relative; z-index: 1; max-width: 1400px; margin: 0 auto; padding: 4rem 4rem; }
.steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 2rem; }
.step {
  text-align: left; padding: 2rem;
  background: linear-gradient(135deg, var(--surface) 0%, var(--surface-2) 100%);
  border-radius: var(--r-lg); border: 1px solid var(--border);
}
.step-num {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 3rem; font-weight: 700;
  background: var(--gradient-text);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
  line-height: 1; margin-bottom: 1rem;
}
.step h3 { font-size: 1.25rem; margin-bottom: 0.5rem; }
.step p { color: var(--text-2); }
.landing-footer {
  position: relative; z-index: 1;
  display: flex; justify-content: space-between; align-items: center;
  max-width: 1400px; margin: 0 auto;
  padding: 3rem 4rem; border-top: 1px solid var(--border);
}
.footer-note { color: var(--muted); font-size: 0.9rem; }

/* APP SHELL */
.app-view {
  display: grid;
  grid-template-columns: 280px 1fr;
  background: var(--bg);
  height: 100vh;
}
.mobile-menu-btn {
  display: none;
  position: fixed; top: 1rem; left: 1rem; z-index: 60;
  width: 40px; height: 40px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-sm); color: var(--text);
  font-size: 1.2rem; cursor: pointer;
}
.mobile-overlay {
  display: none;
  position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 49;
}
.sidebar {
  background: var(--bg-2);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  padding: 1.5rem 1rem; overflow-y: auto;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 0.6rem;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.3rem; font-weight: 700;
  padding: 0.5rem 0.75rem; margin-bottom: 1.25rem;
  cursor: pointer;
}
.sidebar-brand .brand-mark { width: 28px; height: 28px; }
.sidebar-brand .brand-name {
  background: var(--gradient-text);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}
.new-doc-btn { margin-bottom: 1.5rem; }
.sidebar-nav { display: flex; flex-direction: column; gap: 0.25rem; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.7rem 0.85rem;
  border-radius: var(--r-sm);
  color: var(--text-2); text-decoration: none;
  font-weight: 500; font-size: 0.95rem;
  cursor: pointer; transition: all 0.2s;
}
.nav-item:hover { background: var(--surface); color: var(--text); }
.nav-item.active {
  background: var(--surface); color: var(--text);
  box-shadow: inset 3px 0 0 var(--primary);
}
.nav-icon { font-size: 1.1rem; flex-shrink: 0; }

.sidebar-footer { margin-top: auto; padding-top: 1rem; border-top: 1px solid var(--border); }
.user-card {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.6rem; border-radius: var(--r-sm); position: relative;
}
.user-card:hover { background: var(--surface); }
.user-avatar {
  width: 36px; height: 36px;
  border-radius: 50%; background: var(--gradient);
  color: white; display: flex;
  align-items: center; justify-content: center;
  font-weight: 700; flex-shrink: 0; background-size: cover;
}
.user-info { flex: 1; min-width: 0; }
.user-name { font-weight: 600; font-size: 0.9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-email { font-size: 0.8rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-menu-btn {
  background: transparent; border: none; color: var(--text-2);
  padding: 0.3rem; border-radius: 4px; cursor: pointer;
  font-size: 1.2rem;
}
.user-menu-btn:hover { background: var(--surface-2); }
.user-menu {
  position: absolute; bottom: 100%; left: 0; right: 0;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-sm);
  margin-bottom: 0.5rem; overflow: hidden;
  box-shadow: var(--shadow-md); z-index: 5;
}
.user-menu a {
  display: block; padding: 0.7rem 1rem;
  color: var(--text-2); text-decoration: none; font-size: 0.9rem;
}
.user-menu a:hover { background: var(--surface-2); color: var(--text); }

.main-content { overflow-y: auto; padding: 2.5rem 3rem; }
.route-page { max-width: 1400px; margin: 0 auto; }
.page-header {
  display: flex; justify-content: space-between; align-items: flex-end;
  margin-bottom: 2.5rem; gap: 2rem; flex-wrap: wrap;
}
.page-title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 2.2rem; font-weight: 700;
  letter-spacing: -1px; margin-bottom: 0.4rem;
}
.page-sub { color: var(--text-2); font-size: 1rem; }
.search-input {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 0.65rem 1rem; font-size: 0.95rem;
  color: var(--text); width: 280px; font-family: inherit;
}
.search-input:focus { outline: none; border-color: var(--primary); }

/* QUICK ACTIONS / DASHBOARD */
.quick-actions {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem; margin-bottom: 2.5rem;
}
.quick-card {
  display: flex; align-items: center; gap: 1rem;
  padding: 1.25rem;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-md);
  cursor: pointer; transition: all 0.2s;
  text-align: left; font-family: inherit; color: inherit;
}
.quick-card:hover { transform: translateY(-2px); border-color: var(--primary); box-shadow: var(--shadow-glow); }
.quick-icon {
  width: 48px; height: 48px;
  border-radius: var(--r-sm);
  display: flex; align-items: center; justify-content: center;
  color: white; flex-shrink: 0; font-size: 1.5rem;
}
.quick-icon.purple { background: var(--gradient); }
.quick-icon.blue { background: linear-gradient(135deg, #4F46E5, #2563EB); }
.quick-icon.green { background: linear-gradient(135deg, #10B981, #059669); }
.quick-card h3 { font-size: 1rem; margin-bottom: 0.2rem; }
.quick-card p { font-size: 0.85rem; color: var(--muted); }

.dashboard-grid {
  display: grid; grid-template-columns: 1.4fr 1fr;
  gap: 1.5rem;
}

/* PANEL */
.panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 1.5rem;
}
.panel-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 1.25rem; flex-wrap: wrap; gap: 1rem;
}
.panel-header h2 {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.15rem; font-weight: 600;
}

.recent-list, .template-list { display: flex; flex-direction: column; gap: 0.5rem; }
.template-item, .recent-item {
  display: flex; align-items: center; gap: 1rem;
  padding: 0.85rem;
  background: var(--surface-2); border: 1px solid transparent;
  border-radius: var(--r-sm);
  cursor: pointer; font-family: inherit; color: inherit;
  text-align: left; width: 100%; transition: all 0.2s;
}
.template-item:hover, .recent-item:hover {
  border-color: var(--primary); background: var(--surface-3);
}
.template-emoji { font-size: 1.5rem; }
.template-name { font-weight: 600; font-size: 0.95rem; margin-bottom: 0.15rem; }
.recent-item-icon {
  width: 36px; height: 36px;
  background: var(--gradient);
  border-radius: var(--r-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem; flex-shrink: 0;
}
.recent-item-info { flex: 1; min-width: 0; }
.recent-item-title { font-weight: 600; font-size: 0.95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.recent-item-meta { font-size: 0.8rem; color: var(--muted); }

.empty-state { text-align: center; padding: 2rem 1rem; color: var(--muted); }
.empty-state.full { padding: 4rem 1rem; }
.empty-icon { font-size: 3rem; margin-bottom: 0.75rem; }
.empty-state h3 { color: var(--text-2); margin-bottom: 0.5rem; }
.empty-state p:not(.muted) { color: var(--text-2); margin-bottom: 0.25rem; }

/* GENERATOR */
.generator-layout {
  display: grid; grid-template-columns: 1fr 1.5fr;
  gap: 1.5rem;
  height: calc(100vh - 240px); min-height: 600px;
}
.generator-input-panel, .generator-output-panel { min-height: 0; }
.generator-input-panel .panel { height: 100%; overflow-y: auto; }
.doc-editor-panel { display: flex; flex-direction: column; height: 100%; padding: 0; }
.doc-editor-panel > .panel-header { padding: 1.25rem 1.5rem; border-bottom: 1px solid var(--border); margin-bottom: 0; }
.doc-title-input {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.15rem; font-weight: 600;
  background: transparent; border: none; color: var(--text);
  flex: 1;
}
.doc-title-input:focus { outline: none; }
.doc-actions { display: flex; gap: 0.5rem; align-items: center; }
.editor-toolbar {
  display: flex; gap: 0.25rem;
  padding: 0.6rem 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  flex-wrap: wrap; align-items: center;
}
.editor-toolbar button {
  background: transparent; border: none; color: var(--text-2);
  padding: 0.4rem 0.65rem;
  border-radius: 4px; cursor: pointer;
  font-family: inherit; font-size: 0.85rem; min-width: 32px;
}
.editor-toolbar button:hover { background: var(--surface-3); color: var(--text); }
.toolbar-sep { width: 1px; height: 20px; background: var(--border); margin: 0 0.25rem; }
.doc-editor {
  flex: 1; overflow-y: auto;
  padding: 2.5rem 3rem;
  background: var(--bg-2);
  color: var(--text);
  font-family: 'Inter', serif;
  font-size: 0.95rem; line-height: 1.7; min-height: 0;
}
.doc-editor:focus { outline: none; }
.doc-editor h1 { font-family: 'Space Grotesk', sans-serif; font-size: 1.6rem; margin: 1.25rem 0 0.75rem; font-weight: 700; }
.doc-editor h2 { font-family: 'Space Grotesk', sans-serif; font-size: 1.25rem; margin: 1rem 0 0.5rem; font-weight: 600; }
.doc-editor h3 { font-size: 1.1rem; margin: 0.75rem 0 0.4rem; font-weight: 600; }
.doc-editor p { margin: 0.6rem 0; }
.doc-editor ul, .doc-editor ol { padding-left: 1.5rem; margin: 0.5rem 0; }
.doc-editor strong { font-weight: 700; color: var(--text); }
.editor-status {
  padding: 0.6rem 1.5rem;
  border-top: 1px solid var(--border);
  display: flex; justify-content: space-between;
  font-size: 0.8rem; color: var(--muted);
}

.dropdown { position: relative; display: inline-block; }
.dropdown-menu {
  position: absolute; top: 100%; right: 0;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-sm);
  margin-top: 0.25rem; min-width: 180px;
  box-shadow: var(--shadow-md); z-index: 10;
}
.dropdown-menu a {
  display: block; padding: 0.65rem 1rem;
  color: var(--text-2); text-decoration: none; font-size: 0.9rem;
}
.dropdown-menu a:hover { background: var(--surface-2); color: var(--text); }

/* PDF EDITOR */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--r-lg);
  padding: 4rem 2rem; text-align: center;
  cursor: pointer; transition: all 0.2s;
  background: var(--surface);
}
.upload-zone:hover, .upload-zone.dragover {
  border-color: var(--primary);
  background: var(--surface-2);
}
.upload-icon {
  width: 80px; height: 80px;
  background: var(--gradient);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: white; margin: 0 auto 1.25rem;
  font-size: 2rem;
}
.pdf-workspace {
  display: flex; flex-direction: column; gap: 1rem;
  height: calc(100vh - 240px);
}
.pdf-toolbar {
  display: flex; justify-content: space-between; gap: 1rem;
  padding: 0.75rem 1rem;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-md);
  align-items: center; flex-wrap: wrap;
}
.pdf-tools { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.pdf-tool {
  display: flex; align-items: center; gap: 0.4rem;
  padding: 0.5rem 0.85rem;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 6px; color: var(--text-2);
  cursor: pointer; font-family: inherit;
  font-size: 0.85rem; font-weight: 500;
}
.pdf-tool:hover { background: var(--surface-3); color: var(--text); }
.pdf-tool.active { background: var(--gradient); color: white; border-color: transparent; }
.pdf-actions { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.pdf-page-info { color: var(--muted); font-size: 0.85rem; padding: 0 0.5rem; }
.pdf-canvas-wrap {
  flex: 1; overflow: auto;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 2rem;
  display: flex; justify-content: center; align-items: flex-start;
}
.pdf-page-container { position: relative; background: white; box-shadow: var(--shadow-lg); }
.pdf-overlay { position: absolute; inset: 0; pointer-events: none; }
.pdf-overlay.tool-active { pointer-events: auto; cursor: crosshair; }
.pdf-annotation { position: absolute; pointer-events: auto; user-select: none; }
.pdf-annotation.text {
  border: 1px dashed transparent;
  border-radius: 3px; min-width: 60px; padding: 0;
}
.pdf-annotation.text:hover { border-color: var(--primary); }
.pdf-annotation.text:focus-within { border-color: var(--primary); background: rgba(255,255,255,0.6); }
.pdf-text-editor {
  font-family: serif; color: black;
  background: transparent; padding: 2px 6px;
  min-width: 60px; outline: none; cursor: text;
  white-space: pre-wrap;
}
.pdf-text-editor:empty::before {
  content: attr(data-placeholder);
  color: rgba(0,0,0,0.4); font-style: italic; pointer-events: none;
}
.pdf-move-handle {
  position: absolute; top: -10px; left: -10px;
  width: 18px; height: 18px;
  background: var(--primary); color: white;
  border-radius: 50%;
  font-size: 9px; line-height: 18px; text-align: center;
  cursor: move; opacity: 0;
  transition: opacity 0.15s;
  font-weight: 700; letter-spacing: -1px; user-select: none;
}
.pdf-annotation:hover .pdf-move-handle,
.pdf-annotation:focus-within .pdf-move-handle { opacity: 1; }
.pdf-annotation.checkmark {
  font-size: 24px; font-weight: bold; color: black;
  cursor: move; padding: 2px 4px;
}
.pdf-annotation.signature { cursor: move; }
.pdf-annotation.signature img { display: block; max-width: 200px; pointer-events: none; }
.pdf-annotation .delete-btn {
  position: absolute; top: -10px; right: -10px;
  width: 18px; height: 18px;
  background: var(--danger); color: white;
  border: none; border-radius: 50%;
  font-size: 12px; line-height: 1;
  cursor: pointer; opacity: 0;
  transition: opacity 0.2s; z-index: 2;
}
.pdf-annotation:hover .delete-btn,
.pdf-annotation:focus-within .delete-btn { opacity: 1; }

/* LIBRARY */
.library-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1.25rem;
}
.lib-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 1.25rem;
  cursor: pointer; transition: all 0.2s; position: relative;
}
.lib-card:hover {
  transform: translateY(-2px); border-color: var(--primary);
  box-shadow: var(--shadow-glow);
}
.lib-card-icon {
  width: 48px; height: 48px;
  background: var(--gradient);
  border-radius: var(--r-sm);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 1rem; font-size: 1.5rem;
}
.lib-card-title { font-weight: 600; margin-bottom: 0.4rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lib-card-meta { font-size: 0.8rem; color: var(--muted); display: flex; justify-content: space-between; }
.lib-card-actions {
  position: absolute; top: 0.75rem; right: 0.75rem;
  display: flex; gap: 0.25rem; opacity: 0; transition: opacity 0.2s;
}
.lib-card:hover .lib-card-actions { opacity: 1; }
.lib-delete {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 4px; padding: 0.3rem 0.5rem;
  color: var(--text-2); cursor: pointer; font-size: 0.9rem;
}
.lib-delete:hover { background: var(--danger); color: white; border-color: var(--danger); }

/* SETTINGS */
.settings-grid {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}
.ai-status {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: rgba(74,222,128,0.08);
  border: 1px solid rgba(74,222,128,0.25);
  border-radius: var(--r-sm);
  margin-bottom: 1rem; font-size: 0.9rem;
}
.status-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.status-dot.online { background: var(--success); box-shadow: 0 0 8px var(--success); }
.setting-row {
  display: flex; justify-content: space-between;
  padding: 0.75rem 0; border-bottom: 1px solid var(--border);
}
.setting-row:last-of-type { border-bottom: none; }
.setting-actions { display: flex; gap: 0.5rem; margin-top: 1rem; }
.danger-panel {
  border-color: rgba(248,113,113,0.3);
  grid-column: 1 / -1;
}
.danger-panel .panel-header h2 { color: var(--danger); }

/* INPUTS */
.input-group { display: flex; flex-direction: column; gap: 0.4rem; margin-bottom: 1rem; }
.input-group label { font-size: 0.85rem; font-weight: 600; color: var(--text-2); }
.input-group input,
.input-group textarea,
.input-group select,
.panel select {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 0.75rem 1rem;
  font-family: inherit; font-size: 0.95rem;
  color: var(--text); transition: all 0.2s;
  width: 100%;
}
.input-group input:focus,
.input-group textarea:focus,
.input-group select:focus,
.panel select:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}
.input-group textarea { resize: vertical; min-height: 80px; font-family: inherit; }

/* MODAL */
.modal {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center; padding: 1rem;
}
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.7); backdrop-filter: blur(8px); }
.modal-content {
  position: relative;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-xl); padding: 2.5rem;
  width: 100%; max-width: 440px;
  box-shadow: var(--shadow-lg);
  animation: modal-in 0.3s ease;
}
.modal-content.modal-wide {
  max-width: 720px; max-height: 85vh;
  display: flex; flex-direction: column;
}
@keyframes modal-in {
  from { opacity: 0; transform: translateY(20px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.modal-close {
  position: absolute; top: 1rem; right: 1rem;
  width: 32px; height: 32px;
  background: transparent; border: none;
  color: var(--text-2); font-size: 1.5rem;
  cursor: pointer; border-radius: 6px;
}
.modal-close:hover { background: var(--surface-2); color: var(--text); }
.modal-actions {
  display: flex; gap: 0.75rem;
  justify-content: flex-end; margin-top: 1rem;
}
.auth-modal { text-align: center; }
.auth-logo {
  width: 80px; height: 80px;
  margin-bottom: 1rem;
  filter: drop-shadow(0 0 24px rgba(123,107,255,0.5));
}
.auth-title { font-size: 1.6rem; margin-bottom: 0.4rem; font-family: 'Space Grotesk', sans-serif; }
.auth-sub { color: var(--text-2); margin-bottom: 1.75rem; font-size: 0.95rem; }
.divider {
  display: flex; align-items: center;
  margin: 1.5rem 0; color: var(--muted); font-size: 0.85rem;
}
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.divider span { padding: 0 1rem; }
.auth-form { text-align: left; display: flex; flex-direction: column; gap: 1rem; }
.auth-error {
  padding: 0.75rem;
  background: rgba(248,113,113,0.1);
  border: 1px solid rgba(248,113,113,0.3);
  border-radius: 8px;
  color: var(--danger); font-size: 0.85rem;
}
.auth-toggle {
  text-align: center; margin-top: 1.25rem;
  font-size: 0.9rem; color: var(--text-2);
}
.auth-toggle a {
  color: var(--primary-light); text-decoration: none;
  font-weight: 600; margin-left: 0.4rem;
}

.quick-prompts { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 1rem 0; }
.quick-prompts button {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 100px;
  padding: 0.4rem 0.85rem;
  color: var(--text-2); font-size: 0.85rem;
  cursor: pointer; font-family: inherit;
}
.quick-prompts button:hover {
  background: var(--surface-3); color: var(--text); border-color: var(--primary);
}

#signaturePad {
  background: white; border-radius: var(--r-sm);
  cursor: crosshair; width: 100%; max-width: 500px;
  display: block; margin: 1rem 0;
}

/* SUMMARY */
.summary-header { display: flex; align-items: center; gap: 1rem; margin-bottom: 1.5rem; }
.summary-icon {
  width: 44px; height: 44px;
  background: var(--gradient);
  border-radius: var(--r-sm);
  display: flex; align-items: center; justify-content: center;
  color: white; flex-shrink: 0; font-size: 1.3rem;
}
.summary-header h2 { font-family: 'Space Grotesk', sans-serif; font-size: 1.4rem; margin-bottom: 0.15rem; }
.summary-content {
  overflow-y: auto; flex: 1; padding-right: 0.5rem;
  font-size: 0.95rem; line-height: 1.7;
}
.summary-content h1, .summary-content h2 {
  font-family: 'Space Grotesk', sans-serif;
  margin: 1.5rem 0 0.5rem; color: var(--primary-light);
}
.summary-content h1 { font-size: 1.25rem; }
.summary-content h2 { font-size: 1.1rem; }
.summary-content h3 { font-size: 1rem; margin: 1rem 0 0.4rem; color: var(--text); }
.summary-content p { margin: 0.5rem 0; color: var(--text-2); }
.summary-content ul, .summary-content ol { padding-left: 1.5rem; margin: 0.5rem 0; color: var(--text-2); }
.summary-content li { margin: 0.25rem 0; }
.summary-content strong { color: var(--text); }
.summary-loading {
  display: flex; align-items: center; gap: 1rem;
  padding: 2rem; color: var(--text-2); justify-content: center;
}
.summary-loading .spinner {
  width: 24px; height: 24px; border-width: 3px;
  border-color: rgba(123,107,255,0.3);
  border-top-color: var(--primary-light);
}

/* TOAST */
.toast-container {
  position: fixed; bottom: 1.5rem; right: 1.5rem; z-index: 200;
  display: flex; flex-direction: column; gap: 0.5rem;
}
.toast {
  background: var(--surface); border: 1px solid var(--border);
  border-left: 3px solid var(--primary);
  padding: 0.85rem 1.25rem;
  border-radius: var(--r-sm);
  box-shadow: var(--shadow-md);
  min-width: 280px; max-width: 400px;
  display: flex; align-items: center; gap: 0.75rem;
  animation: toast-in 0.3s ease;
}
.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }
.toast.warning { border-left-color: var(--warning); }
@keyframes toast-in { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* RESPONSIVE */
@media (max-width: 1024px) {
  .hero { grid-template-columns: 1fr; padding: 2rem; }
  .hero-art { display: none; }
  .landing-nav { padding: 1rem 2rem; }
  .features, .how, .landing-footer { padding: 3rem 2rem; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .generator-layout { grid-template-columns: 1fr; height: auto; }
  .generator-input-panel .panel { height: auto; }
  .doc-editor-panel { height: 600px; }
  .settings-grid { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .app-view { grid-template-columns: 1fr; }
  .mobile-menu-btn { display: flex; align-items: center; justify-content: center; }
  .sidebar {
    position: fixed; inset: 0; right: auto;
    width: 280px; z-index: 50;
    transform: translateX(-100%);
    transition: transform 0.3s;
  }
  .sidebar.open { transform: translateX(0); }
  .mobile-overlay { display: block; }
  .main-content { padding: 4.5rem 1.5rem 1.5rem; }
  .nav-links a { display: none; }
  .landing-nav { padding: 1rem; }
  .features, .how, .landing-footer { padding: 3rem 1.5rem; flex-direction: column; gap: 1rem; }
  .pdf-toolbar { flex-direction: column; align-items: stretch; }
  .pdf-tools { justify-content: flex-start; }
  .pdf-actions { justify-content: flex-start; }
  .doc-editor { padding: 1.5rem; }
  .search-input { width: 100%; }
  .modal-content { padding: 1.5rem; }
}

/* ===== Adobe-style PDF editor: full-bleed right side ===== */
.pdf-route {
  max-width: none;
  margin: -2.5rem -3rem;
  padding: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
}
.pdf-route .page-header {
  padding: 1rem 2rem;
  margin: 0;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.pdf-route .page-title {
  font-size: 1.4rem; margin-bottom: 0.1rem;
}
.pdf-route .page-sub { font-size: 0.85rem; }
.pdf-route .pdf-workspace {
  flex: 1; height: auto;
  margin: 0; padding: 0;
  gap: 0;
}
.pdf-route .pdf-toolbar {
  border-radius: 0;
  border-left: none; border-right: none;
  border-top: none;
  flex-shrink: 0;
}
.pdf-route .pdf-canvas-wrap {
  border-radius: 0; border: none;
  flex: 1; padding: 1.5rem;
}
.pdf-route .upload-zone { margin: 2rem; }
@media (max-width: 768px) {
  .pdf-route { margin: -4.5rem -1.5rem -1.5rem; }
  .pdf-route .page-header { padding: 0.75rem 1rem 0.75rem 3.25rem; }
  .pdf-route .pdf-canvas-wrap { padding: 0.75rem; }
}

/* ===== GENERATOR 3-COLUMN LAYOUT ===== */
.generator-route {
  max-width: none;
  margin: -2.5rem -3rem;
  padding: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
}
.gen-header {
  display: flex; align-items: center; gap: 1rem;
  padding: 0.85rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-2);
  flex-shrink: 0;
}
.gen-header .doc-title-input {
  flex: 1; min-width: 0;
  background: transparent; border: none; color: var(--text);
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.15rem; font-weight: 600;
  padding: 0.4rem 0;
}
.gen-header .doc-title-input:focus { outline: none; }
.gen-header-actions { display: flex; gap: 0.5rem; align-items: center; }
.gen-saved { color: var(--success); font-size: 0.85rem; min-width: 50px; text-align: right; }

.gen-layout {
  display: grid;
  grid-template-columns: 280px 1fr 320px;
  flex: 1;
  min-height: 0;
}
.gen-insights {
  background: var(--bg-2);
  border-right: 1px solid var(--border);
  padding: 1.5rem 1.25rem;
  overflow-y: auto;
}
.insights-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 1.5rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}
.insights-title {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 600; font-size: 0.95rem;
}
.insights-score { font-weight: 700; font-size: 1.15rem; }
.insights-list { display: flex; flex-direction: column; gap: 1rem; }
.insight-row {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 0.75rem 0.85rem;
}
.insight-row-top {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 0.4rem;
}
.insight-label { font-size: 0.85rem; font-weight: 500; }
.insight-pct { font-weight: 600; font-size: 0.85rem; }
.insight-bar {
  height: 6px;
  background: var(--surface-3);
  border-radius: 3px; overflow: hidden;
}
.insight-bar-fill {
  height: 100%; transition: width 0.4s ease;
  border-radius: 3px;
}
.insight-detail { margin-top: 0.4rem; font-size: 0.75rem; }

.gen-document {
  display: flex; flex-direction: column;
  min-width: 0;
  background: #2a2a40;
  overflow: hidden;
}
.gen-document .editor-toolbar { background: var(--surface); border-bottom: 1px solid var(--border); }
.doc-paper-wrap {
  flex: 1; overflow-y: auto;
  padding: 2rem;
  display: flex; justify-content: center; align-items: flex-start;
  background: linear-gradient(180deg, #1a1a2e 0%, #0f0f1f 100%);
}
.doc-paper {
  position: relative;
  background: white;
  color: #1a1a1a;
  width: 100%; max-width: 820px;
  min-height: 100%;
  padding: 3rem 4rem;
  box-shadow: 0 10px 40px rgba(0,0,0,0.4);
  border-radius: 4px;
}
.doc-paper .doc-editor {
  background: transparent !important;
  color: #1a1a1a !important;
  padding: 0 !important;
  font-family: Georgia, 'Times New Roman', serif !important;
  font-size: 0.95rem;
  line-height: 1.7;
  outline: none;
  position: relative;
  z-index: 1;
}
.doc-paper .doc-editor h1 { color: #1a1a1a; font-family: 'Space Grotesk', sans-serif; font-size: 1.8rem; margin: 1rem 0 0.75rem; }
.doc-paper .doc-editor h2 { color: #1a1a1a; font-family: 'Space Grotesk', sans-serif; font-size: 1.35rem; margin: 1rem 0 0.5rem; }
.doc-paper .doc-editor h3 { color: #1a1a1a; font-size: 1.1rem; }
.doc-paper .doc-editor p { color: #1a1a1a; margin: 0.6rem 0; }
.doc-paper .doc-editor strong { color: #000; }
.doc-paper .doc-editor ul, .doc-paper .doc-editor ol { color: #1a1a1a; }
.doc-watermark {
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%) rotate(-30deg);
  font-size: 5rem; font-weight: 900;
  color: rgba(123,107,255,0.12);
  pointer-events: none; z-index: 0;
  font-family: 'Space Grotesk', sans-serif;
  letter-spacing: 8px; white-space: nowrap;
}
.gen-document .editor-status {
  background: var(--surface); padding: 0.5rem 1.5rem;
  border-top: 1px solid var(--border);
}

.gen-sidebar {
  background: var(--bg-2);
  border-left: 1px solid var(--border);
  padding: 1.5rem 1.25rem;
  overflow-y: auto;
  display: flex; flex-direction: column; gap: 1.5rem;
}
.gen-sidebar-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 1rem;
}
.gen-sidebar-title {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 600; font-size: 0.95rem;
  margin-bottom: 0.25rem;
}
.gen-sidebar-sub { margin-bottom: 0.75rem; }
.brand-row {
  display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem;
}
.brand-row > div { display: flex; flex-direction: column; gap: 0.4rem; }

/* PREVIEW MODAL */
.preview-modal .modal-content { padding: 0; }
.modal-preview {
  max-width: 900px !important;
  max-height: 90vh !important;
  display: flex; flex-direction: column;
  padding: 0 !important;
}
.preview-header {
  padding: 1.25rem 1.75rem 0.75rem;
  border-bottom: 1px solid var(--border);
}
.preview-header h2 { font-family: 'Space Grotesk', sans-serif; font-size: 1.3rem; margin-bottom: 0.2rem; }
.preview-paper-wrap {
  flex: 1; overflow-y: auto;
  padding: 1.5rem;
  background: var(--bg-2);
  display: flex; justify-content: center;
}
.preview-paper {
  position: relative;
  background: white;
  color: #1a1a1a;
  width: 100%; max-width: 720px;
  padding: 3rem 4rem;
  box-shadow: 0 10px 40px rgba(0,0,0,0.5);
  border-radius: 4px;
  font-family: Georgia, serif;
  font-size: 0.95rem;
  line-height: 1.7;
}
.preview-watermark {
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%) rotate(-30deg);
  font-size: 5rem; font-weight: 900;
  color: rgba(123,107,255,0.12);
  pointer-events: none; z-index: 0;
  font-family: 'Space Grotesk', sans-serif;
  letter-spacing: 8px; white-space: nowrap;
}
.preview-paper .preview-title {
  font-family: Arial, sans-serif;
  font-size: 1.5rem;
  margin-bottom: 1.25rem;
  color: #1a1a1a;
  position: relative; z-index: 1;
}
.preview-body { position: relative; z-index: 1; }
.preview-body h1, .preview-body h2, .preview-body h3, .preview-body p, .preview-body li { color: #1a1a1a !important; }
.preview-body h1 { font-family: 'Space Grotesk', sans-serif; font-size: 1.5rem; margin: 1rem 0 0.5rem; }
.preview-body h2 { font-family: 'Space Grotesk', sans-serif; font-size: 1.2rem; margin: 0.85rem 0 0.4rem; }
.preview-body p { margin: 0.5rem 0; }
.preview-body ul, .preview-body ol { padding-left: 1.5rem; }
.preview-actions {
  display: flex; justify-content: flex-end; gap: 0.5rem;
  padding: 1rem 1.75rem;
  border-top: 1px solid var(--border);
}

/* RESPONSIVE for generator */
@media (max-width: 1200px) {
  .gen-layout { grid-template-columns: 240px 1fr 280px; }
}
@media (max-width: 1024px) {
  .gen-layout { grid-template-columns: 1fr; height: auto; min-height: 0; }
  .generator-route { height: auto; min-height: calc(100vh - 0px); }
  .gen-insights { border-right: none; border-bottom: 1px solid var(--border); max-height: 250px; }
  .gen-sidebar { border-left: none; border-top: 1px solid var(--border); }
  .doc-paper { padding: 2rem 1.5rem; }
}
@media (max-width: 768px) {
  .generator-route { margin: -4.5rem -1.5rem -1.5rem; }
  .gen-header { flex-wrap: wrap; padding: 0.6rem 1rem 0.6rem 3.25rem; }
  .gen-header-actions { flex-wrap: wrap; }
  .doc-paper { padding: 1.5rem 1rem; }
  .preview-paper { padding: 1.5rem 1rem; }
}

/* LOGO UPLOAD */
.logo-upload {
  display: flex; align-items: center; justify-content: center;
  padding: 1rem;
  background: var(--surface-2);
  border: 2px dashed var(--border);
  border-radius: var(--r-sm);
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--text-2);
  transition: all 0.2s;
}
.logo-upload:hover { border-color: var(--primary); color: var(--text); background: var(--surface-3); }
.logo-preview {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.5rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
}
.logo-preview img {
  height: 40px; max-width: 80px;
  object-fit: contain;
  background: white;
  border-radius: 4px;
  padding: 4px;
}

/* PLACEHOLDERS */
.placeholder-token {
  background: rgba(251, 191, 36, 0.15);
  color: #b78600;
  padding: 1px 6px;
  border-radius: 4px;
  font-weight: 600;
  border: 1px dashed #fbbf24;
}
.doc-paper .doc-editor .placeholder-token,
.preview-body .placeholder-token {
  background: rgba(251, 191, 36, 0.2);
  color: #92400e;
}

.placeholder-list { display: flex; flex-direction: column; gap: 0.6rem; margin-top: 0.5rem; }
.placeholder-item { display: flex; flex-direction: column; gap: 0.25rem; }
.placeholder-item label {
  font-size: 0.8rem; font-weight: 600;
  color: var(--primary-light);
  background: rgba(123,107,255,0.1);
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  align-self: flex-start;
  font-family: 'SF Mono', monospace;
}
.placeholder-item input {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
  color: var(--text);
  font-family: inherit; font-size: 0.85rem;
}
.placeholder-item input:focus { outline: none; border-color: var(--primary); }

/* === PREVIEW MODAL FIXES === */
/* Use a proper full-screen sheet overlay so the paper has plenty of room */
.preview-modal {
  padding: 0 !important;
  align-items: stretch !important;
  justify-content: stretch !important;
}
.preview-modal .modal-backdrop {
  background: rgba(0, 0, 0, 0.92);
  backdrop-filter: blur(16px);
}
.modal-preview {
  max-width: none !important;
  width: min(1100px, 96vw) !important;
  max-height: none !important;
  height: 96vh !important;
  margin: 2vh auto !important;
  border: 1px solid var(--border);
  background: var(--bg-2);
}
.preview-paper-wrap {
  background: #2a2a40;
  padding: 2rem 1rem;
}
.preview-paper {
  max-width: 800px;
  width: 100%;
  min-height: auto;
}
@media (max-width: 768px) {
  .modal-preview { width: 100vw !important; height: 100vh !important; margin: 0 !important; border-radius: 0 !important; }
  .preview-paper { padding: 1.5rem 1rem; }
  .preview-paper-wrap { padding: 0.75rem; }
}

/* === Preview clean stacking === */
.preview-paper * {
  box-sizing: border-box;
}
.preview-paper > *:not(.preview-watermark) {
  position: relative;
  z-index: 1;
}
.preview-body {
  position: relative;
  z-index: 1;
}
.preview-body > * { display: block; }
.preview-body h1, .preview-body h2, .preview-body h3, .preview-body h4 {
  margin-top: 1.25rem;
  margin-bottom: 0.5rem;
  font-weight: 700;
}
.preview-body h1 { font-size: 1.5rem; font-family: 'Space Grotesk', sans-serif; }
.preview-body h2 { font-size: 1.2rem; font-family: 'Space Grotesk', sans-serif; }
.preview-body p { margin: 0.5rem 0; }
.preview-body ul, .preview-body ol { margin: 0.5rem 0; padding-left: 1.5rem; }
.preview-body li { margin: 0.2rem 0; }
.preview-body * { color: #1a1a1a !important; }
.preview-body strong { color: #000 !important; font-weight: 700; }
.preview-body img { max-width: 100%; height: auto; display: block; margin: 0.75rem 0; }

/* Live header/footer rendering inside the doc paper */
.doc-section {
  position: relative; z-index: 1;
  user-select: none;
  pointer-events: none;  /* visual only — clicks pass through to keep edit focus on body */
}
.doc-section * { color: inherit; }
.doc-section img { pointer-events: auto; }
/* Hint that header/footer applies and explain how to change it */
.doc-section::after {
  content: '';
  display: block;
}
.doc-header-area { margin-bottom: 0.75rem; }
.doc-footer-area { margin-top: 1.5rem; }

/* Preview backdrop fully opaque so underlying generator content cannot bleed through */
.preview-modal .modal-backdrop {
  background: rgba(7, 7, 14, 1) !important;
  backdrop-filter: none !important;
}
.preview-modal .modal-content {
  background: var(--bg-2);
  border: 1px solid var(--border);
  z-index: 1;
}
.preview-paper {
  margin-bottom: 2rem;
}

/* === PDF text annotation inline toolbar === */
.text-anno-toolbar {
  position: absolute;
  bottom: 100%; left: 50%;
  transform: translate(-50%, -6px);
  display: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 6px;
  box-shadow: var(--shadow-md);
  gap: 2px;
  align-items: center;
  z-index: 5;
  white-space: nowrap;
}
.pdf-annotation.text:hover .text-anno-toolbar,
.pdf-annotation.text:focus-within .text-anno-toolbar,
.pdf-annotation.text.focused .text-anno-toolbar {
  display: inline-flex;
}
.text-anno-toolbar button {
  background: transparent;
  border: none;
  color: var(--text);
  cursor: pointer;
  padding: 3px 6px;
  border-radius: 4px;
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  min-width: 26px;
}
.text-anno-toolbar button:hover { background: var(--surface-2); }
.text-anno-toolbar .font-size-display {
  color: var(--text-2);
  font-size: 0.75rem;
  padding: 0 4px;
  min-width: 36px;
  text-align: center;
}
.text-anno-toolbar .toolbar-sep {
  width: 1px; height: 16px;
  background: var(--border);
  margin: 0 4px;
}
.text-anno-toolbar .color-swatch {
  width: 18px !important;
  height: 18px !important;
  min-width: 18px !important;
  padding: 0 !important;
  border: 2px solid var(--border) !important;
  border-radius: 50% !important;
}
.text-anno-toolbar .color-swatch.active {
  border-color: var(--primary-light) !important;
  box-shadow: 0 0 0 2px rgba(123,107,255,0.3);
}
.text-anno-toolbar .color-swatch:hover { transform: scale(1.15); }

/* Make sure text annotation can show overflow toolbar */
.pdf-annotation.text { overflow: visible; }

/* === Watermark customization controls === */
.wm-colors {
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 6px 8px;
}
.wm-colors .color-swatch {
  width: 22px; height: 22px;
  border: 2px solid var(--border);
  border-radius: 50%;
  cursor: pointer;
  padding: 0;
  transition: transform 0.15s;
}
.wm-colors .color-swatch:hover { transform: scale(1.15); }
.wm-colors .color-swatch.active {
  border-color: var(--primary-light);
  box-shadow: 0 0 0 2px rgba(123,107,255,0.3);
}
.color-picker-input {
  width: 32px !important; height: 24px !important;
  padding: 0 !important;
  border: 1px solid var(--border) !important;
  background: transparent !important;
  border-radius: 4px;
  cursor: pointer;
}
.input-group input[type="range"] {
  width: 100%;
  accent-color: var(--primary);
  background: transparent;
  padding: 0.4rem 0;
  border: none;
}
.input-group input[type="range"]:focus { box-shadow: none; }

/* Live watermark layer should sit behind content within doc-paper */
.doc-paper, .preview-paper { position: relative; overflow: hidden; }

/* === Inline image manipulation === */
.doc-img-wrap {
  position: relative;
  outline: 1px dashed transparent;
  transition: outline-color 0.15s;
}
.doc-img-wrap:hover { outline-color: rgba(123,107,255,0.5); }
.doc-img-wrap.selected {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
.doc-img-wrap img { user-select: none; }

.doc-img-toolbar {
  position: fixed;
  display: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px 6px;
  box-shadow: var(--shadow-md);
  z-index: 9999;
  gap: 2px;
  align-items: center;
  transform: translateX(-50%);
  white-space: nowrap;
  font-family: 'Inter', sans-serif;
}
.doc-img-toolbar .sec {
  color: var(--muted); font-size: 0.7rem;
  padding: 0 4px; text-transform: uppercase;
  letter-spacing: 0.5px;
}
.doc-img-toolbar button {
  background: transparent;
  border: none;
  color: var(--text);
  padding: 4px 8px;
  border-radius: 4px;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  min-width: 28px;
}
.doc-img-toolbar button:hover { background: var(--surface-2); }
.doc-img-toolbar button.danger { color: var(--danger); }
.doc-img-toolbar button.danger:hover { background: rgba(248,113,113,0.15); }
.doc-img-toolbar .sep {
  width: 1px; height: 18px;
  background: var(--border);
  margin: 0 4px;
}

/* On the white doc paper, give the image a subtle border */
.doc-paper .doc-img { box-shadow: 0 1px 4px rgba(0,0,0,0.08); }

/* On the live editor, hide the native resize handle background slightly */
.doc-img-wrap[style*="resize"] {
  /* keep the native resize corner visible */
}

/* === Header & Footer customizer === */
.hf-editor {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 0.6rem;
}
.hf-slot { display: flex; flex-direction: column; gap: 0.35rem; }
.hf-slot-label {
  font-size: 0.78rem; font-weight: 600;
  color: var(--text-2);
  margin-bottom: 0.1rem;
}
.hf-fields { display: flex; flex-wrap: wrap; gap: 4px; }
.hf-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 0.75rem; font-weight: 500;
  color: var(--text-2);
  cursor: pointer; user-select: none;
  transition: all 0.15s;
}
.hf-chip input { display: none; }
.hf-chip:hover { background: var(--surface-3); color: var(--text); }
.hf-chip.on {
  background: rgba(123,107,255,0.15);
  border-color: var(--primary);
  color: var(--primary-light);
}
.hf-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; }
.hf-row .input-group { margin-bottom: 0; }
.hf-row input[type="color"] {
  width: 100% !important;
  height: 28px !important;
  padding: 0 !important;
  border: 1px solid var(--border) !important;
  border-radius: 4px;
  background: transparent !important;
  cursor: pointer;
}
