/* ============================================
   ToolsPDF — Modern CSS (No framework)
   Inspired by PDF24 & iLovePDF
   ============================================ */

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

:root {
  /* Colors */
  --c-pdf: #e74c3c;
  --c-pdf-light: #fdecea;
  --c-pdf-dark: #c0392b;
  --c-image: #3498db;
  --c-image-light: #ebf5fb;
  --c-image-dark: #2980b9;
  --c-bg: #f8f9fa;
  --c-bg-alt: #ffffff;
  --c-surface: #ffffff;
  --c-text: #2c3e50;
  --c-text-secondary: #6c757d;
  --c-text-muted: #adb5bd;
  --c-border: #e9ecef;
  --c-border-light: #f1f3f5;
  --c-success: #27ae60;
  --c-success-light: #eafaf1;
  --c-error: #e74c3c;
  --c-error-light: #fdecea;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 30px rgba(0,0,0,0.1);
  --shadow-xl: 0 16px 48px rgba(0,0,0,0.12);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --font: 'Inter', system-ui, -apple-system, sans-serif;
  --transition: 0.2s ease;
  --max-width: 1200px;
}

/* --- Dark Mode --- */
[data-theme="dark"] {
  --c-bg: #0f1117;
  --c-bg-alt: #161822;
  --c-surface: #1e2030;
  --c-text: #e4e6eb;
  --c-text-secondary: #a0a4b0;
  --c-text-muted: #6b7080;
  --c-border: #2a2d3e;
  --c-border-light: #232638;
  --c-pdf-light: #3d1a1a;
  --c-image-light: #1a2d3d;
  --c-success-light: #1a3d2a;
  --c-error-light: #3d1a1a;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.2);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.3);
  --shadow-lg: 0 8px 30px rgba(0,0,0,0.4);
  --shadow-xl: 0 16px 48px rgba(0,0,0,0.5);
}

@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) {
    --c-bg: #0f1117;
    --c-bg-alt: #161822;
    --c-surface: #1e2030;
    --c-text: #e4e6eb;
    --c-text-secondary: #a0a4b0;
    --c-text-muted: #6b7080;
    --c-border: #2a2d3e;
    --c-border-light: #232638;
    --c-pdf-light: #3d1a1a;
    --c-image-light: #1a2d3d;
    --c-success-light: #1a3d2a;
    --c-error-light: #3d1a1a;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.2);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.3);
    --shadow-lg: 0 8px 30px rgba(0,0,0,0.4);
    --shadow-xl: 0 16px 48px rgba(0,0,0,0.5);
  }
}

body {
  font-family: var(--font);
  background: var(--c-bg);
  color: var(--c-text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: inherit; text-decoration: none; }

/* ============================================
   HEADER
   ============================================ */
.site-header {
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-border);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
  background: rgba(255,255,255,0.92);
}
[data-theme="dark"] .site-header {
  background: rgba(30,32,48,0.92);
}

.header-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 24px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  font-size: 1.35rem;
  letter-spacing: -0.02em;
  text-decoration: none;
}
.logo-icon { font-size: 1.5rem; }
.logo-text { color: var(--c-text); }
.logo-accent { color: var(--c-pdf); }

.header-nav {
  display: flex;
  gap: 8px;
}
.nav-link {
  padding: 6px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
  transition: background var(--transition), color var(--transition);
}
.nav-pdf:hover { background: var(--c-pdf-light); color: var(--c-pdf); }
.nav-image:hover { background: var(--c-image-light); color: var(--c-image); }
.nav-ai:hover { background: var(--c-ai-light, #f3f0ff); color: var(--c-ai, #8b5cf6); }

.theme-toggle {
  background: var(--c-bg);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.1rem;
  transition: background var(--transition);
}
.theme-toggle:hover { background: var(--c-border); }
.theme-icon-dark { display: none; }
[data-theme="dark"] .theme-icon-light { display: none; }
[data-theme="dark"] .theme-icon-dark { display: inline; }

/* ============================================
   HERO
   ============================================ */
.hero {
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 40%, #0f3460 100%);
  padding: 72px 24px 64px;
  text-align: center;
  position: relative;
  overflow: hidden;
}
.hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 50% 0%, rgba(231,76,60,0.12) 0%, transparent 60%),
              radial-gradient(ellipse at 80% 100%, rgba(52,152,219,0.1) 0%, transparent 50%);
  pointer-events: none;
}
.hero-inner { position: relative; z-index: 1; max-width: 700px; margin: 0 auto; }
.hero-title {
  font-size: clamp(1.75rem, 4vw, 2.75rem);
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.03em;
  line-height: 1.2;
  margin-bottom: 12px;
}
.hero-subtitle {
  color: rgba(255,255,255,0.7);
  font-size: clamp(0.95rem, 2vw, 1.1rem);
  margin-bottom: 32px;
  line-height: 1.5;
}

