/* =========================================================
   Production UI refinement — preserves existing functionality
   ========================================================= */
:root{
  --radius:6px;
  --accent:#187a57;
  --accent-foreground:#fff;
  --background:#f6f7f6;
  --background-secondary:#f3f5f3;
  --background-tertiary:#eef1ef;
  --foreground:#171b18;
  --surface:#ffffff;
  --surface-secondary:#f8f9f8;
  --surface-tertiary:#f0f2f0;
  --overlay:#ffffff;
  --muted:#68716b;
  --default:#f0f2f0;
  --default-foreground:#303632;
  --border:#e1e5e2;
  --border-secondary:#d5dad6;
  --border-tertiary:#c6cdc8;
  --separator:#ecefec;
  --segment:#ffffff;
  --segment-foreground:#171b18;
  --field-background:#ffffff;
  --field-border:#dfe4e0;
  --field-border-width:1px;
  --field-shadow:none;
  --surface-shadow:none;
  --overlay-shadow:0 18px 44px rgba(24,34,28,.12),0 2px 8px rgba(24,34,28,.06);
  --focus:#248b67;
}
[data-theme="dark"]{
  --accent:#5fbd91;
  --accent-foreground:#0c1d15;
  --background:#0e1110;
  --background-secondary:#111512;
  --background-tertiary:#171c18;
  --foreground:#eff4f0;
  --surface:#141816;
  --surface-secondary:#181d1a;
  --surface-tertiary:#1e2420;
  --overlay:#181d1a;
  --muted:#98a39c;
  --default:#202622;
  --default-foreground:#e6ebe7;
  --border:#29312c;
  --border-secondary:#354038;
  --border-tertiary:#455149;
  --separator:#232a26;
  --segment:#222823;
  --segment-foreground:#f2f5f3;
  --field-background:#171c19;
  --field-border:#323b35;
  --field-shadow:none;
  --surface-shadow:none;
  --overlay-shadow:0 20px 48px rgba(0,0,0,.38),0 1px 4px rgba(0,0,0,.28);
  --focus:#67c79a;
}
body{font-size:13.5px;line-height:1.45;letter-spacing:-.004em;background:var(--background)}

