:root { color-scheme: light; font-family: Arial, Helvetica, sans-serif; color: #172033; background: #f4f6f8; }
* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; }
button, select { font: inherit; }
button { border: 1px solid #94a3b8; border-radius: 6px; background: #fff; color: #172033; padding: 8px 12px; font-weight: 650; cursor: pointer; }
button:hover:not(:disabled) { background: #eff6ff; border-color: #2563eb; }
button:disabled { cursor: not-allowed; opacity: .45; }
button:focus-visible, select:focus-visible { outline: 3px solid #60a5fa; outline-offset: 2px; }
.topbar { background: #fff; border-bottom: 1px solid #cbd5e1; box-shadow: 0 1px 3px #0001; }
.topbar-inner { max-width: 1600px; margin: auto; padding: 12px 16px; display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
h1 { margin: 0 auto 0 0; font-size: 24px; color: #0f172a; }
.local-badge { border: 1px solid #047857; color: #065f46; border-radius: 999px; padding: 5px 11px; font-size: 14px; font-weight: 700; }
.objective-label { display: flex; align-items: center; gap: 7px; font-size: 14px; font-weight: 700; }
select { border: 1px solid #94a3b8; border-radius: 6px; background: #fff; padding: 8px; }
.total-count { min-width: 120px; text-align: right; color: #1e3a8a; font-size: 27px; font-weight: 800; }
.page-shell { max-width: 1600px; margin: auto; padding: 12px 16px 24px; }
.privacy-message { margin: 0 0 12px; padding: 9px 12px; border: 1px solid #f59e0b; border-radius: 6px; background: #fffbeb; color: #78350f; font-size: 14px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 12px; }
.data-message { margin: -4px 0 12px; padding: 8px 11px; border-left: 4px solid #2563eb; background: #eff6ff; color: #1e3a8a; font-size: 13px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; }
.native-file-input { max-width: 255px; padding: 6px; border: 1px solid #94a3b8; border-radius: 6px; background: #fff; color: #334155; }
.native-file-input::file-selector-button { margin-right: 8px; padding: 5px 9px; border: 1px solid #64748b; border-radius: 5px; background: #f8fafc; color: #0f172a; font-weight: 700; cursor: pointer; }
.error-message { margin: 0 0 12px; padding: 9px 12px; border-radius: 6px; background: #fef2f2; color: #991b1b; font-weight: 650; }
.main-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; }
.image-section { min-width: 0; }
.field-tabs { display: flex; gap: 6px; min-height: 38px; overflow-x: auto; padding: 2px 1px 7px; scrollbar-width: thin; }
.field-tab { flex: 0 0 auto; padding: 6px 10px; font-size: 13px; }
.field-tab.active { border-color: #1d4ed8; background: #dbeafe; color: #1e3a8a; box-shadow: 0 0 0 2px #bfdbfe; }
.workspace-status { min-height: 30px; display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; }
#image-status { color: #64748b; font-size: 14px; max-width: 55%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.workspace-scroll { overflow: auto; padding: 8px; min-height: 58vh; border: 1px solid #64748b; border-radius: 8px; background: #0f172a; scrollbar-color: #94a3b8 #1e293b; }
.empty-state { min-height: 55vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 24px; color: #fff; text-align: center; }
.empty-state strong { font-size: 21px; }
.empty-state span { color: #cbd5e1; }
.empty-state button { margin-top: 8px; background: #2563eb; border-color: #2563eb; color: #fff; padding: 11px 18px; }
.zoom-layer { margin: 0 auto; transform-origin: top left; }
.image-workspace { position: relative; width: 100%; overflow: hidden; cursor: crosshair; user-select: none; }
#marrow-image { display: block; width: 100%; height: auto; pointer-events: none; }
#marker-overlay { position: absolute; inset: 0; width: 100%; height: 100%; }
.marker-hit { cursor: pointer; }
.category-panel { align-self: start; padding: 12px; border: 1px solid #cbd5e1; border-radius: 8px; background: #fff; box-shadow: 0 1px 3px #0001; }
.category-panel h2 { margin: 0 0 10px; font-size: 19px; }
.group-title { margin: 10px 0 4px; color: #64748b; font-size: 11px; font-weight: 800; letter-spacing: .07em; text-transform: uppercase; }
.category-row { display: grid; grid-template-columns: 15px minmax(0,1fr) 27px 34px 48px; width: 100%; align-items: center; gap: 5px; margin: 2px 0; padding: 6px 7px; border-color: transparent; text-align: left; font-size: 14px; }
.category-row.active { border-color: #1d4ed8; background: #eff6ff; box-shadow: 0 0 0 2px #bfdbfe; }
.swatch { width: 12px; height: 12px; border: 1px solid #1e293b; border-radius: 50%; }
.category-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
kbd { border: 1px solid #94a3b8; border-radius: 4px; background: #fff; padding: 1px 4px; font-family: inherit; font-size: 12px; text-align: center; }
.category-count, .category-percent { text-align: right; font-variant-numeric: tabular-nums; }
.category-percent { color: #64748b; font-size: 12px; }
.category-popup { position: absolute; z-index: 20; width: 320px; max-height: min(72vh, 560px); overflow: auto; padding: 9px; border: 1px solid #64748b; border-radius: 8px; background: #fff; box-shadow: 0 12px 30px #0005; cursor: default; }
.popup-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 7px; }
.popup-heading button { padding: 4px 7px; font-size: 13px; }
.popup-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
.popup-category { display: grid; grid-template-columns: 11px minmax(0,1fr) auto auto; gap: 5px; align-items: center; min-width: 0; padding: 6px; font-size: 12px; text-align: left; }
.delete-popup { width: 100%; margin-top: 8px; border-color: #f87171; color: #b91c1c; }
.dialog-backdrop { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; padding: 16px; background: #020617aa; }
.dialog-backdrop[hidden] { display: none; }
.help-dialog { width: min(580px, 100%); max-height: 85vh; overflow: auto; padding: 20px; border-radius: 10px; background: #fff; box-shadow: 0 18px 50px #0007; }
.dialog-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.dialog-heading h2 { margin: 0; }
.help-dialog li { margin: 9px 0; }
.help-categories { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; font-size: 14px; }

@media (max-width: 900px) {
  .main-grid { grid-template-columns: 1fr; }
  .category-panel { order: 2; }
}
@media (max-width: 700px) {
  h1 { width: 100%; font-size: 21px; }
  .total-count { margin-left: auto; }
  .workspace-scroll { min-height: 48vh; }
  .field-tabs { margin-right: -16px; padding-right: 16px; }
  .category-popup { position: fixed; inset: auto 0 0 0 !important; width: 100%; max-height: 55vh; transform: none !important; border-radius: 16px 16px 0 0; z-index: 60; }
  .help-categories { grid-template-columns: 1fr 1fr; }
}
