:root {
  --ink: #10232a;
  --ink-soft: #19343c;
  --paper: #f1f4f1;
  --paper-strong: #ffffff;
  --line: #cbd4d0;
  --muted: #63716f;
  --signal: #ee6a3b;
  --signal-dark: #bf4624;
  --teal: #17877f;
  --teal-soft: #d8ebe7;
  --warning: #c54f35;
  --font-display: "Songti SC", "Noto Serif SC", "STSong", serif;
  --font-body: "Avenir Next", "PingFang SC", "Microsoft YaHei", sans-serif;
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
}

body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  letter-spacing: 0;
}

button,
input,
textarea,
select {
  font: inherit;
  letter-spacing: 0;
}

button,
select {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 3px solid rgba(238, 106, 59, 0.3);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

.login-view {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(380px, 0.75fr);
  background: var(--ink);
}

.login-identity {
  min-height: 100vh;
  padding: 9vh 8vw;
  display: flex;
  align-items: flex-end;
  gap: 48px;
  color: #f8faf7;
  border-right: 1px solid #31515a;
  position: relative;
  overflow: hidden;
}

.login-identity::before,
.login-identity::after {
  content: "";
  position: absolute;
  pointer-events: none;
}

.login-identity::before {
  width: 62%;
  height: 1px;
  top: 13%;
  left: 8vw;
  background: #35515a;
  box-shadow: 0 110px 0 #203a42, 0 220px 0 #203a42;
}

.login-identity::after {
  width: 1px;
  height: 72%;
  top: 9%;
  right: 14%;
  background: #29464e;
  box-shadow: -180px 0 0 #1c363e;
}

.archive-stamp {
  width: 104px;
  height: 150px;
  border: 1px solid #739099;
  display: grid;
  grid-template-rows: auto 1fr auto;
  align-items: center;
  justify-items: center;
  padding: 12px;
  color: #a6bcc1;
  position: relative;
  z-index: 1;
}

.archive-stamp strong {
  color: var(--signal);
  font-family: var(--font-display);
  font-size: 54px;
  font-weight: 500;
}

.archive-stamp span {
  font-size: 10px;
  letter-spacing: 0.18em;
}

.login-identity > div:last-child {
  position: relative;
  z-index: 1;
}

.eyebrow,
.section-index,
.source-mark,
.module-header,
.login-edition {
  margin: 0;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.login-identity .eyebrow {
  color: #91aaaF;
  margin-bottom: 20px;
}

.login-identity h1 {
  max-width: 720px;
  margin: 0;
  font-family: var(--font-display);
  font-size: 72px;
  line-height: 1.08;
  font-weight: 600;
}

.login-edition {
  margin-top: 30px;
  color: var(--signal);
}

.login-form {
  align-self: center;
  width: min(420px, calc(100% - 64px));
  margin: 0 auto;
  padding: 42px;
  background: var(--paper-strong);
  border-top: 5px solid var(--signal);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.25);
}

.form-heading {
  margin-bottom: 34px;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--line);
}

.form-heading h2,
.section-heading h2,
.dialog-header h2 {
  margin: 6px 0 0;
  font-family: var(--font-display);
  font-weight: 600;
}

.login-form label,
.intake-form > label,
.review-form label {
  display: block;
  margin: 18px 0 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fbfcfa;
  color: var(--ink);
}

input,
select {
  height: 44px;
  padding: 0 13px;
}

textarea {
  padding: 13px;
  resize: vertical;
  line-height: 1.55;
}

input:hover,
textarea:hover,
select:hover {
  border-color: #9eaaa6;
}

.form-error {
  min-height: 20px;
  margin: 12px 0 0;
  color: var(--warning);
  font-size: 12px;
}

.button {
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 4px;
  padding: 0 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  font-weight: 700;
  transition: transform 140ms ease, background-color 140ms ease, border-color 140ms ease;
}

.button:hover {
  transform: translateY(-1px);
}

.button:disabled {
  cursor: wait;
  opacity: 0.55;
  transform: none;
}

.button svg,
.icon-button svg,
.nav-item svg,
.search-field svg,
.module-header svg {
  width: 17px;
  height: 17px;
  stroke-width: 1.8;
}

.button-primary {
  background: var(--ink);
  color: white;
}

.button-primary:hover {
  background: var(--ink-soft);
}

.button-signal {
  background: var(--signal);
  color: #27150f;
  border-color: #ff8a5f;
}

