:root {
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-2: #f7f6f4;
  --border: #e7e4de;
  --text: #242220;
  --text-muted: #8a8681;

  /* Brand palette, pulled directly from the letterhead ribbon */
  --gold: #f2a93b;
  --orange: #e8542a;
  --magenta: #c8185e;
  --purple: #7b4397;
  --cyan: #2eb5e0;

  --accent: var(--orange);
  --safe: var(--cyan);
  --danger: var(--magenta);

  --radius: 10px;
  --display-font: Georgia, 'Iowan Old Style', 'Palatino Linotype', serif;
  --body-font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --mono-font: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
  --brand-ribbon: linear-gradient(90deg, var(--gold), var(--orange), var(--magenta), var(--purple), var(--cyan));
}

* { box-sizing: border-box; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--body-font);
}

.brand-ribbon {
  height: 5px;
  width: 100%;
  background: var(--brand-ribbon);
}

.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 20px 32px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.brand { display: flex; align-items: center; gap: 10px; }

.brand-logo { height: 32px; width: auto; display: block; }

.brand-mark {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--orange);
}

.brand-name {
  font-family: var(--display-font);
  font-size: 1.3rem;
  letter-spacing: 0.01em;
  color: var(--text);
}

.brand-tag { margin: 0; color: var(--text-muted); font-size: 0.85rem; }

.stage { max-width: 760px; margin: 0 auto; padding: 56px 24px 40px; }

.intro h1 {
  font-family: var(--display-font);
  font-weight: 500;
  font-size: clamp(2rem, 4.5vw, 2.9rem);
  line-height: 1.15;
  margin: 0 0 16px;
  letter-spacing: -0.01em;
  color: var(--text);
}

.intro p {
  color: var(--text-muted);
  font-size: 1.02rem;
  line-height: 1.6;
  max-width: 56ch;
  margin: 0 0 36px;
}

.mode-switch {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  margin-bottom: 24px;
}

.mode-btn {
  border: none;
  background: transparent;
  color: var(--text-muted);
  padding: 9px 18px;
  border-radius: 999px;
  font-size: 0.9rem;
  font-family: var(--body-font);
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
}

.mode-btn:hover { color: var(--text); }

/* Each mode gets its own brand color when active, instead of one repeated orange */
.mode-btn.is-active { color: #fff; font-weight: 600; }
.mode-btn[data-mode="office"].is-active { background: var(--orange); }
.mode-btn[data-mode="images"].is-active { background: var(--purple); }
.mode-btn[data-mode="merge"].is-active { background: var(--magenta); }

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: 0 1px 3px rgba(36, 34, 32, 0.05);
}

.dropzone {
  border: 1.5px dashed var(--border);
  border-radius: var(--radius);
  padding: 40px 20px;
  text-align: center;
  cursor: pointer;
  color: var(--text-muted);
  background: var(--surface-2);
  transition: border-color 0.2s ease, background 0.2s ease;
}

.dropzone:hover, .dropzone:focus-visible, .dropzone.is-drag {
  border-color: var(--orange);
  background: rgba(232, 84, 42, 0.06);
  outline: none;
}

.dropzone-glyph { color: var(--orange); margin-bottom: 10px; }
.dropzone-title { color: var(--text); font-size: 1rem; margin: 0 0 4px; }
.dropzone-sub { margin: 0; font-size: 0.85rem; }

.file-list {
  list-style: none;
  margin: 18px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.file-chip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 0.88rem;
  animation: rise 0.25s ease;
}

.file-chip.is-ashing { animation: ash-out 0.6s ease forwards; }

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

@keyframes ash-out {
  to { opacity: 0; transform: translateY(-4px) scale(0.98); filter: blur(2px); }
}

.file-chip-name {
  font-family: var(--mono-font);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
}

.file-chip-size { color: var(--text-muted); flex-shrink: 0; }

.file-chip-remove {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 2px 6px;
}
.file-chip-remove:hover { color: var(--magenta); }

.panel-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 22px;
  gap: 16px;
}

.hint { margin: 0; color: var(--text-muted); font-size: 0.85rem; }

.convert-btn {
  background: var(--orange);
  color: #fff;
  border: none;
  font-weight: 600;
  font-size: 0.92rem;
  padding: 11px 26px;
  border-radius: 999px;
  cursor: pointer;
  transition: transform 0.15s ease, opacity 0.15s ease;
  flex-shrink: 0;
}

.convert-btn:hover:not(:disabled) { transform: translateY(-1px); }
.convert-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.progress-track {
  margin-top: 18px;
  height: 6px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 30%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--orange), var(--magenta), var(--purple));
  animation: ember-move 1.1s ease-in-out infinite;
}

@keyframes ember-move {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(340%); }
}

.result {
  margin-top: 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  background: rgba(46, 181, 224, 0.08);
  border: 1px solid rgba(46, 181, 224, 0.3);
  border-radius: var(--radius);
  padding: 16px 18px;
  animation: rise 0.35s ease;
}

.result-icon {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--cyan);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 0.9rem;
}

