:root{
  --bg:#020611;
  --panel:rgba(4,14,28,.78);
  --panel2:rgba(7,25,42,.78);
  --line:rgba(93,224,255,.26);
  --line2:rgba(89,255,194,.28);
  --text:#eaffff;
  --muted:#a8bfca;
  --cyan:#5de0ff;
  --green:#59ffc2;
  --gold:#ffd166;
  --danger:#ff6b8a;
}

*{box-sizing:border-box}

body{
  margin:0;
  min-height:100vh;
  color:var(--text);
  font-family:Inter,Arial,sans-serif;
  background:
    radial-gradient(circle at 12% 12%,rgba(93,224,255,.20),transparent 30%),
    radial-gradient(circle at 82% 8%,rgba(89,255,194,.14),transparent 28%),
    radial-gradient(circle at 50% 90%,rgba(93,224,255,.10),transparent 32%),
    linear-gradient(135deg,#01030a,#03111f 50%,#01040b);
  overflow-x:hidden;
}

body:before{
  content:"";
  position:fixed;
  inset:0;
  pointer-events:none;
  background:
    linear-gradient(rgba(255,255,255,.026) 1px,transparent 1px),
    linear-gradient(90deg,rgba(255,255,255,.026) 1px,transparent 1px);
  background-size:44px 44px;
  opacity:.75;
}

body:after{
  content:"";
  position:fixed;
  inset:0;
  pointer-events:none;
  background:linear-gradient(to bottom,rgba(255,255,255,.04),transparent 8%,transparent 92%,rgba(255,255,255,.035));
  mix-blend-mode:screen;
}

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

.ri-page{
  position:relative;
  width:min(1180px,94vw);
  margin:auto;
  padding:26px 0 46px;
}

.topbar{
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:18px;
  margin-bottom:28px;
}

.brand{
  color:var(--text);
  font-weight:900;
  letter-spacing:.24em;
  text-transform:uppercase;
  text-shadow:0 0 18px rgba(93,224,255,.45);
}

.top-actions{
  display:flex;
  align-items:center;
  gap:12px;
  flex-wrap:wrap;
  justify-content:flex-end;
}

.mini-link{
  border:1px solid var(--line);
  border-radius:999px;
  background:rgba(3,10,20,.65);
  padding:10px 14px;
  color:var(--text);
  font-size:13px;
}

.mini-link:hover{
  border-color:rgba(93,224,255,.78);
  box-shadow:0 0 22px rgba(93,224,255,.14);
}

.ai-hero{
  display:grid;
  grid-template-columns:minmax(0,1fr) 300px;
  gap:18px;
  border:1px solid rgba(93,224,255,.16);
  border-radius:28px;
  padding:30px;
  background:linear-gradient(135deg,rgba(4,14,28,.64),rgba(2,8,18,.40));
  box-shadow:0 0 70px rgba(93,224,255,.09);
}

.terminal-label{
  color:var(--green);
  letter-spacing:.26em;
  font-size:12px;
  font-weight:900;
  margin-bottom:16px;
}

h1{
  min-height:80px;
  margin:0;
  max-width:820px;
  font-size:clamp(36px,5vw,68px);
  line-height:1.03;
  letter-spacing:-.045em;
  text-shadow:0 0 34px rgba(93,224,255,.38);
}

.hero-copy{
  color:var(--muted);
  font-size:17px;
  line-height:1.62;
  max-width:760px;
  margin:18px 0 0;
}

.access-card{
  border:1px solid var(--line2);
  border-radius:24px;
  background:linear-gradient(135deg,rgba(5,28,38,.82),rgba(2,8,18,.78));
  padding:20px;
  align-self:stretch;
  display:flex;
  flex-direction:column;
  justify-content:center;
  gap:10px;
}

.access-label{
  color:var(--green);
  font-size:12px;
  font-weight:900;
  letter-spacing:.18em;
  text-transform:uppercase;
}

.access-main{
  font-size:22px;
  font-weight:950;
}

.access-sub{
  color:var(--muted);
  line-height:1.55;
  font-size:13px;
}

.workflow{
  display:grid;
  grid-template-columns:repeat(5,minmax(0,1fr));
  gap:12px;
  margin:18px 0;
}

.step-card{
  min-height:104px;
  text-align:left;
  border:1px solid var(--line);
  border-radius:20px;
  padding:14px;
  background:linear-gradient(145deg,rgba(7,25,42,.74),rgba(2,8,18,.66));
  color:var(--text);
  cursor:pointer;
  transition:.22s ease;
}

.step-card span{
  display:block;
  color:var(--cyan);
  font-size:12px;
  font-weight:950;
  letter-spacing:.2em;
  margin-bottom:12px;
}

.step-card strong{
  display:block;
  font-size:17px;
  margin-bottom:8px;
}

.step-card small{
  color:var(--muted);
  line-height:1.4;
}

.step-card.active,
.step-card:hover{
  border-color:rgba(93,224,255,.78);
  box-shadow:0 0 32px rgba(93,224,255,.16);
  transform:translateY(-2px);
}

.step-card.done{
  border-color:rgba(89,255,194,.50);
}

.step-card.done span,
.step-card.done small{
  color:var(--green);
}

.workspace{
  display:grid;
  grid-template-columns:420px minmax(0,1fr);
  gap:18px;
  align-items:start;
}

.panel{
  position:relative;
  overflow:hidden;
  border:1px solid var(--line);
  border-radius:26px;
  background:linear-gradient(145deg,rgba(7,25,42,.84),rgba(2,8,18,.76));
  padding:22px;
}

.panel h2{
  margin:0 0 14px;
  color:var(--cyan);
}

.panel-head{
  display:flex;
  justify-content:space-between;
  gap:16px;
  align-items:flex-start;
}

.muted{
  color:var(--muted);
  line-height:1.58;
}

label{
  display:block;
  margin-top:14px;
  color:var(--muted);
  font-weight:800;
  font-size:14px;
}

input,
textarea{
  width:100%;
  box-sizing:border-box;
  margin-top:7px;
  padding:12px;
  border:1px solid rgba(93,224,255,.24);
  border-radius:14px;
  color:var(--text);
  background:rgba(3,10,20,.68);
  font:inherit;
  outline:none;
}

textarea{
  min-height:300px;
  resize:vertical;
}

input:focus,
textarea:focus{
  border-color:rgba(93,224,255,.78);
  box-shadow:0 0 0 3px rgba(93,224,255,.10);
}

.action-row{
  display:flex;
  align-items:center;
  gap:10px;
  flex-wrap:wrap;
  margin-top:14px;
}

.action-row.compact{
  margin-top:0;
  justify-content:flex-end;
}

.action-row input[type=file]{
  flex:1 1 220px;
}

.btn{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  width:max-content;
  min-height:42px;
  padding:0 15px;
  border-radius:999px;
  border:1px solid rgba(93,224,255,.28);
  background:rgba(93,224,255,.10);
  color:var(--cyan);
  font-weight:900;
  cursor:pointer;
}

.btn.primary{
  color:var(--green);
  border-color:rgba(89,255,194,.32);
  background:rgba(89,255,194,.08);
}

.btn:disabled{
  opacity:.45;
  cursor:not-allowed;
}

.btn:not(:disabled):hover{
  border-color:rgba(93,224,255,.78);
  box-shadow:0 0 22px rgba(93,224,255,.14);
}

.status-box{
  min-height:22px;
  margin-top:14px;
  color:var(--muted);
  line-height:1.55;
}

.reference-list{
  display:grid;
  gap:12px;
  margin-top:14px;
}

.reference-card{
  border:1px solid rgba(93,224,255,.18);
  border-radius:18px;
  background:rgba(3,10,20,.50);
  padding:14px;
}

.reference-card header{
  display:flex;
  justify-content:space-between;
  gap:12px;
  color:var(--muted);
  font-size:12px;
  font-weight:900;
  margin-bottom:8px;
}

.reference-card p{
  margin:0;
  color:#d1edf3;
  line-height:1.56;
}

.badge{
  display:inline-flex;
  align-items:center;
  border-radius:999px;
  border:1px solid var(--line);
  padding:4px 9px;
  color:var(--muted);
}

.badge.verified{
  color:var(--green);
  border-color:var(--line2);
}

.badge.unresolved{
  color:var(--gold);
  border-color:rgba(255,209,102,.34);
}

.project-drawer{
  position:fixed;
  right:0;
  top:50%;
  transform:translateY(-50%);
  z-index:30;
}

.project-tab{
  writing-mode:vertical-rl;
  transform:rotate(180deg);
  min-height:150px;
  border-radius:22px 0 0 22px;
  border:1px solid rgba(89,255,194,.34);
  border-right:0;
  background:linear-gradient(180deg,rgba(5,28,38,.94),rgba(2,8,18,.88));
  color:var(--green);
  padding:18px 12px;
  font-weight:900;
  cursor:pointer;
  box-shadow:0 0 34px rgba(89,255,194,.10);
}

.project-panel{
  position:absolute;
  right:58px;
  top:50%;
  width:min(360px,calc(100vw - 92px));
  transform:translateY(-50%) translateX(18px);
  opacity:0;
  pointer-events:none;
  border:1px solid rgba(89,255,194,.34);
  border-radius:26px;
  padding:20px;
  background:linear-gradient(135deg,rgba(5,28,38,.96),rgba(2,8,18,.92));
  box-shadow:0 0 58px rgba(89,255,194,.16);
  transition:.22s ease;
}

.project-drawer:hover .project-panel,
.project-drawer.open .project-panel{
  opacity:1;
  pointer-events:auto;
  transform:translateY(-50%) translateX(0);
}

.project-panel h2{
  margin:0 0 12px;
  color:var(--green);
}

.project-list{
  display:grid;
  gap:8px;
  margin-top:12px;
}

.project-item{
  border:1px solid rgba(93,224,255,.18);
  border-radius:14px;
  padding:10px;
  background:rgba(3,10,20,.50);
  cursor:pointer;
}

.project-item:hover{
  border-color:rgba(93,224,255,.78);
}

@media(max-width:980px){
  .ai-hero,
  .workspace{
    grid-template-columns:1fr;
  }

  .workflow{
    grid-template-columns:repeat(2,minmax(0,1fr));
  }
}

@media(max-width:760px){
  .ri-page{padding-top:18px}
  .topbar{align-items:flex-start;flex-direction:column}
  .top-actions{width:100%;justify-content:flex-start}
  .mini-link{border-radius:18px}
  .ai-hero{padding:22px;border-radius:22px}
  h1{min-height:112px}
  .workflow{grid-template-columns:1fr}
  .project-drawer{
    position:relative;
    right:auto;
    top:auto;
    transform:none;
    margin-top:18px;
  }
  .project-tab{
    writing-mode:horizontal-tb;
    transform:none;
    min-height:0;
    width:100%;
    border-radius:999px;
    border-right:1px solid rgba(89,255,194,.34);
  }
  .project-panel{
    position:relative;
    right:auto;
    top:auto;
    width:100%;
    margin-top:14px;
    transform:translateY(-6px);
  }
  .project-drawer:hover .project-panel,
  .project-drawer.open .project-panel{
    transform:translateY(0);
  }
}

.stage-panel{
  position:relative;
  overflow:hidden;
  border:1px solid var(--line);
  border-radius:26px;
  background:linear-gradient(145deg,rgba(7,25,42,.84),rgba(2,8,18,.76));
  padding:24px;
  margin-top:18px;
  box-shadow:0 0 42px rgba(93,224,255,.08);
}

.stage-panel[hidden]{
  display:none !important;
}

.stage-panel h2{
  margin:0 0 12px;
  color:var(--cyan);
  font-size:26px;
}

.stage-panel textarea{
  min-height:360px;
}

.stage-panel .btn{
  margin-top:4px;
}

.project-list{
  display:grid;
  grid-template-columns:repeat(auto-fit,minmax(240px,1fr));
  gap:12px;
  margin-top:16px;
}

.project-item strong{
  display:block;
  color:var(--text);
  margin-bottom:6px;
}

.workflow .step-card{
  cursor:default;
}

.workflow .step-card:hover{
  transform:none;
}

@media(max-width:760px){
  .stage-panel{
    padding:20px;
    border-radius:22px;
  }

  .stage-panel textarea{
    min-height:300px;
  }
}

.active-project{
  margin-top:18px;
  border:1px solid rgba(89,255,194,.34);
  border-radius:22px;
  padding:16px 18px;
  background:
    radial-gradient(circle at 12% 20%,rgba(89,255,194,.14),transparent 36%),
    linear-gradient(135deg,rgba(5,28,38,.88),rgba(2,8,18,.76));
  box-shadow:0 0 34px rgba(89,255,194,.10);
}

.active-project[hidden]{
  display:none !important;
}

.active-project span{
  display:block;
  color:var(--green);
  font-size:12px;
  font-weight:950;
  letter-spacing:.18em;
  text-transform:uppercase;
  margin-bottom:6px;
}

.active-project strong{
  display:block;
  color:var(--text);
  font-size:22px;
  line-height:1.25;
}

.workflow.focus-mode .step-card{
  opacity:.24;
  filter:saturate(.55);
  transform:scale(.98);
}

.workflow.focus-mode .step-card.done{
  opacity:.14;
}

.workflow.focus-mode .step-card.active{
  opacity:1;
  filter:none;
  transform:translateY(-2px);
  border-color:rgba(93,224,255,.82);
  box-shadow:0 0 34px rgba(93,224,255,.18);
}

.workflow.focus-mode .step-card.active small{
  color:var(--green);
}

.stage-panel{
  animation:stageIn .28s ease both;
}

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

.step-card{
  transition:
    opacity .75s ease,
    filter .75s ease,
    transform .75s cubic-bezier(.2,.8,.2,1),
    box-shadow .75s ease,
    border-color .75s ease;
}

.workflow.focus-mode .step-card.done{
  opacity:.08;
  filter:blur(1px) saturate(.35);
  transform:scale(.94);
}

.workflow.focus-mode .step-card.active{
  animation:stepPulse 1.8s ease-in-out infinite;
}

@keyframes stepPulse{
  0%,100%{
    box-shadow:0 0 28px rgba(93,224,255,.16);
  }
  50%{
    box-shadow:0 0 48px rgba(93,224,255,.30),0 0 18px rgba(89,255,194,.16);
  }
}

.stage-panel{
  animation:stageInDramatic .7s cubic-bezier(.2,.8,.2,1) both;
}

@keyframes stageInDramatic{
  from{
    opacity:0;
    transform:translateY(18px) scale(.985);
    filter:blur(4px);
  }
  to{
    opacity:1;
    transform:translateY(0) scale(1);
    filter:blur(0);
  }
}

.stage-panel{
  transition:
    opacity .9s cubic-bezier(.2,.8,.2,1),
    transform .9s cubic-bezier(.2,.8,.2,1),
    filter .9s ease;
}

.stage-panel.stage-leaving{
  opacity:0;
  transform:translateY(-18px) scale(.985);
  filter:blur(5px);
}

.stage-panel.stage-entering{
  animation:stageEnterSlow 1.05s cubic-bezier(.2,.8,.2,1) both;
}

@keyframes stageEnterSlow{
  from{
    opacity:0;
    transform:translateY(22px) scale(.982);
    filter:blur(6px);
  }
  to{
    opacity:1;
    transform:translateY(0) scale(1);
    filter:blur(0);
  }
}

.step-card{
  transition:
    opacity 1.1s ease,
    filter 1.1s ease,
    transform 1.1s cubic-bezier(.2,.8,.2,1),
    box-shadow 1.1s ease,
    border-color 1.1s ease;
}

.workflow.focus-mode .step-card{
  opacity:.16;
  filter:blur(1.5px) saturate(.45);
}

.workflow.focus-mode .step-card.active{
  opacity:1;
  filter:none;
}

.topbar{
  position:sticky;
  top:0;
  z-index:40;
  padding:12px 0;
  background:linear-gradient(180deg,rgba(2,6,17,.96),rgba(2,6,17,.72));
  backdrop-filter:blur(14px);
}

.ai-hero{
  position:sticky;
  top:72px;
  z-index:35;
  backdrop-filter:blur(14px);
}

.workflow{
  position:sticky;
  top:278px;
  z-index:34;
  padding:10px 0;
  background:linear-gradient(180deg,rgba(2,6,17,.82),rgba(2,6,17,.38));
  backdrop-filter:blur(12px);
}

.step-card.active{
  position:relative;
  border-color:rgba(89,255,194,.90) !important;
  color:var(--text);
  box-shadow:
    0 0 42px rgba(89,255,194,.24),
    0 0 20px rgba(93,224,255,.18) !important;
  animation:activeStepBeacon 1.35s ease-in-out infinite !important;
}

.step-card.active:after{
  content:"";
  position:absolute;
  inset:-5px;
  border-radius:24px;
  border:1px solid rgba(89,255,194,.34);
  opacity:.8;
  animation:activeStepRing 1.35s ease-in-out infinite;
  pointer-events:none;
}

@keyframes activeStepBeacon{
  0%,100%{
    transform:translateY(-2px) scale(1);
    box-shadow:0 0 32px rgba(89,255,194,.18),0 0 18px rgba(93,224,255,.12);
  }
  50%{
    transform:translateY(-4px) scale(1.018);
    box-shadow:0 0 58px rgba(89,255,194,.34),0 0 28px rgba(93,224,255,.22);
  }
}

@keyframes activeStepRing{
  0%,100%{
    transform:scale(.99);
    opacity:.35;
  }
  50%{
    transform:scale(1.045);
    opacity:.9;
  }
}

@media(max-width:980px){
  .ai-hero{
    position:relative;
    top:auto;
  }

  .workflow{
    position:sticky;
    top:0;
    z-index:35;
  }
}

#resultsStage .panel-head{
  position:sticky;
  top:390px;
  z-index:32;
  padding:14px;
  margin:-14px -14px 14px;
  border:1px solid rgba(93,224,255,.18);
  border-radius:20px;
  background:linear-gradient(135deg,rgba(4,14,28,.96),rgba(2,8,18,.90));
  backdrop-filter:blur(14px);
  box-shadow:0 0 34px rgba(93,224,255,.10);
}

