:root {
  --forest: #173f35;
  --forest-2: #285f4d;
  --leaf: #6f8d68;
  --rust: #a8502d;
  --gold: #c19549;
  --ink: #242b27;
  --muted: #68716b;
  --paper: #f3f0e7;
  --panel: #fffdf7;
  --line: #d5d5c9;
  --soft-green: #e4ece3;
  --soft-rust: #f3e3da;
  --shadow: 0 18px 55px rgba(38, 53, 43, .12);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { min-height: 100vh; margin: 0; background: radial-gradient(circle at 85% -10%, #dde7da 0, transparent 38%), linear-gradient(145deg, #faf8f1, var(--paper)); }
body::before { content: ""; position: fixed; inset: 0; pointer-events: none; opacity: .14; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='100' height='100'%3E%3Cfilter id='n'%3E%3CfeTurbulence baseFrequency='.7' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.12'/%3E%3C/svg%3E"); }
button, input, textarea, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
a { color: var(--forest-2); }
.skip-link { position: fixed; z-index: 100; top: -60px; left: 18px; padding: 11px 15px; color: #fff; background: var(--forest); }
.skip-link:focus { top: 12px; }
.site-header { position: sticky; z-index: 30; top: 0; display: flex; min-height: 72px; align-items: center; gap: 25px; padding: 9px clamp(16px, 4vw, 58px); border-bottom: 1px solid rgba(23, 63, 53, .14); background: rgba(247, 245, 237, .93); backdrop-filter: blur(16px); }
.brand { display: flex; align-items: center; gap: 11px; margin-right: auto; color: var(--ink); text-decoration: none; }
.brand-mark { display: grid; width: 44px; height: 44px; place-items: center; border: 1px solid var(--forest-2); border-radius: 50%; color: var(--forest); font: 25px Georgia, serif; }
.brand b, .brand small { display: block; }
.brand small { margin-top: 1px; color: var(--muted); }
nav { display: flex; align-items: center; gap: 4px; }
nav a { padding: 9px 13px; border-radius: 999px; color: var(--ink); font-size: 14px; text-decoration: none; }
nav a:hover, nav a.active { color: var(--forest); background: var(--panel); }
.nav-dot { display: inline-block; width: 7px; height: 7px; margin-right: 7px; border-radius: 50%; background: var(--rust); opacity: .25; }
.menu-button { display: none; padding: 8px 13px; border: 1px solid var(--line); border-radius: 999px; background: var(--panel); }
main { position: relative; z-index: 1; }
.page { display: none; width: min(1180px, calc(100% - 36px)); margin: 0 auto; padding: clamp(40px, 6vw, 76px) 0 90px; animation: arrive .24s ease-out; }
.page.active { display: block; }
.wide-page { width: min(1440px, calc(100% - 28px)); }
.editor-page { width: min(1540px, calc(100% - 20px)); padding-top: 20px; }
@keyframes arrive { from { opacity: 0; transform: translateY(7px); } }
.eyebrow { margin: 0 0 10px; color: var(--rust); font-size: 12px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }
h1, h2, h3 { font-family: Georgia, "Times New Roman", serif; font-weight: 500; }
h1 { max-width: 880px; margin: 0; font-size: clamp(44px, 7vw, 80px); line-height: .98; letter-spacing: -.035em; }
h2 { margin: 0; font-size: clamp(32px, 4.5vw, 50px); line-height: 1.04; }
h3 { font-size: 23px; }
.lead { max-width: 760px; margin: 22px 0 0; color: #4e5952; font: 20px/1.55 Georgia, serif; }
.hero { padding: 28px 0 30px; }
.hero-actions, .action-row, .toolbar, .review-options { display: flex; flex-wrap: wrap; gap: 9px; }
.hero-actions { margin-top: 32px; }
.button, button.button { display: inline-flex; min-height: 43px; align-items: center; justify-content: center; padding: 0 17px; border: 1px solid var(--line); border-radius: 999px; color: var(--ink); background: var(--panel); cursor: pointer; font-weight: 650; text-decoration: none; }
.button:hover { border-color: var(--forest-2); background: #f8fbf6; }
.button.primary { border-color: var(--forest); color: white; background: var(--forest); }
.button.danger { border-color: #d9a999; color: #8a361f; }
.button.small { min-height: 33px; padding: 0 11px; font-size: 12px; }
.button:disabled { cursor: not-allowed; opacity: .45; }
.icon { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon-button { width: 34px; padding: 0!important; }
.home-grid { display: grid; grid-template-columns: 1.2fr .8fr; gap: 18px; margin-top: 52px; }
.home-card { min-height: 245px; display: flex; flex-direction: column; overflow: hidden; padding: 27px; border: 1px solid var(--line); border-radius: 15px; color: var(--ink); background: rgba(255, 253, 247, .85); box-shadow: 0 8px 28px rgba(38, 53, 43, .06); text-decoration: none; }
.home-card.source-card { position: relative; padding: 0; background: #d7d0c3; }
.home-card.source-card img { width: 100%; height: 100%; object-fit: cover; opacity: .84; transition: transform .3s; }
.home-card.source-card:hover img { transform: scale(1.025); }
.source-card-label { position: absolute; inset: auto 18px 18px; padding: 13px 16px; border-radius: 10px; color: white; background: rgba(22, 42, 34, .88); }
.home-card h3 { margin: auto 0 8px; font-size: 30px; }
.home-card p { margin: 0; color: var(--muted); line-height: 1.5; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; margin-top: 18px; overflow: hidden; border: 1px solid var(--line); border-radius: 14px; background: var(--line); }
.stat { padding: 22px; background: var(--panel); }
.stat strong { display: block; color: var(--forest); font: 36px Georgia, serif; }
.stat span { color: var(--muted); font-size: 13px; }
.notice { margin-top: 24px; padding: 15px 18px; border-left: 3px solid var(--gold); border-radius: 0 9px 9px 0; color: #66583a; background: #f8efd9; }
.page-head { display: flex; align-items: end; justify-content: space-between; gap: 30px; margin-bottom: 28px; }
.page-head p { max-width: 620px; margin: 12px 0 0; color: var(--muted); line-height: 1.5; }
.toolbar { align-items: center; margin-bottom: 16px; padding: 11px; border: 1px solid var(--line); border-radius: 12px; background: rgba(255, 253, 247, .86); }
.toolbar input, .toolbar select, .form-control { min-height: 41px; padding: 0 12px; border: 1px solid #bfc5bb; border-radius: 8px; color: var(--ink); background: white; }
.toolbar input { flex: 1 1 260px; }
.toolbar .count { margin-left: auto; color: var(--muted); font-size: 13px; }
.tree-shell { min-height: 520px; overflow: auto; padding: 22px; border: 1px solid var(--line); border-radius: 14px; background: rgba(255, 253, 247, .75); box-shadow: inset 0 2px 12px rgba(38, 53, 43, .035); }
.tree-list, .tree-list ul { margin: 0; padding: 0; list-style: none; }
.tree-list ul { position: relative; margin-left: 18px; padding-left: 25px; }
.tree-list ul::before { content: ""; position: absolute; top: 0; bottom: 18px; left: 7px; border-left: 1px solid #bdc9bb; }
.tree-item { position: relative; margin: 4px 0; }
.tree-item > .node-row::before { content: ""; position: absolute; top: 22px; left: -18px; width: 18px; border-top: 1px solid #bdc9bb; }
.tree-list > .tree-item > .node-row::before { display: none; }
.node-row { position: relative; display: flex; max-width: 680px; min-height: 43px; align-items: center; gap: 7px; padding: 4px 7px; border: 1px solid transparent; border-radius: 8px; }
.node-row:hover { border-color: #d5ddd1; background: white; }
.node-row.drop-target { outline: 2px solid var(--forest-2); background: #e4f2e5; }
.node-row.dragging { opacity: .35; }
.node-toggle { flex: 0 0 28px; width: 28px; height: 30px; padding: 0; border: 0; color: var(--muted); background: transparent; cursor: pointer; }
.node-toggle.empty { cursor: default; opacity: .4; }
.node-main { min-width: 0; flex: 1; display: flex; align-items: baseline; gap: 9px; padding: 6px 8px; border: 0; border-radius: 6px; text-align: left; background: transparent; cursor: pointer; }
.node-main:hover { background: var(--soft-green); }
.node-main strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.node-id { color: var(--muted); font: 10px ui-monospace, monospace; }
.confidence { flex: 0 0 auto; padding: 3px 7px; border-radius: 999px; color: #3d6547; background: #e4efe4; font-size: 10px; text-transform: uppercase; }
.confidence.medium { color: #846222; background: #f3ead2; }
.confidence.low { color: #98442c; background: #f4dfd8; }
.review-dot { flex: 0 0 9px; width: 9px; height: 9px; border: 2px solid var(--panel); border-radius: 50%; background: #c7cbc5; box-shadow: 0 0 0 1px #bbc1b8; }
.review-dot.verified { background: #4e8c5c; }
.review-dot.correction { background: var(--rust); }
.review-dot.unsure { background: var(--gold); }
.mobile-move-button, .mobile-move-notice { display: none; }
.empty-state { padding: 45px 20px; text-align: center; color: var(--muted); }
.image-workspace { height: min(76vh, 880px); min-height: 520px; position: relative; overflow: hidden; border: 1px solid #bbb5a9; border-radius: 14px; background-color: #272b29; background-image: linear-gradient(45deg, #303432 25%, transparent 25%), linear-gradient(-45deg, #303432 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #303432 75%), linear-gradient(-45deg, transparent 75%, #303432 75%); background-position: 0 0, 0 8px, 8px -8px, -8px 0; background-size: 16px 16px; cursor: grab; touch-action: none; }
.image-workspace.dragging { cursor: grabbing; }
.image-workspace img { position: absolute; top: 50%; left: 50%; max-width: none; width: min(90%, 1200px); transform-origin: center; user-select: none; pointer-events: none; box-shadow: 0 18px 65px #0008; }
.image-controls { position: absolute; z-index: 3; top: 14px; left: 14px; display: flex; gap: 6px; padding: 6px; border-radius: 10px; background: rgba(255, 253, 247, .92); box-shadow: var(--shadow); }
.image-controls button { width: 38px; height: 36px; padding: 0; border: 1px solid var(--line); border-radius: 7px; background: white; cursor: pointer; }
.image-help { position: absolute; z-index: 3; right: 14px; bottom: 14px; padding: 8px 11px; border-radius: 8px; color: white; background: rgba(18, 25, 21, .72); font-size: 12px; }
.editor-layout { height: calc(100vh - 112px); min-height: 650px; display: grid; grid-template-columns: minmax(300px, .8fr) minmax(380px, 1fr) minmax(360px, .9fr); overflow: hidden; border: 1px solid var(--line); border-radius: 14px; background: var(--panel); box-shadow: var(--shadow); }
.editor-panel { min-width: 0; min-height: 0; display: flex; flex-direction: column; border-right: 1px solid var(--line); }
.editor-panel:last-child { border-right: 0; }
.panel-head { padding: 14px; border-bottom: 1px solid var(--line); background: #f8f8f2; }
.panel-head h2 { font-size: 20px; }
.panel-head p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.panel-tools { display: flex; gap: 7px; margin-top: 10px; }
.panel-tools input { min-width: 0; flex: 1; }
.editor-tree { min-height: 0; flex: 1; overflow: auto; padding: 10px 8px 24px; }
.editor-tree .tree-list ul { margin-left: 8px; padding-left: 15px; }
.editor-tree .tree-list ul::before { left: 4px; }
.editor-tree .node-row { gap: 3px; }
.editor-tree .node-row::before { left: -11px; width: 11px; }
.editor-tree .node-main { gap: 5px; }
.editor-tree .node-main.selected { color: var(--forest); background: #dcebdc; box-shadow: inset 3px 0 var(--forest-2); }
.editor-tree .confidence { display: none; }
.root-drop { margin: 8px; padding: 7px; border: 1px dashed #9cab9a; border-radius: 7px; color: var(--muted); text-align: center; font-size: 11px; }
.root-drop.drop-target { border-color: var(--forest); color: var(--forest); background: #e0eee1; }
.form-scroll { min-height: 0; overflow: auto; padding: 22px clamp(18px, 3vw, 32px) 45px; }
.crumbs { margin: 0 0 17px; color: var(--muted); font-size: 11px; }
.crumbs button { padding: 0; border: 0; color: var(--forest-2); background: transparent; cursor: pointer; }
.person-form { display: grid; gap: 13px; }
.field label { display: block; margin-bottom: 5px; color: var(--muted); font-size: 12px; font-weight: 700; }
.field input, .field textarea, .field select { width: 100%; min-height: 42px; padding: 9px 11px; border: 1px solid #bfc5bb; border-radius: 8px; color: var(--ink); background: white; }
.field textarea { min-height: 86px; resize: vertical; }
.field input[readonly] { color: var(--muted); background: #f0f1ed; }
.field-hint { margin-top: 4px; color: var(--muted); font-size: 10px; }
.review-box { margin-top: 20px; padding: 16px; border: 1px solid #c9d2c6; border-radius: 10px; background: #f3f7f1; }
.review-box h3 { margin: 0 0 4px; font-size: 18px; }
.review-box > p { margin: 0 0 11px; color: var(--muted); font-size: 12px; }
.review-option { min-height: 34px; padding: 0 10px; border: 1px solid var(--line); border-radius: 999px; background: white; cursor: pointer; font-size: 12px; }
.review-option.selected { border-color: var(--forest); color: white; background: var(--forest); }
.review-comment { width: 100%; min-height: 76px; margin-top: 9px; padding: 9px; border: 1px solid #bfc5bb; border-radius: 8px; resize: vertical; }
.editor-source { position: relative; min-height: 0; flex: 1; overflow: hidden; background: #292d2b; cursor: grab; touch-action: none; }
.editor-source.dragging { cursor: grabbing; }
.editor-source img { width: 100%; height: 100%; object-fit: contain; transform-origin: center; user-select: none; pointer-events: none; will-change: transform; }
.editor-image-controls { top: 12px; left: 12px; }
.editor-image-help { position: absolute; right: 12px; bottom: 12px; padding: 7px 9px; border-radius: 7px; color: white; background: rgba(18, 25, 21, .72); font-size: 10px; pointer-events: none; }
.source-caption { padding: 10px 13px; color: var(--muted); border-top: 1px solid var(--line); font-size: 11px; }
.status-bar { position: fixed; z-index: 40; right: 18px; bottom: 16px; max-width: min(500px, calc(100% - 36px)); padding: 10px 15px; border-radius: 999px; color: white; background: var(--forest); box-shadow: var(--shadow); font-size: 12px; }
.status-bar.error { background: #8f3d27; }
.review-summary { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 24px; }
.review-summary > div { padding: 19px; border: 1px solid var(--line); border-radius: 11px; background: var(--panel); }
.review-summary strong { display: block; color: var(--forest); font: 30px Georgia, serif; }
.review-summary span { color: var(--muted); font-size: 12px; }
.review-list { display: grid; gap: 9px; margin-top: 24px; }
.review-item { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 15px; align-items: center; padding: 16px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); }
.review-item h3 { margin: 0 0 4px; font-size: 20px; }
.review-item p { margin: 0; color: var(--muted); }
.review-badge { padding: 5px 9px; border-radius: 999px; background: var(--soft-green); font-size: 11px; }
.review-badge.correction { color: #8a361f; background: var(--soft-rust); }
.review-badge.unsure { color: #785b20; background: #f5ecd6; }
dialog { width: min(680px, calc(100% - 24px)); max-height: 88vh; overflow: auto; padding: 0; border: 0; border-radius: 15px; color: var(--ink); background: var(--panel); box-shadow: 0 25px 90px #0006; }
dialog::backdrop { background: rgba(20, 29, 24, .65); backdrop-filter: blur(3px); }
.dialog-close { position: sticky; z-index: 2; top: 10px; float: right; width: 39px; height: 39px; margin: 10px; border: 0; border-radius: 50%; background: #e8ece5; cursor: pointer; font-size: 25px; }
#dialogContent { padding: 36px clamp(20px, 5vw, 48px) 45px; }
#dialogContent h2 { font-size: 37px; }
.detail-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin: 24px 0; }
.detail-grid div { padding: 12px; border-radius: 8px; background: #f0f2ec; }
.detail-grid small { display: block; margin-bottom: 3px; color: var(--muted); }
.toast { position: fixed; z-index: 99; left: 50%; bottom: 24px; transform: translate(-50%, 18px); padding: 10px 16px; border-radius: 999px; color: white; background: var(--ink); opacity: 0; pointer-events: none; transition: .2s; }
.toast.show { transform: translate(-50%, 0); opacity: 1; }
@media (max-width: 1100px) {
  .editor-layout { grid-template-columns: minmax(280px, .75fr) minmax(380px, 1fr); }
  .source-panel { display: none; }
}
@media (max-width: 820px) {
  .menu-button { display: block; }
  nav { position: absolute; top: 64px; right: 14px; display: none; min-width: 190px; flex-direction: column; align-items: stretch; padding: 9px; border: 1px solid var(--line); border-radius: 11px; background: var(--panel); box-shadow: var(--shadow); }
  nav.open { display: flex; }
  .home-grid { grid-template-columns: 1fr; }
  .home-card.source-card { min-height: 310px; }
  .stats, .review-summary { grid-template-columns: repeat(2, 1fr); }
  .page-head { display: block; }
  .editor-layout { height: auto; min-height: 0; grid-template-columns: 1fr; overflow: visible; }
  .editor-panel { min-height: 500px; border-right: 0; border-bottom: 1px solid var(--line); }
  .form-panel { min-height: 620px; }
  .editor-tree, .form-scroll { max-height: 70vh; }
  .mobile-move-button { display: inline-flex; width: 32px; height: 32px; flex: 0 0 32px; align-items: center; justify-content: center; padding: 0; border: 1px solid var(--line); border-radius: 50%; color: var(--forest); background: white; cursor: pointer; }
  .mobile-move-button.active { border-color: var(--rust); color: white; background: var(--rust); }
  .mobile-move-notice { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; padding: 10px 12px; border-bottom: 1px solid #d7c796; color: #5e4d27; background: #fbf0d1; font-size: 12px; }
  .mobile-move-notice span { flex: 1 1 100%; }
  .mobile-move-notice + .root-drop { display: none; }
  .editor-tree:has(.mobile-move-button.active) .node-main { outline: 1px dashed #91a98f; background: #f5faf3; }
}
@media (max-width: 560px) {
  .site-header { min-height: 64px; padding: 7px 12px; }
  .brand-mark { width: 38px; height: 38px; }
  .page { width: min(100% - 22px, 1180px); padding-top: 42px; }
  .editor-page { width: min(100% - 10px, 1180px); padding-top: 10px; }
  h1 { font-size: 45px; }
  .lead { font-size: 18px; }
  .stats, .review-summary { grid-template-columns: 1fr 1fr; }
  .stat { padding: 16px; }
  .stat strong { font-size: 30px; }
  .tree-shell { padding: 12px 6px; }
  .tree-list ul { margin-left: 6px; padding-left: 14px; }
  .node-row::before { left: -9px!important; width: 9px!important; }
  .confidence { display: none; }
  .image-workspace { min-height: 430px; }
  .image-help { display: none; }
  .review-item { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
}
@media print {
  .site-header, .toolbar, .hero-actions, .action-row, .dialog-close { display: none!important; }
  body { background: white; }
  .page { width: 100%; padding: 0; }
}