/* Global component discipline */
.button{height:34px;border-radius:7px;padding-inline:12px;font-size:12.5px;font-weight:470;gap:7px;box-shadow:none!important;transition:background-color .14s ease,border-color .14s ease,color .14s ease,transform .12s ease}
.button--sm{height:30px;padding-inline:10px;font-size:12px}
.button--lg{height:38px;border-radius:8px}
.button--icon-only{width:34px;padding:0}
.button--icon-only.button--sm{width:30px}
.button--primary{--button-bg:var(--accent);--button-bg-hover:color-mix(in srgb,var(--accent) 88%,#000);--button-fg:var(--accent-foreground)}
.button--secondary{--button-bg:var(--surface-tertiary);--button-bg-hover:var(--default);--button-fg:var(--foreground)}
.button--tertiary,.button--ghost{--button-bg:transparent;--button-bg-hover:var(--default);--button-fg:var(--foreground)}
.button--outline{border:1px solid var(--border);--button-bg:var(--surface);--button-bg-hover:var(--surface-secondary)}
.card{border-radius:10px;box-shadow:none}
.card--secondary{background:var(--surface-secondary)}
.chip{border-radius:5px;background:var(--default);font-size:10.5px;line-height:18px;padding:1px 6px;font-weight:460}
.badge{border-radius:6px;min-width:20px;min-height:20px;font-size:10px}
.close-button{border-radius:7px}
.switch__control{border-radius:999px}
.checkbox__control{border-radius:5px}

/* Header: product identity first, controls second */
.topbar{height:58px;min-height:58px;padding:0 16px;gap:10px;background:var(--surface);border-bottom:1px solid var(--border);z-index:70}
.badge-anchor{display:flex;align-items:center}
#ftog{border:1px solid transparent;color:var(--muted)}
#ftog:hover{border-color:var(--border);color:var(--foreground);background:var(--surface-secondary)}
.brandbar{display:flex;align-items:center;gap:9px;min-width:172px;margin-right:4px;white-space:nowrap}
.brandbar__mark{width:22px;height:22px;border-radius:6px;background:var(--accent);position:relative;box-shadow:inset 0 0 0 1px color-mix(in srgb,#000 8%,transparent)}
.brandbar__mark:before,.brandbar__mark:after{content:"";position:absolute;background:#fff;border-radius:8px 8px 8px 1px;transform:rotate(-35deg)}
.brandbar__mark:before{width:8px;height:12px;left:5px;top:5px}
.brandbar__mark:after{width:5px;height:8px;right:4px;top:4px;opacity:.72;transform:rotate(28deg)}
.brandbar__text{display:flex;flex-direction:column;line-height:1.06}
.brandbar__text strong{font-size:13px;font-weight:540;letter-spacing:-.012em}
.brandbar__text small{font-size:9.5px;color:var(--muted);margin-top:3px;letter-spacing:.02em}
.searchbox{max-width:350px;min-width:220px}
.search-field__group{height:34px;border-radius:8px;background:var(--surface-secondary);border:1px solid var(--border);box-shadow:none}
.search-field__group:hover:not(:focus-within){background:var(--surface);border-color:var(--border-secondary)}
.search-field__group:focus-within{background:var(--surface);border-color:color-mix(in srgb,var(--accent) 55%,var(--border));box-shadow:0 0 0 3px color-mix(in srgb,var(--accent) 11%,transparent)}
.search-field__input{font-size:12.5px!important;padding-block:6px;padding-left:6px!important}
#results{top:calc(100% + 7px);border-radius:10px;border:1px solid var(--border);box-shadow:var(--overlay-shadow);padding:5px;max-height:52vh}
#results button{border-radius:7px;min-height:38px;padding:6px 8px}
#results b{font-size:12.5px;font-weight:500}
#results i{font-size:12.5px}

/* View navigation: quiet tabs, strong selected state */
.topbar .tabs{flex:1;margin-left:4px;justify-content:flex-end;min-width:0}
.topbar .tabs__list-container{background:transparent;border-radius:0;overflow-x:auto}
.tabs__list{padding:0;gap:0;background:transparent}
.tabs__tab{height:34px;min-width:auto;padding:0 10px;border-radius:0;font-size:12px;font-weight:440;color:var(--muted);white-space:nowrap}
.tabs__tab[data-selected="true"]{color:var(--foreground);font-weight:520}
.tabs__indicator{border-radius:0;background:transparent;box-shadow:inset 0 -2px 0 var(--accent);transition-duration:.2s}
.tabs__separator{display:none}

/* Main workspace */
.app{gap:10px;padding:12px 16px 16px;background:var(--background)}
#stage{background:var(--surface);border:1px solid var(--border);border-radius:11px;box-shadow:none}
#v-list{padding:0 14px 72px}
#v-map{padding:12px}

/* Compact, coherent canvas toolbar */
.tools{top:10px;right:10px;flex-direction:row;align-items:center;gap:3px;padding:3px;border:1px solid var(--border);border-radius:9px;background:color-mix(in srgb,var(--surface) 95%,transparent);box-shadow:0 2px 8px rgba(20,28,23,.05)}
.tzoom{flex-direction:row;align-items:center;gap:2px;padding-left:3px;border-left:1px solid var(--separator)}
.tools .button{--button-bg:transparent;--button-bg-hover:var(--default);--button-bg-pressed:var(--default);box-shadow:none!important;color:var(--muted)}
.tools .button:hover{color:var(--foreground)}

/* Drawer: fewer floating surfaces, stronger information hierarchy */
.side{padding:10px 0 10px 10px}
.side .drawer__dialog{width:min(360px,calc(100vw - 28px));border-radius:12px;border:1px solid var(--border);padding:18px 7px 18px 18px;box-shadow:var(--overlay-shadow)}
.side .drawer__body{padding-right:11px}
.side .drawer__close-trigger{right:11px;top:11px}
.side .drawer__header{padding:0 36px 13px 0;border-bottom:1px solid var(--separator)}
.drawer__heading{font-size:15px;font-weight:540;letter-spacing:-.02em}
.drawer__header p{font-size:11px;color:var(--muted);margin-top:4px}
.msec{margin-top:0;padding:17px 0;border-bottom:1px solid var(--separator)}
.msec:last-child{border-bottom:0;padding-bottom:3px}
.msec>h3{font-size:10.5px;font-weight:540;color:var(--muted);text-transform:uppercase;letter-spacing:.065em;margin:0 0 9px}

/* KPI summary is data, not four cards */
.ksum{grid-template-columns:repeat(4,minmax(0,1fr));gap:0;border-block:1px solid var(--separator)}
.ksum .card{padding:10px 6px;background:transparent;border-radius:0;min-width:0;border-right:1px solid var(--separator)}
.ksum .card:last-child{border-right:0}
.ksum b{font-size:16px;line-height:1.15;font-weight:540;letter-spacing:-.035em;font-variant-numeric:tabular-nums}
.ksum .card__description{font-size:9.5px;line-height:1.25;color:var(--muted);margin-top:4px;white-space:normal}
.ksum .hit b{color:var(--foreground)}

/* Filters */
#filters h4{font-size:10px;font-weight:520;color:var(--muted);margin:14px 8px 4px;text-transform:none;letter-spacing:.015em}
.fi,.sw{gap:9px;border-radius:7px;padding:5px 7px;min-height:34px}
.fi:hover,.sw:hover{background:var(--surface-secondary)}
.fi [data-slot="label"],.sw [data-slot="label"]{font-size:12.5px}
.fi[data-selected="true"] [data-slot="label"]{font-weight:480}
.fi .fico,.sw .fico{opacity:.72}
.fi[data-selected="true"] .fico{opacity:1;color:var(--accent)}
.side .checkbox__control{width:16px;height:16px;background:var(--surface);box-shadow:inset 0 0 0 1px var(--border-secondary)}
.clr{margin-top:8px;color:var(--muted)}
.gb{padding:5px 4px;gap:3px 8px}
.gb .gl{font-size:11.5px;gap:7px}
.gb .gl::before{width:7px;height:7px}
.gb b{font-size:11px;font-weight:500}
.gb .gbar{height:3px;background:var(--default)}
.discover-actions{gap:6px}

/* List: dense, scan-friendly */
.lsticky{padding:11px 54px 8px 0;margin-bottom:2px;border-bottom:1px solid var(--separator)}
.crumbs{gap:4px;margin-bottom:8px}
.row{gap:8px;border-radius:6px;padding:3px 8px;min-height:34px}
.row:hover{background:var(--surface-secondary)}
.row.sel{background:color-mix(in srgb,var(--accent) 8%,var(--surface));box-shadow:inset 2px 0 0 var(--accent)}
.row b{font-size:12.5px;font-weight:420}
.row.d1 b{font-size:13.5px;font-weight:540}
.row.d2 b{font-weight:500}
.row.sp b{font-weight:380}
.row i{font-size:12.5px}
.row .cnt{font-size:11px}
.tl ul{border-left:1px solid var(--separator);margin-left:10px;padding-left:10px}

/* Detail panel: a working inspector, not another oversized card */
.detail{width:368px;border:1px solid var(--border);border-radius:11px;background:var(--surface);box-shadow:none}
.detail.shown{animation:din .18s ease-out}
.dh{padding:16px 16px 11px;gap:9px;border-bottom:1px solid var(--separator)}
.db{padding:2px 16px 20px}
.nm strong{font-size:17px;line-height:1.2;font-weight:540;letter-spacing:-.025em}
.nm em{font-size:14px;color:var(--muted)}
.db h3{font-size:10.5px;margin:18px 0 7px;text-transform:uppercase;letter-spacing:.06em;font-weight:540;color:var(--muted)}
.note{font-size:13px;line-height:1.55}
.meta{font-size:12px;line-height:1.5}
.tags{gap:5px;margin-top:10px}
.lin li{padding:2px 0;gap:8px}
.lin small{width:62px;font-size:10.5px}
.lin button{font-size:12.5px;text-decoration:none;min-height:26px}
.lin button:hover{text-decoration:underline;text-underline-offset:3px}
.kids{gap:5px}
.kids .button{border-left:2px solid var(--c);border-radius:6px;height:30px}
.acts{gap:6px;margin-top:16px}

/* Media and informational modules */
.plant-media{margin:3px 0 14px;border-radius:10px;background:var(--surface-secondary)}
.plant-media__hero{background:var(--surface-secondary)}
.plant-media__hero .plant-media__badge{left:8px;top:8px;backdrop-filter:none;background:var(--surface);border:1px solid var(--border);padding:3px 6px;border-radius:5px;font-size:9px;font-weight:500;box-shadow:none}
.plant-media__thumb{border-radius:6px}
.plant-media__source{border-radius:5px}
.plant-media__organ{border-radius:6px;padding:5px 8px;font-size:10px}
.plant-media__organ.is-active{background:var(--accent);color:var(--accent-foreground)}
.wiki-info,.bot-card,.compare-pro{border-radius:10px;background:var(--surface-secondary)}
.wiki-info__mark{border-radius:6px}
.bot-card{padding:12px}
.similar-item{border-radius:8px;background:var(--surface);padding:7px}
.dist-map{border-radius:8px;background:var(--surface-secondary)}
.compare-pro__diff{border-radius:7px}
.compare-pro__sp .search-plant-thumb{border-radius:7px}

/* Treemap / visualization labels */
.mt{border-radius:7px;background:color-mix(in srgb,var(--c) 7%,var(--surface));border-color:color-mix(in srgb,var(--c) 25%,var(--border))}
.mt.l2{border-radius:5px;background:color-mix(in srgb,var(--c) 15%,var(--surface))}
.mt:hover{box-shadow:inset 0 0 0 1px color-mix(in srgb,var(--c) 70%,transparent)}

/* Identification workspace: retain structure, remove template-like card excess */
#v-ident{padding:clamp(18px,2.3vw,30px);background:var(--surface)}
.ident{max-width:1160px;padding-bottom:72px}
.ident__intro{margin:4px 0 22px;gap:20px}
.ident__hero-icon{width:36px;height:36px;border-radius:8px;background:var(--accent-soft)}
.ident__intro h2{font-size:clamp(20px,2vw,26px);letter-spacing:-.04em}
.ident__intro p{font-size:12.5px;line-height:1.55;margin-top:6px}
.ident__layout{grid-template-columns:minmax(0,1.12fr) minmax(310px,.88fr);gap:18px}
.ident__question-card,.ident__results-card{border-radius:11px;border-color:var(--border);box-shadow:none;background:var(--surface)}
.ident__question-card .card__header,.ident__results-card .card__header{padding:17px 18px 0}
.ident__question-card .card__content{padding:15px 18px 18px}
.ident__question-card .card__footer{padding:0 18px 18px}
.ident__results-card .card__content{padding:10px 10px 13px}
.ident__question-card .card__title,.ident__results-card .card__title{font-size:14px;font-weight:540}
.ident__question-card .card__description,.ident__results-card .card__description{font-size:11.5px}
.ident .progress-bar__track{height:4px}
.ident .radio-group{gap:7px}
.ident .radio{min-height:58px;border-radius:8px;background:var(--surface-secondary)}
.ident .radio__content{grid-template-columns:20px minmax(0,1fr);gap:9px;padding:10px 11px}
.ident .radio__control{width:16px;height:16px}
.ident__radio-label{font-size:12px}
.ident__radio-desc{font-size:10.5px}
.ident__history-card{border-radius:9px;padding:11px 12px}
.ident__result{border-radius:7px;padding:8px}
.ident__rank{width:25px;height:25px;border-radius:5px;background:var(--default);color:var(--foreground)}
.ident__notice{border-radius:9px;padding:11px 12px}
.ident__notice-mark{border-radius:5px}
.ident__confirm-card{border-radius:9px;background:var(--surface-secondary)}
.ident__confirm-media .search-plant-thumb{border-radius:7px}

/* Dark mode keeps the same quiet hierarchy */
[data-theme="dark"] .tools{background:color-mix(in srgb,var(--surface) 94%,transparent);box-shadow:none}
[data-theme="dark"] .row.sel{background:color-mix(in srgb,var(--accent) 11%,var(--surface))}

/* Responsive: reprioritize, do not just shrink desktop */
@media (max-width:1120px){
  .brandbar{min-width:auto}
  .brandbar__text small{display:none}
  .searchbox{max-width:300px}
  .tabs__tab{padding-inline:8px}
  .detail{width:340px}
}
@media (max-width:920px){
  .brandbar__text{display:none}
  .brandbar{margin-right:0}
  .searchbox{max-width:none}
}
@media (max-width:820px){
  .topbar{height:auto;min-height:0;flex-wrap:wrap;padding:8px 10px 0;gap:7px;background:var(--surface)}
  .brandbar{display:none}
  #ftog{width:34px;height:34px}
  .searchbox{flex:1;min-width:0}
  .topbar .tabs{order:3;width:100%;margin:0;border-top:1px solid var(--separator)}
  .topbar .tabs__list-container{width:100%}
  .tabs__list{width:max-content;min-width:100%;padding:0}
  .tabs__tab{flex:none;min-width:62px;height:36px;padding:0 9px;font-size:11.5px}
  .app{padding:8px 10px 10px;gap:8px}
  #stage{border-radius:9px}
  .side{padding:8px 0 8px 8px}
  .side .drawer__dialog{border-radius:11px}
  .tools{top:8px;right:8px}
  .detail,.detail.shown{left:10px;right:10px;bottom:10px;border-radius:12px;box-shadow:var(--overlay-shadow)}
  .dh{height:62px;padding:0 12px 0 14px}
  .db{padding:2px 14px 18px}
  #v-list{padding:0 8px 82px}
  #v-ident{padding:14px 10px 92px}
  .ident__layout{grid-template-columns:1fr;gap:10px}
  .ident__intro{margin-bottom:15px}
  .ident__question-card,.ident__results-card{border-radius:9px}
}
@media (max-width:520px){
  .search-field__group{height:34px}
  .ksum{grid-template-columns:repeat(2,1fr)}
  .ksum .card:nth-child(2){border-right:0}
  .ksum .card:nth-child(-n+2){border-bottom:1px solid var(--separator)}
  .ident__intro-main{gap:9px}
  .ident__hero-icon{width:32px;height:32px}
  .ident__intro h2{font-size:19px}
  .ident__summary{margin-left:41px}
}


/* Final visual-noise pass: nested information uses dividers, not card-on-card stacks */
.wiki-info{border:0;border-top:1px solid var(--separator);border-radius:0;background:transparent;margin-top:17px}
.wiki-info__head{padding:13px 0 9px}
.wiki-info__body{padding:0 0 12px}
.wiki-info__loading,.wiki-info__empty{padding:13px 0}
.bot-card{border:0;border-top:1px solid var(--separator);border-radius:0;background:transparent;padding:16px 0 0;margin-top:17px}
.similar-list{gap:0}
.similar-item{border:0;border-top:1px solid var(--separator);border-radius:0;background:transparent;padding:10px 0}
.similar-item:first-child{border-top:0}
.similar-item .search-plant-thumb{border-radius:7px;background:var(--surface-secondary)}
.compare-pro{border:0;border-top:1px solid var(--separator);border-radius:0;background:transparent;margin-top:18px}
.compare-pro__head{padding:16px 0 10px}
.compare-pro__body{padding:12px 0}
.compare-pro__species{border-radius:8px;overflow:hidden}