.button-signal:hover {
  background: #ff7a49;
}

.button-wide {
  width: 100%;
}

.login-form .button {
  margin-top: 20px;
}

.workbench-view {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 242px minmax(560px, 1fr) 286px;
  background: var(--paper);
}

.sidebar {
  min-height: 100vh;
  padding: 24px 18px;
  display: flex;
  flex-direction: column;
  color: #d8e2df;
  background: var(--ink);
  border-right: 1px solid #2a464d;
}

.brand-lockup {
  min-height: 62px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 7px 20px;
  border-bottom: 1px solid #29424a;
}

.brand-mark {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  background: var(--signal);
  color: #29160f;
  font-family: var(--font-display);
  font-size: 20px;
}

.brand-lockup strong,
.sidebar-user strong {
  display: block;
  font-size: 14px;
}

.brand-lockup small,
.sidebar-user small {
  display: block;
  margin-top: 4px;
  color: #7f9aa0;
  font-size: 9px;
  letter-spacing: 0.12em;
}

.primary-nav {
  padding: 24px 0;
  border-bottom: 1px solid #29424a;
}

.nav-item {
  width: 100%;
  min-height: 42px;
  border: 0;
  border-left: 3px solid transparent;
  padding: 0 10px;
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  background: transparent;
  color: #9eb2b5;
  text-align: left;
}

.nav-item span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}

.nav-item b {
  min-width: 24px;
  font-size: 11px;
  text-align: right;
}

.nav-item:hover,
.nav-item.is-active {
  color: white;
  background: #18333b;
  border-left-color: var(--signal);
}

.topic-nav {
  min-height: 0;
  padding-top: 22px;
  flex: 1;
  overflow: auto;
}

.sidebar-label {
  padding: 0 10px 10px;
  display: flex;
  justify-content: space-between;
  color: #6f8b91;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
}

.category-list {
  display: grid;
  gap: 2px;
}

.category-button {
  width: 100%;
  min-height: 38px;
  border: 0;
  padding: 0 10px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  background: transparent;
  color: #a7b8b9;
  text-align: left;
  font-size: 12px;
}

.category-button span:first-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.category-button:hover,
.category-button.is-active {
  color: white;
  background: #18333b;
}

.category-button.is-active::before {
  content: "";
  width: 5px;
  height: 5px;
  background: var(--teal);
  position: absolute;
}

.sidebar-user {
  min-height: 64px;
  margin-top: 16px;
  padding: 14px 7px 0;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) 34px;
  gap: 10px;
  align-items: center;
  border-top: 1px solid #29424a;
}

.user-avatar {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid #47636a;
  color: #b9cbcc;
  font-family: var(--font-display);
}

.icon-button {
  width: 34px;
  height: 34px;
  border: 1px solid transparent;
  border-radius: 4px;
  display: grid;
  place-items: center;
  background: transparent;
  color: inherit;
}

.icon-button:hover {
  border-color: currentColor;
}

.workspace {
  min-width: 0;
  padding: 28px clamp(24px, 3vw, 48px) 60px;
}

.workspace-header {
  min-height: 76px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  border-bottom: 1px solid var(--ink);
}

.workspace-header .eyebrow {
  color: var(--signal-dark);
}

.workspace-header h1 {
  margin: 5px 0 20px;
  font-family: var(--font-display);
  font-size: 31px;
  line-height: 1.1;
  font-weight: 600;
}

.search-field {
  width: min(360px, 42%);
  min-width: 260px;
  height: 42px;
  padding: 0 10px 0 12px;
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  border: 1px solid var(--line);
  background: white;
}

.search-field input {
  height: 38px;
  min-width: 0;
  border: 0;
  padding: 0;
  background: transparent;
}

.search-field input:focus-visible {
  outline: 0;
}

.search-field kbd {
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 2px 5px;
  color: var(--muted);
  background: #f5f7f4;
  font-size: 10px;
}

.metric-strip {
  min-height: 116px;
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  border-bottom: 1px solid var(--line);
}

.metric {
  min-width: 0;
  padding: 22px 18px 18px 0;
  display: grid;
  grid-template-columns: 1fr auto;
  align-content: center;
  border-right: 1px solid var(--line);
}

.metric:not(:first-child) {
  padding-left: 18px;
}

.metric:last-child {
  border-right: 0;
}

.metric span,
.metric small {
  color: var(--muted);
  font-size: 11px;
}

