/* Withdraw bot page: section cards, setting rows, typed controls, keyword chips, save footer */
.wd-search { width: 260px; }
.wd-search kbd {
  position: absolute; right: 9px; padding: 0 6px; border: 1px solid var(--border); border-radius: 5px;
  color: var(--faint); font: 11px/18px var(--mono); pointer-events: none;
}
.wd-search input:focus ~ kbd, .wd-search input:not(:placeholder-shown) ~ kbd { display: none; }
.wd-sections { display: flex; flex-direction: column; gap: 16px; }

/* ---------- section navigation: pill row under the header; a left rail from 1181px ---------- */
.wd-nav {
  position: sticky; top: var(--top-h); z-index: 6; display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none;
  margin: -8px -32px 14px; padding: 8px 32px; background: var(--bg); scroll-behavior: smooth;
}
.wd-nav::-webkit-scrollbar { display: none; }
.wd-nav button {
  flex: none; display: inline-flex; align-items: center; gap: 7px; padding: 6px 12px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface); color: var(--muted);
  font: 500 13px/1.3 inherit; font-family: inherit; white-space: nowrap; cursor: pointer;
  transition: color .15s, background .15s, border-color .15s; -webkit-tap-highlight-color: transparent;
}
.wd-nav button:hover { color: var(--text); }
.wd-nav button:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.wd-nav button[aria-current="true"] { color: var(--text); background: var(--surface-3); border-color: transparent; }
.wd-nav .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--warn); display: none; }
.wd-nav .dirty .dot { display: block; }
.wsec { scroll-margin-top: calc(var(--top-h) + 56px); }
@media (min-width: 1181px) {
  .wd-layout { display: grid; grid-template-columns: 168px minmax(0, 1fr); gap: 28px; align-items: start; }
  .wd-nav { top: calc(var(--top-h) + 20px); flex-direction: column; gap: 2px; margin: 0; padding: 0; overflow: visible; background: none; }
  .wd-nav button { justify-content: space-between; padding: 8px 12px; border-radius: 8px; border-color: transparent; background: transparent; }
  .wd-nav button:hover { background: var(--surface); }
  .wd-nav button[aria-current="true"] { background: var(--surface-2); box-shadow: inset 2px 0 0 var(--accent); }
  .wsec { scroll-margin-top: calc(var(--top-h) + 20px); }
}
.wd mark { background: transparent; color: inherit; text-decoration: underline 2px var(--accent); text-underline-offset: 3px; }

/* ---------- section card ---------- */
.wsec { padding: 0; overflow: hidden; overflow: clip; transition: border-color .2s; }
.wsec.saving { border-color: rgba(232, 176, 75, .35); }
.wsec > summary {
  display: flex; align-items: center; gap: 14px; padding: 18px 22px;
  list-style: none; cursor: pointer; user-select: none; -webkit-tap-highlight-color: transparent;
}
.wsec > summary::-webkit-details-marker { display: none; }
.wsec > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; border-radius: var(--radius); }
.wsec > summary:hover .chev { color: var(--text); }
.gicon {
  flex: none; display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px;
  background: rgba(138, 180, 255, .08); color: var(--accent); box-shadow: inset 0 0 0 1px rgba(138, 180, 255, .14);
}
.wsec[data-group="Buy orders"] .gicon, .wsec[data-group="Other"] .gicon, .wsec[data-group="System"] .gicon {
  background: var(--surface-2); color: var(--muted); box-shadow: inset 0 0 0 1px var(--border);
}
.g-text { flex: 1; min-width: 0; }
.g-text .note { color: var(--muted); font-size: 12.5px; margin-top: 1px; }
.chev { color: var(--faint); transition: transform .22s var(--ease), color .15s; }
.wsec[open] > summary .chev { transform: rotate(90deg); }
.wsec-body { padding: 0 22px 8px; }
.wsec[open] .wsec-body { animation: fade .2s ease-out both; }
.skel-card { padding: 20px 22px 8px; }
.skel-card .skel.row-line { margin: 18px 0; }