/* Search */
.search-wrap { max-width: 520px; margin: 0 auto; }
.search-box {
  position: relative;
  display: flex;
  align-items: center;
}
.search-icon {
  position: absolute;
  left: 16px;
  color: rgba(255,255,255,0.4);
  pointer-events: none;
}
.search-input {
  width: 100%;
  padding: 14px 50px 14px 48px;
  border: 2px solid rgba(255,255,255,0.15);
  border-radius: var(--radius-md);
  background: rgba(255,255,255,0.08);
  color: #fff;
  font-size: 1rem;
  font-family: var(--font);
  outline: none;
  transition: border-color var(--transition), background var(--transition);
  backdrop-filter: blur(8px);
}
.search-input::placeholder { color: rgba(255,255,255,0.4); }
.search-input:focus {
  border-color: rgba(255,255,255,0.35);
  background: rgba(255,255,255,0.12);
}
.search-kbd {
  position: absolute;
  right: 14px;
  background: rgba(255,255,255,0.12);
  color: rgba(255,255,255,0.5);
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-family: var(--font);
  pointer-events: none;
  border: 1px solid rgba(255,255,255,0.1);
}

/* ============================================
   CONTAINER & TOOL GRID
   ============================================ */
.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 40px 24px 80px;
  flex: 1;
}

.category-section { margin-bottom: 56px; }
.category-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 28px;
  padding-bottom: 16px;
  border-bottom: 2px solid var(--c-border);
}
.category-icon-wrap {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.pdf-icon-wrap { background: var(--c-pdf-light); color: var(--c-pdf); }
.image-icon-wrap { background: var(--c-image-light); color: var(--c-image); }
.category-title {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.category-count {
  color: var(--c-text-secondary);
  font-size: 0.875rem;
}

.subcategory-section { margin-bottom: 32px; }
.subcategory-title {
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--c-text-muted);
  margin-bottom: 14px;
  padding-left: 4px;
}

.tools-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}

/* Tool Card */
.tool-card {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 16px 18px;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-md);
  text-decoration: none;
  transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
  cursor: pointer;
}
.tool-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}
.card-pdf:hover { border-color: var(--c-pdf); }
.card-image:hover { border-color: var(--c-image); }

.tool-card-icon {
  font-size: 1.6rem;
  line-height: 1;
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
}
.card-pdf .tool-card-icon { background: var(--c-pdf-light); }
.card-image .tool-card-icon { background: var(--c-image-light); }

.tool-card-body { min-width: 0; }
.tool-card-name {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 2px;
  letter-spacing: -0.01em;
}
.tool-card-desc {
  font-size: 0.8rem;
  color: var(--c-text-secondary);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* No results */
.no-results {
  text-align: center;
  padding: 64px 24px;
  color: var(--c-text-muted);
}
.no-results-icon { font-size: 3rem; margin-bottom: 12px; }
.no-results p { font-size: 1.1rem; }

/* ============================================
   TOOL PAGE
   ============================================ */
.tool-page {
  flex: 1;
  padding: 32px 24px 80px;
}
.tool-page-inner {
  max-width: 720px;
  margin: 0 auto;
}

/* Breadcrumb */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--c-text-muted);
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.breadcrumb a {
  color: var(--c-text-secondary);
  transition: color var(--transition);
}
.breadcrumb a:hover { color: var(--c-pdf); }
.breadcrumb-sep { color: var(--c-text-muted); }
.breadcrumb-current { color: var(--c-text); font-weight: 500; }