.metric strong {
  grid-row: span 2;
  align-self: center;
  font-family: var(--font-display);
  font-size: 38px;
  font-weight: 500;
}

.metric-signal strong {
  color: var(--teal);
}

.metric-alert strong {
  color: var(--signal-dark);
}

.view-panel {
  display: none;
}

.view-panel.is-active {
  display: block;
  animation: panel-in 260ms ease both;
}

@keyframes panel-in {
  from { opacity: 0; transform: translateY(7px); }
  to { opacity: 1; transform: translateY(0); }
}

.intake-band,
.list-section {
  padding: 30px 0;
  border-bottom: 1px solid var(--line);
}

.section-heading {
  min-height: 46px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
}

.section-index {
  color: var(--signal-dark);
}

.section-heading h2 {
  font-size: 21px;
}

.source-mark {
  color: var(--muted);
}

.intake-form {
  margin-top: 22px;
}

.intake-form textarea {
  min-height: 112px;
  border-left: 4px solid var(--ink);
  border-radius: 0 4px 4px 0;
  background: white;
}

.intake-actions {
  min-height: 54px;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
}

.intake-actions > span {
  color: var(--muted);
  font-size: 11px;
}

.segmented-control {
  display: flex;
  border: 1px solid var(--line);
  background: white;
}

.segmented-control button {
  min-height: 34px;
  border: 0;
  border-right: 1px solid var(--line);
  padding: 0 13px;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
}

.segmented-control button:last-child {
  border-right: 0;
}

.segmented-control button.is-active {
  background: var(--ink);
  color: white;
}

.record-list,
.paper-list,
.source-list {
  margin-top: 18px;
  border-top: 1px solid var(--ink);
}

.record-row {
  min-height: 66px;
  padding: 12px 8px;
  display: grid;
  grid-template-columns: 84px minmax(0, 1fr) 116px 120px;
  gap: 16px;
  align-items: center;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.32);
}

.record-row:hover,
.paper-row:hover {
  background: white;
}

.record-id,
.paper-id {
  color: var(--muted);
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 10px;
}

.record-url {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
}

.record-meta {
  color: var(--muted);
  font-size: 10px;
}

.status-chip {
  width: fit-content;
  min-width: 72px;
  padding: 5px 8px;
  border: 1px solid currentColor;
  border-radius: 3px;
  color: var(--muted);
  text-align: center;
  font-size: 10px;
  font-weight: 700;
}

.status-queued,
.status-processing {
  color: var(--signal-dark);
}

.status-completed {
  color: var(--teal);
}

.status-manual,
.status-failed {
  color: var(--warning);
}

.empty-state {
  min-height: 150px;
  padding: 32px;
  display: grid;
  place-items: center;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
  text-align: center;
  font-family: var(--font-display);
}

.literature-section {
  padding-top: 34px;
}

.section-heading select {
  width: 150px;
  height: 36px;
  font-size: 11px;
}

.paper-row {
  width: 100%;
  min-height: 98px;
  border: 0;
  border-bottom: 1px solid var(--line);
  padding: 16px 8px;
  display: grid;
  grid-template-columns: 60px minmax(0, 1fr) 120px 94px;
  gap: 16px;
  align-items: center;
  background: rgba(255, 255, 255, 0.32);
  color: var(--ink);
  text-align: left;
}

.source-section {
  padding-top: 34px;
}

.source-row {
  width: 100%;
  min-height: 88px;
  border: 0;
  border-bottom: 1px solid var(--line);
  padding: 14px 8px;
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr) 140px 90px;
  gap: 16px;
  align-items: center;
  background: rgba(255, 255, 255, 0.32);
  color: var(--ink);
  text-align: left;
}

.source-row:hover {
  background: white;
}

.source-id,
.source-paper-count,
.source-image-count {
  color: var(--muted);
  font-size: 11px;
}

.source-id {
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 10px;
}

.source-main {
  min-width: 0;
}

.source-main strong,
.source-main small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.source-main strong {
  font-family: var(--font-display);
  font-size: 16px;
}

.source-main small {
  margin-top: 7px;
  color: var(--muted);
  font-size: 10px;
}

.source-image-count {
  color: var(--teal);
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  text-align: right;
}

.paper-main {
  min-width: 0;
}

.paper-main strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--font-display);
  font-size: 16px;
}

.paper-main small {
  display: block;
  margin-top: 7px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-size: 10px;
}

