/* ========================================
   UNGUESS Test Manual Generator — Design System
   Brand Colors: Navy #003A57, Green #00B27F, Grey #4B5F5F
   Font: Montserrat
   ======================================== */

:root {
  /* UNGUESS Official Brand */
  --ug-navy: #003A57;
  --ug-navy-dark: #002940;
  --ug-navy-light: #0A4D6E;
  --ug-green: #00B27F;
  --ug-green-dark: #009A6E;
  --ug-green-light: #33C599;
  --ug-green-pale: #E6F9F3;
  --ug-grey: #4B5F5F;
  --ug-grey-light: #8A9A9A;
  --ug-grey-pale: #F2F5F5;

  /* Semantic */
  --bg-primary: #FAFCFC;
  --bg-secondary: #FFFFFF;
  --bg-card: #FFFFFF;
  --bg-card-hover: #F7FAFA;
  --bg-input: #F2F5F5;
  --bg-input-focus: #FFFFFF;

  --border-subtle: #E4EAEA;
  --border-default: #CDD8D8;
  --border-focus: rgba(0, 178, 127, 0.5);
  --border-accent: rgba(0, 178, 127, 0.4);

  --text-primary: #003A57;
  --text-secondary: #4B5F5F;
  --text-muted: #8A9A9A;
  --text-accent: #00B27F;

  --gradient-primary: linear-gradient(135deg, #00B27F 0%, #009A6E 100%);
  --gradient-navy: linear-gradient(135deg, #003A57 0%, #0A4D6E 100%);
  --gradient-hero: linear-gradient(135deg, #00B27F 0%, #33C599 100%);

  --shadow-sm: 0 1px 3px rgba(0, 58, 87, 0.06);
  --shadow-md: 0 4px 12px rgba(0, 58, 87, 0.08);
  --shadow-lg: 0 8px 32px rgba(0, 58, 87, 0.12);
  --shadow-glow: 0 0 40px rgba(0, 178, 127, 0.12);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;

  --font-sans: 'Montserrat', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-default: 250ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 400ms cubic-bezier(0.4, 0, 0.2, 1);
}

[hidden] { display: none !important; }
.pointer-disabled { pointer-events: none; }
.settings-key-panel { margin-top: 16px; }
.settings-key-label { margin-bottom: 8px; }
.settings-key-help { font-size: 10px; color: var(--text-muted); margin-top: 8px; }
.settings-key-help a { color: var(--ug-green); }
.checklist-item { list-style: none; }
.api-key-connected { color: var(--ug-teal); font-size: 13px; font-weight: 600; }
.api-key-missing { color: #e74c3c; font-size: 13px; font-weight: 600; }
.api-key-warning { border-color: rgba(231, 76, 60, 0.3); }

/* ========== Dark Theme ========== */
[data-theme="dark"] {
  --bg-primary: #0E1A20;
  --bg-secondary: #13242D;
  --bg-card: #162A33;
  --bg-card-hover: #1C333D;
  --bg-input: #1A2F38;
  --bg-input-focus: #203A44;

  --border-subtle: #244049;
  --border-default: #2E4D57;
  --border-focus: rgba(0, 178, 127, 0.6);
  --border-accent: rgba(0, 178, 127, 0.5);

  --text-primary: #E6F1F1;
  --text-secondary: #AFC3C3;
  --text-muted: #7C9292;
  --text-accent: #2ED3A3;

  --ug-navy: #E6F1F1;          /* navy is used as a primary text color in places */
  --ug-grey: #AFC3C3;
  --ug-grey-pale: #1A2F38;
  --ug-green-pale: #0E2E26;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 40px rgba(0, 178, 127, 0.18);

  color-scheme: dark;
}

/* Dark-mode component overrides for elements with hardcoded light backgrounds */
[data-theme="dark"] .header {
  background: rgba(19, 36, 45, 0.9);
}
[data-theme="dark"] .btn-ghost:hover {
  color: var(--text-primary);
}

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

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

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

/* ========== Login Page ========== */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-primary);
  position: relative;
  overflow: hidden;
}

.login-theme-toggle {
  position: absolute;
  top: 20px;
  right: 20px;
  z-index: 3;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  font-family: var(--font-sans);
  cursor: pointer;
  transition: all var(--transition-default);
}

.login-theme-toggle:hover {
  color: var(--text-primary);
  border-color: var(--ug-green);
}

.login-page::before {
  content: '';
  position: absolute;
  top: -50%;
  right: -30%;
  width: 800px;
  height: 800px;
  background: radial-gradient(circle, rgba(0,178,127,0.06) 0%, transparent 70%);
  pointer-events: none;
}

.login-page::after {
  content: '';
  position: absolute;
  bottom: -40%;
  left: -20%;
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, rgba(0,58,87,0.04) 0%, transparent 70%);
  pointer-events: none;
}

/* Decorative squares (UNGUESS brand element) */
.login-deco {
  position: absolute;
  pointer-events: none;
}

.login-deco-1 {
  top: 80px;
  left: 60px;
  width: 18px;
  height: 18px;
  background: #00B27F;
  opacity: 0.2;
}

.login-deco-2 {
  top: 110px;
  left: 90px;
  width: 14px;
  height: 14px;
  background: #003A57;
  opacity: 0.15;
}

.login-deco-3 {
  bottom: 120px;
  right: 80px;
  width: 20px;
  height: 20px;
  background: #00B27F;
  opacity: 0.18;
}

.login-deco-4 {
  bottom: 90px;
  right: 50px;
  width: 12px;
  height: 12px;
  background: #8A9A9A;
  opacity: 0.15;
}

.login-deco-5 {
  top: 200px;
  right: 150px;
  width: 16px;
  height: 16px;
  background: #CDD8D8;
  opacity: 0.25;
}

.login-card {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: 420px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: 48px 40px 40px;
  box-shadow: 0 8px 40px rgba(0, 58, 87, 0.08);
  animation: loginFadeIn 0.5s ease;
}

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

.login-logo {
  display: flex;
  justify-content: center;
  margin-bottom: 32px;
}

.login-logo img {
  height: 32px;
  width: auto;
}

.login-title {
  text-align: center;
  font-size: 20px;
  font-weight: 700;
  color: var(--ug-navy);
  margin-bottom: 6px;
}

.login-subtitle {
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 32px;
  font-weight: 400;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.login-field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.login-field input {
  width: 100%;
  padding: 12px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 14px;
  font-family: var(--font-sans);
  transition: all var(--transition-default);
  outline: none;
}

.login-field input:focus {
  background: var(--bg-input-focus);
  border-color: var(--ug-green);
  box-shadow: 0 0 0 3px rgba(0, 178, 127, 0.1);
}

.login-btn {
  width: 100%;
  padding: 14px 24px;
  background: var(--gradient-primary);
  border: none;
  border-radius: var(--radius-sm);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  font-family: var(--font-sans);
  cursor: pointer;
  transition: all var(--transition-default);
  margin-top: 6px;
  letter-spacing: 0.02em;
}

.login-btn:hover {
  box-shadow: 0 6px 20px rgba(0, 178, 127, 0.3);
  transform: translateY(-1px);
}

.login-btn:active {
  transform: translateY(0);
}

.login-error {
  text-align: center;
  font-size: 13px;
  color: #D94040;
  min-height: 20px;
  margin-top: 4px;
  font-weight: 500;
}

.login-footer {
  text-align: center;
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid var(--border-subtle);
  font-size: 11px;
  color: var(--text-muted);
}

.login-footer a {
  color: var(--ug-green);
  text-decoration: none;
  font-weight: 500;
}

/* ========== Background ========== */
.bg-mesh {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse at 20% 50%, rgba(0, 178, 127, 0.03) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 20%, rgba(0, 178, 127, 0.02) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 80%, rgba(0, 58, 87, 0.02) 0%, transparent 50%);
  pointer-events: none;
  z-index: 0;
}

.bg-grid {
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(0, 58, 87, 0.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 58, 87, 0.02) 1px, transparent 1px);
  background-size: 60px 60px;
  pointer-events: none;
  z-index: 0;
  mask-image: radial-gradient(ellipse at center, black 30%, transparent 80%);
  -webkit-mask-image: radial-gradient(ellipse at center, black 30%, transparent 80%);
}

