:root {
  --right: #10dc60;
  --wrong: #f04141;
  --corrected: #ffce00;
  --pending: rgba(0, 0, 0, 0.2);
  --highlight: rgba(255, 206, 0, 0.45);
  --teal: #14b8a6;
  --navy: #0f172a;
}
html, body { margin: 0; height: 100%; }
body {
  display: grid;
  grid-template-columns: 14rem minmax(0, 1fr) 24rem;
  height: 100vh;
  font: 14px/1.4 system-ui, sans-serif;
  color: #0f172a;
  background: #f8fafc;
}
aside, #viewer { min-height: 0; overflow: auto; }
#sidebar {
  display: flex;
  flex-direction: column;
  background: var(--navy);
  color: #fff;
  border-right: 1px solid #1e293b;
  padding: 0;
}
#brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.85rem;
  margin: 0;
  padding: 1rem 1.15rem 0.75rem;
}
#brand > img { height: 60px; width: auto; }
#product-row {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0.5rem;
  width: 100%;
  min-height: 1.75rem;
  padding-left: 0.15rem;
}
#product-mark { display: flex; flex: none; }
#product-mark img, #product-mark svg { height: 1.75rem; width: auto; display: block; }
#product-mark svg { width: 1.75rem; }
#brand h1 {
  margin: 0;
  font-size: 1.125rem;
  line-height: 1.75rem;
  font-weight: 600;
  color: #fff;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#suite-toggle {
  display: grid;
  place-items: center;
  flex: none;
  width: 1.75rem;
  height: 1.75rem;
  margin-left: auto;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #fff;
  cursor: pointer;
}
#suite-toggle svg { width: 1rem; height: 1rem; fill: currentColor; }
#suite-toggle:hover, #suite-toggle[aria-expanded="true"] { background: rgba(255, 255, 255, 0.1); }
#aspects {
  border-left: 1px solid #e2e8f0;
  padding: 0.75rem 0.75rem 2rem;
  background: #f8fafc;
}
#suite {
  position: absolute;
  top: calc(100% + 0.25rem);
  right: 0;
  z-index: 3;
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
  min-width: 11rem;
  margin: 0;
  padding: 0.35rem;
  border-radius: 8px;
  background: #1e293b;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
}
#suite[hidden] { display: none; }
#suite a {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  border-radius: 6px;
  padding: 0.4rem 0.55rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.6);
  text-decoration: none;
  transition: color 0.2s ease, background-color 0.2s ease;
}
#suite a img, #suite a svg { height: 1.05rem; width: auto; display: block; flex: none; }
#suite a svg { width: 1.05rem; }
#suite a:hover { color: #fff; background: rgba(255, 255, 255, 0.1); }
#suite a.active, #suite a.active:hover { color: #fff; background: var(--teal); }
#lens-nav {
  display: none;
  flex-direction: column;
  gap: 0.25rem;
  margin: 0;
  padding: 0.15rem 0.75rem 0;
}
body.suite-lens #lens-nav { display: flex; }
#lens-nav a {
  border-radius: 6px;
  padding: 0.45rem 0.75rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.6);
  text-decoration: none;
}
#lens-nav a:hover { color: #fff; background: rgba(255, 255, 255, 0.1); }
#lens-nav a.active, #lens-nav a.active:hover { color: #fff; background: var(--teal); }
#app-nav {
  display: none;
  flex-direction: column;
  gap: 0.25rem;
  margin: 0;
  padding: 0.35rem 0.75rem 0;
  min-height: 0;
}
body.suite-frame #app-nav { display: flex; }
#app-nav[hidden] { display: none !important; }
#app-nav a {
  border-radius: 6px;
  padding: 0.4rem 0.75rem;
  font-size: 0.8125rem;
  font-weight: 500;
  line-height: 1.3;
  color: rgba(255, 255, 255, 0.6);
  text-decoration: none;
}
#app-nav a:hover { color: #fff; background: rgba(255, 255, 255, 0.1); }
#app-nav a.active, #app-nav a.active:hover { color: #fff; background: var(--teal); }
#app-nav p {
  margin: 0.65rem 0 0.1rem;
  padding: 0 0.75rem;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.45);
}
#filters {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin: 0.5rem 0 0;
  padding: 0.5rem 0.75rem 0;
  border-top: 1px solid #1e293b;
}
body.suite-dms,
body.suite-frame,
body.suite-other,
body.suite-learn { grid-template-columns: 14rem minmax(0, 1fr); }
body.suite-dms #viewer,
body.suite-dms #aspects,
body.suite-dms #filters,
body.suite-dms #documents,
body.suite-frame #viewer,
body.suite-frame #aspects,
body.suite-frame #filters,
body.suite-frame #documents,
body.suite-other #viewer,
body.suite-other #aspects,
body.suite-other #filters,
body.suite-other #documents,
body.suite-learn #viewer,
body.suite-learn #aspects,
body.suite-learn #filters,
body.suite-learn #documents { display: none; }
#training { overflow: auto; padding: 1.25rem 1.5rem 2.5rem; background: #f8fafc; }
#training[hidden] { display: none !important; }
#training h2 { margin: 0 0 0.35rem; font-size: 1.25rem; }
#training > p { margin: 0 0 1rem; color: #475569; max-width: 42rem; }
.train {
  display: grid;
  grid-template-columns: 11rem 8rem minmax(0, 1.4fr) minmax(8rem, 0.8fr) auto;
  gap: 0.75rem;
  align-items: start;
  margin: 0 0 0.75rem;
  padding: 0.75rem;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #fff;
}
.train strong, .train span { display: block; }
.train .logic { color: #475569; font-size: 0.8125rem; }
.train input { width: 100%; box-sizing: border-box; }
.train .actions { display: flex; gap: 0.35rem; }
.train button { border: 1px solid #cbd5e1; border-radius: 6px; background: #fff; padding: 0.35rem 0.55rem; cursor: pointer; }
.train button.keep { background: var(--teal); border-color: var(--teal); color: #fff; }
#stage { display: none; position: relative; min-height: 0; background: #fff; }
#frame-loading {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0f172a;
}
#frame-loading[hidden] { display: none !important; }
.boot-track { width: 12rem; height: 4px; overflow: hidden; border-radius: 999px; background: #1e293b; }
.boot-bar { width: 40%; height: 100%; background: #14b8a6; animation: boot-slide 1s ease-in-out infinite; }
@keyframes boot-slide { from { transform: translateX(-120%); } to { transform: translateX(280%); } }
body.suite-dms #stage,
body.suite-frame #stage { display: flex; flex-direction: column; }
#stage-note { margin: 2rem; color: #475569; max-width: 36rem; }
#app-frame { flex: 1; width: 100%; min-height: 0; border: 0; background: #fff; }
#stage-note[hidden], #app-frame[hidden], #lens-nav[hidden] { display: none !important; }
#product { display: none; padding: 2rem; }
body.suite-other #product { display: block; }
#product h2 { margin: 0 0 0.5rem; font-size: 1.25rem; }
#product p { margin: 0; color: #475569; max-width: 36rem; }
#logout {
  margin: auto 0.75rem 1rem;
  border: 1px solid #1e293b;
  border-radius: 6px;
  background: transparent;
  color: rgba(255, 255, 255, 0.9);
  text-align: left;
  padding: 0.5rem 0.75rem;
  font-size: 0.75rem;
  cursor: pointer;
}
#logout:hover { background: rgba(255, 255, 255, 0.1); }
.login-body {
  display: grid;
  grid-template-columns: 1fr;
  place-items: center;
  background: var(--navy);
  color: #fff;
}
#login {
  display: grid;
  gap: 0.75rem;
  width: 18rem;
  padding: 1.5rem;
  border-radius: 12px;
  background: #fff;
  color: #0f172a;
}
#login img { height: 60px; width: auto; justify-self: center; }
#login h1 { margin: 0; font-size: 1.125rem; justify-self: center; text-align: center; }
#login label { display: grid; gap: 0.25rem; font-size: 0.875rem; }
#login input {
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 0.45rem 0.6rem;
  font: inherit;
}
#login button {
  border: 0;
  border-radius: 6px;
  background: var(--teal);
  color: #fff;
  padding: 0.55rem 0.75rem;
  font: inherit;
  font-weight: 500;
  cursor: pointer;
}
#login-error { min-height: 1.2em; margin: 0; color: #b42318; font-size: 0.875rem; }
#filters button, #documents button, .actions button, .response button {
  text-align: left;
  border: 0;
  background: transparent;
  padding: 0.35rem 0.45rem;
  cursor: pointer;
  color: inherit;
}
#filters button {
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.6);
  transition: color 0.2s ease, background-color 0.2s ease;
}
#filters button:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
}
#filters button.active,
#filters button.active:hover {
  color: #fff;
  background: var(--teal);
}
#documents {
  list-style: none;
  margin: 0.5rem 0.75rem 0;
  padding: 0.5rem 0 1rem;
  border-top: 1px solid #1e293b;
}
#documents button { width: 100%; border-left: 6px solid rgba(255, 255, 255, 0.35); overflow-wrap: anywhere; }
#documents button.tone-right { border-left-color: var(--right); }
#documents button.tone-wrong { border-left-color: var(--wrong); }
#documents button.tone-corrected { border-left-color: var(--corrected); }
#documents button.tone-pending { border-left-color: rgba(255, 255, 255, 0.35); }
#documents button.tone-uncertain { border-left-color: var(--corrected); }
#documents button.active { background: rgba(255, 255, 255, 0.08); }
#documents small { display: block; color: #94a3b8; }
#doc-head {
  display: flex;
  flex-direction: column;
  margin-bottom: 0.75rem;
  border-left: 10px solid var(--pending);
  padding-left: 0.55rem;
  color: #444;
}
#doc-head small { color: #555; font-weight: 400; }
#doc-head.tone-right { border-left-color: var(--right); }
#doc-head.tone-wrong { border-left-color: var(--wrong); }
#doc-head.tone-corrected, #doc-head.tone-uncertain { border-left-color: var(--corrected); }
#doc-head.tone-pending { border-left-color: var(--pending); }
h3 { font-size: 0.75rem; margin: 0.9rem 0 0.35rem; color: #64748b; text-transform: uppercase; letter-spacing: 0.03em; cursor: pointer; }
.card {
  position: relative;
  border: 1px solid #e2e8f0;
  border-left: 10px solid var(--pending);
  border-radius: 8px;
  margin: 0 0 0.55rem;
  background: #fff;
}
.card .bar { position: absolute; left: -10px; top: 0; bottom: 0; width: 10px; cursor: help; }
.card .bar-reason {
  display: none;
  position: absolute;
  left: 4px;
  top: 0.35rem;
  z-index: 2;
  max-width: 16rem;
  font-size: 12px;
  line-height: 1.3;
  font-weight: 400;
  background: #1c1c1c;
  color: #fff;
  border-radius: 2px;
  padding: 2px 6px;
}
.card .bar:hover + .bar-reason { display: block; }
.card-right { border-left-color: var(--right); }
.card-wrong { border-left-color: var(--wrong); }
.card-corrected { border-left-color: var(--corrected); }
.card-pending { border-left-color: var(--pending); }
.card-uncertain { border-left-color: var(--corrected); }
.card header { display: flex; align-items: center; gap: 0.4rem; padding: 0.45rem 0.6rem; font-weight: 600; cursor: pointer; }
.card .caret { width: 0.8rem; color: #666; }
.card .recog { width: 16px; height: 16px; margin-left: auto; flex: none; }
.card .recog-missing, .card .recog-later { color: #989aa2; }
.card .recog-certain { color: #1c1c1c; }
.card .recog-probable { color: #b8860b; }
.card .recog-wrong { color: var(--wrong); }
.card .recog-right { color: #087a32; }
.card .body { padding: 0 0.6rem 0.55rem; }
.card .original {
  display: none;
  font-size: 12px;
  line-height: 1.2;
  font-weight: 400;
  background: #989aa2;
  color: #fff;
  border-radius: 2px;
  padding: 0 4px;
  margin: 0 0 0.25rem;
}
.card.card-corrected:hover .original { display: inline-block; }
.card .mapped {
  font-size: 12px;
  line-height: 1.3;
  color: #475569;
  margin: 0 0 0.2rem;
}
.card:not(.open) .body { display: none; }
.card.active { background: var(--highlight); }
.place { display: flex; align-items: center; gap: 0.45rem; margin: 0.15rem 0 0; }
.coords { margin: 0; font-size: 11px; color: #64748b; }
.box-clear { border: 0; background: transparent; color: #0f766e; font-size: 11px; cursor: pointer; padding: 0; }
.card input {
  width: 100%;
  box-sizing: border-box;
  border: 0;
  border-bottom: 1px solid transparent;
  background: transparent;
  padding: 0.2rem 0.15rem 0.15rem;
  color: inherit;
  font: inherit;
}
.card input.right { border-bottom-color: var(--right); }
.card input.wrong { border-bottom-color: var(--wrong); }
.card input.corrected, .card input.uncertain { border-bottom-color: var(--corrected); }
.card input:focus { outline: none; background: rgba(0, 0, 0, 0.02); }
.response { display: flex; gap: 0.25rem; margin-top: 0.35rem; }
.response button { border: 1px solid transparent; border-radius: 4px; }
.response button.chosen-right { color: #087a32; border-color: var(--right); }
.response button.chosen-wrong { color: #b42318; border-color: var(--wrong); }
.actions { display: flex; gap: 0.35rem; align-items: center; margin: 0.75rem 0; }
#viewer { background: #e2e8f0; padding: 0.75rem; }
#pager {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin: -0.75rem -0.75rem 0.75rem;
  padding: 0.45rem 0.75rem;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
}
#pager button {
  width: 2rem;
  height: 2rem;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  background: #fff;
  color: #0f172a;
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
}
#pager button:disabled { opacity: 0.35; cursor: default; }
#pager label { display: flex; align-items: center; gap: 0.35rem; color: #475569; }
#page-input {
  width: 3.2rem;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 0.2rem 0.3rem;
  font: inherit;
  text-align: center;
  color: #0f172a;
}
#page-wrap { position: relative; display: inline-block; background: #fff; }
#page, #marks, #text-layer, #draw { position: absolute; left: 0; top: 0; }
#page { position: relative; }
#marks, #draw { pointer-events: none; }
#text-layer { line-height: 1; opacity: 0.3; }
#text-layer span { position: absolute; color: transparent; white-space: pre; transform-origin: 0 0; }
#text-layer ::selection { background: rgba(20, 90, 150, 0.35); }
#viewer-note { color: #555; }