/* Tool Header */
.tool-header {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-bottom: 32px;
}
.tool-header-icon {
  width: 64px;
  height: 64px;
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  flex-shrink: 0;
}
.tool-icon-pdf { background: var(--c-pdf-light); }
.tool-icon-image { background: var(--c-image-light); }
.tool-title {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.tool-desc {
  color: var(--c-text-secondary);
  font-size: 1rem;
  margin-top: 4px;
}

/* Alert */
.alert {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  margin-bottom: 20px;
}
.alert-error {
  background: var(--c-error-light);
  color: var(--c-error);
  border: 1px solid rgba(231,76,60,0.2);
}
.alert-close {
  margin-left: auto;
  background: none;
  border: none;
  color: inherit;
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0 4px;
  opacity: 0.6;
}
.alert-close:hover { opacity: 1; }

/* Upload Form */
.upload-form { display: flex; flex-direction: column; gap: 20px; }

/* Dropzone */
.dropzone {
  border: 2px dashed var(--c-border);
  border-radius: var(--radius-lg);
  padding: 48px 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
  position: relative;
  background: var(--c-surface);
}
.dropzone:hover,
.dropzone.drag-over {
  border-color: var(--c-pdf);
  background: var(--c-pdf-light);
}
.dropzone-content { pointer-events: none; }
.dropzone-content .btn-upload { pointer-events: auto; }

.dropzone-icon {
  color: var(--c-text-muted);
  margin-bottom: 16px;
}
.dropzone-text {
  font-size: 1.05rem;
  color: var(--c-text);
  margin-bottom: 4px;
}
.dropzone-subtext {
  font-size: 0.85rem;
  color: var(--c-text-muted);
  margin-bottom: 12px;
}
.dropzone-formats {
  font-size: 0.78rem;
  color: var(--c-text-muted);
  margin-top: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}
.dropzone-multi-badge {
  background: var(--c-image-light);
  color: var(--c-image);
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 600;
}

.file-input-hidden {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

/* File List */
.file-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.file-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
}
.file-item-icon { font-size: 1.2rem; }
.file-item-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
}
.file-item-size {
  color: var(--c-text-muted);
  font-size: 0.8rem;
  white-space: nowrap;
}
.file-item-remove {
  background: none;
  border: none;
  color: var(--c-text-muted);
  cursor: pointer;
  font-size: 1.1rem;
  padding: 2px 4px;
  border-radius: 4px;
  transition: color var(--transition), background var(--transition);
}
.file-item-remove:hover {
  color: var(--c-error);
  background: var(--c-error-light);
}

/* Tool Options */
.tool-options {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-md);
  padding: 20px;
}
.options-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--c-text);
}
.options-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}
.option-field { display: flex; flex-direction: column; gap: 6px; }
.option-label {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--c-text-secondary);
}
.option-input {
  padding: 10px 12px;
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-family: var(--font);
  background: var(--c-bg);
  color: var(--c-text);
  outline: none;
  transition: border-color var(--transition);
}
.option-input:focus { border-color: var(--c-pdf); }
select.option-input {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236c757d' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition: background var(--transition), transform var(--transition), box-shadow var(--transition);
  text-decoration: none;
}
.btn:active { transform: scale(0.98); }

.btn-primary {
  background: var(--c-pdf);
  color: #fff;
}
.btn-primary:hover { background: var(--c-pdf-dark); box-shadow: var(--shadow-md); }

.btn-outline {
  background: transparent;
  border: 1px solid var(--c-border);
  color: var(--c-text);
}
.btn-outline:hover { background: var(--c-bg); }

