:root {
  --purple: #7132f5;
  --purple-dark: #5741d8;
  --purple-deep: #5b1ecf;
  --purple-soft: rgba(133, 91, 251, 0.16);
  --black: #101114;
  --muted: #686b82;
  --soft-text: #9497a9;
  --border: #dedee5;
  --surface: #ffffff;
  --surface-soft: #f7f8fb;
  --green: #149e61;
  --green-dark: #026b3f;
  --amber: #a15c00;
  --amber-bg: rgba(245, 158, 11, 0.15);
  --red: #b42318;
  --red-bg: rgba(244, 63, 94, 0.12);
  --shadow: rgba(0, 0, 0, 0.03) 0 4px 24px;
  --micro-shadow: rgba(16, 24, 40, 0.04) 0 1px 4px;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--surface);
  color: var(--black);
  font-family: "Kraken-Product", "Helvetica Neue", Helvetica, Arial, sans-serif;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
}

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

.topbar {
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  border-bottom: 1px solid rgba(104, 107, 130, 0.18);
  background: rgba(255, 255, 255, 0.96);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-logo {
  width: auto;
  height: 38px;
  max-width: 116px;
  display: block;
  object-fit: contain;
  flex: 0 0 auto;
}

.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--purple);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 700;
  box-shadow: var(--shadow);
}

.brand-title {
  font-family: "Kraken-Brand", "IBM Plex Sans", Helvetica, Arial, sans-serif;
  font-size: 20px;
  font-weight: 700;
  line-height: 1.2;
}

.brand-subtitle {
  color: var(--soft-text);
  font-size: 12px;
  line-height: 1.33;
}

.topbar-actions,
.viewer-actions,
.doc-controls,
.drop-actions,
.zoom-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar-new-task {
  min-height: 38px;
}

.user-pill {
  min-height: 34px;
  max-width: 220px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 10px;
  border-radius: 8px;
  background: rgba(20, 158, 97, 0.12);
  color: var(--green-dark);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.2;
}

.user-pill span:last-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar .secondary-button {
  width: auto;
}

.health-pill {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(104, 107, 130, 0.08);
  color: #484b5e;
  font-size: 14px;
  line-height: 1.2;
  white-space: nowrap;
}

.health-pill.is-ok {
  background: rgba(20, 158, 97, 0.16);
  color: var(--green-dark);
}

.health-pill.is-warn {
  background: var(--amber-bg);
  color: var(--amber);
}

.health-pill.is-bad {
  background: var(--red-bg);
  color: var(--red);
}

.health-pill #healthText {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.service-state {
  min-height: 22px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 6px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.58);
  color: #484b5e;
  line-height: 1;
}

.service-state strong,
.service-state span {
  font-size: 12px;
  line-height: 1;
}

.service-state strong {
  font-weight: 700;
}

.service-state.is-online {
  color: var(--green-dark);
}

.service-state.is-standby {
  color: var(--amber);
}

.service-state.is-offline {
  color: var(--red);
}

.service-state.is-unknown {
  color: var(--muted);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}

.upload-page,
.preview-page {
  min-height: calc(100vh - 72px);
  background: var(--surface-soft);
  overflow-x: hidden;
}

.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px 18px;
  background:
    linear-gradient(135deg, rgba(20, 158, 97, 0.08), transparent 34%),
    linear-gradient(315deg, rgba(113, 50, 245, 0.08), transparent 38%),
    var(--surface-soft);
}

.auth-panel {
  width: min(100%, 440px);
  padding: 26px;
  background: #fff;
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 22px;
}

.auth-tabs {
  width: 100%;
  margin-bottom: 16px;
}

.auth-tabs button {
  flex: 1 1 0;
}

.auth-status,
.auth-error {
  min-height: 40px;
  display: flex;
  align-items: center;
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 12px;
  font-size: 14px;
  line-height: 1.4;
}

.auth-status {
  background: rgba(104, 107, 130, 0.08);
  color: var(--muted);
}

.auth-error {
  background: var(--red-bg);
  color: var(--red);
  border: 1px solid rgba(180, 35, 24, 0.18);
}

.auth-form {
  display: grid;
  gap: 14px;
}

.auth-field {
  width: 100%;
  min-width: 0;
  flex: none;
}

.auth-verification {
  display: grid;
  gap: 12px;
}

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