#btnVerify:not(:disabled),
#btnExport:not(:disabled){
  animation:actionBeacon 1.45s ease-in-out infinite;
}

@keyframes actionBeacon{
  0%,100%{
    box-shadow:0 0 20px rgba(89,255,194,.12);
    border-color:rgba(89,255,194,.32);
  }
  50%{
    box-shadow:0 0 42px rgba(89,255,194,.28),0 0 18px rgba(93,224,255,.16);
    border-color:rgba(89,255,194,.78);
  }
}

@media(max-width:980px){
  #resultsStage .panel-head{
    top:76px;
  }
}

.project-item{
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:12px;
}

.project-item > div{
  min-width:0;
  flex:1;
}

.btn.small{
  min-height:34px;
  padding:0 11px;
  font-size:12px;
}

.btn.danger{
  color:#ff9aae;
  border-color:rgba(255,107,138,.38);
  background:rgba(255,107,138,.08);
}

.btn.danger:hover{
  border-color:rgba(255,107,138,.78);
  box-shadow:0 0 22px rgba(255,107,138,.18);
}

#topAction.command-active{
  animation:actionBeacon 1.35s ease-in-out infinite;
}

#topAction:disabled{
  opacity:.45;
  animation:none;
}

.workflow[hidden]{
  display:none !important;
}

