:root {
  color-scheme: light;
  font-family: "PingFang SC", "Segoe UI", Inter, system-ui, -apple-system, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  --bg: #f2f7fa;
  --bg-soft: #e9f1f6;
  --panel: #ffffff;
  --text: #1f2a44;
  --muted: #7b879f;
  --border: #dfe9f0;
  --accent: #246390;
  --accent-dark: #1b4e73;
  --accent-soft: #e8f1f7;
  --purple: #7ab0cf;
  --danger: #d14343;
  --shadow: 0 10px 30px rgba(36, 99, 144, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 10% 20%, rgba(122, 176, 207, 0.14), transparent 24%),
    radial-gradient(circle at 90% 10%, rgba(36, 99, 144, 0.1), transparent 28%),
    linear-gradient(180deg, #f6fafc 0%, var(--bg) 100%);
  min-height: 100vh;
}

button,
a,
select,
input {
  font: inherit;
}

svg:not(.file-thumb-icon) {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.app {
  min-height: 100vh;
}

.topbar,
.shell {
  display: flex;
}

.topbar {
  align-items: center;
  justify-content: space-between;
  height: 56px;
  padding: 0 20px;
  background: rgba(255, 255, 255, 0.92);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar-left,
.topbar-right,
.brand,
.sidebar-tabs,
.panel-meta,
.results-top,
.source-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: linear-gradient(135deg, #7ab0cf, #246390);
  color: #fff;
  font-weight: 700;
}

.brand-name {
  font-size: 1.05rem;
  font-weight: 700;
}

.brand {
  border: none;
  background: none;
  padding: 0;
  cursor: pointer;
}

.brand:hover .brand-logo {
  opacity: 0.85;
}

.brand-logo {
  height: 42px;
  width: auto;
  display: block;
}

.top-link {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.92rem;
}


.new-parsing-btn {
  width: 100%;
  padding: 9px 13px;
  border: none;
  border-radius: 10px;
  background: #fff;
  border: 1px dashed #b6d0e1;
  color: var(--text);
  font-size: 0.8rem;
  font-weight: 500;
  box-shadow: var(--shadow);
  cursor: pointer;
}

.new-parsing-btn:hover {
  background: var(--accent-soft);
  color: var(--text);
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.icon-btn:hover {
  background: var(--accent-soft);
  color: var(--text);
}

.icon-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  pointer-events: none;
}

.icon-btn.small {
  width: 32px;
  height: 32px;
}

.shell {
  min-height: calc(100vh - 56px);
}

.sidebar {
  flex: 0 0 var(--sidebar-width, 248px);
  width: var(--sidebar-width, 248px);
  padding: 18px 14px;
  border-right: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.72);
  transition: width 0.2s ease, padding 0.2s ease, transform 0.2s ease;
}

.shell:not(.sidebar-open) .sidebar {
  flex-basis: 0;
  width: 0;
  padding: 0;
  overflow: hidden;
  border-right: none;
}

.sidebar-resizer {
  flex: 0 0 8px;
  position: relative;
  cursor: col-resize;
  z-index: 21;
  touch-action: none;
}

.sidebar-resizer::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 2px;
  transform: translateX(-50%);
  background: var(--border);
  border-radius: 1px;
  transition: background 0.15s ease, width 0.15s ease;
}

.sidebar-resizer:hover::after,
.sidebar-resizer.active::after {
  background: var(--accent);
  width: 3px;
}

.shell:not(.sidebar-open) .sidebar-resizer {
  display: none;
}

.shell.sidebar-resizing {
  cursor: col-resize;
}

.shell.sidebar-resizing .sidebar {
  transition: none;
}

.sidebar-backdrop {
  display: none;
}

.sign-in-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  margin-top: 14px;
  padding: 10px 12px;
  border: none;
  border-radius: 12px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.sidebar-tabs {
  margin-top: 22px;
  gap: 12px;
}

.sidebar-tabs .tab {
  border: none;
  background: transparent;
  color: var(--muted);
  font-weight: 500;
  font-size: 0.85rem;
  cursor: pointer;
  padding: 6px 0;
}

.sidebar-tabs .tab.active {
  color: var(--text);
  border-bottom: 2px solid var(--accent);
}

.icon-btn.active {
  background: var(--accent-soft);
  color: var(--accent);
}

.sidebar-search {
  margin-top: 10px;
}

.sidebar-search input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 0.85rem;
  color: var(--text);
  background: var(--panel);
  outline: none;
}

