:root {
  color-scheme: light;
  --bg: #f6f7f2; --surface: #ffffff; --surface-2: #eff1ea; --line: #e0e3d8; --line-2: #c9cdbf;
  --text: #171a14; --text-2: #4c5246; --muted: #6a7064;
  --accent: #2f7d32; --accent-ink: #ffffff; --accent-soft: #e6f2e2;
  --ok: #2f7d32; --warn: #a86400; --bad: #b42318; --info: #2a63b8;
  --ok-soft: #e6f2e2; --warn-soft: #fbf0dc; --bad-soft: #fbe6e3; --info-soft: #e5eefa;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 4px 16px rgba(0,0,0,.04);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #121510; --surface: #1a1e17; --surface-2: #22271e; --line: #2d3328; --line-2: #3d4537;
    --text: #f1f4ec; --text-2: #c2c9b8; --muted: #959d8a;
    --accent: #6cbf5f; --accent-ink: #0f1a0c; --accent-soft: #233420;
    --ok: #7dcc6e; --warn: #f0b34a; --bad: #ff8a80; --info: #7fb0ff;
    --ok-soft: #1f3020; --warn-soft: #3a2d14; --bad-soft: #3d1f1c; --info-soft: #1c2a40;
    --shadow: 0 1px 2px rgba(0,0,0,.4);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121510; --surface: #1a1e17; --surface-2: #22271e; --line: #2d3328; --line-2: #3d4537;
  --text: #f1f4ec; --text-2: #c2c9b8; --muted: #959d8a;
  --accent: #6cbf5f; --accent-ink: #0f1a0c; --accent-soft: #233420;
  --ok: #7dcc6e; --warn: #f0b34a; --bad: #ff8a80; --info: #7fb0ff;
  --ok-soft: #1f3020; --warn-soft: #3a2d14; --bad-soft: #3d1f1c; --info-soft: #1c2a40;
  --shadow: 0 1px 2px rgba(0,0,0,.4);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
[hidden] { display: none !important; }
a { color: var(--accent); }
h1, h2, h3, h4 { margin: 0; letter-spacing: -0.01em; }
h1 { font-size: clamp(24px, 3.6vw, 34px); line-height: 1.15; }
h2 { font-size: 16px; font-weight: 650; }
h3 { font-size: 15px; }
.muted { color: var(--muted); font-weight: 400; }

.top { display: flex; align-items: center; gap: 14px; padding: 10px 16px; border-bottom: 1px solid var(--line); background: var(--surface); position: sticky; top: 0; z-index: 5; }
.back { color: var(--text-2); text-decoration: none; font-size: 14px; white-space: nowrap; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 650; flex: 1; min-width: 0; }
.logo { width: 24px; height: 24px; color: var(--accent); flex: none; }
.icon-btn { width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--text-2); cursor: pointer; display: grid; place-items: center; }
.icon-btn svg { width: 18px; height: 18px; }

.wrap { max-width: 1180px; margin: 0 auto; padding: 20px 16px 40px; }
.intro { margin: 4px 0 18px; max-width: 760px; }
.intro p { color: var(--text-2); margin: 8px 0 0; font-size: 16px; }

.layout { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: 18px; align-items: start; }
@media (max-width: 880px) { .layout { grid-template-columns: minmax(0, 1fr); } }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; min-width: 0; }
.card + .card, .layout + .card { margin-top: 18px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }

.btn { font: inherit; font-size: 14px; font-weight: 600; padding: 9px 14px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--surface); color: var(--text); cursor: pointer; min-height: 40px; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.05); }
.btn:disabled { opacity: .5; cursor: not-allowed; filter: none; }
.btn.small { padding: 6px 11px; min-height: 34px; font-size: 13px; }
.btn.wide { width: 100%; margin-top: 14px; font-size: 16px; min-height: 46px; }
.link-btn { background: none; border: 0; color: var(--accent); font: inherit; font-size: 14px; cursor: pointer; padding: 4px; }
.hint { color: var(--muted); font-size: 13px; margin: 8px 0 0; }

.drop { border: 2px dashed var(--line-2); border-radius: 12px; padding: 26px 16px; text-align: center; background: var(--surface-2); }
.drop.over { border-color: var(--accent); background: var(--accent-soft); }
.drop svg { width: 46px; height: 46px; color: var(--accent); }
.drop-title { margin: 6px 0 12px; font-weight: 600; }
.drop-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