/* ========== Header ========== */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  background: rgba(255, 255, 255, 0.9);
  border-bottom: 1px solid var(--border-subtle);
}

.header-inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  display: flex;
  align-items: center;
  gap: 14px;
}

.logo-img {
  height: 28px;
  width: auto;
}

.logo-divider {
  width: 1px;
  height: 24px;
  background: var(--border-default);
}

.logo-text h1 {
  font-size: 13px;
  font-weight: 700;
  color: var(--ug-navy);
  letter-spacing: -0.01em;
  line-height: 1.2;
}

.logo-text p {
  font-size: 10px;
  color: var(--text-muted);
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-ghost {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  background: transparent;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  font-family: var(--font-sans);
  cursor: pointer;
  transition: all var(--transition-default);
  white-space: nowrap;
}

.btn-ghost:hover {
  background: var(--ug-green-pale);
  border-color: var(--ug-green);
  color: var(--ug-navy);
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: background var(--transition-default);
  animation: pulse-dot 2s infinite;
}

.status-dot.connected { background: var(--ug-green); }
.status-dot.error { background: #D94040; }

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* ========== Main ========== */
.main-container {
  position: relative;
  z-index: 1;
  max-width: 960px;
  margin: 0 auto;
  padding: 0 24px 80px;
}

/* ========== Hero ========== */
.hero {
  text-align: center;
  padding: 48px 0 36px;
}

.hero-title {
  font-size: clamp(28px, 4.5vw, 40px);
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -0.02em;
  margin-bottom: 14px;
  color: var(--ug-navy);
}

.gradient-text {
  background: var(--gradient-hero);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero-desc {
  font-size: 14px;
  color: var(--text-secondary);
  max-width: 540px;
  margin: 0 auto;
  line-height: 1.7;
  font-weight: 400;
}

/* ========== Form ========== */
.generator-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.form-section {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 20px;
  transition: border-color var(--transition-default);
  box-shadow: var(--shadow-sm);
}

.form-section:hover {
  border-color: var(--border-default);
}

.form-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 10px;
}

.form-label svg {
  color: var(--ug-green);
  flex-shrink: 0;
}

.form-hint {
  font-weight: 400;
  color: var(--text-muted);
  font-size: 11px;
  margin-left: auto;
}

.form-input {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 13px;
  font-family: var(--font-sans);
  transition: all var(--transition-default);
  outline: none;
}

.form-input:focus {
  background: var(--bg-input-focus);
  border-color: var(--ug-green);
  box-shadow: 0 0 0 3px rgba(0, 178, 127, 0.1);
}

.form-input::placeholder {
  color: var(--text-muted);
}

.form-textarea {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 13px;
  font-family: var(--font-sans);
  resize: vertical;
  min-height: 100px;
  transition: border-color var(--transition-default), background-color var(--transition-default), box-shadow var(--transition-default);
  outline: none;
}

.form-textarea:focus {
  background: var(--bg-input-focus);
  border-color: var(--ug-green);
  box-shadow: 0 0 0 3px rgba(0, 178, 127, 0.1);
}

/* ========== Output Type Cards ========== */
.output-type-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.output-type-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 16px;
  background: var(--bg-input);
  border: 2px solid var(--border-subtle);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-default);
  text-align: center;
}