.intro-stage{
  max-width:760px;
  margin-left:auto;
  margin-right:auto;
  text-align:center;
}

.intro-stage .action-row{
  justify-content:center;
}

.machine-start{
  min-height:54px;
  padding:0 24px;
  font-size:15px;
  animation:actionBeacon 1.35s ease-in-out infinite;
}

/* RI V2 declutter pass */
#resultsStage .panel-head{
  position:relative !important;
  top:auto !important;
  z-index:auto !important;
  padding:0 0 14px !important;
  margin:0 0 14px !important;
  border:0 !important;
  background:transparent !important;
  box-shadow:none !important;
  backdrop-filter:none !important;
}

#resultActionHint{
  display:none;
}

.access-card.collapsed{
  max-height:46px;
  overflow:hidden;
  cursor:pointer;
  opacity:.62;
  transition:.35s ease;
}

.access-card.collapsed:hover{
  max-height:220px;
  opacity:1;
  box-shadow:0 0 34px rgba(89,255,194,.18);
}

.access-card.collapsed .access-sub{
  display:none;
}

.access-card.collapsed:hover .access-sub{
  display:block;
}

.command-card{
  border:1px solid var(--line2);
  border-radius:24px;
  background:linear-gradient(135deg,rgba(5,28,38,.82),rgba(2,8,18,.78));
  padding:16px;
}