.btn-process {
  width: 100%;
  padding: 16px 24px;
  font-size: 1.05rem;
  border-radius: var(--radius-md);
}
.btn-pdf { background: var(--c-pdf); color: #fff; }
.btn-pdf:hover:not(:disabled) { background: var(--c-pdf-dark); box-shadow: var(--shadow-md); }
.btn-image { background: var(--c-image); color: #fff; }
.btn-image:hover:not(:disabled) { background: var(--c-image-dark); box-shadow: var(--shadow-md); }
.btn-process:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-upload {
  display: inline-flex;
  padding: 10px 20px;
  font-size: 0.9rem;
}

/* Progress */
.progress-wrap {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-md);
  padding: 24px;
  margin-top: 20px;
}
.progress-info {
  display: flex;
  justify-content: space-between;
  font-size: 0.88rem;
  color: var(--c-text-secondary);
  margin-bottom: 10px;
}
.progress-bar {
  height: 8px;
  background: var(--c-bg);
  border-radius: 4px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--c-pdf), var(--c-image));
  border-radius: 4px;
  transition: width 0.3s ease;
  animation: progressPulse 1.5s ease-in-out infinite;
}
@keyframes progressPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.8; }
}

/* Result */
.result-wrap {
  margin-top: 20px;
}
.result-success {
  text-align: center;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-md);
  padding: 40px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
.result-success h3 {
  font-size: 1.4rem;
  color: var(--c-success);
}
.result-success p {
  color: var(--c-text-secondary);
  margin-bottom: 8px;
}

/* Related Tools */
.related-tools {
  margin-top: 48px;
  padding-top: 32px;
  border-top: 1px solid var(--c-border);
}
.related-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 16px;
}
.related-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 10px;
}
.tool-card-mini {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
  font-size: 0.88rem;
  font-weight: 500;
}
.tool-card-mini:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}
.tool-card-mini.card-pdf:hover { border-color: var(--c-pdf); }
.tool-card-mini.card-image:hover { border-color: var(--c-image); }
.tool-card-mini-icon { font-size: 1.2rem; }

/* ============================================
   404 PAGE
   ============================================ */
.error-page {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 80px 24px;
}
.error-content {
  text-align: center;
  max-width: 480px;
}
.error-code {
  font-size: 6rem;
  font-weight: 800;
  letter-spacing: -0.04em;
  background: linear-gradient(135deg, var(--c-pdf), var(--c-image));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1;
  margin-bottom: 12px;
}
.error-content h1 {
  font-size: 1.5rem;
  margin-bottom: 8px;
}
.error-content p {
  color: var(--c-text-secondary);
  margin-bottom: 24px;
}

/* ============================================
   FOOTER
   ============================================ */
.site-footer {
  background: var(--c-surface);
  border-top: 1px solid var(--c-border);
  padding: 40px 24px;
  text-align: center;
}
.footer-inner {
  max-width: var(--max-width);
  margin: 0 auto;
}
.footer-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 800;
  font-size: 1.2rem;
  margin-bottom: 8px;
}
.footer-tagline {
  color: var(--c-text-secondary);
  font-size: 0.9rem;
  margin-bottom: 16px;
}
.footer-links {
  display: flex;
  gap: 24px;
  justify-content: center;
  margin-bottom: 16px;
}
.footer-links a {
  color: var(--c-text-secondary);
  font-size: 0.85rem;
  transition: color var(--transition);
}
.footer-links a:hover { color: var(--c-pdf); }
.footer-copy {
  color: var(--c-text-muted);
  font-size: 0.78rem;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
  .header-inner { padding: 0 16px; height: 56px; }
  .header-nav { display: none; }
  .hero { padding: 48px 16px 40px; }
  .container { padding: 24px 16px 60px; }
  .tools-grid { grid-template-columns: 1fr; }
  .tool-page { padding: 20px 16px 60px; }
  .tool-header { flex-direction: column; align-items: flex-start; gap: 12px; }
  .tool-header-icon { width: 52px; height: 52px; font-size: 1.6rem; }
  .tool-title { font-size: 1.35rem; }
  .dropzone { padding: 32px 16px; }
  .options-grid { grid-template-columns: 1fr; }
  .related-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 480px) {
  .tools-grid { grid-template-columns: 1fr; }
  .related-grid { grid-template-columns: 1fr; }
  .hero-title { font-size: 1.5rem; }
  .search-input { font-size: 0.9rem; padding: 12px 40px 12px 44px; }
  .search-kbd { display: none; }
}

@media (min-width: 769px) and (max-width: 1024px) {
  .tools-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ============================================
   AI TOOLS — Category & Cards
   ============================================ */
:root {
  --c-ai: #8b5cf6;
  --c-ai-light: #f3f0ff;
  --c-ai-dark: #7c3aed;
}
[data-theme="dark"] {
  --c-ai-light: #2d1f5e;
}
@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) {
    --c-ai-light: #2d1f5e;
  }
}