.output-type-card input { display: none; }

.output-type-card:hover {
  border-color: var(--border-default);
  background: var(--bg-card-hover);
}

.output-type-card.active {
  border-color: var(--ug-green);
  background: var(--ug-green-pale);
  box-shadow: 0 0 16px rgba(0, 178, 127, 0.1);
}

.card-icon { font-size: 26px; line-height: 1; }
.card-title { font-size: 13px; font-weight: 700; color: var(--text-primary); }
.card-desc { font-size: 11px; color: var(--text-muted); line-height: 1.4; }

/* ========== Dropzone ========== */
.dropzone {
  border: 2px dashed var(--border-default);
  border-radius: var(--radius-md);
  padding: 32px 24px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition-default);
  position: relative;
}

.dropzone:hover, .dropzone.dragover {
  border-color: var(--ug-green);
  background: rgba(0, 178, 127, 0.03);
}

.dropzone.dragover {
  border-style: solid;
  box-shadow: inset 0 0 30px rgba(0, 178, 127, 0.05);
}

.dropzone-icon {
  color: var(--text-muted);
  margin-bottom: 10px;
  transition: color var(--transition-default);
}

.dropzone:hover .dropzone-icon { color: var(--ug-green); }

.dropzone-text { font-size: 13px; color: var(--text-secondary); margin-bottom: 4px; }