.paper-tags {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.paper-tags span {
  color: var(--teal);
  font-size: 10px;
}

.signal-rail {
  min-height: 100vh;
  padding: 24px 20px;
  background: #e4e9e5;
  border-left: 1px solid var(--line);
}

.agent-module,
.rail-section {
  padding: 20px 0 24px;
  border-bottom: 1px solid #bfc9c5;
}

.agent-module {
  padding-top: 6px;
}

.module-header {
  min-height: 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--muted);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--teal);
  box-shadow: 0 0 0 4px rgba(23, 135, 127, 0.14);
}

.status-dot.is-running {
  background: var(--signal);
  box-shadow: 0 0 0 4px rgba(238, 106, 59, 0.15);
  animation: signal-pulse 1.2s ease-in-out infinite;
}

@keyframes signal-pulse {
  50% { opacity: 0.45; }
}

.agent-state {
  padding: 24px 0 18px;
}

.agent-state strong {
  display: block;
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 500;
}

.agent-state span {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 11px;
}

.agent-track {
  height: 4px;
  margin-bottom: 20px;
  overflow: hidden;
  background: #c5cfcb;
}

.agent-track span {
  width: 0;
  height: 100%;
  display: block;
  background: var(--signal);
  transition: width 260ms ease;
}

.agent-track span.is-running {
  width: 72%;
  animation: track-move 1.8s ease-in-out infinite alternate;
}

@keyframes track-move {
  from { transform: translateX(-35%); }
  to { transform: translateX(70%); }
}

.manual-list {
  margin-top: 12px;
}

.manual-item {
  padding: 12px 0;
  border-bottom: 1px solid #c8d0cd;
}

.manual-item:last-child {
  border-bottom: 0;
}

.manual-item strong,
.manual-item small {
  display: block;
}

.manual-item strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 11px;
}

.manual-item small {
  margin-top: 5px;
  color: var(--warning);
  font-size: 9px;
}

.button-browser {
  margin-top: 9px;
  border: 1px solid var(--ink);
  background: transparent;
  color: var(--ink);
  text-decoration: none;
}

.button-browser:hover {
  background: var(--ink);
  color: var(--paper);
}

.manual-retry {
  height: 28px;
  margin-top: 9px;
  padding: 0 9px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--ink);
  background: transparent;
  color: var(--ink);
  font-size: 9px;
  font-weight: 700;
  cursor: pointer;
}

.manual-retry svg {
  width: 12px;
  height: 12px;
}

.manual-retry:disabled {
  opacity: 0.45;
  cursor: wait;
}

.schedule-module strong {
  display: block;
  margin-top: 14px;
  font-family: var(--font-display);
  font-size: 32px;
  font-weight: 500;
}

.schedule-module > span {
  color: var(--muted);
  font-size: 10px;
}

.paper-dialog {
  width: min(1080px, calc(100vw - 48px));
  height: min(780px, calc(100vh - 48px));
  padding: 0;
  border: 1px solid var(--ink);
  border-radius: 4px;
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 32px 100px rgba(10, 25, 30, 0.38);
}

.paper-dialog::backdrop {
  background: rgba(8, 22, 27, 0.68);
}

.dialog-header {
  min-height: 86px;
  padding: 20px 24px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  color: white;
  background: var(--ink);
}

.dialog-header h2 {
  max-width: 760px;
  font-size: 24px;
}

.dialog-grid {
  height: calc(100% - 86px);
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
}

.paper-reading {
  min-width: 0;
  overflow: auto;
  background: white;
}

.note-content {
  min-width: 0;
  padding: 30px clamp(24px, 4vw, 54px) 60px;
  overflow: visible;
}

.note-content h1,
.note-content h2,
.note-content h3 {
  font-family: var(--font-display);
  font-weight: 600;
}

.note-content h1 {
  margin: 0 0 32px;
  font-size: 28px;
}

.note-content h2 {
  margin: 34px 0 12px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  font-size: 19px;
}

.note-content p,
.note-content li {
  color: #33494e;
  font-size: 14px;
  line-height: 1.8;
}