.command-actions{
  margin-top:10px;
}

.export-options{
  display:grid;
  gap:12px;
  margin:16px 0;
}

.export-options label{
  border:1px solid rgba(93,224,255,.18);
  border-radius:16px;
  background:rgba(3,10,20,.48);
  padding:12px;
  margin:0;
}

/* v13 access chip refinement */
.access-card.collapsed{
  min-height:40px;
  max-height:40px;
  padding:10px 12px;
  opacity:.58;
}

.access-card.collapsed .access-label{
  margin:0;
}

.access-card.collapsed .access-label:after{
  content:" checked";
  color:var(--green);
}

.access-card.collapsed .access-main,
.access-card.collapsed .access-sub{
  display:none;
}

.access-card.collapsed:hover{
  max-height:220px;
  padding:20px;
  opacity:1;
}

.access-card.collapsed:hover .access-main,
.access-card.collapsed:hover .access-sub{
  display:block;
}

.power-logout{
  width:38px;
  height:38px;
  border-radius:999px;
  border:1px solid rgba(255,107,138,.42);
  background:rgba(255,107,138,.08);
  color:#ff6b8a;
  font-size:18px;
  font-weight:900;
  cursor:pointer;
  opacity:.72;
  transition:.22s ease;
}

.top-actions:hover .power-logout,
.power-logout:hover,
.power-logout:focus{
  opacity:1;
  color:#fff;
  background:#dc2626;
  border-color:#ff6b8a;
  box-shadow:0 0 28px rgba(255,107,138,.34);
  outline:none;
}