.dropzone-link {
  color: var(--ug-green);
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.dropzone-hint { font-size: 11px; color: var(--text-muted); }
.dropzone.small { padding: 20px 16px; }
.dropzone.small .dropzone-icon { display: none; }

/* ========== File List ========== */
.file-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 10px;
}

.file-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  animation: slideIn 0.3s ease;
}

.file-item-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

.file-item-icon.pdf { background: rgba(217, 64, 64, 0.1); }
.file-item-icon.excel { background: rgba(0, 178, 127, 0.1); }
.file-item-icon.image { background: rgba(0, 58, 87, 0.08); }
.file-item-icon.video { background: rgba(245, 158, 11, 0.1); }

.file-item-info { flex: 1; min-width: 0; }
.file-item-name { font-size: 12px; font-weight: 500; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-item-size { font-size: 11px; color: var(--text-muted); }

.file-item-remove {
  width: 28px; height: 28px; border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  border: none; background: transparent; color: var(--text-muted);
  cursor: pointer; font-size: 16px; transition: all var(--transition-fast);
}

.file-item-remove:hover {
  background: rgba(217, 64, 64, 0.1);
  color: #D94040;
}

@keyframes slideIn {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ========== URL Input ========== */
.url-input-group { display: flex; gap: 8px; }
.url-input-group .form-input { flex: 1; }

.btn-add {
  padding: 10px 16px;
  background: var(--ug-green-pale);
  border: 1px solid rgba(0, 178, 127, 0.3);
  border-radius: var(--radius-sm);
  color: var(--ug-green-dark);
  font-size: 12px;
  font-weight: 600;
  font-family: var(--font-sans);
  cursor: pointer;
  transition: all var(--transition-default);
  white-space: nowrap;
}

.btn-add:hover {
  background: rgba(0, 178, 127, 0.12);
  border-color: var(--ug-green);
}

.tag-list { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }

.tag {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 12px;
  background: var(--ug-green-pale);
  border: 1px solid rgba(0, 178, 127, 0.2);
  border-radius: 100px;
  font-size: 11px;
  color: var(--ug-green-dark);
  animation: slideIn 0.3s ease;
}

.tag-remove {
  width: 16px; height: 16px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  border: none; background: rgba(217, 64, 64, 0.15);
  color: #D94040; cursor: pointer; font-size: 10px; line-height: 1;
}

/* ========== Collapsible ========== */
.collapsible .collapsible-trigger {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%; background: none; border: none; cursor: pointer; padding: 0; margin-bottom: 0;
}

.collapsible .chevron { color: var(--text-muted); transition: transform var(--transition-default); }
.collapsible.open .chevron { transform: rotate(180deg); }
.collapsible .collapsible-content { display: none; margin-top: 12px; }
.collapsible.open .collapsible-content { display: block; animation: slideIn 0.3s ease; }
.collapsible .collapsible-trigger .form-label { margin-bottom: 0; }

/* ========== Diff Mode Toggle ========== */
.diff-mode-section {
  padding-top: 4px;
}

.diff-mode-toggle {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: var(--bg-card);
  transition: border-color var(--transition-default), background var(--transition-default);
  user-select: none;
}

.diff-mode-toggle:hover {
  border-color: var(--border-default);
  background: var(--bg-card-hover);
}

.diff-mode-toggle input { display: none; }

.toggle-track {
  flex-shrink: 0;
  position: relative;
  width: 36px;
  height: 20px;
  border-radius: 10px;
  background: var(--border-default);
  transition: background var(--transition-default);
}

.toggle-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
  transition: transform var(--transition-default);
}

.diff-mode-toggle input:checked ~ .toggle-track {
  background: var(--ug-green);
}

.diff-mode-toggle input:checked ~ .toggle-track .toggle-thumb {
  transform: translateX(16px);
}

.diff-mode-toggle.active {
  border-color: var(--ug-green);
  background: var(--ug-green-pale);
}

.toggle-content {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.toggle-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.3;
}

.toggle-desc {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.4;
}

/* ========== Primary Button ========== */
.btn-primary {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 10px; width: 100%; padding: 14px 32px;
  background: var(--gradient-primary);
  border: none; border-radius: var(--radius-md);
  color: white; font-size: 14px; font-weight: 700;
  font-family: var(--font-sans); cursor: pointer;
  transition: all var(--transition-default);
  box-shadow: 0 4px 16px rgba(0, 178, 127, 0.2);
  position: relative; overflow: hidden;
  letter-spacing: 0.01em;
}

.btn-primary::before {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.15) 0%, transparent 50%);
  opacity: 0; transition: opacity var(--transition-default);
}