.framer .frame-box { background: #10120e; border-radius: 12px; overflow: hidden; display: flex; justify-content: center; }
#view { display: block; max-width: 100%; height: auto; max-height: 460px; cursor: grab; touch-action: none; }
#view:active { cursor: grabbing; }
#view:focus-visible { outline: 3px solid var(--accent); outline-offset: -3px; }
.frame-tools { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 10px; font-size: 14px; }
.zoom { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 160px; }
.zoom input { flex: 1; accent-color: var(--accent); }
.switch { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.switch input { accent-color: var(--accent); width: 18px; height: 18px; }
.map-legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; color: var(--text-2); margin-top: 6px; }
.sw { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.sw.y { background: rgb(255,196,0); } .sw.b { background: rgb(214,64,32); } .sw.p { background: rgb(140,90,255); }

.field { display: block; margin-top: 14px; font-weight: 600; font-size: 14px; }
.field select { display: block; width: 100%; margin-top: 6px; font: inherit; font-weight: 400; padding: 9px 10px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--surface); color: var(--text); min-height: 42px; }
.model-line { font-size: 13px; color: var(--text-2); margin-top: 8px; min-height: 1.4em; }
.progress { height: 6px; background: var(--surface-2); border-radius: 4px; overflow: hidden; margin-top: 6px; }
.progress .bar { height: 100%; width: 0; background: var(--accent); transition: width .2s; }

.examples { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 14px; }
.examples h3 { font-size: 14px; margin-bottom: 10px; }
.ex-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; }
.ex { display: flex; flex-direction: column; align-items: center; gap: 5px; padding: 6px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--text-2); font: inherit; font-size: 12px; line-height: 1.25; cursor: pointer; text-align: center; }
.ex:hover { border-color: var(--accent); color: var(--text); }
.ex img { width: 72px; height: 72px; object-fit: cover; border-radius: 7px; }

.empty-title { font-weight: 650; margin: 0 0 8px; }
.tips { margin: 0; padding-left: 18px; color: var(--text-2); }
.tips li + li { margin-top: 6px; }

.verdict { border-radius: 12px; padding: 12px 14px; background: var(--surface-2); border: 1px solid var(--line); }
.verdict.v-confident { background: var(--ok-soft); border-color: transparent; }
.verdict.v-likely { background: var(--info-soft); border-color: transparent; }
.verdict.v-uncertain, .verdict.v-unfamiliar { background: var(--warn-soft); border-color: transparent; }
.verdict.v-not-leaf { background: var(--bad-soft); border-color: transparent; }
.v-head { display: flex; align-items: center; gap: 8px; font-size: 18px; line-height: 1.3; }
.v-dot { width: 10px; height: 10px; border-radius: 50%; flex: none; background: var(--muted); }
.v-confident .v-dot { background: var(--ok); } .v-likely .v-dot { background: var(--info); }
.v-uncertain .v-dot, .v-unfamiliar .v-dot { background: var(--warn); } .v-not-leaf .v-dot { background: var(--bad); }
.v-line { margin: 6px 0 0; color: var(--text-2); font-size: 14px; }