/* Single-command RI flow: only the top action should guide the user */
#resultsStage .action-row,
#btnVerify,
#btnExport{
  display:none !important;
}

.command-card{
  border-color:rgba(89,255,194,.42) !important;
  box-shadow:0 0 30px rgba(89,255,194,.12);
}

#topAction{
  width:100%;
  min-height:46px;
  border-color:rgba(89,255,194,.72) !important;
  box-shadow:0 0 26px rgba(89,255,194,.18);
}

#topAction:not(:disabled){
  animation:topActionPulse 1.45s ease-in-out infinite;
}

#topAction:disabled{
  opacity:.48;
  cursor:not-allowed;
  animation:none;
}

@keyframes topActionPulse{
  0%,100%{
    box-shadow:0 0 24px rgba(89,255,194,.18),0 0 12px rgba(93,224,255,.12);
  }
  50%{
    box-shadow:0 0 44px rgba(89,255,194,.36),0 0 24px rgba(93,224,255,.20);
  }
}

.access-card.admin-full{
  border-color:rgba(255,209,102,.56) !important;
  box-shadow:0 0 26px rgba(255,209,102,.16);
}

.access-card.admin-full #quotaStatus{
  color:var(--gold);
}

.access-card.collapsed{
  max-height:52px !important;
  min-height:52px;
  overflow:hidden !important;
  opacity:.72;
  cursor:pointer;
  transition:max-height .55s ease, opacity .35s ease, box-shadow .35s ease;
}

