:root {
  --bg: #F2F2F0;
  --surface: #FFFFFF;
  --ink: #23180F;
  --muted: #6F665D;
  --line: #E1DED9;
  --orange: #FF9A1F;
  --orange-hi: #FFB24D;
  --orange-light: #FFC375;
  --orange-soft: #FFF1DE;
  --orange-deep: #A35400;
  --ok: #2F7A3E;
  --danger: #B3261E;
  --radius: 12px;
  --cond: "Barlow Condensed", "Arial Narrow", sans-serif;
  --body: "Barlow", system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.45 var(--body);
  padding-bottom: env(safe-area-inset-bottom);
  display: flex; flex-direction: column;
  -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--orange); outline-offset: 2px; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
::placeholder { color: #B9B2AA; opacity: 1; }

/* Top bar */
.top {
  display: flex; align-items: center; gap: 18px;
  padding: calc(10px + env(safe-area-inset-top)) 20px 10px;
  background: var(--ink); color: #fff;
}
.brand { display: flex; align-items: center; gap: 10px; font: 700 24px/1 var(--cond); letter-spacing: .01em; }
.brand img { height: 30px; width: auto; }
.brand span { font-weight: 500; color: var(--orange-light); }
.station-switch { display: flex; background: rgba(255,255,255,.08); border-radius: 9px; padding: 3px; }
.station-switch button {
  border: 0; background: none; color: rgba(255,255,255,.7);
  padding: 7px 14px; border-radius: 7px; cursor: pointer; font-weight: 500;
}
.station-switch button[aria-pressed="true"] { background: var(--orange); color: var(--ink); font-weight: 600; }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.sync { display: flex; align-items: center; gap: 6px; font-size: 14px; color: rgba(255,255,255,.75); margin-right: 6px; }
.sync i { width: 9px; height: 9px; border-radius: 50%; background: #999; }
.sync.on i { background: #6FCF7F; }
.sync.off i { background: #E5533D; }

.btn {
  border: 1px solid var(--line); background: var(--surface);
  padding: 9px 16px; border-radius: 9px; cursor: pointer; font-weight: 600;
  min-height: 44px; white-space: nowrap;
}
.btn:hover { border-color: #CFC9C1; }
.btn.primary { background: var(--orange); border-color: var(--orange); color: var(--ink); }
.btn.primary:hover { background: var(--orange-hi); border-color: var(--orange-hi); }
.btn.ghost { background: transparent; border-color: rgba(127,127,127,.35); }
.top .btn.ghost { color: #fff; }
.btn.danger { color: var(--danger); background: none; border-color: transparent; padding-left: 0; }
.btn:disabled { opacity: .55; cursor: default; }

/* Shelf tag: what's on the table */
.tag {
  display: flex; align-items: stretch;
  margin: 14px 20px 0;
  background: var(--orange-soft);
  border-radius: var(--radius);
  border-left: 10px solid var(--orange);
  min-height: 92px; position: relative;
}
.tag::after {
  content: ""; position: absolute; left: -10px; top: 50%;
  width: 14px; height: 14px; margin-top: -7px; border-radius: 50%; background: var(--bg);
}
.tag-main { flex: 1; padding: 12px 18px 12px 24px; display: flex; flex-direction: column; justify-content: center; min-width: 0; }
.tag-label { font-size: 13px; color: var(--orange-deep); font-weight: 600; }
.tag-name {
  font: 700 34px/1.05 var(--cond); border: 0; background: none; padding: 0;
  text-align: left; cursor: pointer; color: var(--ink);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%;
}
.tag-empty { font: 600 26px/1.1 var(--cond); color: var(--muted); }
.tag-code { font: 500 18px/1.2 var(--cond); letter-spacing: .14em; font-variant-numeric: tabular-nums; color: var(--muted); }
.tag-progress {
  display: flex; flex-direction: column; justify-content: center; gap: 6px;
  padding: 12px 20px; border-left: 1px dashed #F2C489; width: 300px; font-size: 14px;
}
.tag-progress b { font: 700 22px/1 var(--cond); }
.tag-progress .miss { color: var(--muted); }
.canon {
  display: flex; flex-direction: column; justify-content: center; align-items: flex-start; gap: 6px;
  padding: 12px 20px; border-left: 1px dashed #F2C489; font-size: 14px; min-width: 250px;
}
.canon-state { font-weight: 600; display: flex; align-items: center; gap: 7px; }
.canon-state .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--orange); animation: pulse 1.6s infinite; }
.warn { color: var(--orange-deep); font-weight: 600; }
.tag.flash { animation: flash .7s; }
@keyframes pulse { 50% { opacity: .3; } }
@keyframes flash { 0% { background: #fff; } 100% { background: var(--orange-soft); } }

/* Progress meter: one segment per checklist item */
.meter { display: flex; gap: 3px; }
.meter i { flex: 1; height: 6px; border-radius: 3px; background: #EADFD0; }
.meter i.on { background: var(--orange); }
.meter.done i.on { background: var(--ok); }

/* Layout */
.shell {
  flex: 1; min-height: 0;
  display: grid; grid-template-columns: 330px 1fr; gap: 16px;
  padding: 16px 20px 20px;
}
.list-pane, .editor {
  background: var(--surface); border-radius: var(--radius);
  border: 1px solid var(--line); min-height: 0; overflow: auto;
}
.list-pane { display: flex; flex-direction: column; }
.list-tools { padding: 12px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--surface); z-index: 1; }
.list-tools input { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 9px; background: var(--bg); }
.chips { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line); background: none; border-radius: 99px; padding: 4px 12px; font-size: 14px; cursor: pointer; }
.chip[aria-pressed="true"] { background: var(--ink); color: #fff; border-color: var(--ink); }

.list { list-style: none; margin: 0; padding: 0; }
.list li { border-bottom: 1px solid var(--line); }
.row {
  display: grid; grid-template-columns: 56px 1fr; gap: 12px; align-items: center;
  width: 100%; padding: 11px 12px; border: 0; background: none; text-align: left; cursor: pointer;
  border-left: 4px solid transparent;
}
.row:hover { background: #FAF8F5; }
.row.open { background: var(--orange-soft); border-left-color: var(--orange); }
.thumb {
  width: 56px; height: 56px; border-radius: 8px; background: var(--bg) center/contain no-repeat;
  display: grid; place-items: center; font-size: 11px; color: var(--muted); border: 1px solid var(--line);
}
.row-top { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.row-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-sub { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; margin-bottom: 6px; display: flex; gap: 8px; }
.row .meter i { height: 4px; }
.status { font-size: 12px; font-weight: 600; padding: 1px 8px; border-radius: 99px; background: var(--bg); color: var(--muted); flex: none; }
.status.review { background: var(--orange-soft); color: var(--orange-deep); }
.status.ready, .status.published { background: #E3F2E5; color: var(--ok); }
.on-table { color: var(--orange-deep); font-weight: 600; }
.empty { padding: 32px 20px; color: var(--muted); }

/* Editor */
.editor { padding: 0 26px 30px; }
.ed-head {
  position: sticky; top: 0; background: var(--surface); z-index: 3;
  padding: 16px 0 12px; border-bottom: 1px solid var(--line);
}
.ed-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.ed-head h2 { font: 700 30px/1.1 var(--cond); margin: 0; flex: 1; min-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.back { display: none; }
.save-state { font-size: 13px; color: var(--muted); min-width: 64px; text-align: right; }
.save-state.err { color: var(--danger); font-weight: 600; }
.ed-head select { padding: 8px 10px; border-radius: 9px; border: 1px solid var(--line); background: var(--surface); min-height: 44px; }
.checks { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.check {
  font-size: 13px; font-weight: 600; border-radius: 99px; padding: 4px 11px; cursor: pointer;
  border: 1px dashed #D9B98F; background: #fff; color: var(--orange-deep);
}
.check.ok { border: 1px solid transparent; background: #EEF6EF; color: var(--ok); cursor: default; }
.check.ok::before { content: "✓ "; }

.ed-body { display: grid; gap: 34px; margin-top: 22px; }
.ed-photos h3, .group h3 { font: 600 21px/1.2 var(--cond); margin: 0 0 12px; }
.group + .group { margin-top: 26px; }
.fields { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px 14px; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field.wide { grid-column: 1 / -1; }
.field.two { grid-column: span 2; }
.field label, .field .lbl { font-size: 14px; color: var(--muted); }
.field input, .field select, .field textarea {
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 9px; background: #FCFBFA; width: 100%;
  font-size: 16px; min-height: 46px;
}
.field textarea { min-height: 84px; resize: vertical; }
.field input:focus, .field textarea:focus, .field select:focus {
  border-color: var(--orange); background: #fff; outline: none; box-shadow: 0 0 0 3px var(--orange-soft);
}
.field input.code { font-family: var(--cond); font-size: 19px; letter-spacing: .08em; }
.field.flag input { border-color: #F2C489; }

.affix { display: flex; align-items: stretch; }
.affix span { display: grid; place-items: center; padding: 0 12px; background: var(--bg); border: 1px solid var(--line); border-right: 0; border-radius: 9px 0 0 9px; color: var(--muted); font-weight: 600; }
.affix input { border-radius: 0 9px 9px 0; }
.stepper { display: flex; }
.stepper input { text-align: center; border-radius: 0; }
.stepper button { width: 46px; border: 1px solid var(--line); background: var(--bg); cursor: pointer; font-size: 20px; font-weight: 600; }
.stepper button:first-child { border-radius: 9px 0 0 9px; border-right: 0; }
.stepper button:last-child { border-radius: 0 9px 9px 0; border-left: 0; }
.stepper button:active { background: var(--orange-soft); }

.measure { display: flex; gap: 8px; align-items: center; }
.measure input { min-width: 0; }
.measure .x { color: var(--muted); font-weight: 600; }
.seg { display: flex; background: var(--bg); border-radius: 9px; padding: 3px; border: 1px solid var(--line); flex: none; }
.seg button { border: 0; background: none; padding: 0 12px; min-height: 38px; border-radius: 7px; cursor: pointer; font-weight: 600; color: var(--muted); }
.seg button[aria-pressed="true"] { background: #fff; color: var(--ink); box-shadow: 0 1px 2px rgba(35,24,15,.15); }

.capture-bar { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 14px; }
.capture-bar .btn { white-space: normal; line-height: 1.2; }
.photo-set { margin-bottom: 16px; }
.photo-set h4 { margin: 0 0 8px; font-size: 15px; font-weight: 600; }
.photo-set h4 span { color: var(--muted); font-weight: 400; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.shot a { position: relative; }
.badge { position: absolute; left: 6px; top: 6px; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 99px; background: rgba(255,255,255,.92); color: var(--ink); }
.badge.nutrition { background: var(--orange); }
.badge.ingredients { background: var(--orange-light); }
.shot { border: 1px solid var(--line); border-radius: 9px; overflow: hidden; background: #fff; }
.shot.primary { border: 2px solid var(--orange); }
.shot a { display: block; aspect-ratio: 1; background: #F7F6F4 center/contain no-repeat; }
.shot-tools { display: flex; gap: 4px; padding: 6px; align-items: center; }
.shot-tools select { flex: 1; min-width: 0; font-size: 13px; padding: 4px; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.icon-btn { border: 1px solid var(--line); background: #fff; border-radius: 6px; padding: 3px 7px; cursor: pointer; font-size: 13px; }
.icon-btn.on { background: var(--orange); border-color: var(--orange); font-weight: 600; }
.uploading { font-size: 14px; color: var(--orange-deep); font-weight: 600; margin: 6px 0 10px; }
.drop-hint { border: 2px dashed var(--line); border-radius: var(--radius); padding: 22px; text-align: center; color: var(--muted); font-size: 15px; }
.ed-photos.dragging .drop-hint, .ed-photos.dragging .grid { outline: 3px dashed var(--orange); outline-offset: 4px; }

.finish {
  margin-top: 30px; padding: 16px 18px; border-radius: var(--radius);
  background: var(--bg); display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
.finish p { margin: 0; flex: 1; min-width: 200px; }
.finish.done { background: #EEF6EF; }
.danger-zone { margin-top: 22px; }

/* Wide screens: photos left, form right */
@media (min-width: 1200px) {
  .ed-body { grid-template-columns: minmax(320px, 400px) minmax(0, 780px); }
  .ed-photos { position: sticky; top: 150px; align-self: start; max-height: calc(100vh - 360px); overflow: auto; padding-right: 4px; }
}

/* AI */
.tool-row { display: flex; gap: 8px; margin-top: 10px; }
.tool-row .btn { flex: 1; min-height: 38px; padding: 6px 10px; font-size: 14px; }
.lbl-row { display: flex; align-items: center; gap: 8px; min-height: 22px; }
.lbl-row label, .lbl-row .lbl { flex: 1; }
.count { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.count.over { color: var(--danger); font-weight: 600; }
.ai-ok { display: none; border: 0; background: var(--orange); color: var(--ink); font-size: 12px; font-weight: 600; padding: 2px 10px; border-radius: 99px; cursor: pointer; }
.field.ai .ai-ok { display: inline-block; }
.field.ai input, .field.ai textarea, .field.ai select { border-color: var(--orange); background: #FFF8EE; }
.field.ai > label, .field.ai .lbl-row label, .field.ai .lbl-row .lbl { color: var(--orange-deep); font-weight: 600; }
.ai-note { margin: 2px 0 0; font-size: 13px; color: var(--orange-deep); }
.ai-flag { color: var(--orange-deep); font-weight: 600; }
.ai-bar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-top: 12px; padding: 10px 14px; border-radius: 10px;
  background: var(--orange-soft); font-size: 15px;
}
.ai-bar span { flex: 1; min-width: 220px; }
.ai-bar .btn { min-height: 38px; padding: 6px 12px; }
.ai-bar.err { background: #FBE9E7; color: var(--danger); }
.ai-bar.run { background: #FFF6EA; }
.spin { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--orange-light); border-top-color: var(--orange-deep); animation: spin .8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }

.nut-head { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 12px; }
.nut-head label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.nut-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px 14px; }
.nut { display: flex; align-items: center; gap: 8px; font-size: 14px; border-bottom: 1px solid var(--line); padding: 4px 0; }
.nut span:first-child { flex: 1; }
.nut-in { display: flex; align-items: center; gap: 4px; width: 104px; }
.nut-in input { min-height: 36px !important; padding: 6px 8px !important; text-align: right; }
.nut-in i { font-style: normal; color: var(--muted); font-size: 13px; width: 26px; }
.style-text { width: 100%; padding: 12px; border: 1px solid var(--line); border-radius: 9px; font-size: 15px; resize: vertical; }
.modal-foot { display: flex; align-items: center; gap: 10px; margin-top: 12px; }
.modal-foot span { flex: 1; font-size: 14px; }

/* Photo editor */
.modal.ie { padding: 12px; }
.ie-card { background: var(--surface); border-radius: 16px; width: min(1400px, 100%); height: min(940px, calc(100dvh - 24px)); display: flex; flex-direction: column; padding: 16px 18px; }
.ie-head-actions { display: flex; gap: 8px; }
.ie-head-actions a { text-decoration: none; color: var(--ink); display: inline-flex; align-items: center; }
.ie-body { flex: 1; min-height: 0; display: grid; grid-template-columns: 1fr 330px; gap: 16px; }
.ie-stage {
  position: relative; min-height: 0; border-radius: 12px; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  background: repeating-conic-gradient(#E9E6E1 0 25%, #F5F3F0 0 50%) 0 0 / 22px 22px;
  touch-action: none;
}
#ieCanvas { display: block; }
.ie-crop { position: absolute; border: 2px solid var(--orange); box-shadow: 0 0 0 9999px rgba(35,24,15,.45); cursor: move; touch-action: none; }
.ie-crop i { position: absolute; width: 22px; height: 22px; background: #fff; border: 2px solid var(--orange); border-radius: 50%; }
.ie-crop i[data-h="nw"] { left: -12px; top: -12px; cursor: nwse-resize; }
.ie-crop i[data-h="ne"] { right: -12px; top: -12px; cursor: nesw-resize; }
.ie-crop i[data-h="sw"] { left: -12px; bottom: -12px; cursor: nesw-resize; }
.ie-crop i[data-h="se"] { right: -12px; bottom: -12px; cursor: nwse-resize; }
.ie-crop i[data-h="n"] { left: calc(50% - 11px); top: -12px; cursor: ns-resize; }
.ie-crop i[data-h="s"] { left: calc(50% - 11px); bottom: -12px; cursor: ns-resize; }
.ie-crop i[data-h="w"] { top: calc(50% - 11px); left: -12px; cursor: ew-resize; }
.ie-crop i[data-h="e"] { top: calc(50% - 11px); right: -12px; cursor: ew-resize; }
.ie-side { overflow: auto; padding-right: 4px; }
.ie-side section { padding: 12px 0; border-bottom: 1px solid var(--line); }
.ie-side section:first-child { padding-top: 0; }
.ie-side h3 { font: 600 19px/1.2 var(--cond); margin: 0 0 8px; }
.ie-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 8px; }
.ie-btns .btn, .ie-side > section > .btn { min-height: 38px; padding: 6px 10px; font-size: 14px; }
.ie-side > section > .btn { width: 100%; margin-top: 6px; }
.ie-range { display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; font-size: 14px; margin: 6px 0; }
.ie-range output { color: var(--muted); font-variant-numeric: tabular-nums; }
.ie-range input { grid-column: 1 / -1; accent-color: var(--orange); width: 100%; }
.ie-check { display: flex; gap: 8px; align-items: center; font-size: 15px; margin-bottom: 6px; }
.ie-check input { accent-color: var(--orange); width: 18px; height: 18px; }
.ie-result { width: 100%; max-width: 220px; aspect-ratio: auto; display: block; margin: 8px auto 4px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.ie-small { font-size: 13px; text-align: center; margin: 0; }
.ie-field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); margin: 6px 0; }
.ie-field input { padding: 9px 10px; border: 1px solid var(--line); border-radius: 8px; font-size: 15px; color: var(--ink); width: 100%; }
.ie-file { display: flex; align-items: center; }
.ie-file input { border-radius: 8px 0 0 8px; }
.ie-file b { padding: 9px 10px; background: var(--bg); border: 1px solid var(--line); border-left: 0; border-radius: 0 8px 8px 0; font-weight: 500; color: var(--muted); }
.ie-foot { display: flex; align-items: center; gap: 8px; padding-top: 12px; }
.ie-foot span { flex: 1; font-size: 14px; }
.ie-ai { background: var(--orange-soft); margin: 0 -10px; padding: 12px 10px !important; border-radius: 10px; border-bottom: 0 !important; }
.ie-presets { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.ie-presets label { display: flex; gap: 8px; align-items: flex-start; font-size: 14px; line-height: 1.3; }
.ie-presets input { accent-color: var(--orange); width: 17px; height: 17px; flex: none; margin: 0; }
#ieAiCustom { width: 100%; padding: 8px 10px; border: 1px solid #F2C489; border-radius: 8px; font-size: 14px; resize: vertical; background: #fff; }
.ie-ai > .btn { width: 100%; margin: 8px 0 6px; }
.ie-ai .ie-small { text-align: left; }
.ie-compare { position: absolute; inset: 0; z-index: 3; background: var(--surface); display: flex; flex-direction: column; padding: 12px; gap: 10px; }
.ie-pair { flex: 1; min-height: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.ie-pair figure { margin: 0; min-height: 0; display: flex; flex-direction: column; gap: 6px; }
.ie-pair img { flex: 1; min-height: 0; width: 100%; object-fit: contain; background: #fff; border: 1px solid var(--line); border-radius: 10px; cursor: zoom-in; }
.ie-pair img.zoom { object-fit: cover; cursor: zoom-out; }
.ie-pair figcaption { font-weight: 600; font-size: 14px; text-align: center; }
.ie-warn { margin: 0; font-size: 14px; color: var(--orange-deep); text-align: center; font-weight: 600; }
.ie-compare-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.ie-busy { position: absolute; inset: 0; z-index: 4; background: rgba(255,255,255,.82); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; font-weight: 600; text-align: center; padding: 20px; }
.ie-busy .spin { width: 34px; height: 34px; border-width: 3px; }
.shot-open { display: block; width: 100%; aspect-ratio: 1; border: 0; padding: 0; cursor: pointer; background: #F7F6F4 center/contain no-repeat; position: relative; }
.badge.edited { left: auto; right: 6px; background: var(--ink); color: #fff; }
.shot-name { font-size: 12px; color: var(--muted); padding: 0 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.photo-tools { display: flex; gap: 8px; margin: -4px 0 12px; }
.photo-tools .btn { min-height: 36px; padding: 5px 10px; font-size: 14px; }

/* Modal + login */
.modal, .login { position: fixed; inset: 0; z-index: 20; background: rgba(35,24,15,.6); display: grid; place-items: center; padding: 16px; }
.login { background: var(--ink); }
.modal-card, .login-card { background: var(--surface); border-radius: 16px; padding: 20px; width: min(520px, 100%); }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.modal-head h2 { font: 700 26px/1 var(--cond); margin: 0; }
.video-wrap { position: relative; background: #000; border-radius: 10px; overflow: hidden; aspect-ratio: 4 / 3; }
.video-wrap video { width: 100%; height: 100%; object-fit: cover; }
.aim { position: absolute; inset: 30% 12%; border: 3px solid var(--orange); border-radius: 10px; box-shadow: 0 0 0 999px rgba(0,0,0,.25); }
.manual { display: flex; gap: 8px; margin-top: 10px; }
.manual input { flex: 1; padding: 10px 12px; border: 1px solid var(--line); border-radius: 9px; font-size: 18px; font-family: var(--cond); letter-spacing: .08em; }
.login-card { display: flex; flex-direction: column; gap: 10px; width: min(340px, 100%); align-items: stretch; }
.login-logo { height: 80px; width: auto; align-self: center; }
.login-card .brand { color: var(--ink); justify-content: center; margin-bottom: 10px; }
.login-card .brand span { color: var(--orange); }
.login-card input { padding: 12px; font-size: 22px; letter-spacing: .3em; border: 1px solid var(--line); border-radius: 9px; text-align: center; }
.err { color: var(--danger); min-height: 1.2em; margin: 0; font-size: 14px; }

.toast {
  position: fixed; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom)); transform: translate(-50%, 160%);
  background: var(--ink); color: #fff; padding: 11px 18px; border-radius: 9px; z-index: 30;
  transition: transform .2s; max-width: calc(100% - 32px); font-weight: 500;
}
.toast.show { transform: translate(-50%, 0); }
.toast.error { background: var(--danger); }

/* Tablet and phone: one pane at a time */
@media (max-width: 900px) {
  .top { flex-wrap: wrap; gap: 10px; padding-left: 12px; padding-right: 12px; }
  .top-actions { width: 100%; margin-left: 0; }
  .top-actions .btn.primary { flex: 1; }
  .tag { margin: 10px 12px 0; flex-wrap: wrap; }
  .tag-name { font-size: 28px; }
  .tag-progress, .canon { border-left: 0; border-top: 1px dashed #F2C489; width: auto; flex: 1 1 100%; }
  .shell { grid-template-columns: 1fr; padding: 10px 12px 12px; }
  .shell.editing .list-pane { display: none; }
  .shell:not(.editing) .editor { display: none; }
  .back { display: inline-block; }
  body.editing .tag-progress { display: none; }
  body.editing .tag { min-height: 0; }
  body.editing .tag-main { padding-top: 8px; padding-bottom: 8px; }
  .editor { padding: 0 14px 24px; }
}
@media (max-width: 1100px) {
  .nut-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .ie-body { grid-template-columns: 1fr; grid-template-rows: 46vh auto; }
  .ie-card { height: calc(100dvh - 24px); }
  .ie-side { overflow: visible; }
  .ie-body { overflow: auto; }
}
@media (max-width: 600px) {
  .nut-head, .nut-grid { grid-template-columns: 1fr 1fr; }
  .fields { grid-template-columns: 1fr 1fr; }
  .field.two { grid-column: 1 / -1; }
  .measure { flex-wrap: wrap; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