.ai-icon-wrap { background: var(--c-ai-light); color: var(--c-ai); }
.card-ai:hover { border-color: var(--c-ai); }
.card-ai .tool-card-icon { background: var(--c-ai-light); }
.tool-icon-ai { background: var(--c-ai-light); }
.btn-ai { background: var(--c-ai); color: #fff; }
.btn-ai:hover:not(:disabled) { background: var(--c-ai-dark); box-shadow: var(--shadow-md); }
.btn-sm { padding: 6px 14px; font-size: 0.82rem; }

/* ============================================
   CHAT WITH PDF
   ============================================ */
.chat-page .tool-page-inner { max-width: 800px; }

.chat-upload { margin-bottom: 20px; }

.chat-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 60px 24px;
  color: var(--c-text-secondary);
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--c-border);
  border-top-color: var(--c-ai);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.chat-container {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 200px);
  min-height: 500px;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.chat-doc-info {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 20px;
  background: var(--c-bg);
  border-bottom: 1px solid var(--c-border);
  font-size: 0.88rem;
}
.doc-icon { font-size: 1.2rem; }
.doc-name { font-weight: 600; }
.doc-meta { color: var(--c-text-muted); font-size: 0.8rem; }

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.chat-msg {
  display: flex;
  gap: 12px;
  max-width: 85%;
}
.chat-msg-user {
  align-self: flex-end;
  flex-direction: row-reverse;
}
.chat-msg-ai { align-self: flex-start; }

.chat-msg-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 700;
  flex-shrink: 0;
  text-transform: uppercase;
}
.chat-msg-ai .chat-msg-avatar {
  background: var(--c-ai-light);
  color: var(--c-ai);
}
.chat-msg-user .chat-msg-avatar {
  background: var(--c-pdf-light);
  color: var(--c-pdf);
}

.chat-msg-body {
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 0.92rem;
  line-height: 1.6;
}
.chat-msg-ai .chat-msg-body {
  background: var(--c-bg);
  border: 1px solid var(--c-border);
}
.chat-msg-user .chat-msg-body {
  background: var(--c-ai);
  color: #fff;
}
.chat-msg-body p { margin-bottom: 8px; }
.chat-msg-body p:last-child { margin-bottom: 0; }
.chat-msg-body ul { padding-left: 20px; margin: 8px 0; }
.chat-msg-body li { margin-bottom: 4px; }
.chat-msg-body code {
  background: rgba(0,0,0,0.08);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.85em;
}
.chat-error { color: var(--c-error); }

.typing-dots span {
  animation: typingBlink 1.4s infinite;
  font-size: 1.5rem;
  line-height: 1;
}
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typingBlink {
  0%, 60%, 100% { opacity: 0.2; }
  30% { opacity: 1; }
}

.chat-input-wrap {
  display: flex;
  gap: 10px;
  padding: 16px 20px;
  border-top: 1px solid var(--c-border);
  background: var(--c-bg);
}
.chat-input {
  flex: 1;
  padding: 12px 16px;
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-family: var(--font);
  background: var(--c-surface);
  color: var(--c-text);
  outline: none;
  transition: border-color var(--transition);
}
.chat-input:focus { border-color: var(--c-ai); }
.chat-send {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
}

/* AI Result */
.ai-result {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.ai-result-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--c-border);
  background: var(--c-bg);
}
.ai-result-header h3 {
  font-size: 1rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}
.ai-result-body {
  padding: 24px 20px;
  font-size: 0.95rem;
  line-height: 1.7;
  max-height: 600px;
  overflow-y: auto;
}
.ai-result-body p { margin-bottom: 12px; }
.ai-result-body ul { padding-left: 20px; margin: 8px 0; }
.ai-result-body li { margin-bottom: 6px; }
.ai-result-body strong { color: var(--c-text); }
.ai-result + .btn { margin-top: 16px; }

@media (max-width: 768px) {
  .chat-container { height: calc(100vh - 180px); min-height: 400px; }
  .chat-msg { max-width: 95%; }
}