.btn-primary:hover::before { opacity: 1; }

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 24px rgba(0, 178, 127, 0.3);
}

.btn-primary:active {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(0, 178, 127, 0.2);
}

.btn-primary:disabled {
  opacity: 0.6; cursor: not-allowed; transform: none; box-shadow: none;
}

.btn-primary:disabled::before { display: none; }

/* ========== Progress ========== */
.progress-container { margin-top: 24px; }

.progress-card {
  background: var(--bg-card); border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg); padding: 28px;
  display: flex; flex-direction: column; align-items: center; gap: 16px;
  animation: slideIn 0.4s ease; box-shadow: var(--shadow-md);
}

.progress-spinner {
  width: 40px; height: 40px;
  border: 3px solid var(--border-subtle);
  border-top-color: var(--ug-green);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.progress-info { text-align: center; }
.progress-info h3 { font-size: 15px; font-weight: 700; margin-bottom: 4px; color: var(--ug-navy); }
.progress-info p { font-size: 12px; color: var(--text-secondary); }

.progress-bar {
  width: 100%; height: 4px;
  background: var(--bg-input); border-radius: 100px; overflow: hidden;
}

.progress-bar-fill {
  height: 100%; background: var(--gradient-primary);
  border-radius: 100px; width: 0%;
  transition: width 0.5s ease;
}

/* Live tail of the AI output while it streams */
.live-preview {
  width: 100%;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  overflow: hidden;
}

.live-preview-header {
  display: flex; align-items: center; gap: 7px;
  padding: 8px 12px;
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.6px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-subtle);
}

.live-preview-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--ug-green);
  animation: livePulse 1.2s ease-in-out infinite;
}

@keyframes livePulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.live-preview pre {
  margin: 0;
  padding: 12px 14px;
  max-height: 220px;
  overflow-y: auto;
  font-family: 'SF Mono', Consolas, monospace;
  font-size: 11px;
  line-height: 1.6;
  color: var(--text-secondary);
  white-space: pre-wrap;
  word-break: break-word;
}

.progress-cancel {
  border: 1px solid var(--border-subtle);
  background: var(--bg-input);
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.progress-cancel:hover {
  border-color: #E74C3C;
  color: #E74C3C;
}

/* ========== Result ========== */
.result-container { margin-top: 24px; animation: slideIn 0.4s ease; }

.result-header {
  background: var(--bg-card);
  border: 1px solid var(--ug-green);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: 20px; display: flex; align-items: center;
  justify-content: space-between; flex-wrap: wrap; gap: 12px;
  box-shadow: var(--shadow-sm);
}

.result-header h3 { font-size: 16px; font-weight: 700; color: var(--ug-navy); }

.result-meta { display: flex; gap: 16px; font-size: 12px; color: var(--text-secondary); }
.result-meta-item { display: flex; align-items: center; gap: 4px; }

.token-usage-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  margin-top: 8px;
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.06) 0%, rgba(251, 191, 36, 0.08) 100%);
  border: 1px solid rgba(245, 158, 11, 0.2);
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--text-secondary);
  width: 100%;
}
.token-usage-badge .token-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.token-usage-badge .token-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}
.token-usage-badge .token-divider {
  color: var(--border-default);
  font-size: 11px;
}
.token-usage-badge strong {
  color: var(--ug-navy);
  font-weight: 700;
}

.result-actions {
  background: var(--bg-card);
  border-left: 1px solid var(--border-subtle);
  border-right: 1px solid var(--border-subtle);
  padding: 12px 20px; display: flex; gap: 8px; flex-wrap: wrap;
}

.btn-action {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; border-radius: var(--radius-sm);
  font-size: 12px; font-weight: 600; font-family: var(--font-sans);
  cursor: pointer; transition: all var(--transition-default);
  border: 1px solid; text-decoration: none;
}

