:root{
  --bg:#020611;
  --panel:rgba(4,14,28,.82);
  --panel2:rgba(7,25,42,.82);
  --line:rgba(93,224,255,.26);
  --line2:rgba(89,255,194,.30);
  --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,.18),transparent 30%),
    radial-gradient(circle at 84% 10%,rgba(89,255,194,.13),transparent 28%),
    linear-gradient(135deg,#01030a,#03111f 50%,#01040b);
}

body:before{
  content:"";
  position:fixed;
  inset:0;
  pointer-events:none;
  background:linear-gradient(rgba(255,255,255,.035) 1px,transparent 1px);
  background-size:100% 32px;
  opacity:.22;
}

.cir-page{
  width:min(1180px,calc(100% - 32px));
  margin:0 auto;
  padding:26px 0 56px;
}

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

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

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

.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;
  text-decoration:none;
}

.ai-hero,
.stage-panel,
.workflow .step-card{
  border:1px solid var(--line);
  background:linear-gradient(145deg,rgba(7,25,42,.86),rgba(2,8,18,.78));
  box-shadow:0 0 42px rgba(93,224,255,.08);
}

.ai-hero{
  position:sticky;
  top:0;
  z-index:20;
  display:grid;
  grid-template-columns:1fr 330px;
  gap:22px;
  align-items:center;
  border-radius:26px;
  padding:24px;
  backdrop-filter:blur(14px);
}

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

h1{
  min-height:70px;
  margin:0;
  color:var(--cyan);
  font-size:clamp(34px,5vw,62px);
  line-height:1;
}

.hero-copy,
.muted{
  color:var(--muted);
  line-height:1.55;
}

.hero-side{
  display:grid;
  gap:12px;
}

.access-card,
.command-card{
  border:1px solid var(--line2);
  border-radius:20px;
  padding:16px;
  background:rgba(2,8,18,.68);
}

.access-label{
  color:var(--green);
  font-size:11px;
  font-weight:950;
  letter-spacing:.18em;
  text-transform:uppercase;
  margin-bottom:7px;
}

.access-main{
  color:var(--text);
  font-size:22px;
  font-weight:950;
}

.access-sub{
  color:var(--muted);
  margin-top:5px;
  line-height:1.4;
}

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

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

.step-card{
  border-radius:18px;
  padding:12px;
  min-height:86px;
  transition:.45s ease;
}

.step-card span{
  color:var(--green);
  font-size:12px;
  font-weight:950;
}

.step-card strong{
  display:block;
  margin-top:8px;
  color:var(--text);
}

.step-card small{
  display:block;
  margin-top:5px;
  color:var(--muted);
  line-height:1.3;
}

.step-card.active{
  border-color:rgba(89,255,194,.78);
  box-shadow:0 0 34px rgba(89,255,194,.20);
}

.step-card.done{
  opacity:.34;
}

.stage-panel{
  border-radius:26px;
  padding:24px;
  margin-top:18px;
}

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

label{
  display:block;
  margin:16px 0 8px;
  color:var(--green);
  font-weight:900;
}

input[type="text"],
input[type="file"]{
  width:100%;
  border:1px solid var(--line);
  border-radius:16px;
  background:rgba(2,8,18,.72);
  color:var(--text);
  padding:13px 14px;
  font:inherit;
}

.action-row{
  display:flex;
  gap:12px;
  flex-wrap:wrap;
  margin-top:16px;
}

.btn{
  min-height:44px;
  border:1px solid var(--line);
  border-radius:16px;
  background:rgba(3,10,20,.74);
  color:var(--text);
  font-weight:900;
  cursor:pointer;
  padding:0 16px;
  text-decoration:none;
}

.btn.primary{
  border-color:rgba(89,255,194,.72);
  background:linear-gradient(135deg,rgba(89,255,194,.18),rgba(93,224,255,.12));
  box-shadow:0 0 28px rgba(89,255,194,.16);
}

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

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

.status-box.error{
  color:var(--danger);
}

.status-box.success{
  color:var(--green);
}

.project-list,
.result-list{
  display:grid;
  gap:12px;
  margin-top:16px;
}

.project-item,
.result-card{
  border:1px solid var(--line);
  border-radius:18px;
  background:rgba(2,8,18,.58);
  padding:14px;
}

.project-item{
  cursor:pointer;
}

.project-item:hover{
  border-color:rgba(89,255,194,.62);
  box-shadow:0 0 24px rgba(89,255,194,.12);
}

.result-card header{
  display:flex;
  justify-content:space-between;
  gap:12px;
  align-items:flex-start;
}