.access-card.collapsed .access-sub{
  opacity:0;
}

.access-card.collapsed:hover,
.access-card.collapsed:focus-within{
  max-height:180px !important;
  opacity:1;
  box-shadow:0 0 34px rgba(89,255,194,.18);
}

.access-card.collapsed:hover .access-sub,
.access-card.collapsed:focus-within .access-sub{
  opacity:1;
}

/* The sticky Current action button is the only active workflow command */
#btnExtract{
  display:none !important;
}

#prepareStage .action-row{
  display:none !important;
}

.boundary-list{
  display:grid;
  gap:14px;
  margin-top:16px;
}

.boundary-card{
  border:1px solid rgba(93,224,255,.24);
  border-radius:18px;
  background:rgba(2,8,18,.64);
  padding:14px;
  box-shadow:0 0 24px rgba(93,224,255,.08);
}

.boundary-card header{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  margin-bottom:10px;
}

.boundary-card textarea{
  width:100%;
  min-height:118px;
  resize:vertical;
  border-radius:14px;
  border:1px solid rgba(93,224,255,.28);
  background:rgba(1,5,12,.86);
  color:var(--text);
  padding:12px;
  font:14px/1.55 Inter,Arial,sans-serif;
}

.boundary-card textarea:focus{
  outline:none;
  border-color:rgba(89,255,194,.74);
  box-shadow:0 0 24px rgba(89,255,194,.14);
}

/* Guided export selection */
.export-choice-grid{
  display:grid;
  grid-template-columns:repeat(auto-fit,minmax(260px,1fr));
  gap:14px;
  margin-top:18px;
}