.btn-action.primary {
  background: var(--ug-green); border-color: var(--ug-green); color: white;
}
.btn-action.primary:hover {
  background: var(--ug-green-dark); box-shadow: 0 4px 12px rgba(0, 178, 127, 0.2);
}

.btn-action.secondary {
  background: transparent; border-color: var(--border-default); color: var(--text-secondary);
}
.btn-action.secondary:hover {
  background: var(--ug-green-pale); border-color: var(--ug-green); color: var(--ug-navy);
}

.btn-action.download {
  background: var(--ug-green-pale);
  border-color: rgba(0, 178, 127, 0.3);
  color: var(--ug-green-dark);
}
.btn-action.download:hover {
  background: rgba(0, 178, 127, 0.12); border-color: var(--ug-green);
}

.result-content {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle); border-top: none;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  padding: 24px; max-height: 70vh; overflow-y: auto;
}

/* Markdown rendering */
.result-content .markdown-body { font-size: 13px; line-height: 1.7; color: var(--text-primary); }
.result-content .markdown-body h1 { font-size: 20px; font-weight: 800; margin: 24px 0 12px; padding-bottom: 8px; border-bottom: 2px solid var(--ug-green-pale); color: var(--ug-navy); }
.result-content .markdown-body h2 { font-size: 17px; font-weight: 700; margin: 20px 0 10px; color: var(--ug-green-dark); }
.result-content .markdown-body h3 { font-size: 14px; font-weight: 700; margin: 18px 0 8px; color: var(--ug-navy); }
.result-content .markdown-body h4 { font-size: 13px; font-weight: 700; margin: 16px 0 6px; color: var(--ug-green); }
.result-content .markdown-body p { margin: 8px 0; }
.result-content .markdown-body ul, .result-content .markdown-body ol { margin: 8px 0; padding-left: 24px; }
.result-content .markdown-body li { margin: 4px 0; }
.result-content .markdown-body code { background: var(--bg-input); padding: 2px 6px; border-radius: 4px; font-family: var(--font-mono); font-size: 12px; }
.result-content .markdown-body pre { background: var(--ug-navy-dark); color: #E6F9F3; padding: 16px; border-radius: var(--radius-sm); overflow-x: auto; margin: 12px 0; }
.result-content .markdown-body pre code { background: transparent; padding: 0; color: inherit; }
.result-content .markdown-body table { width: 100%; border-collapse: collapse; margin: 16px 0; }
.result-content .markdown-body th { background: var(--ug-green-pale); padding: 10px 14px; text-align: left; font-weight: 600; font-size: 12px; border: 1px solid var(--border-subtle); color: var(--ug-navy); }
.result-content .markdown-body td { padding: 10px 14px; border: 1px solid var(--border-subtle); font-size: 12px; }
.result-content .markdown-body tr:nth-child(even) { background: var(--ug-grey-pale); }
.result-content .markdown-body blockquote { border-left: 3px solid var(--ug-green); padding: 8px 16px; margin: 12px 0; background: var(--ug-green-pale); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.result-content .markdown-body strong { color: var(--ug-navy); font-weight: 700; }
.result-content .markdown-body hr { border: none; border-top: 1px solid var(--border-subtle); margin: 20px 0; }

.result-content::-webkit-scrollbar { width: 6px; }
.result-content::-webkit-scrollbar-track { background: transparent; }
.result-content::-webkit-scrollbar-thumb { background: var(--border-default); border-radius: 3px; }

/* ========== Modal ========== */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0, 58, 87, 0.45);
  backdrop-filter: blur(8px); z-index: 200;
  display: flex; align-items: center; justify-content: center;
  padding: 24px; animation: fadeIn 0.2s ease;
}

.modal {
  width: 100%; max-width: 520px;
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xl);
  overflow: hidden; animation: modalSlide 0.3s ease;
  box-shadow: var(--shadow-lg);
}

.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 24px; border-bottom: 1px solid var(--border-subtle);
}

.modal-header h3 { font-size: 15px; font-weight: 700; color: var(--ug-navy); }

.modal-close {
  width: 32px; height: 32px; border-radius: 8px;
  border: none; background: transparent; color: var(--text-muted);
  font-size: 20px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--transition-fast);
}
.modal-close:hover { background: var(--bg-input); color: var(--text-primary); }