.captcha-frame {
  min-height: 58px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  color: var(--soft-text);
}

.captcha-frame svg {
  display: block;
  width: 100%;
  height: 58px;
}

.verification-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 10px;
}

.auth-code-button {
  min-width: 126px;
  height: 44px;
}

.auth-submit {
  width: 100%;
  margin-top: 2px;
}

.auth-footer-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 16px;
}

.text-button {
  min-height: 32px;
  padding: 4px 6px;
  background: transparent;
  color: var(--purple-dark);
  font-weight: 600;
  cursor: pointer;
}

.text-button:hover {
  color: var(--purple-deep);
}

.upload-page-inner {
  width: min(1280px, calc(100vw - 48px));
  margin: 0 auto;
  padding: 24px 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.upload-page-inner > * {
  min-width: 0;
}

.task-sidebar {
  background: #fbfbfd;
  padding: 18px;
}

.task-library {
  overflow: hidden;
  min-height: 240px;
  border: 1px solid rgba(104, 107, 130, 0.18);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--micro-shadow);
}

.sidebar-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  margin: 0 2px 12px;
}

.sidebar-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
}

.task-list {
  min-width: 0;
  max-width: 100%;
  display: grid;
  gap: 8px;
}

.task-pagination {
  margin-top: 12px;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.task-pagination span {
  min-width: 0;
  flex: 1 1 auto;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.task-item {
  width: 100%;
  text-align: left;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  background: #fff;
  border: 1px solid rgba(104, 107, 130, 0.18);
  border-radius: 8px;
  padding: 12px;
  box-shadow: var(--micro-shadow);
  transition: border-color 0.16s ease, transform 0.16s ease, background 0.16s ease;
}

.task-item:hover {
  border-color: rgba(113, 50, 245, 0.38);
}

.task-item.is-active {
  border-color: var(--purple);
  background: rgba(133, 91, 251, 0.08);
}

.task-item.is-selected {
  border-color: rgba(113, 50, 245, 0.62);
}

.task-check {
  width: 22px;
  height: 36px;
  display: grid;
  place-items: center;
}

.task-check input {
  width: 16px;
  height: 16px;
  accent-color: var(--purple);
  cursor: pointer;
}

.task-main {
  min-width: 0;
  width: 100%;
  padding: 0;
  display: grid;
  grid-template-columns: minmax(220px, 1.4fr) minmax(220px, 0.95fr) minmax(150px, 0.7fr);
  align-items: center;
  gap: 14px;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.task-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.task-cancel,
.task-delete {
  opacity: 0.76;
}

.task-item:hover .task-cancel,
.task-item:hover .task-delete,
.task-cancel:focus-visible,
.task-delete:focus-visible {
  opacity: 1;
}

.task-title {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.task-meta {
  margin-top: 8px;
  color: var(--soft-text);
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  font-size: 12px;
}

.task-capability {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  color: #484b5e;
  font-size: 12px;
  line-height: 1.2;
}

.task-state {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.task-stage {
  min-width: 0;
  color: var(--soft-text);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.task-capability span,
.task-option-summary {
  min-height: 24px;
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  padding: 4px 7px;
  border-radius: 6px;
  background: rgba(104, 107, 130, 0.08);
  border: 1px solid rgba(104, 107, 130, 0.14);
  color: #484b5e;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.progress-box {
  width: 240px;
  display: grid;
  gap: 6px;
}

.progress-box.compact {
  width: 100%;
  grid-column: 1 / -1;
  margin-top: 0;
  gap: 5px;
}

.progress-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.33;
}

.progress-line span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.progress-line strong {
  color: var(--purple);
  font-size: 12px;
}

.progress-track {
  height: 8px;
  overflow: hidden;
  border-radius: 9999px;
  background: rgba(104, 107, 130, 0.12);
}

.progress-fill {
  height: 100%;
  min-width: 8px;
  border-radius: inherit;
  background: var(--purple);
  transition: width 0.35s ease;
}

.progress-box.is-active .progress-fill {
  background-image: linear-gradient(
    45deg,
    rgba(255, 255, 255, 0.32) 25%,
    transparent 25%,
    transparent 50%,
    rgba(255, 255, 255, 0.32) 50%,
    rgba(255, 255, 255, 0.32) 75%,
    transparent 75%,
    transparent
  );
  background-size: 18px 18px;
  animation: progress-stripes 1s linear infinite;
}

.progress-detail {
  color: var(--soft-text);
  font-size: 12px;
  line-height: 1.33;
}

.progress-message {
  align-content: center;
  justify-items: stretch;
  gap: 14px;
}

@keyframes progress-stripes {
  from {
    background-position: 0 0;
  }
  to {
    background-position: 18px 0;
  }
}

.workspace {
  min-width: 0;
  background: var(--surface);
}

.upload-panel {
  padding: 24px;
  background: #fff;
}

.upload-card {
  border: 1px solid rgba(104, 107, 130, 0.18);
  border-radius: 8px;
  box-shadow: var(--micro-shadow);
}

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

.panel-title {
  font-size: 22px;
  font-weight: 700;
  line-height: 1.2;
}

.panel-subtitle {
  margin-top: 5px;
  color: var(--soft-text);
  font-size: 14px;
  line-height: 1.43;
}

.upload-form {
  display: grid;
  gap: 14px;
}

.drop-zone {
  min-height: 102px;
  border: 1px dashed rgba(104, 107, 130, 0.36);
  border-radius: 12px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  padding: 18px;
  background: #fff;
  transition: border-color 0.16s ease, background 0.16s ease;
}

.drop-zone.is-dragover {
  border-color: var(--purple);
  background: rgba(133, 91, 251, 0.08);
}

.drop-icon {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: var(--purple-soft);
  color: var(--purple);
}

.drop-title {
  font-size: 18px;
  font-weight: 700;
  line-height: 1.25;
}

.drop-meta {
  margin-top: 4px;
  color: var(--soft-text);
  font-size: 14px;
}

.selected-files {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.file-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 30px;
  max-width: 280px;
  padding: 6px 8px;
  border-radius: 8px;
  background: rgba(104, 107, 130, 0.08);
  color: #484b5e;
  font-size: 13px;
  white-space: nowrap;
}

.file-chip span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
}

.settings-row {
  display: flex;
  align-items: end;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-start;
}

.field {
  display: grid;
  gap: 6px;
  min-width: 150px;
  flex: 0 1 150px;
}

.backend-field {
  min-width: 190px;
  flex-basis: 190px;
}

.field.short {
  min-width: 112px;
  width: 112px;
  flex: 0 0 112px;
}

.field span,
.toggle-field span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.33;
}

.field select,
.field input {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  height: 44px;
  border-radius: 10px;
  border: 1px solid var(--border);
  padding: 0 12px;
  background: #fff;
  color: var(--black);
  outline: none;
}

.field select:focus,
.field input:focus {
  border-color: var(--purple);
  box-shadow: 0 0 0 3px rgba(113, 50, 245, 0.12);
}

.toggle-field {
  min-height: 44px;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
}

.toggle-field input {
  width: 16px;
  height: 16px;
  accent-color: var(--purple);
}

.primary-button,
.secondary-button,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  border-radius: 12px;
  cursor: pointer;
  white-space: nowrap;
  transition: transform 0.14s ease, background 0.14s ease, border-color 0.14s ease, opacity 0.14s ease;
}

.primary-button {
  background: var(--purple);
  color: #fff;
  padding: 13px 16px;
  font-weight: 600;
}

.primary-button:hover {
  background: var(--purple-dark);
}

.secondary-button {
  background: #fff;
  color: var(--purple-dark);
  border: 1px solid var(--purple-dark);
  padding: 11px 14px;
  font-weight: 600;
}

.secondary-button:hover {
  background: rgba(133, 91, 251, 0.08);
}

.icon-button {
  width: 40px;
  height: 40px;
  background: rgba(148, 151, 169, 0.08);
  color: var(--black);
}

.icon-button:hover {
  background: rgba(148, 151, 169, 0.16);
}

.icon-button.compact {
  width: 32px;
  height: 32px;
  min-height: 32px;
  border-radius: 10px;
}

.primary-button:disabled,
.secondary-button:disabled,
.icon-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.compact-action {
  min-height: 38px;
  padding: 8px 10px;
  border-radius: 10px;
  font-size: 14px;
}

.tiny-action {
  min-height: 32px;
  padding: 6px 8px;
  border-radius: 10px;
  font-size: 12px;
}

.icon-button.danger {
  color: var(--red);
  background: var(--red-bg);
}

.icon-button.danger:hover {
  background: rgba(244, 63, 94, 0.2);
}

.danger-action {
  border-color: rgba(180, 35, 24, 0.42);
  color: var(--red);
}

.danger-action:hover {
  background: var(--red-bg);
}

.viewer-section {
  min-height: calc(100vh - 96px);
}

.viewer-section.is-empty {
  display: grid;
  place-items: center;
}

.empty-state {
  color: var(--soft-text);
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 15px;
}

.viewer-shell {
  width: 100%;
  max-width: 100%;
  height: calc(100vh - 96px);
  min-height: 680px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.viewer-toolbar {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 24px;
  border-bottom: 1px solid rgba(104, 107, 130, 0.18);
  background: #fff;
}

.preview-page .viewer-toolbar {
  position: relative;
  top: auto;
  z-index: 12;
}

.preview-page {
  padding-top: 24px;
}

.viewer-toolbar > * {
  min-width: 0;
}

.doc-controls {
  flex: 1 1 auto;
  flex-wrap: wrap;
  row-gap: 8px;
}

.viewer-actions {
  flex: 0 0 auto;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.preview-back-button {
  flex: 0 0 auto;
}

.compact-field {
  min-width: 280px;
  max-width: 520px;
  flex: 1 1 360px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.compact-field > span {
  flex: 0 0 auto;
  line-height: 1;
}

.compact-field select {
  flex: 1 1 auto;
  min-width: 0;
  height: 38px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.status-badge {
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  padding: 6px 8px;
  border-radius: 6px;
  background: rgba(104, 107, 130, 0.12);
  color: #484b5e;
  font-size: 12px;
  font-weight: 700;
}

.status-badge.succeeded {
  background: rgba(20, 158, 97, 0.16);
  color: var(--green-dark);
}

.status-badge.running,
.status-badge.queued,
.status-badge.creating {
  background: var(--amber-bg);
  color: var(--amber);
}

.status-badge.cancelled,
.status-badge.canceled {
  background: rgba(104, 107, 130, 0.12);
  color: #484b5e;
}

.status-badge.failed {
  background: var(--red-bg);
  color: var(--red);
}

.stage-text {
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  color: var(--soft-text);
  font-size: 13px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 260px;
}

.task-option-summary {
  flex: 0 0 auto;
  min-height: 32px;
  font-size: 12px;
  line-height: 1.2;
}

.segmented-control {
  display: inline-flex;
  align-items: center;
  padding: 3px;
  border-radius: 12px;
  background: rgba(104, 107, 130, 0.08);
  gap: 2px;
}

.segmented-control button {
  min-height: 32px;
  padding: 0 10px;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
}

.segmented-control button.is-active {
  color: var(--purple);
  background: #fff;
  box-shadow: var(--micro-shadow);
}

.split-view {
  width: 100%;
  max-width: 100%;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

.pane {
  min-width: 0;
  max-width: 100%;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  background: var(--surface-soft);
}

.original-pane {
  border-right: 1px solid rgba(104, 107, 130, 0.18);
}

.pane-head {
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  background: #fff;
  border-bottom: 1px solid rgba(104, 107, 130, 0.18);
}

.pane-title {
  font-size: 16px;
  font-weight: 700;
  line-height: 1.25;
}

.pane-subtitle {
  margin-top: 3px;
  color: var(--soft-text);
  font-size: 12px;
  line-height: 1.33;
  max-width: 48vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pane-scroll {
  min-width: 0;
  max-width: 100%;
  overflow: auto;
  min-height: 0;
  scroll-behavior: auto;
  overscroll-behavior: contain;
}

.pdf-pages,
.result-content {
  padding: 24px;
}

.pdf-page,
.result-page {
  margin: 0 auto 16px;
  max-width: 980px;
  background: #fff;
  border: 1px solid rgba(104, 107, 130, 0.18);
  border-radius: 8px;
  box-shadow: var(--micro-shadow);
}

.pdf-page {
  padding: 10px;
}

.pdf-page canvas,
.pdf-page img {
  display: block;
  margin: 0 auto;
  max-width: 100%;
  height: auto;
  background: #fff;
}

.pdf-page-media {
  position: relative;
  width: fit-content;
  max-width: 100%;
  margin: 0 auto;
}

.pdf-page-media > canvas,
.pdf-page-media > img {
  position: relative;
  z-index: 0;
}

.pdf-annotation-layer {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}

.pdf-annotation-box {
  position: absolute;
  --annotation-color: #2456d6;
  padding: 0;
  border: 1.5px solid #356df5;
  border-radius: 0;
  background: rgba(53, 109, 245, 0.04);
  color: var(--annotation-color);
  cursor: pointer;
  pointer-events: auto;
  transition: background 0.12s ease, border-color 0.12s ease, box-shadow 0.12s ease;
}

.pdf-annotation-box span {
  position: absolute;
  top: -20px;
  left: -1px;
  display: inline-flex;
  align-items: center;
  min-height: 18px;
  padding: 1px 5px;
  border-radius: 4px 4px 0 0;
  background: var(--annotation-color);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
  opacity: 0;
  transform: translateY(2px);
  transition: opacity 0.12s ease, transform 0.12s ease;
}

.pdf-annotation-box:hover,
.pdf-annotation-box:focus-visible,
.pdf-annotation-box.is-selected {
  background: rgba(53, 109, 245, 0.14);
  border-color: #1f5cff;
  box-shadow: 0 0 0 2px rgba(53, 109, 245, 0.18);
  outline: none;
}

.pdf-annotation-box:hover span,
.pdf-annotation-box:focus-visible span,
.pdf-annotation-box.is-selected span {
  opacity: 1;
  transform: translateY(0);
}

.pdf-annotation-box.is-table,
.pdf-annotation-box.is-image,
.pdf-annotation-box.is-chart {
  --annotation-color: #39a331;
  border-color: #54b948;
  background: rgba(84, 185, 72, 0.06);
}

.pdf-annotation-box.is-table:hover,
.pdf-annotation-box.is-image:hover,
.pdf-annotation-box.is-chart:hover,
.pdf-annotation-box.is-table:focus-visible,
.pdf-annotation-box.is-image:focus-visible,
.pdf-annotation-box.is-chart:focus-visible,
.pdf-annotation-box.is-table.is-selected,
.pdf-annotation-box.is-image.is-selected,
.pdf-annotation-box.is-chart.is-selected {
  border-color: #35a72f;
  background: rgba(84, 185, 72, 0.16);
  box-shadow: 0 0 0 2px rgba(84, 185, 72, 0.18);
}

.pdf-annotation-box.is-equation {
  --annotation-color: #df4e95;
  border-color: #ef69a7;
  background: rgba(239, 105, 167, 0.07);
}

.pdf-annotation-box.is-equation:hover,
.pdf-annotation-box.is-equation:focus-visible,
.pdf-annotation-box.is-equation.is-selected {
  border-color: #df4e95;
  background: rgba(239, 105, 167, 0.17);
  box-shadow: 0 0 0 2px rgba(239, 105, 167, 0.18);
}

.page-label {
  color: var(--soft-text);
  font-size: 12px;
  font-weight: 700;
  margin: 0 0 8px;
}

.result-page {
  padding: 16px;
}

.result-page h3 {
  margin: 0 0 12px;
  font-size: 15px;
  line-height: 1.3;
}

.ocr-block {
  border-top: 1px solid rgba(104, 107, 130, 0.14);
  padding-top: 10px;
  margin-top: 10px;
}

.ocr-type {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 3px 6px;
  border-radius: 6px;
  background: rgba(104, 107, 130, 0.1);
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  margin-bottom: 6px;
}

.markdown-body {
  max-width: 980px;
  margin: 0 auto;
  padding: 22px;
  background: #fff;
  border: 1px solid rgba(104, 107, 130, 0.18);
  border-radius: 8px;
  box-shadow: var(--micro-shadow);
  line-height: 1.55;
}

.markdown-page {
  margin-bottom: 16px;
}

.mineru-md-block {
  margin: 0;
  border: 1px solid transparent;
  border-radius: 4px;
  transition: background 0.12s ease, border-color 0.12s ease, box-shadow 0.12s ease;
}

.mineru-md-block.is-selected,
.markdown-page.is-selected-page,
.markdown-body.is-selected-page {
  border-color: #356df5;
  background: rgba(53, 109, 245, 0.13);
  box-shadow: 0 0 0 2px rgba(53, 109, 245, 0.12);
}

.mineru-md-block.is-selected {
  padding: 6px;
  margin: 4px -7px;
}

.markdown-body img {
  display: block;
  width: auto;
  max-width: 100% !important;
  height: auto !important;
  margin: 14px auto;
  object-fit: contain;
}

.markdown-body .katex-display {
  overflow-x: auto;
  overflow-y: hidden;
  padding: 2px 0;
}

.math-error {
  color: #b42318;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3 {
  font-family: "Kraken-Brand", "IBM Plex Sans", Helvetica, Arial, sans-serif;
  line-height: 1.25;
  letter-spacing: 0;
}

.markdown-body h1 {
  font-size: 28px;
}

.markdown-body h2 {
  font-size: 22px;
}

.markdown-body h3 {
  font-size: 18px;
}

.markdown-body table {
  width: 100%;
  max-width: 100%;
  display: block;
  overflow-x: auto;
  border-collapse: collapse;
  margin: 14px 0;
  font-size: 14px;
}

.markdown-body th,
.markdown-body td {
  border: 1px solid var(--border);
  padding: 8px;
  vertical-align: top;
}

.code-view {
  max-width: 980px;
  margin: 0 auto;
  padding: 16px;
  background: #fff;
  border: 1px solid rgba(104, 107, 130, 0.18);
  border-radius: 8px;
  box-shadow: var(--micro-shadow);
  color: #24262d;
  white-space: pre-wrap;
  word-break: break-word;
  font: 13px/1.55 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}

.loading-block,
.message-block {
  max-width: 760px;
  min-height: 76px;
  margin: 0 auto;
  display: grid;
  place-items: center;
  color: var(--muted);
  background: #fff;
  border: 1px solid rgba(104, 107, 130, 0.18);
  border-radius: 8px;
  padding: 18px;
  text-align: center;
}

.message-block.is-error {
  color: var(--red);
  background: var(--red-bg);
  border-color: rgba(180, 35, 24, 0.18);
}

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

.toast {
  background: #fff;
  border: 1px solid rgba(104, 107, 130, 0.18);
  border-left: 4px solid var(--purple);
  box-shadow: var(--shadow);
  border-radius: 8px;
  padding: 12px;
  font-size: 14px;
  line-height: 1.4;
}

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

.icon {
  width: 18px;
  height: 18px;
  display: inline-block;
  flex: 0 0 auto;
  background-color: currentColor;
  mask: center / contain no-repeat;
  -webkit-mask: center / contain no-repeat;
}

.icon-refresh-cw { mask-image: url("/vendor/lucide/refresh-cw.svg"); -webkit-mask-image: url("/vendor/lucide/refresh-cw.svg"); }
.icon-arrow-left { mask-image: url("/vendor/lucide/arrow-left.svg"); -webkit-mask-image: url("/vendor/lucide/arrow-left.svg"); }
.icon-plus { mask-image: url("/vendor/lucide/plus.svg"); -webkit-mask-image: url("/vendor/lucide/plus.svg"); }
.icon-rotate-cw { mask-image: url("/vendor/lucide/rotate-cw.svg"); -webkit-mask-image: url("/vendor/lucide/rotate-cw.svg"); }
.icon-upload-cloud { mask-image: url("/vendor/lucide/cloud-upload.svg"); -webkit-mask-image: url("/vendor/lucide/cloud-upload.svg"); }
.icon-file-up { mask-image: url("/vendor/lucide/file-up.svg"); -webkit-mask-image: url("/vendor/lucide/file-up.svg"); }
.icon-folder-up { mask-image: url("/vendor/lucide/folder-up.svg"); -webkit-mask-image: url("/vendor/lucide/folder-up.svg"); }
.icon-play { mask-image: url("/vendor/lucide/play.svg"); -webkit-mask-image: url("/vendor/lucide/play.svg"); }
.icon-circle-stop { mask-image: url("/vendor/lucide/circle-stop.svg"); -webkit-mask-image: url("/vendor/lucide/circle-stop.svg"); }
.icon-files { mask-image: url("/vendor/lucide/files.svg"); -webkit-mask-image: url("/vendor/lucide/files.svg"); }
.icon-download { mask-image: url("/vendor/lucide/download.svg"); -webkit-mask-image: url("/vendor/lucide/download.svg"); }
.icon-package { mask-image: url("/vendor/lucide/package.svg"); -webkit-mask-image: url("/vendor/lucide/package.svg"); }
.icon-zoom-out { mask-image: url("/vendor/lucide/zoom-out.svg"); -webkit-mask-image: url("/vendor/lucide/zoom-out.svg"); }
.icon-zoom-in { mask-image: url("/vendor/lucide/zoom-in.svg"); -webkit-mask-image: url("/vendor/lucide/zoom-in.svg"); }
.icon-trash-2 { mask-image: url("/vendor/lucide/trash-2.svg"); -webkit-mask-image: url("/vendor/lucide/trash-2.svg"); }
.icon-chevron-left { mask-image: url("/vendor/lucide/chevron-left.svg"); -webkit-mask-image: url("/vendor/lucide/chevron-left.svg"); }
.icon-chevron-right { mask-image: url("/vendor/lucide/chevron-right.svg"); -webkit-mask-image: url("/vendor/lucide/chevron-right.svg"); }
.icon-log-in { mask-image: url("/vendor/lucide/log-in.svg"); -webkit-mask-image: url("/vendor/lucide/log-in.svg"); }
.icon-log-out { mask-image: url("/vendor/lucide/log-out.svg"); -webkit-mask-image: url("/vendor/lucide/log-out.svg"); }
.icon-user-plus { mask-image: url("/vendor/lucide/user-plus.svg"); -webkit-mask-image: url("/vendor/lucide/user-plus.svg"); }
.icon-key-round { mask-image: url("/vendor/lucide/key-round.svg"); -webkit-mask-image: url("/vendor/lucide/key-round.svg"); }
.icon-send { mask-image: url("/vendor/lucide/send.svg"); -webkit-mask-image: url("/vendor/lucide/send.svg"); }
.icon-shield-check { mask-image: url("/vendor/lucide/shield-check.svg"); -webkit-mask-image: url("/vendor/lucide/shield-check.svg"); }

@media (max-width: 1180px) {
  .upload-page-inner {
    width: min(calc(100% - 32px), 1040px);
  }

  .viewer-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .viewer-actions {
    justify-content: space-between;
  }
}

@media (max-width: 900px) {
  .topbar {
    padding: 0 16px;
  }

  .upload-page-inner {
    width: min(calc(100% - 28px), 760px);
    grid-template-columns: 1fr;
    padding: 20px 0;
  }

  .task-library {
    min-height: auto;
  }

  .task-pagination {
    justify-content: flex-end;
  }

  .task-main {
    grid-template-columns: minmax(0, 1fr);
    gap: 10px;
  }

  .task-state {
    justify-content: flex-start;
  }

  .drop-zone {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .drop-actions {
    grid-column: 1 / -1;
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .split-view {
    grid-template-columns: 1fr;
  }

  .original-pane {
    border-right: 0;
    border-bottom: 1px solid rgba(104, 107, 130, 0.18);
  }

  .viewer-shell {
    height: auto;
    grid-template-rows: auto minmax(760px, auto);
  }

  .pane-scroll {
    max-height: 64vh;
  }
}

@media (max-width: 640px) {
  .brand-subtitle,
  .health-pill {
    display: none;
  }

  .auth-page {
    align-items: start;
    padding: 18px 12px;
  }

  .auth-panel {
    padding: 20px;
  }

  .verification-row {
    grid-template-columns: 1fr;
  }

  .auth-code-button {
    width: 100%;
  }

  .user-pill {
    width: 36px;
    min-height: 36px;
    padding: 0;
    justify-content: center;
  }

  .user-pill span:last-child,
  #logoutButton span:last-child {
    display: none;
  }

  .upload-panel,
  .viewer-toolbar {
    padding-left: 14px;
    padding-right: 14px;
  }

  .drop-zone {
    padding: 14px;
  }

  .settings-row,
  .viewer-actions,
  .doc-controls {
    align-items: stretch;
    flex-direction: column;
  }

  .task-option-summary,
  .progress-message .progress-box {
    width: 100%;
  }

  .field,
  .field.short,
  .compact-field {
    width: 100%;
    min-width: 0;
    flex: 0 0 auto;
  }

  .primary-button,
  .secondary-button {
    width: 100%;
  }

  .topbar .secondary-button,
  .icon-button {
    width: auto;
  }

  .segmented-control {
    width: 100%;
    overflow-x: auto;
  }
}