.sidebar-search input:focus {
  border-color: var(--accent);
}

.sidebar-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.filter-chip {
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--panel);
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.filter-chip:hover {
  border-color: var(--accent);
  color: var(--text);
}

.filter-chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.type-bubble {
  display: inline-block;
  flex-shrink: 0;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-size: 0.68rem;
  font-weight: 600;
  white-space: nowrap;
}

.fav-star {
  color: #f5a623;
}

.context-menu {
  position: fixed;
  z-index: 1000;
  min-width: 180px;
  padding: 4px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
}

.context-menu button {
  display: block;
  width: 100%;
  padding: 8px 12px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font-size: 0.85rem;
  text-align: left;
  cursor: pointer;
}

.context-menu button:hover {
  background: var(--accent-soft);
}

.context-menu button.danger {
  color: var(--danger);
}

.context-menu button.danger:hover {
  background: rgba(209, 67, 67, 0.12);
}

.context-menu.hidden {
  display: none;
}

.recent-list {
  list-style: none;
  margin: 14px 0 0;
  padding: 0;
}

.recent-list li {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 10px 8px;
  border-radius: 12px;
  cursor: pointer;
  position: relative;
}

.recent-list li.active,
.recent-list li:hover {
  background: var(--accent-soft);
}

.recent-list .thumb {
  --file-thumb-body: #7ab0cf;
  --file-thumb-fold: #246390;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  flex-shrink: 0;
}


.recent-list .meta {
  min-width: 0;
  flex: 1;
}

.recent-delete-btn {
  flex-shrink: 0;
  opacity: 0;
  transition: opacity 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.recent-list li:hover .recent-delete-btn,
.recent-list li:focus-within .recent-delete-btn {
  opacity: 1;
}

.recent-delete-btn:hover {
  background: rgba(209, 67, 67, 0.12);
  color: var(--danger);
}

.recent-list .meta strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.78rem;
}

.recent-list .meta-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 1px;
}

.recent-list .meta-time {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-size: 0.72rem;
}

.empty-state {
  color: var(--muted);
  justify-content: center;
  cursor: default;
}

.main {
  flex: 1;
  min-width: 0;
}

.landing-view {
  padding: 18px 28px 40px;
}

.announcement {
  display: inline-flex;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.88rem;
}

.hero {
  margin-top: 28px;
  text-align: center;
}

