@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

/* ---- Aquila Path brand tokens (see aquila-path-brand-system.html) ----
   Original semantic names kept (--eosin, --teal, --amber, --yellow) so every
   existing rule below still works -- only what they point to changed:
   --eosin (primary accent) -> purple, --amber/--yellow (wrong-class / boundary
   flag) -> rose. --teal (the "this tile is correct" action) stays its own
   green by explicit request, rather than folding into purple/rose. */
:root{
  color-scheme:light;
  --bg:#FFFFFF;
  --surface:#F4F2F6;
  --surface-tint:#EBE7EF;
  --ink:#1A1A1A;
  --ink-soft:#3D3D3D;
  --ink-mute:#686868;
  --line:#DCDCDC;
  --line-strong:#686868;
  --eosin:#390E5E;
  --eosin-soft:color-mix(in srgb, #390E5E 12%, #FFFFFF);
  --amber:#DC4B6A;
  --amber-soft:#FCEEF1;
  --yellow:#DC4B6A;
  --yellow-ink:#FFFFFF;
  --teal:#1C6B56;
  --teal-soft:#DDEFE8;
  --danger:#D83659;
  --danger-soft:#FCEEF1;
  --focus:#390E5E;
  --btn-text:#FFFFFF;
  --shadow:none;
}
*{box-sizing:border-box;}
body{
  margin:0;
  background:var(--bg);
  color:var(--ink);
  font-family:'Inter',system-ui,-apple-system,'Segoe UI',sans-serif;
  font-size:17px;
  line-height:1.6;
}
.mono{font-family:'JetBrains Mono','SFMono-Regular',Consolas,monospace;}
button{font-family:inherit; cursor:pointer;}
button:focus-visible, [tabindex]:focus-visible{outline:3px solid var(--focus); outline-offset:2px;}

.app{display:flex; min-height:100vh;}

.appbar{padding:24px 0 32px; display:flex; justify-content:space-between; align-items:center; gap:14px; flex-wrap:wrap;}
.account-bar{display:flex; align-items:center; gap:10px; font-size:13px;}
.account-bar .account-id{display:flex; align-items:center; gap:8px; margin-right:4px;}
.account-bar .account-avatar{
  width:26px; height:26px; border-radius:50%; background:var(--eosin); color:var(--btn-text);
  display:flex; align-items:center; justify-content:center; flex-shrink:0;
  font-size:11.5px; font-weight:700; font-family:'JetBrains Mono',monospace;
}
.account-bar .account-email{color:var(--ink-soft); font-weight:600;}
.account-bar .account-link{
  display:inline-flex; align-items:center;
  background:var(--surface); border:1.5px solid var(--line-strong); border-radius:8px;
  color:var(--ink-soft); font-size:12.5px; font-weight:700;
  cursor:pointer; padding:7px 12px; text-decoration:none;
  transition:border-color .15s, color .15s, background .15s;
}
.account-bar .account-link:hover{border-color:var(--eosin); color:var(--eosin); background:var(--eosin-soft);}
.account-bar #logoutBtn{border-color:var(--amber); color:var(--amber); background:var(--amber-soft);}
.account-bar #logoutBtn:hover{background:var(--amber); color:var(--btn-text);}
.app-title-row{display:flex; align-items:center; gap:12px;}
.app-logo{width:28px; height:28px; flex-shrink:0;}
.appbar .app-title{font-size:15px; font-weight:700; margin:0 0 2px; color:var(--ink);}
.appbar .app-sub{font-size:12.5px; color:var(--ink-mute); margin:0;}

/* ---- main ---- */
main{flex:1; min-width:0; padding:0 40px 40px; max-width:1120px; margin:0 auto;}

.topbar{display:flex; justify-content:space-between; align-items:flex-end; gap:20px; margin-bottom:30px; flex-wrap:wrap;}
.topbar-text{max-width:44em;}
.select-label-inline{display:block; font-size:13px; font-weight:700; color:var(--ink-mute); margin:0 0 6px; cursor:pointer;}
.star-legend{
  display:inline-flex; align-items:center; gap:6px; margin:10px 0 0; padding:5px 12px;
  font-size:13.5px; font-weight:600; color:var(--eosin); background:var(--eosin-soft);
  border-radius:8px;
}
.star-legend[hidden]{display:none;}
.topbar p{margin:0; font-size:14.5px; color:var(--ink-soft);}

.class-select-wrap{position:relative; display:inline-block;}
.class-select{
  appearance:none; -webkit-appearance:none; -moz-appearance:none;
  font-family:inherit; font-size:17px; font-weight:600; color:var(--ink);
  background:var(--eosin-soft); border:2px solid var(--eosin); border-radius:10px;
  padding:12px 42px 12px 16px; cursor:pointer; min-height:48px; max-width:100%;
}
.class-select:hover{background:var(--surface);}
.class-select-wrap::after{
  content:'▾'; position:absolute; right:16px; top:50%; transform:translateY(-50%);
  color:var(--eosin); font-size:15px; pointer-events:none;
}

.page-tabs{display:flex; gap:4px; background:var(--surface-tint); padding:4px; border-radius:10px; flex-shrink:0;}
.page-tab{
  border:none; background:none; padding:9px 16px; font-size:13.5px; font-weight:700;
  color:var(--ink-mute); border-radius:8px;
}
.page-tab.on{background:var(--eosin); color:var(--btn-text);}

.panel{
  background:var(--surface); border:1px solid var(--line); border-radius:16px;
  padding:30px 32px; margin-bottom:26px; box-shadow:var(--shadow);
}
.panel h2{font-size:13px; font-weight:700; margin:0 0 20px; color:var(--eosin); text-transform:uppercase; letter-spacing:.04em;}

/* ---- query card ---- */
.query-panel{background:var(--surface); border-color:var(--eosin-soft);}
.query-instructions{margin:22px 0 0; padding-top:20px; border-top:1px solid var(--line); font-size:14.5px; color:var(--ink-soft); line-height:1.7;}
.query-card{display:flex; gap:26px; align-items:center; flex-wrap:wrap;}
.query-thumb{
  width:220px; height:220px; border-radius:12px; object-fit:contain; flex-shrink:0;
  border:4px solid var(--eosin); background:var(--surface-tint); box-shadow:var(--shadow);
  cursor:zoom-in;
}
.query-meta{font-size:15px; color:var(--ink-soft); flex:1; min-width:220px;}
.query-meta .qlabel{
  display:inline-block; font-size:12.5px; color:var(--eosin); background:var(--eosin-soft);
  padding:4px 11px; border-radius:10px; margin-bottom:8px; font-weight:700;
}
.query-meta .qlabel.warn{color:var(--yellow-ink); background:var(--yellow);}
.query-meta .qslide{font-family:'JetBrains Mono',monospace; font-size:12px; color:var(--ink-mute); display:block; margin-top:6px;}

/* ---- toolbar ---- */
.toolbar{display:flex; justify-content:space-between; align-items:center; margin-bottom:20px; gap:14px; flex-wrap:wrap;}
.bulk-actions{display:flex; gap:10px; flex-wrap:wrap;}
.bigbtn{
  border-radius:10px; padding:11px 16px; font-size:14.5px; font-weight:700; border:2px solid;
  display:inline-flex; align-items:center; gap:7px; text-decoration:none;
}
/* Confirm/skip act on the CURRENT batch -- the two buttons used constantly -- so
   they're fused into one segmented control (.batch-group): a single bordered unit
   makes the relationship between them obvious at a glance, not just a color hint.
   Undo (corrects the PAST) and Next batch (moves to the FUTURE, now rarely needed
   manually since a full batch auto-advances) sit outside that group, outline-only
   and muted, reading past -> [present] -> future left to right. */
.batch-group{
  display:flex; border:2px solid var(--teal); border-radius:10px; overflow:hidden;
}
.batch-btn{
  border:none; padding:11px 18px; font-size:14.5px; font-weight:700; cursor:pointer;
  display:inline-flex; align-items:center; gap:7px;
}
.batch-btn.confirm-all{background:var(--teal-soft); color:var(--teal);}
.batch-btn.confirm-all:hover{background:var(--teal); color:var(--btn-text);}
.batch-btn.skip-all{background:var(--surface); color:var(--ink-soft); border-left:2px solid var(--teal);}
.batch-btn.skip-all:hover{background:var(--surface-tint); color:var(--ink);}

.bigbtn.undo{background:transparent; border-color:var(--line); color:var(--ink-mute);}
.bigbtn.undo:hover{background:var(--surface-tint); border-color:var(--line-strong); color:var(--ink-soft);}
.bigbtn.next{background:transparent; border-color:var(--line); color:var(--ink-mute); margin-left:auto;}
.bigbtn.next:hover{background:var(--surface-tint); border-color:var(--line-strong); color:var(--ink);}
.pool-note{font-size:14.5px; color:var(--ink-soft); margin:0 0 22px;}

/* ---- retrieval grid ---- */
.rgrid{display:grid; grid-template-columns:repeat(3,1fr); gap:24px;}
.rtile{
  border-radius:14px; border:2px solid var(--line); background:var(--surface-tint);
  overflow:hidden; display:flex; flex-direction:column;
}
.rtile.decided{border-color:var(--line); opacity:.5;}
.rtile-imgwrap{position:relative; width:100%; aspect-ratio:1; cursor:zoom-in;}
.rtile-imgwrap img{width:100%; height:100%; object-fit:contain; display:block;}
.boundary-badge{
  position:absolute; top:8px; left:8px; background:var(--yellow); color:var(--yellow-ink);
  font-size:11.5px; font-weight:700; padding:3px 8px; border-radius:7px;
}
.decided-flag{
  position:absolute; inset:0; display:flex; align-items:center; justify-content:center;
  font-size:15px; font-weight:700; color:#fff; text-align:center; padding:8px;
  background:rgba(28,107,86,.75);
}
.decided-flag.correct{background:rgba(220,75,106,.8);}
.decided-flag.skip{background:rgba(104,104,104,.65);}
.rtile-actions{display:flex; flex-direction:column; gap:9px; padding:14px;}
.abtn{
  border-radius:9px; padding:10px 8px; font-size:13.5px; font-weight:700; border:2px solid;
  display:flex; align-items:center; justify-content:center; gap:6px; width:100%;
  min-height:44px;
}
.abtn.confirm{background:var(--teal-soft); border-color:var(--teal); color:var(--teal);}
.abtn.confirm:hover{background:var(--teal); color:var(--btn-text);}
.abtn.correct{background:var(--amber-soft); border-color:var(--amber); color:var(--amber);}
.abtn.correct:hover{background:var(--amber); color:var(--btn-text);}
.abtn.skip{background:var(--surface); border-color:var(--line-strong); color:var(--ink-soft);}
.abtn.skip:hover{background:var(--line-strong); color:var(--ink);}
.empty-note{font-size:15px; color:var(--ink-mute); padding:20px 4px;}

/* ---- correct popover ---- */
.popover-backdrop{
  position:fixed; inset:0; background:rgba(33,29,58,.4); display:flex;
  align-items:center; justify-content:center; z-index:50; padding:16px;
}
.popover{
  background:var(--surface); border-radius:16px; padding:26px; width:420px; max-width:100%;
  max-height:90vh; overflow-y:auto;
  border:1px solid var(--line-strong);
}
.popover h3{margin:0 0 6px; font-size:18px; font-weight:700;}
.popover .ptile-preview{display:flex; align-items:center; gap:14px; margin-bottom:18px;}
.popover .ptile-preview img{width:64px; height:64px; border-radius:8px; object-fit:contain; background:var(--surface-tint);}
.popover .ptile-preview span{font-size:13.5px; color:var(--ink-mute);}
.popover label{display:block; font-size:13.5px; font-weight:700; color:var(--ink-soft); margin-bottom:6px;}
.class-chip-grid{display:flex; flex-wrap:wrap; gap:8px; margin-bottom:6px;}
.class-chip{
  border:2px solid var(--line-strong); border-radius:10px; padding:11px 15px;
  font-size:14.5px; font-weight:700; color:var(--ink); background:var(--surface-tint);
  min-height:46px;
}
.class-chip:hover{background:var(--amber-soft); border-color:var(--amber); color:var(--amber);}
.chiprow{display:flex; flex-wrap:wrap; gap:7px; margin-bottom:16px;}
.rchip{
  border:2px solid var(--line-strong); border-radius:16px; padding:7px 13px;
  font-size:13px; color:var(--ink-soft); cursor:pointer; background:var(--surface);
}
.rchip.on{background:var(--eosin-soft); border-color:var(--eosin); color:var(--eosin);}
.popover textarea{
  width:100%; border:2px solid var(--line); border-radius:9px; padding:10px 12px;
  font-family:inherit; font-size:13.5px; resize:vertical; min-height:56px; margin-bottom:18px;
}
.popover-actions{
  display:flex; justify-content:flex-end; gap:10px;
  position:sticky; bottom:-26px; margin:18px -26px -26px; padding:14px 26px;
  background:var(--surface); border-top:1px solid var(--line);
}
.pbtn{border-radius:9px; padding:10px 16px; font-size:14px; font-weight:600; border:2px solid var(--line-strong); background:var(--surface);}
.pbtn.primary{background:var(--eosin); color:var(--btn-text); border-color:var(--eosin);}

/* ---- zoom modal ---- */
.zoom-modal{width:520px;}
.zoom-main{display:flex; gap:18px; align-items:center; margin-bottom:18px;}
.zoom-bigimg{
  width:220px; height:220px; border-radius:12px; object-fit:contain; flex-shrink:0;
  background:var(--surface-tint); border:2px solid var(--line);
}
.zoom-context-label{font-size:12.5px; font-weight:700; color:var(--ink-mute); text-transform:uppercase; letter-spacing:.03em; margin:0 0 10px;}
.zoom-context-wrap{
  position:relative; width:100%; aspect-ratio:1; margin-bottom:18px;
  border-radius:10px; overflow:hidden; border:1px solid var(--line);
}
.zoom-context-img{width:100%; height:100%; object-fit:cover; display:block; background:var(--surface-tint);}
.zoom-center-box{position:absolute; outline:3px solid #E5383B; outline-offset:-3px; pointer-events:none;}

/* ---- progress + audit ---- */
.progress-grid{display:grid; grid-template-columns:repeat(4,1fr); gap:14px; margin-bottom:22px;}
.pcounter{background:var(--surface-tint); border-radius:12px; padding:18px 16px; text-align:center;}
.pcounter .pv{font-size:28px; font-weight:700; color:var(--ink);}
.pcounter .pl{font-size:12.5px; color:var(--ink-mute); margin-top:4px;}
.class-table{width:100%; border-collapse:collapse; font-size:14px;}
.class-table th{text-align:left; font-weight:700; color:var(--ink-mute); font-size:12px; padding:8px 10px; border-bottom:2px solid var(--line);}
.class-table td{padding:9px 10px; border-bottom:1px solid var(--line); color:var(--ink-soft);}
.class-table td.num{font-weight:600; color:var(--ink); text-align:right;}
.class-table tr.current td{background:var(--eosin-soft);}

.audit-list{display:flex; flex-direction:column; gap:0;}
.audit-row{
  display:flex; gap:14px; padding:10px 0; border-bottom:1px solid var(--line);
  font-size:13.5px; color:var(--ink-mute);
  align-items:baseline; flex-wrap:wrap;
}
.audit-row:last-child{border-bottom:none;}
.audit-row .tag{font-size:12px; padding:2px 10px; border-radius:10px; font-weight:700;}
.tag.confirm{background:var(--teal-soft); color:var(--teal);}
.tag.correct{background:var(--amber-soft); color:var(--amber);}
.tag.skip{background:var(--surface-tint); color:var(--ink-mute);}

.toast{
  position:fixed; bottom:28px; left:50%; transform:translateX(-50%);
  background:var(--eosin); color:var(--btn-text); padding:13px 24px; border-radius:11px; font-size:15px;
  font-weight:600; opacity:0; pointer-events:none; transition:opacity .2s;
}
.toast.show{opacity:1;}

/* ---- responsive ----
   Three tiers, matched by app.js's gridK() so the batch size and the grid shape
   agree: phone <=640px -> 4 tiles / 2x2, tablet 641-1024px -> 6 tiles / 2x3,
   laptop+ >1024px -> 9 tiles / 3x3 (the CSS default above). */
@media (max-width:1024px){
  main{padding:0 20px 24px;}
  .appbar{padding:16px 0 18px;}
  .panel{padding:18px;}
  .rgrid{grid-template-columns:repeat(2,1fr);}
  .progress-grid{grid-template-columns:repeat(2,1fr);}
  .query-thumb{width:150px; height:150px;}
}

@media (max-width:640px){
  body{font-size:16px;}
  main{padding:0 14px 20px;}
  .panel{padding:16px; border-radius:12px;}
  .rgrid{grid-template-columns:repeat(2,1fr);}
  .class-select{font-size:16px; padding:11px 38px 11px 14px;}
  .topbar p{font-size:13.5px;}
  .query-card{gap:14px;}
  .query-thumb{width:110px; height:110px; border-width:3px;}
  .toolbar{gap:10px;}
  /* Batch group (Confirm/Skip) takes its own full-width row -- it's the primary
     action and reads as one big control. Undo + Next batch pair up on the row
     below, each half-width -- clearly secondary to the group above them. */
  .bulk-actions{width:100%;}
  .batch-group{order:1; flex:1 1 100%;}
  .batch-btn{flex:1; justify-content:center; min-height:44px;}
  .bigbtn.undo{order:2; flex:1 1 calc(50% - 4px); justify-content:center; min-height:44px; margin-left:0;}
  .bigbtn.next{order:3; flex:1 1 calc(50% - 4px); justify-content:center; min-height:44px; margin-left:0;}
  .rgrid{gap:12px;}
  .zoom-main{flex-direction:column; align-items:center; text-align:center; margin-bottom:14px;}
  .zoom-bigimg{width:160px; height:160px;}
  .popover{padding:20px;}
  .progress-grid{grid-template-columns:repeat(2,1fr);}
  .class-table{font-size:12.5px;}
}