/* ---------- setting row ---------- */
.wrow {
  position: relative; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: 10px 32px;
  padding: 14px 0; border-top: 1px solid rgba(42, 46, 51, .6); transition: opacity .2s;
}
.wsec-body > .wrow:first-child, .kw-grid + .wrow { border-top-color: transparent; }
.wrow::before {
  content: ""; position: absolute; left: -22px; top: 12px; bottom: 12px; width: 2px; border-radius: 2px;
  background: var(--accent); transform: scaleY(0); transition: transform .18s var(--ease);
}
.wrow.dirty::before { transform: scaleY(1); }
.wrow.dimmed { opacity: .45; }
.wrow.flash { animation: flash .9s ease-out; }
.lbl { display: flex; align-items: center; gap: 6px; font-weight: 500; }
.lbl .ico { color: var(--faint); }
.help-btn {
  position: relative; display: inline-grid; place-items: center; width: 17px; height: 17px; padding: 0; border-radius: 50%;
  border: 1px solid var(--border); background: transparent; color: var(--muted); font: 500 10.5px/1 inherit; font-family: inherit;
  cursor: pointer; transition: color .15s, border-color .15s, background .15s; -webkit-tap-highlight-color: transparent;
}
.help-btn::after { content: ""; position: absolute; inset: -9px; } /* larger tap target */
.help-btn:hover { color: var(--text); border-color: var(--faint); }
.help-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.help-btn[aria-expanded="true"] { color: var(--accent); border-color: rgba(138, 180, 255, .4); background: rgba(138, 180, 255, .08); }
.wrow .desc, .kw-col .desc { color: var(--muted); font-size: 12.5px; line-height: 1.45; margin-top: 2px; }
.help {
  margin-top: 8px; padding: 8px 10px; max-width: 520px; border-radius: 8px; background: var(--surface-2);
  color: var(--muted); font-size: 12.5px; line-height: 1.5; animation: fade .18s ease-out both;
}
.reason { color: var(--faint); font-size: 12px; margin-top: 4px; }
.wctl { min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
.ctl-line { display: flex; align-items: center; gap: 6px; width: 100%; }
.ctl-line > .txt-ctl { flex: 1; min-width: 0; }
.ro-val { color: var(--muted); font-family: var(--mono); font-size: 12.5px; overflow-wrap: anywhere; padding-top: 2px; }
.was { color: var(--faint); font-size: 12px; text-decoration: line-through; text-decoration-color: rgba(93, 98, 106, .7); }
.was:empty, .row-msg:empty, .saved-note:empty { display: none; }
.row-msg { font-size: 12.5px; line-height: 1.4; }
.row-msg.err { color: var(--neg); }
.row-msg.warn { color: var(--warn); }
.saved-note { color: var(--pos); font-size: 12px; }
.saved-note.fade { animation: saved-fade 10s linear forwards; }
@keyframes saved-fade { 0%, 85% { opacity: 1; } 100% { opacity: 0; visibility: hidden; } }
.revert { width: 28px; height: 28px; }

/* number with unit + stepper */
.num-ctl { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.stepper { display: flex; align-items: stretch; border: 1px solid var(--border); border-radius: 9px; background: var(--bg); transition: border-color .15s, box-shadow .15s; }
.stepper:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(138, 180, 255, .15); }
.stepper .step {
  width: 34px; border: 0; background: transparent; color: var(--muted); font: 500 16px/1 inherit; font-family: inherit;
  cursor: pointer; transition: background .15s, color .15s; -webkit-tap-highlight-color: transparent;
}
.stepper .step:first-child { border-radius: 8px 0 0 8px; border-right: 1px solid var(--border); }
.stepper .step:last-child { border-radius: 0 8px 8px 0; border-left: 1px solid var(--border); }
.stepper .step:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
.stepper .step:disabled { opacity: .4; cursor: default; }
.unit-field { display: flex; align-items: center; gap: 4px; padding: 0 10px; cursor: text; }
.unit-field input { width: 84px; border: 0; background: transparent; padding: 8px 0; text-align: right; font-variant-numeric: tabular-nums; box-shadow: none; }
.unit-field input:focus { box-shadow: none; }
.unit-field .pre, .unit-field .suf { color: var(--faint); font-size: 13px; white-space: nowrap; }
.null-pill {
  padding: 5px 11px; border-radius: 999px; border: 1px dashed var(--border); background: transparent;
  color: var(--muted); font: 12.5px/1.3 inherit; font-family: inherit; cursor: pointer; transition: all .15s;
}
.null-pill:hover { color: var(--text); border-color: var(--faint); }
.null-pill[aria-pressed="true"] { border-style: solid; border-color: rgba(138, 180, 255, .35); color: var(--accent); background: rgba(138, 180, 255, .08); }
.null-pill:focus-visible, .switch:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* toggle switch */
.tog { display: flex; align-items: center; gap: 10px; }
.switch {
  position: relative; width: 40px; height: 24px; flex: none; padding: 0; border: 0; border-radius: 999px;
  background: var(--surface-3); cursor: pointer; transition: background .2s; -webkit-tap-highlight-color: transparent;
}
.switch .knob {
  position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%;
  background: #c9ccd1; box-shadow: 0 1px 3px rgba(0, 0, 0, .4); transition: transform .22s var(--ease), background .2s;
}
.switch[aria-checked="true"] { background: rgba(62, 207, 142, .55); }
.switch[aria-checked="true"] .knob { transform: translateX(16px); background: #fff; }
.switch:disabled { opacity: .5; cursor: default; }
.sw-text { color: var(--muted); font-size: 13px; min-width: 24px; }

.txt-ctl { display: flex; flex-direction: column; gap: 6px; width: 100%; }
.txt-ctl input { width: 100%; max-width: 420px; }
.fmt-note { color: var(--faint); font-size: 12px; }
/* price sources: market name + modifier % per row */
.src-ctl { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; }
.src-rows { display: flex; flex-direction: column; gap: 6px; }
.src-rows:empty { display: none; }
.src-row { display: flex; align-items: center; gap: 6px; }
.src-name { width: 190px; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.src-mod { border: 1px solid var(--border); border-radius: 9px; background: var(--bg); transition: border-color .15s, box-shadow .15s; }
.src-mod:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(138, 180, 255, .15); }
.src-mod input { width: 52px; }

/* ---------- keywords ---------- */
.kw-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; padding: 2px 0 18px; }
.kw-col { background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 16px; min-width: 0; display: flex; flex-direction: column; }
.kw-head { display: flex; align-items: center; gap: 8px; }
.kw-head h3 { font-size: 14px; }
.kw-head .ico { color: var(--faint); margin-left: auto; }
.kw-head .help-btn { margin-left: 2px; }
.kw-count { padding: 0 7px; border-radius: 999px; background: var(--surface-2); color: var(--muted); font-size: 12px; line-height: 19px; font-variant-numeric: tabular-nums; }
.kw-list { margin-top: 12px; gap: 6px; }
.kw-empty { color: var(--faint); font-size: 12.5px; }
.kw { padding-right: 3px; color: var(--text); background: var(--surface); animation: pop .18s var(--ease) both; }
.kw.and .plus { color: var(--faint); padding: 0 1px; }
.kw.and.info { color: var(--accent); }
.kw.pending { border-style: dashed; opacity: .8; }
.kw.fresh { animation: pop .18s var(--ease) both, flash 1.2s ease-out; }
.kw.pulse { animation: kw-pulse .5s ease-in-out 2; }
@keyframes kw-pulse { 50% { box-shadow: 0 0 0 3px rgba(232, 176, 75, .35); border-color: var(--warn); } }
.kw button {
  display: inline-grid; place-items: center; width: 18px; height: 18px; padding: 0;
  border: 0; border-radius: 50%; background: transparent; color: var(--muted); cursor: pointer;
  transition: background .15s, color .15s;
}
.kw button:hover { background: rgba(240, 97, 109, .15); color: var(--neg); }
.kw button:disabled { opacity: .4; cursor: default; }
.kw.gone { animation: chip-out .16s var(--ease) forwards; }
.kw-add { margin-top: auto; padding-top: 14px; }
.kw-add input { width: 100%; }
.kw-tip { color: var(--faint); font-size: 11.5px; margin-top: 6px; }
.kw-hint { color: var(--warn); font-size: 12.5px; }
.kw-hint:empty, .kw-status:empty { display: none; }
.kw-hint, .kw-status { margin-top: 8px; }
.kw-status { display: flex; align-items: center; gap: 10px; font-size: 12.5px; flex-wrap: wrap; }
.kw-status .saving-note { margin: 0; }
.kw-status .link-btn { padding: 0; border: 0; background: none; color: var(--accent); font: inherit; cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.saving-note { display: flex; align-items: center; gap: 8px; color: var(--warn); font-size: 12.5px; }
.saving-note::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; animation: pulse 1.2s ease-in-out infinite; flex: none; }

/* ---------- section footer: unsaved / saving ---------- */
.wsec-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 12px 20px; flex-wrap: wrap;
  padding: 14px 22px; border-top: 1px solid var(--border); background: rgba(138, 180, 255, .035);
  animation: foot-in .18s var(--ease) both;
}
.wsec.saving .wsec-foot { background: rgba(232, 176, 75, .05); }
.wsec-foot.failed { background: rgba(240, 97, 109, .05); }
@keyframes foot-in { from { opacity: 0; transform: translateY(6px); } }
.foot-left { min-width: 0; flex: 1 1 260px; }
.foot-msg { font-weight: 500; }
.wsec.saving .foot-msg { color: var(--warn); }
.foot-sub { color: var(--muted); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.foot-btns { display: flex; gap: 8px; }
.wbar { position: relative; height: 3px; margin-top: 8px; border-radius: 3px; background: var(--surface-3); overflow: hidden; max-width: 420px; }
.wbar span { position: absolute; inset: 0 auto 0 0; background: var(--warn); border-radius: 3px; transition: width .4s var(--ease); }
.wbar::after {
  content: ""; position: absolute; inset: 0; width: 40%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .18), transparent);
  animation: wbar-run 1.6s linear infinite;
}
@keyframes wbar-run { from { transform: translateX(-100%); } to { transform: translateX(250%); } }