.result-copy { flex: 1; }
.result-title { margin: 0 0 2px; font-weight: 600; color: var(--text); }
.result-sub { margin: 0; color: var(--text-muted); font-size: 0.82rem; line-height: 1.5; }

.download-btn {
  background: var(--cyan);
  color: #fff;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.88rem;
  padding: 9px 18px;
  border-radius: 999px;
  flex-shrink: 0;
}

.error {
  margin-top: 16px;
  color: var(--magenta);
  background: rgba(200, 24, 94, 0.06);
  border: 1px solid rgba(200, 24, 94, 0.25);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 0.88rem;
}

.how {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  margin-top: 44px;
}

.how-step { border-top: 3px solid var(--border); padding-top: 12px; }
.how-step:nth-child(1) { border-top-color: var(--gold); }
.how-step:nth-child(2) { border-top-color: var(--orange); }
.how-step:nth-child(3) { border-top-color: var(--magenta); }

.how-index {
  display: block;
  font-family: var(--display-font);
  color: var(--text);
  font-size: 0.95rem;
  margin-bottom: 6px;
}

.how-step p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.85rem;
  line-height: 1.55;
}

.page-footer {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.78rem;
  padding: 30px 24px 40px;
}

@media (max-width: 620px) {
  .how { grid-template-columns: 1fr; }
  .panel-footer { flex-direction: column; align-items: stretch; }
  .convert-btn { width: 100%; }
}

/* --- Hero layout with 3D document stack illustration --- */

.intro {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 32px;
}

.intro-copy { flex: 1 1 380px; min-width: 280px; }

.intro-art {
  flex: 0 0 220px;
  display: flex;
  justify-content: center;
}

.stack-svg {
  width: 220px;
  height: auto;
  filter: drop-shadow(0 24px 30px rgba(36, 34, 32, 0.14));
}

.stack-sheet {
  transform-origin: 50% 50%;
}

.stack-sheet-1 { animation: float1 5s ease-in-out infinite; }
.stack-sheet-2 { animation: float2 6s ease-in-out infinite; }
.stack-sheet-3 { animation: float3 4.5s ease-in-out infinite; }

@keyframes float1 {
  0%, 100% { transform: rotate(-6deg) translateY(0); }
  50% { transform: rotate(-6deg) translateY(-6px); }
}
@keyframes float2 {
  0%, 100% { transform: rotate(3deg) translateY(0); }
  50% { transform: rotate(3deg) translateY(-4px); }
}
@keyframes float3 {
  0%, 100% { transform: rotate(-2deg) translateY(0); }
  50% { transform: rotate(-2deg) translateY(-8px); }
}

@media (max-width: 700px) {
  .intro {
    flex-direction: column-reverse;
    text-align: left;
  }
  .intro-art { flex: none; width: 160px; }
  .stack-svg { width: 160px; }
}
/* --- PDF editor workspace --- */

.canvas-wrap {
  position: relative;
  margin-top: 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: auto;
  max-height: 70vh;
  background: var(--surface-2);
  display: flex;
  justify-content: center;
  padding: 16px;
}

#pdfCanvas {
  box-shadow: 0 2px 10px rgba(36, 34, 32, 0.12);
  background: #fff;
  cursor: text;
}

.edit-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.edit-nav-btn {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  width: 32px;
  height: 32px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
}
.edit-nav-btn:hover { border-color: var(--orange); }

.edit-page-indicator {
  font-size: 0.85rem;
  color: var(--text-muted);
  min-width: 90px;
}

.edit-hint {
  font-size: 0.82rem;
  color: var(--text-muted);
  flex: 1;
}

.edit-toolbar .convert-btn {
  padding: 8px 18px;
  font-size: 0.85rem;
}

.pdf-text-box {
  position: absolute;
  min-width: 60px;
  min-height: 20px;
  padding: 2px 4px;
  font-family: var(--body-font);
  font-size: 16px;
  color: #1a1a1a;
  background: rgba(255, 235, 150, 0.35);
  border: 1px dashed var(--orange);
  outline: none;
  white-space: pre-wrap;
}

.pdf-text-box:focus {
  background: rgba(255, 235, 150, 0.55);
}
/* --- Language toggle button --- */

.lang-toggle {
  margin-inline-start: auto;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 7px 16px;
  border-radius: 999px;
  font-size: 0.82rem;
  cursor: pointer;
  font-family: var(--body-font);
}

.lang-toggle:hover { border-color: var(--orange); }

/* --- Arabic / RTL support --- */

[dir="rtl"] {
  --display-font: 'Segoe UI', Tahoma, Arial, sans-serif;
}

[dir="rtl"] body {
  font-family: 'Segoe UI', Tahoma, Arial, sans-serif;
}

/* Filenames stay left-to-right even in Arabic mode, since they're
   usually Latin-script system filenames and look broken if mirrored. */
[dir="rtl"] .file-chip-name {
  direction: ltr;
  text-align: left;
}

[dir="rtl"] .intro-art {
  order: -1;
}

@media (max-width: 700px) {
  [dir="rtl"] .intro {
    flex-direction: column-reverse;
  }
}