.paper-sources {
  margin: 0 clamp(24px, 4vw, 54px) 42px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

.paper-sources-empty {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.paper-source-list {
  margin-top: 10px;
  display: grid;
  gap: 6px;
}

.paper-source-button {
  width: 100%;
  min-height: 38px;
  padding: 8px 10px;
  display: grid;
  grid-template-columns: 16px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  text-align: left;
  font-size: 11px;
}

.paper-source-button:hover {
  border-color: var(--teal);
  color: var(--teal);
}

.paper-source-button span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.paper-source-button svg {
  width: 15px;
  height: 15px;
}

.review-form {
  padding: 28px 22px;
  border-left: 1px solid var(--line);
  background: #e6ebe7;
}

.review-form .button {
  margin-top: 22px;
}

.source-dialog {
  width: min(920px, calc(100vw - 48px));
  max-width: none;
  max-height: calc(100vh - 48px);
  padding: 0;
  border: 1px solid var(--ink);
  border-radius: 4px;
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 32px 100px rgba(10, 25, 30, 0.38);
}

.source-dialog::backdrop {
  background: rgba(8, 22, 27, 0.68);
}

.source-dialog-meta {
  min-height: 58px;
  padding: 12px 24px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px 20px;
  align-items: center;
  border-bottom: 1px solid var(--line);
  background: #e6ebe7;
  color: var(--muted);
  font-size: 11px;
}

.source-original-link {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--teal);
  font-weight: 700;
  text-decoration: none;
}

.source-original-link:hover {
  color: var(--signal-dark);
}

.source-original-link svg {
  width: 14px;
  height: 14px;
}

.source-content {
  max-height: calc(100vh - 194px);
  padding: 34px clamp(20px, 5vw, 76px) 54px;
  overflow: auto;
  background: white;
}

.source-content > * {
  max-width: 760px;
  margin-right: auto;
  margin-left: auto;
}

.source-content h1,
.source-content h2,
.source-content h3 {
  font-family: var(--font-display);
  font-weight: 600;
}

.source-content h1 {
  margin-top: 0;
  font-size: 30px;
}

.source-content h2 {
  margin-top: 38px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  font-size: 21px;
}

.source-content h3 {
  margin-top: 26px;
  font-size: 17px;
}

.source-content p,
.source-content li {
  color: #33494e;
  font-size: 15px;
  line-height: 1.9;
}

.source-content code {
  padding: 1px 4px;
  background: #edf2ef;
  color: var(--ink-soft);
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 0.9em;
}

.source-figure {
  min-height: 180px;
  display: grid;
  align-content: center;
  margin-top: 28px;
  margin-bottom: 28px;
  padding: 12px;
  background: #e8efeb;
  border: 1px solid var(--line);
}

.source-figure img {
  display: block;
  width: auto;
  max-width: 100%;
  height: auto;
}

.source-image-fallback {
  color: var(--warning);
  font-size: 13px;
}

.source-figure figcaption {
  margin-top: 8px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
}

.toast-region {
  position: fixed;
  z-index: 100;
  top: 18px;
  right: 18px;
  width: min(360px, calc(100vw - 36px));
  display: grid;
  gap: 8px;
}

.toast {
  min-height: 46px;
  padding: 12px 15px;
  border-left: 4px solid var(--teal);
  background: var(--ink);
  color: white;
  box-shadow: 0 12px 34px rgba(10, 25, 30, 0.24);
  font-size: 12px;
  animation: toast-in 180ms ease both;
}

.toast.is-error {
  border-left-color: var(--signal);
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 1160px) {
  .workbench-view {
    grid-template-columns: 220px minmax(0, 1fr);
  }

  .signal-rail {
    display: none;
  }
}

@media (max-width: 820px) {
  .login-view {
    grid-template-columns: 1fr;
  }

  .login-identity {
    min-height: 42vh;
    padding: 52px 32px 36px;
    align-items: flex-end;
    border-right: 0;
    border-bottom: 1px solid #31515a;
  }

  .login-identity h1 {
    font-size: 48px;
  }

  .archive-stamp {
    width: 76px;
    height: 112px;
  }

  .archive-stamp strong {
    font-size: 38px;
  }

  .login-form {
    margin: 36px auto;
  }

  .workbench-view {
    display: block;
  }

  .sidebar {
    min-height: auto;
    padding: 12px 16px;
    display: grid;
    grid-template-columns: 1fr auto;
    position: sticky;
    z-index: 20;
    top: 0;
  }

  .brand-lockup {
    min-height: 46px;
    padding: 0;
    border: 0;
  }

  .primary-nav {
    grid-column: 1 / -1;
    padding: 10px 0 0;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    border: 0;
  }

  .nav-item {
    grid-template-columns: 18px minmax(0, 1fr);
    min-height: 38px;
  }

  .nav-item b {
    display: none;
  }

  .topic-nav {
    display: none;
  }

  .sidebar-user {
    min-height: 46px;
    margin: 0;
    padding: 0;
    border: 0;
  }

  .sidebar-user > div,
  .user-avatar {
    display: none;
  }

  .workspace {
    padding: 22px 18px 50px;
  }

  .workspace-header {
    display: block;
  }

  .search-field {
    width: 100%;
    min-width: 0;
    margin-bottom: 18px;
  }

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

  .metric:nth-child(2) {
    border-right: 0;
  }

  .metric:nth-child(-n + 2) {
    border-bottom: 1px solid var(--line);
  }

  .record-row {
    grid-template-columns: 66px minmax(0, 1fr) 82px;
  }

  .record-meta {
    display: none;
  }

  .paper-row {
    grid-template-columns: 46px minmax(0, 1fr) 86px;
  }

  .source-row {
    grid-template-columns: 56px minmax(0, 1fr) 68px;
    gap: 12px;
  }

  .source-paper-count {
    display: none;
  }

  .paper-tags {
    display: none;
  }

  .dialog-grid {
    display: block;
    overflow: auto;
  }

  .note-content {
    overflow: visible;
  }

  .source-dialog-meta {
    padding: 12px 18px;
  }

  .source-content {
    max-height: calc(100vh - 190px);
  }

  .review-form {
    border-top: 1px solid var(--line);
    border-left: 0;
  }
}

@media (max-width: 520px) {
  .login-identity {
    min-height: 36vh;
    padding: 36px 22px 28px;
    gap: 20px;
  }

  .archive-stamp {
    display: none;
  }

  .login-identity h1 {
    font-size: 40px;
  }

  .login-form {
    width: calc(100% - 32px);
    padding: 28px 22px;
  }

  .brand-lockup strong {
    font-size: 12px;
  }

  .nav-item span {
    font-size: 11px;
  }

  .metric {
    min-height: 92px;
    padding: 15px 12px 15px 0;
  }

  .metric:not(:first-child) {
    padding-left: 12px;
  }

  .metric strong {
    font-size: 30px;
  }

  .section-heading {
    display: block;
  }

  .segmented-control,
  .section-heading select {
    width: 100%;
    margin-top: 16px;
  }

  .segmented-control button {
    flex: 1;
  }

  .record-row {
    grid-template-columns: minmax(0, 1fr) 80px;
  }

  .record-id {
    display: none;
  }

  .paper-row {
    grid-template-columns: minmax(0, 1fr) 82px;
  }

  .primary-nav {
    gap: 2px;
  }

  .nav-item {
    min-height: 54px;
    grid-template-columns: 1fr;
    grid-template-rows: 16px minmax(0, 1fr);
    gap: 2px;
    padding: 5px 2px;
    border-bottom: 2px solid transparent;
    border-left: 0;
    text-align: center;
  }

  .nav-item svg {
    justify-self: center;
  }

  .nav-item span {
    overflow: visible;
    text-overflow: clip;
    white-space: normal;
    font-size: 10px;
    line-height: 1.2;
  }

  .nav-item:hover,
  .nav-item.is-active {
    border-bottom-color: var(--signal);
    border-left-color: transparent;
  }

  .source-row {
    grid-template-columns: 50px minmax(0, 1fr) 58px;
    gap: 8px;
    min-height: 78px;
    padding: 12px 4px;
  }

  .source-main strong {
    font-size: 14px;
  }

  .source-image-count {
    font-size: 10px;
  }

  .paper-id {
    display: none;
  }

  .paper-dialog {
    width: 100vw;
    height: 100vh;
    max-width: none;
    max-height: none;
    border: 0;
    border-radius: 0;
  }

  .source-dialog {
    width: calc(100vw - 24px);
    max-height: calc(100vh - 24px);
  }

  .source-dialog .dialog-header {
    min-height: 76px;
    padding: 16px 18px;
  }

  .source-dialog-meta {
    gap: 7px 14px;
  }

  .source-original-link {
    width: 100%;
    margin-left: 0;
  }

  .source-content {
    max-height: calc(100vh - 208px);
    padding: 26px 18px 40px;
  }

  .source-content h1 {
    font-size: 25px;
  }

  .source-content p,
  .source-content li {
    font-size: 14px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