.result-card h3{
  margin:0;
  color:var(--text);
}

.badge{
  border:1px solid var(--line2);
  border-radius:999px;
  padding:5px 9px;
  color:var(--green);
  font-size:12px;
  font-weight:900;
  white-space:nowrap;
}

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

  .topbar{
    align-items:flex-start;
    flex-direction:column;
  }

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

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

  .ai-hero{
    padding:14px;
  }

  h1{
    min-height:0;
    font-size:28px;
  }
}

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

.citation-editor-card{
  border:1px solid var(--line);
  border-radius:18px;
  padding:14px;
  background:rgba(2,8,18,.58);
}

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

.editor-actions{
  display:flex;
  flex-wrap:wrap;
  gap:8px;
  justify-content:flex-end;
}

.btn.small{
  min-height:32px;
  padding:0 10px;
  font-size:12px;
  border-radius:12px;
}

.btn.danger{
  border-color:rgba(255,107,138,.45);
  color:var(--danger);
}

.citation-editor-card textarea{
  width:100%;
  min-height:78px;
  max-height:45vh;
  resize:vertical;
  border:1px solid var(--line);
  border-radius:14px;
  background:rgba(2,8,18,.72);
  color:var(--text);
  padding:12px;
  font:inherit;
  line-height:1.45;
}

.editor-help input{
  margin-top:8px;
}

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

.export-choice{
  display:block;
  border:1px solid var(--line2);
  border-radius:20px;
  padding:18px;
  background:rgba(2,8,18,.68);
  cursor:pointer;
}

.export-choice input{
  margin-right:8px;
}

.export-choice-kicker{
  display:block;
  color:var(--green);
  font-size:11px;
  font-weight:950;
  letter-spacing:.16em;
  text-transform:uppercase;
  margin-bottom:8px;
}

.export-choice strong{
  display:block;
  color:var(--text);
  font-size:20px;
}

.export-choice small{
  display:block;
  color:var(--muted);
  margin-top:6px;
  line-height:1.45;
}

.command-buttons{
  display:grid;
  grid-template-columns:minmax(0,1fr) auto;
  gap:8px;
  align-items:center;
}

.start-over-btn{
  min-height:38px;
  padding:0 12px;
  font-size:12px;
  color:#fecdd3;
  border-color:rgba(248,113,113,.38);
  background:rgba(127,29,29,.22);
  box-shadow:none;
}

.start-over-btn:hover,
.start-over-btn:focus{
  border-color:rgba(248,113,113,.85);
  box-shadow:0 0 18px rgba(248,113,113,.20);
}

@media(max-width:760px){
  .command-buttons{
    grid-template-columns:1fr;
  }

  .start-over-btn{
    min-height:32px;
  }
}

/* Citation V2 single-action flow: upload uses the sticky top action only */
#uploadStage .action-row{
  display:none !important;
}

/* Keep access available without letting it dominate the working area */
.access-card.collapsed{
  max-height:44px;
  overflow:hidden;
  opacity:.62;
  cursor:help;
  transition:max-height .35s ease, opacity .25s ease, box-shadow .25s ease;
}

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

/* Cleaner collapsed access chip and project deletion controls */
.access-card.collapsed{
  min-height:42px;
  max-height:42px;
  padding:9px 12px;
  display:grid;
  grid-template-columns:auto minmax(0,1fr);
  column-gap:10px;
  align-items:center;
  overflow:hidden;
  opacity:.82;
  border-color:rgba(89,255,194,.42);
  box-shadow:0 0 18px rgba(89,255,194,.10);
}

.access-card.collapsed .access-label{
  margin:0;
  font-size:10px;
  letter-spacing:.12em;
}

.access-card.collapsed .access-main{
  font-size:13px;
  line-height:1.1;
  white-space:nowrap;
}

.access-card.collapsed .access-sub{
  grid-column:1 / -1;
  margin:4px 0 0;
  font-size:12px;
  line-height:1.25;
  white-space:normal;
  overflow:visible;
  opacity:0;
  transform:translateY(-4px);
  transition:opacity .25s ease, transform .25s ease;
}

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

.access-card.collapsed:hover .access-sub,
.access-card.collapsed:focus-within .access-sub{
  opacity:1;
  transform:translateY(0);
}

.project-item{
  display:grid;
  grid-template-columns:minmax(0,1fr) auto;
  gap:10px;
  align-items:center;
}

.project-open{
  appearance:none;
  border:0;
  background:transparent;
  color:inherit;
  text-align:left;
  padding:0;
  cursor:pointer;
  min-width:0;
}

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

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

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