.top3 { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 8px; }
.pick { width: 100%; display: grid; grid-template-columns: 26px 1fr auto; grid-template-areas: "r n v" "r b b"; gap: 4px 10px; align-items: center; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.pick:hover { border-color: var(--line-2); }
.pick.on { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.pick.dim { opacity: .7; }
.rank { grid-area: r; width: 24px; height: 24px; border-radius: 50%; background: var(--surface-2); display: grid; place-items: center; font-size: 13px; font-weight: 700; color: var(--text-2); }
.pick.on .rank { background: var(--accent); color: var(--accent-ink); }
.pname { grid-area: n; font-weight: 600; min-width: 0; }
.pname .crop { color: var(--muted); font-weight: 500; }
.pval { grid-area: v; font-variant-numeric: tabular-nums; font-weight: 700; }
.pbar { grid-area: b; height: 6px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.pbar i { display: block; height: 100%; background: var(--accent); border-radius: 4px; }

.condition { margin-top: 16px; }
.condition header h3 { font-size: 20px; margin-top: 2px; }
.c-crop { margin: 0; color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: .04em; }
.c-path { margin: 2px 0 0; color: var(--text-2); font-size: 14px; }
.c-sum { margin: 10px 0 0; }
.c-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 18px; margin-top: 12px; }
@media (max-width: 560px) { .c-grid { grid-template-columns: minmax(0, 1fr); } }
.c-grid h4 { font-size: 13px; color: var(--text-2); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 4px; }
.c-grid ul { margin: 0; padding-left: 18px; }
.c-grid li + li { margin-top: 4px; }
.c-grid p { margin: 0; }
.none { color: var(--muted); margin: 0; }
.map-stats { margin-top: 14px; font-size: 14px; color: var(--text-2); }
.map-stats p { margin: 0; }
.confirm { margin-top: 14px; padding: 12px 14px; border-left: 4px solid var(--warn); background: var(--warn-soft); border-radius: 0 10px 10px 0; font-size: 14px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.tech { font-size: 12px; color: var(--muted); margin: 10px 0 0; }

.hist { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; }
.hist-item { width: 100%; display: flex; gap: 10px; align-items: center; padding: 8px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--text); font: inherit; font-size: 13px; text-align: left; cursor: pointer; }
.hist-item img { border-radius: 6px; object-fit: cover; flex: none; }
.hist-item span { display: flex; flex-direction: column; min-width: 0; }
.hist-item small { color: var(--muted); }

#libSearch { font: inherit; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--surface); color: var(--text); min-width: 0; width: 260px; max-width: 100%; }
.lib { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px 18px; }
.lib-crop h3 { font-size: 14px; margin-bottom: 4px; }
.lib-item { border-top: 1px solid var(--line); }
.lib-item summary { padding: 7px 2px; cursor: pointer; font-size: 14px; }
.lib-item .condition { margin: 0 0 12px; font-size: 14px; }
.lib-item .c-grid { grid-template-columns: minmax(0, 1fr); }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin: 12px 0; }
.stat { background: var(--surface-2); border-radius: 10px; padding: 10px 12px; display: flex; flex-direction: column; }
.stat b { font-size: 24px; font-variant-numeric: tabular-nums; }
.stat span { font-weight: 600; font-size: 13px; }
.stat small { color: var(--muted); font-size: 12px; }
.about p { color: var(--text-2); }
.about summary { cursor: pointer; font-weight: 600; }

.foot { max-width: 1180px; margin: 0 auto; padding: 0 16px 40px; color: var(--muted); font-size: 13px; }

@media print {
  .top, .photo-card, .history, .library, .about, .foot, .actions, .tech { display: none !important; }
  body { background: #fff; color: #000; }
  .layout { display: block; }
  .card { box-shadow: none; border: 0; }
}

/* account + Expert check (paid lane) */
.acct { display: flex; align-items: center; gap: 8px; }
.credits { font-size: 13px; color: var(--text-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
a.btn { text-decoration: none; display: inline-flex; align-items: center; }
@media (max-width: 520px) { .back { display: none; } .acct .btn.small { padding: 5px 9px; } }
.expert { margin-top: 16px; border: 1px solid var(--line); border-radius: 12px; padding: 14px; background: var(--surface-2); }
.expert h3 { font-size: 16px; }
.expert .hint { margin-top: 6px; }
.expert textarea { display: block; width: 100%; margin-top: 6px; font: inherit; font-weight: 400; font-size: 14px; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--surface); color: var(--text); resize: vertical; }
.x-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 12px; }
.x-meter { font-size: 13px; color: var(--text-2); margin: 8px 0 0; min-height: 1.2em; }
.x-gate { font-size: 13px; margin: 6px 0 0; padding: 8px 10px; border-radius: 8px; background: var(--warn-soft); }
.x-err { font-size: 13px; margin: 6px 0 0; padding: 8px 10px; border-radius: 8px; background: var(--bad-soft); color: var(--text); }
.x-prog { margin-top: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.x-prog-head { margin: 0 0 6px; font-size: 14px; display: flex; justify-content: space-between; }
.x-steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.x-steps li { display: flex; align-items: center; gap: 8px; }
.x-steps .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--line-2); flex: none; }
.x-steps li.on { color: var(--text); font-weight: 600; } .x-steps li.on .dot { background: var(--info); }
.x-steps li.done { color: var(--text-2); } .x-steps li.done .dot { background: var(--ok); }
.x-steps li.failed { color: var(--bad); } .x-steps li.failed .dot { background: var(--bad); }
.x-out { margin-top: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.x-head { border-radius: 10px; padding: 10px 12px; background: var(--surface-2); }
.x-head.x-ok { background: var(--ok-soft); } .x-head.x-info { background: var(--info-soft); }
.x-head.x-warn { background: var(--warn-soft); } .x-head.x-bad { background: var(--bad-soft); }
.x-head h3 { font-size: 19px; margin: 2px 0 0; }
.x-kicker { margin: 0; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-2); }
.x-meta, .x-sum { margin: 6px 0 0; font-size: 14px; }
.x-chip { display: inline-block; font-size: 12px; font-weight: 600; padding: 1px 8px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line-2); vertical-align: 1px; }
.x-chip.x-high { color: var(--ok); } .x-chip.x-medium { color: var(--info); } .x-chip.x-low { color: var(--warn); }
.x-photo, .x-crop { margin: 10px 0 0; font-size: 14px; }
.x-photo.x-not_leaf, .x-photo.x-too_blurry { color: var(--bad); }
.x-sec { margin-top: 12px; }
.x-sec h4, .x-hist h4 { font-size: 13px; color: var(--text-2); text-transform: uppercase; letter-spacing: .04em; margin: 0 0 4px; }
.x-sec ul { margin: 0; padding-left: 18px; font-size: 14px; }
.x-sec li + li { margin-top: 4px; }
.x-ext { margin-top: 12px; padding: 10px 12px; border-left: 4px solid var(--info); background: var(--info-soft); border-radius: 0 8px 8px 0; font-size: 14px; }
.x-rec { margin-top: 10px; padding: 10px 12px; border-radius: 8px; font-size: 14px; background: var(--surface-2); }
.x-rec ul { margin: 4px 0 0; padding-left: 18px; }
.x-rec-agree { background: var(--ok-soft); } .x-rec-partial { background: var(--info-soft); } .x-rec-disagree { background: var(--warn-soft); }
.x-warn, .x-note { font-size: 13px; margin: 10px 0 0; color: var(--text-2); }
.x-warn { color: var(--bad); font-weight: 600; }
.x-hist { margin-top: 12px; }
@media print { .expert .hint, .expert .field, .x-actions, .x-meter, .x-gate, .x-prog, .x-hist { display: none !important; } .expert { border: 0; background: none; padding: 0; } }
