/* =========================================================
   TOKENS
========================================================= */
:root{
  --ink-950: #0D1017;
  --ink-900: #12151C;
  --ink-800: #171C26;
  --surface: #1B2029;
  --surface-2: #212734;
  --border: #2A3140;
  --border-soft: #232938;

  --text-hi: #EDEFF4;
  --text-mid: #A7AEC0;
  --text-low: #6C7387;

  --accent: #5B8DEF;        /* indigo-cyan — link/primary */
  --accent-soft: #5B8DEF26;
  --accent-2: #34D6C4;      /* teal — success / destination */
  --signal: #F2A93B;        /* amber — in-progress / warning */
  --danger: #F0577A;

  --font-display: "JetBrains Mono", ui-monospace, monospace;
  --font-body: "Inter", -apple-system, sans-serif;

  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-sm: 8px;

  --shadow-card: 0 1px 0 rgba(255,255,255,0.02) inset, 0 20px 40px -24px rgba(0,0,0,0.6);
}

*{ box-sizing: border-box; }
html,body{ height:100%; }

body{
  margin:0;
  background: radial-gradient(1200px 600px at 15% -10%, #1A2130 0%, var(--ink-950) 55%) fixed;
  color: var(--text-hi);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}

.noise-overlay{
  position: fixed; inset:0; pointer-events:none; z-index:0;
  background-image: radial-gradient(rgba(255,255,255,0.025) 1px, transparent 1px);
  background-size: 3px 3px;
  opacity:0.5;
}

.app{ position:relative; z-index:1; max-width: 1180px; margin: 0 auto; padding: 28px 24px 60px; }

/* =========================================================
   TOPBAR
========================================================= */
.topbar{
  display:flex; align-items:center; justify-content:space-between;
  padding-bottom: 22px; margin-bottom: 26px;
  border-bottom: 1px solid var(--border-soft);
}
.brand{ display:flex; align-items:center; gap:12px; }
.brand-mark{
  font-size: 22px; color: var(--ink-950);
  width:38px; height:38px; display:grid; place-items:center;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-radius: 10px;
  font-family: var(--font-display);
}
.brand-text{ display:flex; flex-direction:column; line-height:1.15; }
.brand-name{ font-family: var(--font-display); font-weight:700; font-size:17px; letter-spacing:0.2px; }
.brand-tag{ font-size:11.5px; color: var(--text-low); letter-spacing:0.3px; }

.auth-area{ display:flex; align-items:center; gap:10px; }
.auth-status-text{ font-size:13px; color: var(--text-mid); font-family: var(--font-display); }
.status-dot{ width:8px; height:8px; border-radius:50%; display:inline-block; }
.status-dot--off{ background: var(--text-low); }
.status-dot--on{ background: var(--accent-2); box-shadow: 0 0 0 4px #34D6C41f; }

/* =========================================================
   BUTTONS
========================================================= */
.btn{
  font-family: var(--font-body);
  font-weight:600; font-size:13.5px; letter-spacing:0.2px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor:pointer;
  padding: 9px 16px;
  transition: transform .12s ease, background .15s ease, border-color .15s ease, opacity .15s ease;
  display:inline-flex; align-items:center; justify-content:center; gap:8px;
}
.btn:active{ transform: translateY(1px); }
.btn:disabled{ opacity:0.4; cursor:not-allowed; }

.btn--ghost{ background: transparent; border-color: var(--border); color: var(--text-hi); }
.btn--ghost:hover:not(:disabled){ border-color: var(--accent); color: var(--accent); }
.btn--sm{ padding:7px 12px; font-size:12.5px; }

.btn--secondary{ background: var(--surface-2); border-color: var(--border); color: var(--text-hi); }
.btn--secondary:hover:not(:disabled){ border-color: var(--accent); background:#232B3B; }

.btn--full{ width:100%; margin-top:12px; }

.btn--primary{
  background: linear-gradient(135deg, var(--accent), #7AA6FF);
  color: #0B0E14; border: none;
  font-family: var(--font-display); font-weight:700; letter-spacing:0.4px;
  box-shadow: 0 12px 24px -12px #5B8DEF80;
}
.btn--primary:hover:not(:disabled){ filter: brightness(1.06); }

.btn--danger-ghost{ background: transparent; border-color: var(--border); color: var(--text-mid); }
.btn--danger-ghost:hover:not(:disabled){ border-color: var(--danger); color: var(--danger); }

.btn--lg{ padding: 14px 26px; font-size:14px; flex:1; }

.icon-btn{
  width:38px; height:38px; flex-shrink:0;
  border-radius: var(--radius-sm);
  border:1px solid var(--border); background: var(--surface-2);
  color: var(--text-mid); cursor:pointer; font-size:15px;
  transition: all .15s ease;
}
.icon-btn:hover{ border-color: var(--accent); color: var(--accent); }
.icon-btn.is-copied{ border-color: var(--accent-2); color: var(--accent-2); }

.btn-loader{
  width:14px; height:14px; border-radius:50%;
  border: 2px solid #0B0E1440; border-top-color:#0B0E14;
  display:none; animation: spin .7s linear infinite;
}
.btn--primary.is-loading .btn-loader{ display:inline-block; }

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

/* =========================================================
   PIPELINE LAYOUT
========================================================= */
.pipeline{
  display:grid;
  grid-template-columns: 1fr 120px 1fr;
  align-items:start;
  gap: 8px;
}
@media (max-width: 860px){
  .pipeline{ grid-template-columns: 1fr; }
  .flow-connector{ transform: rotate(90deg); margin: 4px auto; width:64px; }
}

.doc-card{
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: var(--shadow-card);
}
.doc-card--source{ border-top: 2px solid var(--accent); }
.doc-card--dest{ border-top: 2px solid var(--accent-2); }

.doc-card__eyebrow{
  font-family: var(--font-display); font-size:11px; letter-spacing:1px;
  color: var(--text-low); text-transform:uppercase; margin-bottom:14px;
}

.field-label{ display:block; font-size:12.5px; color: var(--text-mid); margin-bottom:8px; }

.url-row{ display:flex; gap:8px; }
.url-input{
  flex:1; min-width:0;
  background: var(--ink-900);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-hi);
  font-family: var(--font-display);
  font-size:13px;
  padding: 12px 14px;
  outline:none;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.url-input::placeholder{ color: var(--text-low); }
.url-input:focus{ border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.url-input.is-invalid{ border-color: var(--danger); }
.url-input.is-valid{ border-color: var(--accent-2); }

.field-hint{ font-size:11.5px; margin: 7px 2px 0; min-height:14px; }
.field-hint.is-error{ color: var(--danger); }
.field-hint.is-ok{ color: var(--accent-2); }

.doc-preview{
  margin-top:16px;
  background: var(--ink-900);
  border: 1px dashed var(--border);
  border-radius: var(--radius-md);
  min-height: 120px; max-height:180px; overflow-y:auto;
  padding: 14px 16px;
  font-size: 12.5px; color: var(--text-mid);
}
.doc-preview__empty{ color: var(--text-low); font-style:italic; }
.doc-preview h1,.doc-preview h2,.doc-preview h3{ color: var(--text-hi); margin:0 0 6px; font-size:14px;}
.doc-preview p{ margin:0 0 8px; }
.doc-preview ul,.doc-preview ol{ margin:0 0 8px; padding-left:18px; }
.doc-preview b{ color: var(--text-hi); }

.stat-row{ display:flex; gap:20px; margin-top:16px; }
.stat{ display:flex; flex-direction:column; }
.stat-num{ font-family: var(--font-display); font-size:19px; font-weight:700; color: var(--text-hi); }
.stat-label{ font-size:10.5px; color: var(--text-low); text-transform:uppercase; letter-spacing:0.5px; }

/* Mode toggle */
.mode-toggle{
  display:flex; background: var(--ink-900); border:1px solid var(--border);
  border-radius: var(--radius-sm); padding:3px; margin-top:4px;
}
.mode-opt{
  flex:1; border:none; background:transparent; color: var(--text-mid);
  font-size:12.5px; font-weight:600; padding:9px 10px; border-radius:6px; cursor:pointer;
  transition: all .15s ease; font-family: var(--font-body);
}
.mode-opt.is-active{ background: var(--surface-2); color: var(--text-hi); box-shadow: inset 0 0 0 1px var(--border); }
.mode-opt[data-mode="replace"].is-active{ color: var(--danger); }

.dest-warning{
  margin-top:12px; font-size:11.5px; line-height:1.5; color: var(--text-mid);
  background: var(--accent-soft); border:1px solid #5B8DEF33;
  border-radius: var(--radius-sm); padding:10px 12px;
}
.dest-warning.is-danger{ background:#F0577A1a; border-color:#F0577A40; color:#FFC2D2; }
.dest-warning strong{ color: var(--text-hi); }

/* =========================================================
   FLOW CONNECTOR (signature element)
========================================================= */
.flow-connector{
  position:relative; height: 140px; display:flex; align-items:center; justify-content:center;
  margin-top: 46px;
}
.flow-track{ width:100%; height:40px; overflow:visible; }
.flow-track path{
  fill:none; stroke: var(--border); stroke-width:2; stroke-dasharray: 4 6;
}
.flow-dots{ position:absolute; inset:0; }
.flow-dot{
  position:absolute; top:50%; left:0; width:7px; height:7px; border-radius:50%;
  background: var(--text-low); transform: translate(-50%,-50%);
  opacity:0;
}
.flow-connector.is-active .flow-dot{
  background: var(--signal);
  box-shadow: 0 0 8px 1px #F2A93B80;
  animation: flow-move 1.6s ease-in-out infinite;
}
.flow-connector.is-done .flow-track path{ stroke: var(--accent-2); stroke-dasharray:none; }
.flow-connector.is-done .flow-dot{ display:none; }

.flow-connector.is-active .flow-dot:nth-child(1){ animation-delay: 0s; }
.flow-connector.is-active .flow-dot:nth-child(2){ animation-delay: 0.5s; }
.flow-connector.is-active .flow-dot:nth-child(3){ animation-delay: 1s; }

@keyframes flow-move{
  0%{ left:0%; opacity:0; }
  10%{ opacity:1; }
  90%{ opacity:1; }
  100%{ left:100%; opacity:0; }
}

.flow-badge{
  position:absolute; bottom:0; left:50%; transform:translateX(-50%);
  font-family: var(--font-display); font-size:10px; letter-spacing:0.5px;
  color: var(--text-low); background: var(--ink-900); border:1px solid var(--border);
  padding:3px 9px; border-radius:20px; text-transform:uppercase;
}
.flow-connector.is-active .flow-badge{ color: var(--signal); border-color:#F2A93B55; }
.flow-connector.is-done .flow-badge{ color: var(--accent-2); border-color:#34D6C455; }

@media (prefers-reduced-motion: reduce){
  .flow-connector.is-active .flow-dot{ animation:none; opacity:1; left:50%; }
}

/* =========================================================
   ACTION BAR
========================================================= */
.action-bar{ display:flex; gap:14px; margin: 30px 0; }
@media (max-width:560px){ .action-bar{ flex-direction:column; } }

/* =========================================================
   STATUS PANEL
========================================================= */
.status-panel{ display:grid; grid-template-columns: 260px 1fr; gap:18px; }
@media (max-width: 860px){ .status-panel{ grid-template-columns: 1fr; } }

.status-steps{
  background: var(--surface); border:1px solid var(--border-soft); border-radius: var(--radius-lg);
  padding: 18px; display:flex; flex-direction:column; gap:14px;
}
.step{
  font-size:12.5px; color: var(--text-low); display:flex; align-items:center; gap:10px;
  transition: color .2s ease;
}
.step-dot{ width:8px; height:8px; border-radius:50%; background: var(--border); flex-shrink:0; transition: all .2s ease; }
.step.is-active{ color: var(--signal); }
.step.is-active .step-dot{ background: var(--signal); box-shadow:0 0 0 3px #F2A93B26; }
.step.is-done{ color: var(--text-hi); }
.step.is-done .step-dot{ background: var(--accent-2); }
.step.is-error{ color: var(--danger); }
.step.is-error .step-dot{ background: var(--danger); }

.log-terminal{
  background: var(--ink-900); border:1px solid var(--border-soft); border-radius: var(--radius-lg);
  overflow:hidden; display:flex; flex-direction:column; min-height: 230px;
}
.log-terminal__bar{
  display:flex; align-items:center; gap:6px; padding:10px 14px;
  background: var(--ink-800); border-bottom:1px solid var(--border-soft);
}
.log-dot{ width:9px; height:9px; border-radius:50%; }
.log-dot--r{ background:#F0577A; } .log-dot--y{ background:#F2A93B; } .log-dot--g{ background:#34D6C4; }
.log-title{ margin-left:8px; font-family: var(--font-display); font-size:11.5px; color: var(--text-low); }

.log-body{
  flex:1; padding: 12px 16px; overflow-y:auto; max-height: 260px;
  font-family: var(--font-display); font-size:12px; line-height:1.9;
}
.log-line{ white-space: pre-wrap; word-break: break-word; color: var(--text-mid); }
.log-line--muted{ color: var(--text-low); }
.log-line--ok{ color: var(--accent-2); }
.log-line--warn{ color: var(--signal); }
.log-line--error{ color: var(--danger); }
.log-line .ts{ color: var(--text-low); margin-right:8px; }

/* =========================================================
   FOOTNOTE
========================================================= */
.footnote{
  text-align:center; margin-top: 34px; font-size:11.5px; color: var(--text-low);
}
