:root{
  --paper:#f3e9d2;
  --paper-hi:#f8f0dd;
  --paper-lo:#e9d9b8;
  --paper-deep:#e0cfa9;
  --ink:#1e3629;
  --ink-2:#34503a;
  --ink-3:#5a7052;
  --moss:#3f6b3f;
  --ochre:#e0a13c;
  --ochre-deep:#b97c25;
  --line:rgba(30,54,41,.62);
  --line-soft:rgba(30,54,41,.28);
  --shadow:0 10px 26px rgba(27,40,24,.24), 0 2px 6px rgba(27,40,24,.14);
  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.86' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.12 0 0 0 0 0.09 0 0 0 0 0.04 0 0 0 0.16 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  --display:"Fraunces", Georgia, serif;
  --sans:"IBM Plex Sans", "Trebuchet MS", sans-serif;
  --mono:"IBM Plex Mono", "Courier New", monospace;
  --dock-h:44px;
}

*{ box-sizing:border-box; }
html,body{ height:100%; }
body{
  margin:0;
  overflow:hidden;
  background:
    radial-gradient(120% 90% at 28% 74%, #c8b27a 0%, #dcc79a 34%, #e8d9b5 60%, #c3cbb0 100%);
  font-family:var(--sans);
  color:var(--ink);
  -webkit-user-select:none;
  user-select:none;
  -webkit-tap-highlight-color:transparent;
  overscroll-behavior:none;
}
.world-vignette{
  position:fixed;
  inset:0;
  z-index:2;
  pointer-events:none;
  background:
    radial-gradient(ellipse 118% 92% at 46% 42%, rgba(0,0,0,0) 44%, rgba(21,31,17,.28) 100%),
    linear-gradient(180deg, rgba(255,201,120,.08) 0%, rgba(255,201,120,0) 32%);
}
#world{
  position:fixed;
  inset:0;
  width:100%;
  height:100%;
  display:block;
  touch-action:none;
  cursor:none;
  outline:none;
}

/* ------- paper surface ------- */
.panel{
  position:fixed;
  z-index:6;
  background:
    linear-gradient(176deg, rgba(255,252,241,.55) 0%, rgba(255,255,255,0) 38%),
    linear-gradient(180deg, var(--paper-hi) 0%, var(--paper) 55%, var(--paper-lo) 100%);
  border:1px solid var(--line);
  border-radius:3px;
  box-shadow:var(--shadow), inset 0 1px 0 rgba(255,255,255,.55);
}
.panel::after,.paper-panel::after{
  content:"";
  position:absolute;
  inset:0;
  border-radius:inherit;
  pointer-events:none;
  background-image:var(--grain);
  background-size:140px 140px;
  background-repeat:repeat;
  opacity:.34;
  mix-blend-mode:multiply;
}
.panel > *{ position:relative; z-index:1; }
.paper-panel{ position:relative; }

/* ------- top left identity ------- */
.identity{
  left:16px;
  top:14px;
  width:clamp(258px, 33vw, 468px);
  padding:9px 11px 10px;
  animation:settle .7s cubic-bezier(.2,.8,.25,1) both;
}
.brand-row{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:8px;
}
.wordmark{
  display:block;
  width:min(67%, 278px);
  height:auto;
  margin-top:2px;
  filter:drop-shadow(0 1px 0 rgba(255,255,255,.45));
}
.rose-btn{
  flex:0 0 auto;
  width:clamp(39px, 6.6vw, 74px);
  height:auto;
  padding:0;
  border:0;
  background:none;
  cursor:pointer;
  display:grid;
  place-items:center;
  transition:transform .25s ease, filter .25s ease;
}
.rose-btn:hover{ transform:rotate(-8deg) scale(1.04); }
.rose-btn:active{ transform:scale(.96) rotate(4deg); }
.compass-rose{ width:100%; height:auto; display:block; filter:drop-shadow(0 1px 2px rgba(30,54,41,.25)); }
.steps{
  display:flex;
  align-items:center;
  gap:6px;
  margin-top:8px;
}
.step{
  flex:1 1 0;
  padding:0;
  border:0;
  background:none;
  cursor:pointer;
  transition:transform .25s cubic-bezier(.2,.8,.25,1), filter .25s ease;
  filter:drop-shadow(0 1px 2px rgba(30,54,41,.14));
}
.step img{ display:block; width:100%; height:auto; }
.step.is-current{ transform:scale(1.055); filter:drop-shadow(0 3px 5px rgba(30,54,41,.24)); cursor:default; }
.step:not(.is-current):hover{ transform:translateY(-1px); }