.export-choice{
  position:relative;
  display:flex;
  flex-direction:column;
  gap:8px;
  min-height:156px;
  padding:18px;
  border:1px solid rgba(93,224,255,.28);
  border-radius:20px;
  background:
    radial-gradient(circle at 14% 14%,rgba(93,224,255,.12),transparent 34%),
    linear-gradient(145deg,rgba(7,25,42,.86),rgba(2,8,18,.78));
  cursor:pointer;
  box-shadow:0 0 28px rgba(93,224,255,.08);
  transition:.22s ease;
}

.export-choice input{
  position:absolute;
  opacity:0;
  pointer-events:none;
}

.export-choice-kicker{
  color:var(--green);
  font-size:12px;
  font-weight:950;
  letter-spacing:.16em;
  text-transform:uppercase;
}

.export-choice strong{
  color:var(--text);
  font-size:20px;
  line-height:1.18;
}

.export-choice em{
  color:var(--muted);
  font-style:normal;
  font-size:14px;
  line-height:1.45;
}

.export-choice:has(input:checked){
  border-color:rgba(89,255,194,.72);
  box-shadow:0 0 36px rgba(89,255,194,.18),0 0 16px rgba(93,224,255,.12);
}

.export-choice:has(input:checked)::after{
  content:"Selected";
  position:absolute;
  right:14px;
  top:14px;
  border:1px solid rgba(89,255,194,.54);
  border-radius:999px;
  padding:5px 8px;
  color:var(--green);
  font-size:11px;
  font-weight:900;
  background:rgba(4,22,26,.88);
}

#exportStage .action-row{
  display:none !important;
}

.next-stage{
  border-color:rgba(89,255,194,.42);
  box-shadow:0 0 44px rgba(89,255,194,.12);
}

.next-action-row{
  display:flex;
  align-items:center;
  gap:12px;
  flex-wrap:wrap;
  margin-top:18px;
}

.glow-next{
  animation:nextGlowPulse 1.45s ease-in-out infinite;
}

@keyframes nextGlowPulse{
  0%,100%{
    box-shadow:0 0 24px rgba(89,255,194,.20),0 0 10px rgba(93,224,255,.12);
  }
  50%{
    box-shadow:0 0 48px rgba(89,255,194,.42),0 0 26px rgba(93,224,255,.24);
  }
}

.status-box.warning{
  color:var(--gold);
  border-color:rgba(255,209,102,.36);
}

/* Compact sticky command area, especially for mobile paste/workspace access */
@media(max-width:760px){
  .topbar{
    position:relative;
    top:auto;
    padding:10px 0;
  }

  .ai-hero{
    position:sticky;
    top:0;
    z-index:45;
    display:grid;
    grid-template-columns:1fr;
    gap:8px;
    padding:10px 12px;
    border-radius:0 0 18px 18px;
    margin-left:-12px;
    margin-right:-12px;
    background:linear-gradient(180deg,rgba(2,6,17,.96),rgba(2,6,17,.82));
    box-shadow:0 12px 28px rgba(0,0,0,.28);
  }

  .ai-hero .terminal-label{
    font-size:9px;
    margin-bottom:4px;
    letter-spacing:.14em;
  }

  .ai-hero h1,
  #typedTitle{
    min-height:0 !important;
    margin:0;
    font-size:16px !important;
    line-height:1.15;
  }

  .hero-copy,
  #aiMessage{
    margin:4px 0 0;
    font-size:12px;
    line-height:1.25;
    max-height:34px;
    overflow:hidden;
  }

  .hero-side{
    display:grid;
    grid-template-columns:1fr;
    gap:8px;
  }

  .access-card{
    display:none;
  }

  .command-card{
    padding:8px;
    border-radius:16px;
    min-height:0;
  }

  .command-card .access-label{
    display:none;
  }

  .command-actions{
    display:block;
  }

  #topAction{
    min-height:38px;
    height:38px;
    padding:0 12px;
    font-size:12px;
    border-radius:14px;
  }

  #topAction:disabled{
    opacity:.55;
    box-shadow:none !important;
    animation:none !important;
  }

  .workflow{
    position:relative;
    top:auto;
    z-index:1;
    padding:6px 0;
    background:transparent;
    backdrop-filter:none;
  }

  .workflow.focus-mode .step-card:not(.active){
    display:none;
  }

  .workflow{
    grid-template-columns:1fr;
  }

  .step-card{
    min-height:42px;
    padding:8px 10px;
    border-radius:14px;
  }

  .step-card span{
    font-size:10px;
  }

  .step-card strong{
    font-size:12px;
  }

  .step-card small{
    font-size:11px;
  }

  .stage-panel{
    scroll-margin-top:132px;
  }

  #prepareStage textarea,
  .stage-panel textarea{
    min-height:52vh;
  }
}