/* save confirm: old -> new */
.wd-diff { display: grid; grid-template-columns: auto auto auto auto; gap: 8px 10px; align-items: baseline; padding: 12px 14px; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; }
.wd-diff .d-row { display: contents; }
.wd-diff .d-label { color: var(--muted); }
.wd-diff .d-old { color: var(--faint); text-decoration: line-through; font-variant-numeric: tabular-nums; }
.wd-diff .d-arrow { color: var(--faint); }
.wd-diff .d-new { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.wd-diff span { overflow-wrap: anywhere; }

/* undo toast (local undoToast) */
.toast.wd-undo { display: flex; align-items: center; gap: 12px; }
.toast.wd-undo .btn { margin: -4px -6px -4px auto; color: var(--accent); }

@media (max-width: 1000px) {
  .wd-nav { margin: -8px -20px 14px; padding: 8px 20px; }
}
@media (max-width: 900px) {
  .wrow { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  .kw-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 720px) {
  .wd-nav { top: 0; margin: -6px -16px 10px; padding: 8px 16px; }
  .wd-nav button { min-height: 36px; padding: 6px 14px; }
  .wsec { scroll-margin-top: 58px; }
  .wd-sections { gap: 12px; }
  .wd-search { width: auto; flex: 1 1 200px; }
  .wd-search kbd { display: none; }
  .wsec > summary { padding: 12px 16px; gap: 12px; }
  .gicon { width: 32px; height: 32px; }
  .wsec-body { padding: 0 16px 4px; }
  .wrow::before { left: -16px; }
  .wrow { padding: 12px 0; gap: 8px; }
  /* a switch sits beside its label instead of on its own line */
  .wrow:has(.tog) { grid-template-columns: minmax(0, 1fr) fit-content(45%); column-gap: 14px; align-items: start; }
  .wrow:has(.tog) .sw-text { display: none; }
  .wrow:has(.tog) .wctl { align-items: flex-end; text-align: right; }
  .ctl-line > .num-ctl { flex: 1; min-width: 0; }
  .stepper { flex: 1 1 100%; max-width: 280px; }
  .stepper .unit-field { flex: 1; }
  .stepper .step { width: 44px; }
  .unit-field input { width: 72px; min-height: 40px; flex: 1; min-width: 0; }
  .src-ctl, .src-rows { width: 100%; }
  .src-name { flex: 1; width: auto; }
  .src-mod input { flex: none; width: 48px; }
  .kw-grid { gap: 12px; padding-bottom: 12px; }
  .kw-col { padding: 12px; }
  .kw-list { margin-top: 10px; }
  .kw-add { padding-top: 10px; }
  .chip.kw { line-height: 28px; padding-left: 11px; }
  .kw button { position: relative; width: 28px; height: 28px; }
  .wsec-foot { padding: 12px 16px; position: sticky; bottom: calc(64px + env(safe-area-inset-bottom)); z-index: 5; background: var(--surface-2); }
  .foot-btns { width: 100%; }
  .foot-btns .btn { flex: 1; }
  .null-pill { min-height: 36px; }
  .revert { width: 40px; height: 40px; }
  .wd-diff { grid-template-columns: minmax(0, 1fr) auto auto auto; font-size: 13px; }
}