.modal-body { padding: 24px; }
.modal-desc { font-size: 12px; color: var(--text-secondary); margin-bottom: 16px; line-height: 1.6; }

.kb-status { margin-top: 16px; }

.kb-doc {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px; background: var(--bg-input);
  border: 1px solid var(--border-subtle); border-radius: var(--radius-sm);
  margin-bottom: 8px; animation: slideIn 0.3s ease;
}

.kb-doc-info { display: flex; flex-direction: column; gap: 2px; }
.kb-doc-name { font-size: 12px; font-weight: 600; color: var(--text-primary); }
.kb-doc-meta { font-size: 10px; color: var(--text-muted); }

.kb-empty {
  text-align: center; padding: 24px; color: var(--text-muted); font-size: 12px;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes modalSlide { from { opacity: 0; transform: translateY(16px) scale(0.98); } to { opacity: 1; transform: translateY(0) scale(1); } }

/* ========== Toast ========== */
.toast-container {
  position: fixed; bottom: 24px; right: 24px; z-index: 300;
  display: flex; flex-direction: column; gap: 8px;
}

.toast {
  padding: 12px 18px; background: var(--bg-card);
  border: 1px solid var(--border-default); border-radius: var(--radius-md);
  font-size: 12px; color: var(--text-primary);
  box-shadow: var(--shadow-lg); animation: toastIn 0.3s ease;
  display: flex; align-items: center; gap: 10px; max-width: 360px;
}

.toast.error { border-color: rgba(217, 64, 64, 0.4); }
.toast.success { border-color: rgba(0, 178, 127, 0.4); }

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

/* ========== Footer ========== */
.footer {
  text-align: center;
  padding: 20px;
  color: var(--text-muted);
  font-size: 11px;
  border-top: 1px solid var(--border-subtle);
  margin-top: 36px;
}

.footer a {
  color: var(--ug-green);
  text-decoration: none;
  font-weight: 500;
}

.footer a:hover { text-decoration: underline; }

/* ========== Responsive ========== */
@media (max-width: 640px) {
  .header-inner { padding: 10px 16px; }
  .main-container { padding: 0 16px 60px; }
  .hero { padding: 32px 0 24px; }
  .output-type-grid { grid-template-columns: 1fr; }
  .url-input-group { flex-direction: column; }
  .result-header { flex-direction: column; align-items: flex-start; }
  .result-actions { flex-direction: column; }
  .form-section { padding: 16px; }
  .login-card { margin: 16px; padding: 32px 24px 28px; }
}

/* ========== Instructions Modal ========== */
.modal-wide { max-width: 680px; }
.modal-scroll { max-height: 70vh; overflow-y: auto; }

.instructions h4 {
  font-size: 14px; font-weight: 700; color: var(--ug-navy);
  margin: 18px 0 8px; padding-bottom: 6px;
  border-bottom: 1px solid var(--border-subtle);
}

.instructions h4:first-child { margin-top: 0; }

.instructions ol, .instructions ul {
  padding-left: 22px; margin: 8px 0; font-size: 12px;
  color: var(--text-secondary); line-height: 1.7;
}

.instructions li { margin: 6px 0; }
.instructions strong { color: var(--ug-navy); }
.instructions p { font-size: 12px; color: var(--text-secondary); line-height: 1.7; margin: 6px 0; }
.instructions code { background: var(--bg-input); padding: 2px 6px; border-radius: 4px; font-family: var(--font-mono); font-size: 11px; color: var(--ug-green-dark); }

.instructions-table {
  width: 100%; border-collapse: collapse; margin: 10px 0; font-size: 12px;
}
.instructions-table th {
  background: var(--ug-green-pale); padding: 8px 12px; text-align: left;
  font-weight: 600; border: 1px solid var(--border-subtle); color: var(--ug-navy);
}
.instructions-table td {
  padding: 8px 12px; border: 1px solid var(--border-subtle); color: var(--text-secondary);
}

/* ========== API Key Status ========== */
.api-key-status {
  padding: 12px;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  font-size: 12px;
}

/* ========== KB Loading ========== */
.kb-loading {
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
  padding: 8px;
}

/* ========== Google Auth Banner ========== */
.google-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  border-radius: 8px;
  margin: 0 0 16px 0;
  font-size: 14px;
  font-weight: 500;
}
.google-banner.disconnected {
  background: rgba(231, 76, 60, 0.1);
  border: 1px solid rgba(231, 76, 60, 0.3);
  color: #c0392b;
}
.google-banner.connected {
  background: rgba(39, 174, 96, 0.1);
  border: 1px solid rgba(39, 174, 96, 0.3);
  color: #27ae60;
}
.google-banner-text { flex: 1; }
.google-banner-btn {
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  text-decoration: none;
  display: inline-block;
}
.google-banner-btn.connect {
  background: #4285F4;
  color: white;
}
.google-banner-btn.disconnect {
  background: rgba(0,0,0,0.1);
  color: inherit;
}