.hero h1 {
  margin: 0;
  font-size: clamp(1.7rem, 3.2vw, 2.4rem);
  letter-spacing: -0.02em;
  background: linear-gradient(90deg, #246390, #7ab0cf);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.hero h3 {
  margin: 0;
  font-size: clamp(1.2rem, 2.4vw, 1.8rem);
  letter-spacing: -0.02em;
  background: linear-gradient(90deg, #246390, #7ab0cf);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.hero p {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.upload-zone {
  position: relative;
  max-width: 920px;
  margin: 34px auto 0;
  padding: 42px 24px 28px;
  border: 1px dashed #b6d0e1;
  border-radius: 18px;
  background: rgb(255, 255, 255);
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.upload-zone.dragover {
  border-color: var(--accent);
  background: #e8f1f7;
}

.upload-zone input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.upload-zone:hover {
  border-color: var(--accent);
}

.upload-zone strong {
  display: block;
  margin-top: 10px;
  font-size: 1rem;
}

.upload-zone span {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.9rem;
}

.upload-zone .muted {
  font-size: 0.82rem;
}

.upload-icon {
  display: grid;
  place-items: center;
}

.upload-icon svg {
  width: 56px;
  height: 56px;
  fill: #9dc2d9;
  stroke: none;
}

.model-picker {
  display: grid;
  gap: 8px;
  justify-items: center;
  margin-top: 22px;
}

.model-picker label {
  color: var(--muted);
  font-size: 0.9rem;
}

.select-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.model-picker select,
.results-top select {
  appearance: none;
  min-width: 220px;
  padding: 10px 42px 10px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
}

.badge-new {
  position: absolute;
  right: -8px;
  top: -8px;
  padding: 2px 8px;
  border-radius: 999px;
  background: linear-gradient(135deg, #246390, #7ab0cf);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
}

.examples-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
  max-width: 1080px;
  margin: 34px auto 0;
}

.example-card {
  padding: 14px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  cursor: pointer;
}

.example-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 34px rgba(36, 99, 144, 0.13);
}

.example-card .thumb {
  height: 120px;
  border-radius: 12px;
  background: linear-gradient(135deg, #edf3ff, #f8fbff);
}

.example-card .thumb.math { background: linear-gradient(135deg, #efe9ff, #f7f3ff); }
.example-card .thumb.article { background: linear-gradient(135deg, #e8f0ff, #f7faff); }
.example-card .thumb.vertical { background: linear-gradient(135deg, #eaf7ff, #f4fbff); }
.example-card .thumb.notes { background: linear-gradient(135deg, #fff4e8, #fffaf3); }
.example-card .thumb.poster { background: linear-gradient(135deg, #ffeef1, #fff7f8); }
.example-card .thumb.formula { background: linear-gradient(135deg, #edf0ff, #f7f8ff); }
.example-card .thumb.chemistry { background: linear-gradient(135deg, #e9fff3, #f5fff9); }
.example-card .thumb.chinese { background: linear-gradient(135deg, #fff0ea, #fff8f4); }
.example-card .thumb.table { background: linear-gradient(135deg, #e8f4ff, #f4f9ff); }

.example-card h3 {
  margin: 12px 0 6px;
  font-size: 0.98rem;
}

.example-card .tag {
  color: var(--muted);
  font-size: 0.82rem;
}

.workspace-view {
  height: calc(100vh - 56px);
}

.workspace-grid {
  display: flex;
  align-items: stretch;
  height: 100%;
  padding: 10px;
}

.source-panel {
  flex: 0 0 60%;
  min-width: 240px;
  max-width: calc(100% - 240px);
  transition: flex-basis 0.2s ease;
}

.results-panel {
  flex: 1 1 auto;
  min-width: 240px;
}

.panel-resizer {
  flex: 0 0 14px;
  position: relative;
  cursor: col-resize;
  z-index: 1;
  touch-action: none;
}

.panel-resizer::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 2px;
  transform: translateX(-50%);
  background: var(--border);
  border-radius: 1px;
  transition: background 0.15s ease, width 0.15s ease;
}

.panel-resizer::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 4px;
  height: 28px;
  transform: translate(-50%, -50%);
  border-radius: 3px;
  background: var(--border);
  box-shadow:
    0 -9px 0 -1px var(--border),
    0 9px 0 -1px var(--border);
  opacity: 0;
  transition: opacity 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.panel-resizer:hover::after,
.panel-resizer.active::after {
  background: var(--accent);
  width: 2px;
}

.panel-resizer:hover::before,
.panel-resizer.active::before {
  opacity: 1;
  background: var(--accent);
  box-shadow:
    0 -9px 0 -1px var(--accent),
    0 9px 0 -1px var(--accent);
}

.panel-resizer.active ~ .source-panel,
.workspace-grid.resizing .source-panel {
  transition: none;
}

.workspace-grid.resizing {
  cursor: col-resize;
}

.workspace-grid.resizing .source-media,
.workspace-grid.resizing #sourcePdf {
  pointer-events: none;
}

.panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 4px 14px rgba(36, 99, 144, 0.06);
}

.result-tabs {
  display: flex;
  gap: 18px;
}

.panel-tab,
.result-tab {
  border: none;
  background: transparent;
  padding: 0 0 6px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 400;
  cursor: pointer;
}

.panel-tab.active,
.result-tab.active {
  color: var(--accent);
  border-bottom: 2px solid var(--accent);
}

.panel-meta {
  justify-content: space-between;
  padding: 8px 12px;
  color: var(--muted);
  font-size: 0.84rem;
  border-bottom: 1px solid var(--border);
}

.source-viewport {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: auto;
  background: #f7f9fd;
  display: grid;
  place-items: center;
  padding: 12px;
}

.source-media {
  max-width: 100%;
  transform-origin: center center;
  transition: transform 0.15s ease;
}

.source-media.hidden,
.hidden {
  display: none !important;
}

#sourcePdf {
  width: 100%;
  height: 100%;
  min-height: 520px;
  border: none;
}

.source-loading,
.parsed-content .placeholder {
  color: var(--muted);
}

.source-toolbar {
  justify-content: center;
  padding: 8px 12px 10px;
}

.toolbar-divider {
  width: 1px;
  height: 18px;
  background: var(--border);
}

.results-top {
  justify-content: space-between;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
}

.results-actions {
  display: flex;
  gap: 6px;
}

.result-pane {
  display: none;
  flex: 1;
  min-height: 0;
  flex-direction: column;
}

.result-pane.active {
  display: flex;
}

.parsed-content {
  flex: 1;
  overflow: auto;
  padding: 12px 14px;
}

.parsed-content table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 12px;
  font-size: 0.9rem;
}

.parsed-content th,
.parsed-content td {
  border: 1px solid #d2e1eb;
  padding: 6px 8px;
  vertical-align: top;
}

.parsed-page h3 {
  margin: 0 0 8px;
  font-size: 0.92rem;
  color: var(--muted);
}

.page-footer {
  padding: 6px 14px 10px;
  color: #b4bfd4;
  font-size: 0.8rem;
}

.json-content {
  flex: 1;
  margin: 0;
  padding: 12px 14px;
  overflow: auto;
  background: #f8faff;
  color: #33415f;
  font-size: 0.85rem;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(31, 42, 68, 0.35);
  z-index: 40;
}

.modal {
  width: min(420px, calc(100vw - 32px));
  padding: 22px 24px;
  border-radius: 16px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.modal h2 {
  margin: 0 0 4px;
  font-size: 1.05rem;
}

.modal .muted {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 0.88rem;
}

.parse-options {
  display: grid;
  gap: 10px;
}

.parse-options label {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
}

.parse-options label:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.parse-options label:has(input:disabled) {
  opacity: 0.5;
  cursor: not-allowed;
}

.parse-options input {
  accent-color: var(--accent);
}

.parse-everything {
  border-style: dashed;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 18px;
}

.modal-btn {
  padding: 9px 16px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
}

.modal-btn.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.modal-btn.primary:hover:not(:disabled) {
  background: var(--accent-dark);
}

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

.download-menu-wrap {
  position: relative;
}

.download-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 25;
  width: 300px;
  padding: 6px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
}

.download-menu button {
  display: block;
  width: 100%;
  padding: 9px 12px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.download-menu button:hover {
  background: var(--accent-soft);
}

.download-menu strong {
  display: block;
  font-size: 0.88rem;
  font-weight: 600;
}

.download-menu span {
  display: block;
  color: var(--muted);
  font-size: 0.76rem;
}

.parsed-block {
  position: relative;
  margin: 0 0 8px;
  padding: 4px 6px;
  border: 1px solid transparent;
  border-radius: 6px;
}

.parsed-block:hover {
  border-color: #23b26d;
}

.parsed-block:hover::before {
  content: attr(data-label);
  position: absolute;
  top: -1px;
  left: -1px;
  z-index: 2;
  padding: 1px 8px;
  background: #23b26d;
  color: #fff;
  font-size: 0.66rem;
  border-radius: 5px 0 5px 0;
}

.parsed-block.editing {
  border-color: #23b26d;
}

.parsed-block-content[contenteditable="true"] {
  outline: none;
  background: rgba(35, 178, 109, 0.08);
  border-radius: 4px;
}

.parsed-block-actions {
  position: absolute;
  right: 4px;
  bottom: 4px;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 9px;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s ease;
}

.parsed-block:hover .parsed-block-actions,
.parsed-block.editing .parsed-block-actions {
  opacity: 1;
  pointer-events: auto;
}

.block-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 9px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  font-size: 0.76rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}

.block-action-btn svg {
  width: 14px;
  height: 14px;
}

.block-action-btn:hover {
  background: var(--accent-soft);
  color: var(--accent);
}

.block-action-btn.is-saving {
  color: #23b26d;
}

.block-action-btn.is-saving:hover {
  background: rgba(35, 178, 109, 0.12);
}

.block-action-divider {
  width: 1px;
  height: 16px;
  background: var(--border);
}

.block-include {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 9px;
  font-size: 0.76rem;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
}

.block-include input {
  margin: 0;
  accent-color: #23b26d;
  cursor: pointer;
}

.parsed-block.excluded .parsed-block-content {
  opacity: 0.35;
}

.parsed-block.excluded:hover::before {
  content: attr(data-label) " · excluded";
  background: #9aa4ad;
}

.parsed-block.excluded:hover {
  border-color: #9aa4ad;
}

.source-highlight {
  position: absolute;
  z-index: 6;
  border: 2px solid #23b26d;
  background: rgba(35, 178, 109, 0.14);
  border-radius: 2px;
  pointer-events: none;
}

.source-highlight-tag {
  position: absolute;
  top: -2px;
  left: -2px;
  padding: 1px 8px;
  background: #23b26d;
  color: #fff;
  font-size: 0.66rem;
  border-radius: 2px 0 4px 0;
  white-space: nowrap;
}

.parsed-paragraph {
  margin: 0 0 10px;
  font-size: 0.92rem;
}

.signature-crop {
  display: block;
  max-width: 60%;
  margin: 0 0 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.status-toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  padding: 12px 18px;
  border-radius: 12px;
  background: rgba(31, 42, 68, 0.92);
  color: #fff;
  box-shadow: var(--shadow);
  z-index: 30;
}

.status-toast.error {
  background: rgba(209, 67, 67, 0.95);
}

@media (max-width: 1100px) {
  .examples-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .workspace-grid {
    grid-template-columns: 1fr;
    height: auto;
  }

  .workspace-view {
    height: auto;
  }
}

@media (max-width: 820px) {
  .shell:not(.sidebar-open) .sidebar {
    flex-basis: auto;
    width: min(280px, 86vw);
    padding: 18px 14px;
    overflow: auto;
    border-right: 1px solid var(--border);
  }

  .sidebar {
    position: fixed;
    top: 56px;
    left: 0;
    bottom: 0;
    z-index: 30;
    transform: translateX(-100%);
    box-shadow: var(--shadow);
    background: var(--panel);
  }

  .shell.sidebar-open .sidebar {
    transform: translateX(0);
  }

  .sidebar-backdrop {
    position: fixed;
    inset: 56px 0 0 0;
    z-index: 25;
    background: rgba(31, 42, 68, 0.35);
    backdrop-filter: blur(2px);
  }

  .shell.sidebar-open .sidebar-backdrop {
    display: block;
  }

  .sidebar-resizer {
    display: none;
  }

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

  .top-link {
    display: none;
  }
}

/* --- PaddleOCR feature additions: samples, formulas, seals, charts, OCR --- */

.sample-grid {
  position: relative;
  max-width: 920px;
  margin: 22px auto 0;
}

.sample-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.sample-card {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel);
  box-shadow: 0 4px 14px rgba(36, 99, 144, 0.04);
  cursor: pointer;
  text-align: left;
  transition:
    border-color 0.15s ease,
    box-shadow 0.15s ease,
    transform 0.15s ease;
}

.sample-card:hover,
.sample-card:focus-visible {
  border-color: #b6d0e1;
  box-shadow: var(--shadow);
  transform: translateY(-1px);
  outline: none;
}

.sample-card-thumb {
  width: 44px;
  height: 56px;
  border-radius: 6px;
  object-fit: cover;
  border: 1px solid var(--border);
  flex-shrink: 0;
  background: #f5f8fa;
}

.sample-card-body {
  min-width: 0;
  flex: 1;
}

.sample-card-title {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sample-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}

.sample-tag {
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-size: 0.68rem;
  font-weight: 500;
  line-height: 1.4;
}

.sample-preview {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 10;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--panel);
  box-shadow: 0 24px 60px rgba(36, 99, 144, 0.18);
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.sample-preview img {
  display: block;
  max-width: min(280px, 70vw);
  max-height: min(360px, 50vh);
  border-radius: 8px;
  object-fit: contain;
}

@media (max-width: 820px) {
  .sample-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 520px) {
  .sample-list {
    grid-template-columns: 1fr;
  }
}

.formula-content,
.chart-content {
  margin: 0;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-family: "SF Mono", ui-monospace, Menlo, Consolas, monospace;
  font-size: 0.82rem;
  white-space: pre-wrap;
  word-break: break-word;
}

.seal-text {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.85rem;
  font-style: italic;
}

.chart-crop {
  display: block;
  max-width: 90%;
  margin: 0 0 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.chart-title {
  margin: 0 0 8px;
  font-size: 0.9rem;
  font-weight: 600;
  text-align: center;
}

/* --- Skipped (un-extracted) region overlays on the source preview ------ */

.skip-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 0;
  height: 0;
  overflow: visible;
  pointer-events: none;
}

.skip-overlay {
  position: absolute;
  z-index: 5;
  border: 1.5px dashed transparent;
  border-radius: 3px;
  pointer-events: auto;
  transition: border-color 0.12s ease, background 0.12s ease;
}

.skip-overlay:hover {
  border-color: #9aa4ad;
  background: rgba(154, 164, 173, 0.14);
}

.skip-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  z-index: 2;
  display: inline-grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--border);
  color: #9aa4ad;
  box-shadow: var(--shadow);
}

.skip-badge svg {
  width: 13px;
  height: 13px;
}

.skip-overlay:hover .skip-badge {
  color: var(--accent);
  border-color: var(--accent);
}

.skip-tag {
  position: absolute;
  top: -2px;
  left: -2px;
  z-index: 2;
  padding: 1px 8px;
  background: #9aa4ad;
  color: #fff;
  font-size: 0.66rem;
  border-radius: 3px 0 5px 0;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s ease;
}

.skip-actions {
  position: absolute;
  right: 2px;
  bottom: 2px;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 9px;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s ease;
}

.skip-overlay:hover .skip-tag,
.skip-overlay:hover .skip-actions {
  opacity: 1;
}

.skip-overlay:hover .skip-actions {
  pointer-events: auto;
}

.skip-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 9px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  font-size: 0.76rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}

.skip-btn svg {
  width: 14px;
  height: 14px;
}

.skip-btn:hover {
  background: var(--accent-soft);
  color: var(--accent);
}

.skip-btn.primary {
  color: var(--accent);
  font-weight: 600;
}

.skip-btn.primary:hover {
  background: var(--accent);
  color: #fff;
}

