:root {
  /* Palette pulled from the converter's own output, so the UI matches the
     Word document it produces. */
  --ink:        #0E1B2A;   /* primary text / deep navy */
  --ink-2:      #41525F;   /* secondary text */
  --ink-3:      #74848F;   /* faint text, captions */
  --paper:      #EDF1F5;   /* page background */
  --surface:    #FFFFFF;   /* cards */
  --accent:     #1A5485;   /* riyad heading blue */
  --accent-2:   #2372B2;   /* metadata band blue */
  --accent-soft:#D6E4F0;   /* step-table header tint */
  --line:       #DCE6EE;   /* hairline borders */
  --line-strong:#9DB7C9;   /* table border gray */
  --ok:         #157F6B;   /* muted teal-green */
  --ok-soft:    #E2F0EB;
  --err:        #B23A2E;   /* brick */
  --err-soft:   #F7E7E4;

  --font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "JetBrains Mono", "Cascadia Code", Menlo, Consolas, monospace;

  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(14,27,42,.05), 0 8px 28px rgba(14,27,42,.06);
  --maxw: 760px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font-ui);
  color: var(--ink);
  background:
    /* faint vertical column rules near the top, evoking the step-table grid */
    linear-gradient(90deg, transparent calc(50% - 360px), color-mix(in srgb, var(--line) 55%, transparent) calc(50% - 360px), transparent calc(50% - 359px)) 0 0 / 100% 320px no-repeat,
    linear-gradient(90deg, transparent calc(50% - 120px), color-mix(in srgb, var(--line) 45%, transparent) calc(50% - 120px), transparent calc(50% - 119px)) 0 0 / 100% 320px no-repeat,
    linear-gradient(90deg, transparent calc(50% + 120px), color-mix(in srgb, var(--line) 45%, transparent) calc(50% + 120px), transparent calc(50% + 121px)) 0 0 / 100% 320px no-repeat,
    linear-gradient(90deg, transparent calc(50% + 360px), color-mix(in srgb, var(--line) 55%, transparent) calc(50% + 360px), transparent calc(50% + 361px)) 0 0 / 100% 320px no-repeat,
    var(--paper);
  line-height: 1.55;
}

.mono { font-family: var(--font-mono); }

.visually-hidden, .skip-link:not(:focus) {
  position: absolute !important; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: fixed; top: 10px; left: 10px; z-index: 50;
  background: var(--accent); color: #fff; padding: 8px 14px;
  border-radius: var(--radius-sm); text-decoration: none; font-weight: 600;
}

/* -------------------------------------------------------------- top bar --- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 18px 24px;
  max-width: var(--maxw); margin: 0 auto;
}
.brand { display: flex; align-items: center; gap: 12px; }
.mark { width: 34px; height: 34px; flex: 0 0 auto; }
.wordmark { display: flex; flex-direction: column; line-height: 1.15; }
.wordmark .name { font-weight: 700; letter-spacing: -0.01em; font-size: 1.05rem; }
.wordmark .sub { font-size: .8rem; color: var(--ink-3); }

.status {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--font-mono); font-size: .78rem; color: var(--ink-2);
  background: var(--surface); border: 1px solid var(--line);
  padding: 7px 12px; border-radius: 999px;
}
.status-dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--ink-3); flex: 0 0 auto;
}
.status[data-state="ok"]       .status-dot { background: var(--ok); box-shadow: 0 0 0 4px var(--ok-soft); }
.status[data-state="degraded"] .status-dot { background: var(--err); box-shadow: 0 0 0 4px var(--err-soft); }
.status[data-state="offline"]  .status-dot { background: var(--ink-3); }
.status[data-state="checking"] .status-dot { background: var(--accent-2); animation: pulse 1.4s ease-in-out infinite; }

/* ----------------------------------------------------------------- main --- */
main {
  max-width: var(--maxw); margin: 0 auto; padding: 8px 24px 64px;
}
.hero { padding: 18px 0 26px; }
.hero h1 {
  font-size: clamp(1.7rem, 4.4vw, 2.5rem);
  line-height: 1.1; letter-spacing: -0.02em; margin: 0 0 .5em;
}
.lede { font-size: 1.05rem; color: var(--ink-2); margin: 0; max-width: 60ch; }
.lede code, .hero code {
  font-family: var(--font-mono); font-size: .92em;
  background: var(--accent-soft); color: var(--accent);
  padding: .05em .35em; border-radius: 5px;
}