/* ========== Recently generated manuals ========== */
.manual-history {
  margin: 0 0 16px 0;
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-sm);
}
.history-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}
.history-header {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-secondary);
}
.history-tools { display: flex; align-items: center; gap: 8px; }
.history-search {
  padding: 5px 10px;
  border-radius: 6px;
  border: 1px solid var(--border-default);
  background: var(--bg-input);
  color: var(--text-primary);
  font-size: 13px;
  font-family: var(--font-sans);
  width: 160px;
}
.history-search:focus { outline: none; border-color: var(--border-focus); background: var(--bg-input-focus); }
.history-clear {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 12px;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 6px;
}
.history-clear:hover { color: #e74c3c; }
.history-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.history-item { margin: 0; display: flex; align-items: stretch; gap: 4px; }
.history-link {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 8px 10px;
  border-radius: 6px;
  text-decoration: none;
  transition: background 0.15s ease;
  min-width: 0;
}
.history-link:hover { background: var(--bg-card-hover); }
.history-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.history-meta {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}
.history-delete {
  flex-shrink: 0;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0 8px;
  border-radius: 6px;
  font-size: 14px;
}
.history-delete:hover { color: #e74c3c; background: var(--bg-card-hover); }
.history-empty { font-size: 13px; color: var(--text-muted); padding: 4px 0; }

/* ========== Field hint ========== */
.field-hint {
  font-size: 12px;
  color: var(--text-secondary);
  margin: 6px 0 0 0;
}

/* ========== File reorder (drag-drop) ========== */
.file-item[draggable="true"] { cursor: grab; }
.file-item.dragging { opacity: 0.45; cursor: grabbing; }
.file-item.drag-over { border-color: var(--border-focus); box-shadow: 0 0 0 2px var(--border-accent); }
.file-drag-handle {
  flex-shrink: 0;
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1;
  padding-right: 4px;
  cursor: grab;
  user-select: none;
}

/* ── Form flow: step badges, 3-column project row, submit gating hint ── */
.step-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--ug-green);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
}

.form-row-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.form-step-divider {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  margin: 12px 0 4px 0;
  padding-top: 14px;
  border-top: 1px solid var(--border-subtle);
}

.submit-hint {
  text-align: center;
  font-size: 12px;
  color: #E67E22;
  margin-top: 8px;
}

@media (max-width: 640px) {
  .form-row-3 { grid-template-columns: 1fr; }
}

/* ── Context preset chips ── */
.context-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

.preset-chip {
  border: 1px solid var(--border-subtle);
  background: transparent;
  color: var(--text-muted);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.preset-chip:hover {
  border-color: var(--ug-green);
  color: var(--ug-green);
  background: var(--ug-green-pale);
}

/* ── Regenerate-with-feedback box ── */
.feedback-box {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 12px 0;
  padding: 12px;
  border: 1px dashed var(--border-subtle);
  border-radius: 10px;
}

.feedback-box .btn-action {
  align-self: flex-start;
}

/* ── Client names field (diff mode: DOCX reviewer comments) ── */
.client-names-field {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed var(--border-subtle);
}

.client-names-field .form-label {
  margin-bottom: 6px;
}

/* ── Update-preview banner (original Doc approval flow) ── */
.preview-banner {
  margin-bottom: 14px;
  padding: 10px 14px;
  border: 1px solid #E67E22;
  border-radius: 10px;
  background: rgba(230, 126, 34, 0.08);
  color: #E67E22;
  font-size: 13px;
}

.markdown-body mark {
  background: #FFF176;
  color: #333;
  padding: 0 2px;
  border-radius: 2px;
}