/* ------- left tool rail ------- */
.tool-rail{
  left:14px;
  top:174px;
  width:clamp(62px, 6.8vh, 86px);
  padding:5px 5px 6px;
  display:flex;
  flex-direction:column;
  gap:4px;
  align-items:center;
  animation:settle .7s .12s cubic-bezier(.2,.8,.25,1) both;
}
.tool{
  width:100%;
  padding:0;
  border:0;
  background:none;
  cursor:pointer;
  display:flex;
  flex-direction:column;
  align-items:center;
  gap:3px;
}
.tool-tile{
  position:relative;
  width:clamp(34px, 5.5vh, 56px);
  aspect-ratio:1/1;
  display:grid;
  place-items:center;
  padding:5px;
  border:1px solid var(--line-soft);
  border-radius:2px;
  background:linear-gradient(180deg, rgba(255,255,255,.34), rgba(214,196,158,.18));
  box-shadow:inset 0 1px 0 rgba(255,255,255,.45);
  transition:background .22s ease, border-color .22s ease, box-shadow .22s ease;
}
.tool-tile img{
  width:76%;
  height:76%;
  object-fit:contain;
  display:block;
  transition:transform .22s ease;
}
.tool-label{
  font-family:var(--mono);
  font-size:clamp(6.8px, .78vw, 9.5px);
  letter-spacing:.03em;
  color:var(--ink-2);
  line-height:1;
  transition:color .22s ease;
}
.tool:hover .tool-tile{ border-color:var(--line); background:linear-gradient(180deg, rgba(255,255,255,.55), rgba(214,196,158,.28)); }
.tool:hover .tool-tile img{ transform:scale(1.05); }
.tool.is-active .tool-tile{
  background:linear-gradient(180deg, #e8b157 0%, var(--ochre) 58%, #d0902e 100%);
  border-color:#9b6b1d;
  box-shadow:inset 0 1px 0 rgba(255,245,214,.65), inset 0 -3px 0 rgba(126,84,19,.34), 0 2px 5px rgba(30,54,41,.22);
}
.tool.is-active .tool-tile::after{
  content:"";
  position:absolute;
  left:7px; right:7px; bottom:3px;
  height:2px;
  border-radius:2px;
  background:#7e5413;
  opacity:.55;
}
.tool.is-active .tool-label{ color:#3c2b0e; font-weight:600; }

/* ------- right herbarium ------- */
.herbarium{
  right:14px;
  top:14px;
  width:clamp(96px, 11.6vw, 168px);
  padding:5px;
  display:flex;
  flex-direction:column;
  gap:6px;
  animation:settle .7s .2s cubic-bezier(.2,.8,.25,1) both;
}
.specimen{
  width:100%;
  padding:3px 3px 4px;
  border:1px solid var(--line-soft);
  border-radius:2px;
  background:linear-gradient(180deg, rgba(255,252,242,.4), rgba(220,202,165,.18));
  cursor:pointer;
  display:flex;
  flex-direction:column;
  align-items:stretch;
  gap:1px;
  overflow:hidden;
  transition:transform .25s cubic-bezier(.2,.8,.25,1), border-color .2s ease, box-shadow .2s ease, background .2s ease;
}
.spec-art{
  display:grid;
  place-items:center;
  height:clamp(42px, 8.5vh, 96px);
  padding:2px 1px;
  margin-bottom:2px;
  overflow:hidden;
}
.spec-art img{
  width:100%;
  height:100%;
  object-fit:contain;
  display:block;
  filter:drop-shadow(0 1px 1px rgba(30,54,41,.18));
}
.spec-meta{
  display:flex;
  align-items:baseline;
  justify-content:space-between;
  gap:4px;
  padding:1px 2px 0;
  position:relative;
  z-index:1;
  background:linear-gradient(180deg, rgba(243,233,210,0) 0%, rgba(243,233,210,.9) 45%);
}
.spec-name{
  font-family:var(--sans);
  font-size:clamp(7.5px, .8vw, 11px);
  font-weight:500;
  color:var(--ink-2);
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}
.spec-count{
  font-family:var(--mono);
  font-size:clamp(7px, .75vw, 10px);
  font-weight:500;
  color:var(--ink-3);
}
.specimen:hover{ background:linear-gradient(180deg, rgba(255,255,255,.6), rgba(220,202,165,.28)); border-color:var(--line); }
.specimen.is-active{
  transform:translateY(-3px);
  border:2px solid var(--ink);
  padding:2px 2px 3px;
  background:linear-gradient(180deg, #fbf4e2, #eee0c0);
  box-shadow:0 6px 12px rgba(27,40,24,.22);
  z-index:2;
}
.specimen.is-active .spec-name{ color:var(--ink); font-weight:600; }
.specimen.is-active .spec-count{ color:var(--ochre-deep); font-weight:600; }
.spec-count.ticking{ animation:tick .42s cubic-bezier(.2,.9,.3,1); }
@keyframes tick{
  0%{ transform:scale(1); }
  35%{ transform:scale(1.5); color:var(--ochre-deep); }
  100%{ transform:scale(1); }
}

/* ------- bottom readout ------- */
.readout{
  left:50%;
  bottom:calc(var(--dock-h) + 9px);
  transform:translateX(-50%);
  display:flex;
  align-items:center;
  justify-content:center;
  gap:clamp(4px, .8vw, 10px);
  padding:5px clamp(8px, 1.1vw, 15px);
  border-radius:2px;
  font-family:var(--mono);
  font-size:clamp(8.2px, .95vw, 12px);
  color:var(--ink-2);
  white-space:nowrap;
  animation:settle .7s .28s cubic-bezier(.2,.8,.25,1) both;
}
.ro-item{ display:inline-flex; align-items:baseline; gap:4px; }
.ro-key{ color:var(--ink-3); font-size:.86em; letter-spacing:.04em; }
.ro-val{ color:var(--ink); font-weight:500; font-variant-numeric:tabular-nums; }
.ro-sep{ color:var(--line-soft); }
.help-btn{
  margin-left:3px;
  width:1.55em;
  height:1.55em;
  padding:0;
  border:1px solid var(--line-soft);
  border-radius:50%;
  background:linear-gradient(180deg, #fbf4e2, #e7d7b4);
  color:var(--ink-2);
  font-family:var(--display);
  font-size:.88em;
  font-weight:600;
  line-height:1;
  cursor:pointer;
  display:inline-grid;
  place-items:center;
  transition:background .2s ease, transform .2s ease;
}
.help-btn:hover{ background:var(--ochre); color:#2c220d; transform:translateY(-1px); }

/* ------- help card ------- */
.help-card{
  position:fixed;
  z-index:18;
  left:50%;
  bottom:calc(var(--dock-h) + 54px);
  width:min(92vw, 470px);
  transform:translateX(-50%);
  animation:helpIn .35s cubic-bezier(.2,.8,.25,1) both;
}
.help-card[hidden]{ display:none; }
.help-card .paper-panel{
  padding:15px 17px 13px;
  background:
    linear-gradient(176deg, rgba(255,252,241,.6), rgba(255,255,255,0) 40%),
    linear-gradient(180deg, var(--paper-hi), var(--paper) 60%, var(--paper-lo));
  border:1px solid var(--line);
  border-radius:3px;
  box-shadow:var(--shadow), inset 0 1px 0 rgba(255,255,255,.55);
}
.help-card h2{
  margin:0 0 8px;
  font-family:var(--display);
  font-weight:600;
  font-size:19px;
  letter-spacing:.01em;
  color:var(--ink);
}
.help-list{
  list-style:none;
  margin:0;
  padding:0;
  display:grid;
  gap:6px;
}
.help-list li{
  display:grid;
  grid-template-columns:92px 1fr;
  gap:8px;
  align-items:baseline;
  font-size:12px;
  line-height:1.35;
}
.help-list b{
  font-family:var(--mono);
  font-size:9.5px;
  letter-spacing:.05em;
  text-transform:uppercase;
  color:var(--ochre-deep);
  font-weight:600;
}
.help-list span{ color:var(--ink-2); }
.help-foot{
  margin:10px 0 0;
  padding-top:8px;
  border-top:1px solid var(--line-soft);
  font-size:10.5px;
  color:var(--ink-3);
}
@keyframes helpIn{ from{ opacity:0; transform:translateX(-50%) translateY(8px); } to{ opacity:1; transform:translateX(-50%) translateY(0); } }

/* ------- folded dock ------- */
.dock{
  position:fixed;
  z-index:8;
  left:0; right:0; bottom:0;
  height:var(--dock-h);
  border-top:1px solid var(--line);
  border-radius:12px 12px 0 0;
  background:
    linear-gradient(180deg, rgba(255,255,255,.45), rgba(255,255,255,0) 42%),
    linear-gradient(180deg, var(--paper-hi) 0%, var(--paper) 52%, var(--paper-deep) 100%);
  box-shadow:0 -8px 20px rgba(27,40,24,.18), inset 0 1px 0 rgba(255,255,255,.5);
  cursor:pointer;
  display:flex;
  align-items:center;
  justify-content:center;
  transition:transform .3s cubic-bezier(.2,.8,.25,1), box-shadow .3s ease;
  animation:settle .7s .34s cubic-bezier(.2,.8,.25,1) both;
}
.dock::after{
  content:"";
  position:absolute; inset:0;
  border-radius:inherit;
  pointer-events:none;
  background-image:var(--grain);
  background-size:140px 140px;
  opacity:.26;
  mix-blend-mode:multiply;
}
.dock:hover{ transform:translateY(-3px); box-shadow:0 -12px 26px rgba(27,40,24,.22), inset 0 1px 0 rgba(255,255,255,.5); }
.dock.is-lifting{ transform:translateY(-7px); }
.dock-handle{
  position:absolute;
  top:5px; left:50%;
  width:74px; height:5px;
  transform:translateX(-50%);
  border-radius:4px;
  border:1px solid rgba(30,54,41,.28);
  background:linear-gradient(180deg, #d8c49b, #bda77b);
  box-shadow:inset 0 1px 1px rgba(255,255,255,.5);
}
.dock-label{
  position:relative;
  z-index:1;
  margin-top:8px;
  font-family:var(--mono);
  font-size:clamp(7.5px, .8vw, 10px);
  letter-spacing:.24em;
  text-transform:uppercase;
  color:rgba(30,54,41,.46);
}

/* ------- capture ------- */
.capture-wrap{
  position:fixed;
  inset:0;
  z-index:30;
  display:grid;
  place-items:center;
  padding:14px;
  background:rgba(15,28,20,.46);
  animation:fadeIn .28s ease both;
}
.capture-wrap[hidden]{ display:none; }
.capture-card{
  position:relative;
  width:min(94vw, 800px);
  padding:13px;
  animation:settle .45s cubic-bezier(.2,.8,.25,1) both;
}
.capture-head{
  display:flex;
  align-items:baseline;
  justify-content:space-between;
  gap:10px;
  padding:0 2px 8px;
}
.capture-kicker{
  font-family:var(--display);
  font-size:19px;
  font-weight:600;
  color:var(--ink);
}
.capture-meta{
  font-family:var(--mono);
  font-size:9.5px;
  letter-spacing:.08em;
  color:var(--ink-3);
}
.capture-frame{
  border:1px solid var(--line);
  border-radius:2px;
  background:#16241b;
  padding:4px;
  box-shadow:inset 0 2px 8px rgba(0,0,0,.28);
}
.capture-frame img{
  display:block;
  width:100%;
  max-height:54vh;
  object-fit:contain;
  background:#16241b;
}
.capture-actions{
  display:flex;
  justify-content:flex-end;
  gap:8px;
  padding-top:10px;
}
.paper-btn{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  padding:7px 14px;
  border:1px solid var(--line);
  border-radius:2px;
  background:linear-gradient(180deg, #fbf4e2, #e8d8b5);
  box-shadow:0 2px 5px rgba(27,40,24,.16), inset 0 1px 0 rgba(255,255,255,.55);
  font-family:var(--mono);
  font-size:10px;
  letter-spacing:.06em;
  text-transform:uppercase;
  color:var(--ink);
  text-decoration:none;
  cursor:pointer;
  transition:transform .18s ease, background .18s ease;
}
.paper-btn:hover{ transform:translateY(-1px); }
.paper-btn-primary{
  background:linear-gradient(180deg, #e8b157, var(--ochre) 60%, #d0902e);
  border-color:#9b6b1d;
  color:#2e230e;
  font-weight:600;
}
@keyframes fadeIn{ from{ opacity:0; } to{ opacity:1; } }

/* ------- toast + loading ------- */
.toast{
  position:fixed;
  z-index:26;
  left:50%;
  bottom:calc(var(--dock-h) + 58px);
  transform:translateX(-50%) translateY(8px);
  max-width:min(88vw, 420px);
  padding:8px 14px;
  border:1px solid var(--line);
  border-radius:2px;
  background:linear-gradient(180deg, var(--paper-hi), var(--paper-lo));
  box-shadow:var(--shadow);
  font-family:var(--sans);
  font-size:11.5px;
  line-height:1.35;
  color:var(--ink-2);
  text-align:center;
  opacity:0;
  pointer-events:none;
  transition:opacity .28s ease, transform .32s cubic-bezier(.2,.8,.25,1);
}
.toast.show{ opacity:1; transform:translateX(-50%) translateY(0); }
.loading{
  position:fixed;
  z-index:40;
  inset:0;
  display:grid;
  place-items:center;
  background:linear-gradient(175deg, #ead9b7 0%, #d6c69c 55%, #adb895 100%);
  transition:opacity .7s ease;
}
.loading.done{ opacity:0; pointer-events:none; }
.loading span{
  padding:12px 22px;
  border:1px solid var(--line);
  border-radius:2px;
  background:linear-gradient(180deg, var(--paper-hi), var(--paper-lo));
  box-shadow:var(--shadow);
  font-family:var(--display);
  font-size:16px;
  letter-spacing:.02em;
  color:var(--ink);
}

@keyframes settle{
  from{ opacity:0; translate:0 15px; }
  to{ opacity:1; translate:0 0; }
}

/* ------- unlit step nudge ------- */
@keyframes stepNudge{
  0%,100%{ transform:translateY(0); }
  30%{ transform:translateY(-2px); }
  60%{ transform:translateY(1px); }
}
.step.nudge{ animation:stepNudge .45s ease; }

/* ------- short screens ------- */
@media (max-width:760px){
  .identity{ left:8px; top:8px; width:min(70vw, 292px); padding:7px 8px 8px; }
  .brand-row{ gap:5px; }
  .wordmark{ width:min(66%, 168px); }
  .rose-btn{ width:clamp(34px, 10vw, 46px); }
  .steps{ gap:4px; margin-top:6px; }
  .tool-rail{ left:8px; top:118px; width:56px; padding:4px 3px 5px; gap:3px; }
  .tool-tile{ width:32px; padding:3px; }
  .tool-label{ font-size:7px; }
  .herbarium{ right:8px; top:8px; width:88px; padding:4px; gap:4px; }
  .spec-art{ height:clamp(34px, 7.4vh, 52px); padding:1px 0; }
  .spec-name{ font-size:8px; }
  .spec-count{ font-size:7.5px; }
  .readout{ bottom:calc(var(--dock-h) + 7px); gap:4px; padding:4px 7px; font-size:clamp(7.2px, 2vw, 9px); max-width:calc(100vw - 12px); }
  .ro-y{ display:none !important; }
  :root{ --dock-h:34px; }
  .dock-handle{ width:56px; height:4px; top:4px; }
  .help-card{ bottom:calc(var(--dock-h) + 46px); }
  .help-list li{ grid-template-columns:78px 1fr; font-size:11.5px; }
  .capture-actions{ flex-direction:column-reverse; }
  .paper-btn{ width:100%; }
}

@media (max-width:390px){
  .identity{ width:min(74vw, 250px); }
  .herbarium{ width:78px; }
  .tool-rail{ width:50px; }
  .ro-item .ro-key{ display:none; }
  .ro-item{ gap:2px; }
  .ro-sep{ display:none; }
  .readout{ gap:7px; }
}

@media (max-height:560px) and (orientation:landscape){
  :root{ --dock-h:28px; }
  .identity{ left:8px; top:8px; width:min(42vw, 330px); padding:5px 7px 6px; }
  .wordmark{ width:min(64%, 158px); }
  .rose-btn{ width:34px; }
  .steps{ margin-top:4px; gap:5px; }
  .tool-rail{
    left:8px; top:88px;
    width:112px;
    display:grid;
    grid-template-columns:1fr 1fr;
    gap:4px;
    padding:4px;
  }
  .tool{ gap:1px; }
  .tool-tile{ width:30px; aspect-ratio:1/1; padding:3px; }
  .tool-label{ font-size:6.5px; }
  .herbarium{
    right:8px; top:8px;
    width:172px;
    display:grid;
    grid-template-columns:1fr 1fr;
    gap:4px;
    padding:4px;
  }
  .specimen{ padding:2px 2px 3px; }
  .spec-art{ height:30px; }
  .spec-name{ font-size:7px; }
  .spec-count{ font-size:7px; }
  .specimen.is-active{ transform:translateY(-2px); padding:1px 1px 2px; }
  .readout{ bottom:calc(var(--dock-h) + 5px); font-size:8px; padding:3px 7px; }
  .capture-frame img{ max-height:46vh; }
  .help-card{ bottom:calc(var(--dock-h) + 40px); }
}

@media (prefers-reduced-motion:reduce){
  *{ animation-duration:.001ms !important; animation-iteration-count:1 !important; transition-duration:.001ms !important; }
}