.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 26px; margin-top: 22px;
}

/* ------------------------------------------------------------ converter --- */
.converter { padding: 22px; }
.view { animation: fade .25s ease both; }

.dropzone {
  border: 1.5px dashed var(--line-strong); border-radius: var(--radius);
  background: color-mix(in srgb, var(--accent-soft) 22%, var(--surface));
  padding: 40px 24px; text-align: center; cursor: pointer;
  transition: border-color .15s, background .15s, transform .05s;
}
.dropzone:hover { border-color: var(--accent-2); background: color-mix(in srgb, var(--accent-soft) 40%, var(--surface)); }
.dropzone:focus-visible { outline: 3px solid var(--accent-2); outline-offset: 3px; }
.dropzone.dragover {
  border-color: var(--accent); border-style: solid;
  background: color-mix(in srgb, var(--accent-soft) 60%, var(--surface));
  transform: scale(1.005);
}
.dz-icon { width: 48px; height: 48px; margin-bottom: 6px; }
.dz-title { font-size: 1.15rem; font-weight: 650; margin: 6px 0 2px; }
.dz-sub { margin: 0; color: var(--ink-2); }
.dz-sub .link { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.hint { text-align: center; color: var(--ink-3); font-size: .85rem; margin: 14px 0 2px; }

.file-row {
  display: flex; align-items: center; gap: 14px;
  padding: 14px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--accent-soft) 16%, var(--surface));
}
.file-glyph {
  flex: 0 0 auto; width: 44px; height: 44px; border-radius: 8px;
  display: grid; place-items: center; font-family: var(--font-mono);
  font-size: .72rem; font-weight: 700; color: #fff; background: var(--accent);
  letter-spacing: .04em;
}
.file-meta { flex: 1 1 auto; min-width: 0; }
.file-name { margin: 0; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-size { margin: 2px 0 0; font-size: .82rem; color: var(--ink-3); }

.actions { display: flex; align-items: center; gap: 16px; margin-top: 20px; flex-wrap: wrap; }

.btn-primary {
  appearance: none; border: 0; cursor: pointer; text-decoration: none;
  background: var(--accent); color: #fff; font-family: var(--font-ui);
  font-size: 1rem; font-weight: 600; padding: 13px 24px;
  border-radius: var(--radius-sm); transition: background .15s, transform .05s;
  display: inline-flex; align-items: center; gap: 8px;
}
.btn-primary:hover { background: #14456e; }
.btn-primary:active { transform: translateY(1px); }
.btn-primary:focus-visible { outline: 3px solid var(--accent-2); outline-offset: 2px; }

.btn-text {
  appearance: none; border: 0; background: none; cursor: pointer;
  color: var(--ink-2); font-family: var(--font-ui); font-size: .92rem;
  padding: 6px 4px; text-decoration: underline; text-underline-offset: 3px;
}
.btn-text:hover { color: var(--accent); }
.btn-text:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 2px; border-radius: 4px; }

/* ----------------------------------------------- pipeline (signature) --- */
.run-file { color: var(--ink-3); font-size: .85rem; margin: 0 0 18px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.pipeline {
  list-style: none; margin: 0; padding: 6px 0; display: flex; gap: 0;
}
.pipeline li {
  flex: 1 1 0; position: relative; text-align: center;
  padding-top: 38px;
}
/* connector line behind the nodes */
.pipeline li::before {
  content: ""; position: absolute; top: 14px; left: -50%; width: 100%; height: 2px;
  background: var(--line); z-index: 0;
}
.pipeline li:first-child::before { display: none; }
.pipeline li[data-state="done"]::before,
.pipeline li[data-state="active"]::before { background: var(--accent-2); }

.pipeline .node {
  position: absolute; top: 0; left: 50%; transform: translateX(-50%);
  width: 30px; height: 30px; border-radius: 50%; z-index: 1;
  display: grid; place-items: center;
  background: var(--surface); border: 2px solid var(--line);
  font-family: var(--font-mono); font-size: .8rem; color: var(--ink-3);
  transition: background .2s, border-color .2s, color .2s;
}
.pipeline li[data-state="done"] .node { background: var(--ok); border-color: var(--ok); color: #fff; }
.pipeline li[data-state="active"] .node {
  background: var(--accent); border-color: var(--accent); color: #fff;
}
.pipeline li[data-state="active"] .node::after {
  content: ""; position: absolute; inset: -6px; border-radius: 50%;
  border: 2px solid var(--accent); opacity: .5; animation: ring 1.5s ease-out infinite;
}
.pipeline .node svg { width: 16px; height: 16px; }
.pipeline .plabel {
  display: block; font-size: .78rem; color: var(--ink-3); padding: 0 4px;
  font-family: var(--font-mono); letter-spacing: -0.01em;
}
.pipeline li[data-state="active"] .plabel { color: var(--accent); font-weight: 600; }
.pipeline li[data-state="done"] .plabel { color: var(--ink-2); }

.run-note { text-align: center; color: var(--ink-2); font-size: .82rem; margin: 18px 0 2px; min-height: 1.2em; }
.run-note.queued { color: var(--accent-2); }
.run-note.error  { color: var(--err); }

/* ---------------------------------------------------------- result rows --- */
.result { display: flex; align-items: center; gap: 16px; padding: 6px 0; }
.result-icon { width: 40px; height: 40px; flex: 0 0 auto; border-radius: 50%; padding: 7px; }
.result.ok  .result-icon { color: var(--ok); background: var(--ok-soft); }
.result.err .result-icon { color: var(--err); background: var(--err-soft); }
.result-title { margin: 0; font-weight: 650; font-size: 1.12rem; }
.result-sub { margin: 3px 0 0; color: var(--ink-2); font-size: .9rem; }
.result.ok .result-sub { color: var(--ink-3); }

/* ---------------------------------------------------------------- notes --- */
.notes h2 { font-size: 1.15rem; margin: 0 0 4px; letter-spacing: -0.01em; }
.notes-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 26px; margin-top: 14px; }
.notes-grid h3 {
  font-size: .76rem; text-transform: uppercase; letter-spacing: .08em;
  color: var(--accent); margin: 0 0 8px; font-family: var(--font-mono); font-weight: 600;
}
.notes-grid ul { margin: 0; padding-left: 18px; color: var(--ink-2); }
.notes-grid li { margin: 6px 0; font-size: .92rem; }
.notes-grid strong { color: var(--ink); font-weight: 600; }
.retention {
  margin: 22px 0 0; padding-top: 16px; border-top: 1px solid var(--line);
  color: var(--ink-3); font-size: .86rem;
}

/* --------------------------------------------------------------- footer --- */
.footer {
  max-width: var(--maxw); margin: 0 auto; padding: 0 24px 40px;
  display: flex; gap: 10px; flex-wrap: wrap; align-items: center;
  color: var(--ink-3); font-size: .82rem;
}
.footer .dot { opacity: .5; }

/* ------------------------------------------------------------ animation --- */
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .35; } }
@keyframes ring  { 0% { transform: scale(.7); opacity: .6; } 100% { transform: scale(1.5); opacity: 0; } }
@keyframes fade  { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

@media (max-width: 600px) {
  .topbar { flex-wrap: wrap; }
  .notes-grid { grid-template-columns: 1fr; gap: 18px; }
  .pipeline { flex-direction: column; gap: 14px; align-items: stretch; }
  .pipeline li { padding: 0 0 0 42px; text-align: left; min-height: 30px; display: flex; align-items: center; }
  .pipeline li::before { top: -14px; left: 14px; width: 2px; height: 100%; }
  .pipeline li:first-child::before { display: none; }
  .pipeline .node { left: 0; top: 50%; transform: translateY(-50%); }
  .pipeline .plabel { padding-left: 0; }
}

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