@media(max-width:420px){
  .ai-hero{
    padding:8px 10px;
  }

  .hero-copy,
  #aiMessage{
    display:none;
  }

  #topAction{
    height:36px;
    min-height:36px;
  }

  .stage-panel{
    scroll-margin-top:104px;
  }
}

/* Mobile work stages: collapse typewriter header and leave only the action command */
@media(max-width:760px){
  body.ri-compact-work-stage .ai-hero{
    padding:7px 10px;
    gap:0;
  }

  body.ri-compact-work-stage .ai-hero > div:first-child{
    display:none;
  }

  body.ri-compact-work-stage .hero-side{
    gap:0;
  }

  body.ri-compact-work-stage .command-card{
    padding:6px;
    border-radius:14px;
    background:rgba(2,8,18,.86);
  }

  body.ri-compact-work-stage #topAction{
    height:34px;
    min-height:34px;
    font-size:11px;
    border-radius:12px;
  }

  body.ri-compact-work-stage .workflow{
    display:none;
  }

  body.ri-compact-work-stage .stage-panel{
    scroll-margin-top:54px;
  }

  body.ri-compact-work-stage #prepareStage textarea,
  body.ri-compact-work-stage .stage-panel textarea{
    min-height:66vh;
  }
}

@media(max-width:420px){
  body.ri-compact-work-stage .ai-hero{
    padding:6px 8px;
  }

  body.ri-compact-work-stage .stage-panel{
    scroll-margin-top:48px;
  }
}

.hallucination-warning{
  border:1px solid rgba(255,209,102,.70);
  border-radius:22px;
  padding:18px;
  margin:16px 0;
  background:
    radial-gradient(circle at 10% 18%,rgba(255,209,102,.20),transparent 32%),
    linear-gradient(135deg,rgba(52,28,4,.92),rgba(8,12,20,.82));
  color:var(--text);
  box-shadow:0 0 34px rgba(255,209,102,.16);
}

.hallucination-warning.clear{
  border-color:rgba(89,255,194,.45);
  background:
    radial-gradient(circle at 10% 18%,rgba(89,255,194,.14),transparent 32%),
    linear-gradient(135deg,rgba(5,34,28,.88),rgba(8,12,20,.82));
}

.warning-kicker{
  color:var(--gold);
  font-size:11px;
  font-weight:950;
  letter-spacing:.18em;
  text-transform:uppercase;
  margin-bottom:8px;
}

.hallucination-warning.clear .warning-kicker{
  color:var(--green);
}

.hallucination-warning h3{
  margin:0 0 8px;
  color:var(--gold);
  font-size:22px;
}

.hallucination-warning.clear h3{
  color:var(--green);
}

.hallucination-warning p{
  margin:0;
  color:var(--text);
  line-height:1.55;
}

.warning-numbers{
  margin-top:12px;
  color:var(--danger);
  font-weight:900;
}

/* Boundary review boxes should fit each reference instead of using one large fixed height */
.boundary-card textarea{
  min-height:74px !important;
  height:auto;
  max-height:42vh;
  overflow:auto;
  resize:vertical;
  line-height:1.45;
}

.restart-row{
  margin-top:12px;
  display:flex;
  justify-content:flex-start;
}

.restart-paste-btn{
  border-color:rgba(255,209,102,.70) !important;
  color:var(--gold) !important;
  background:rgba(255,209,102,.10) !important;
  box-shadow:0 0 22px rgba(255,209,102,.16);
}

.restart-paste-btn:hover,
.restart-paste-btn:focus{
  box-shadow:0 0 32px rgba(255,209,102,.28);
}

#resultSummary.status-box{
  display:block;
  margin:0 0 14px;
  padding:14px 16px;
  border:1px solid rgba(255,209,102,.42);
  border-radius:18px;
  background:rgba(255,209,102,.08);
  color:var(--text);
}

#resultSummary.status-box.success{
  border-color:rgba(89,255,194,.42);
  background:rgba(89,255,194,.08);
}

#resultSummary .restart-row{
  margin-top:10px;
}
