/* Components. Hierarchy of radii: controls 7, cards 10, panels/sheets 14+, pills 999. */

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 36px; padding: 0 14px;
  border: 1px solid transparent; border-radius: var(--r-sm);
  background: none; font-weight: 500; font-size: var(--fs-13); letter-spacing: -0.005em;
  white-space: nowrap; user-select: none;
  transition: background-color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease), transform var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
.btn:active:not(:disabled) { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: default; }
.btn-sm { height: 32px; padding: 0 11px; gap: 6px; }
.btn-block { width: 100%; }
.btn-primary { background: var(--ink); color: var(--bg); box-shadow: var(--shadow-1); }
.btn-primary:hover { background: color-mix(in oklab, var(--ink) 86%, var(--accent)); }
.btn-secondary { background: var(--surface); border-color: var(--line-strong); box-shadow: var(--shadow-1), var(--inset-hi); }
.btn-secondary:hover { background: var(--well); }
.btn-quiet { color: var(--ink-2); }
.btn-quiet:hover { background: var(--hover); color: var(--ink); }
.btn-danger:hover { color: #B3261E; background: color-mix(in oklab, #B3261E 8%, transparent); }
:root[data-theme='dark'] .btn-danger:hover { color: #F08A80; }
.btn kbd { margin-left: auto; }

.icon-btn {
  display: inline-grid; place-items: center;
  width: 36px; height: 36px; flex: none;
  border: 0; border-radius: var(--r-sm); background: none; color: var(--ink-2);
  transition: background-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease), transform var(--t-fast) var(--ease), opacity var(--t-fast);
}
.icon-btn:hover:not(:disabled) { background: var(--hover); color: var(--ink); }
.icon-btn:active:not(:disabled) { transform: scale(.92); }
.icon-btn:disabled { opacity: .32; cursor: default; }
.icon-btn.on { color: var(--accent-text); background: var(--accent-soft); }

kbd {
  display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 5px;
  border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 5px;
  font: 500 11px/1 var(--font-sans); color: var(--muted); background: var(--surface);
}

/* ---------- segmented ---------- */
.seg {
  position: relative; display: inline-flex; align-items: stretch; flex: none;
  padding: 3px; gap: 0; border-radius: 9px;
  background: var(--well-2);
  box-shadow: inset 0 0 0 1px var(--line);
}
.seg-thumb {
  position: absolute; top: 3px; bottom: 3px; left: 0; width: 0;
  border-radius: 6px; background: var(--surface);
  box-shadow: 0 1px 2px rgba(40,30,20,.12), 0 0 0 1px var(--line), var(--inset-hi);
  transition: transform var(--t-med) var(--spring), width var(--t-med) var(--spring);
}
:root[data-theme='dark'] .seg-thumb { background: color-mix(in oklab, var(--ink) 13%, var(--surface)); }
.seg-btn {
  position: relative; z-index: 1;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 30px; padding: 0 12px; border: 0; border-radius: 6px; background: none;
  color: var(--muted); font-weight: 500; font-size: var(--fs-13); white-space: nowrap;
  transition: color var(--t-fast) var(--ease);
}
.seg-btn:hover { color: var(--ink); }
.seg-btn[aria-checked='true'] { color: var(--ink); }
.seg-sm .seg-btn { height: 26px; padding: 0 9px; font-size: var(--fs-12); }
.seg-sm .seg-btn:has(.ico):not(:has(span)) { width: 30px; padding: 0; }

/* ---------- menu ---------- */
.menu {
  position: fixed; z-index: 60; min-width: 236px; max-width: calc(100vw - 16px);
  padding: 5px; border-radius: 12px;
  background: color-mix(in oklab, var(--surface) 96%, transparent);
  backdrop-filter: blur(24px) saturate(1.5); -webkit-backdrop-filter: blur(24px) saturate(1.5);
  border: 1px solid var(--glass-line); box-shadow: var(--shadow-3);
  opacity: 0; transform: scale(.96) translateY(-4px);
  transition: opacity var(--t-fast) var(--ease), transform var(--t-med) var(--spring);
}
.menu.in { opacity: 1; transform: none; }
.menu-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  min-height: 36px; padding: 6px 10px; border: 0; border-radius: 8px; background: none; text-align: left;
  font-size: var(--fs-13); color: var(--ink);
}
.menu-item:hover, .menu-item:focus-visible { background: var(--hover); box-shadow: none; }
.menu-item .ico { color: var(--muted); flex: none; }
.menu-item > .ico:last-child { margin-left: auto; color: var(--accent-text); }
.menu-text { display: flex; flex-direction: column; line-height: 1.3; flex: 1; min-width: 0; }
.menu-text small { color: var(--muted); font-size: var(--fs-12); }
.menu-ico-gap { width: 17px; flex: none; }
.menu-sep { height: 1px; margin: 5px 6px; background: var(--line); }
.menu-label { padding: 8px 10px 4px; font-size: var(--fs-12); color: var(--muted); }
.menu-swatch { width: 22px; height: 22px; flex: none; }

/* ---------- topbar specifics ---------- */
.pn { position: relative; display: flex; align-items: center; min-width: 0; flex: 0 1 auto; color: var(--muted); }
.project-name {
  min-width: 60px; max-width: 100%; height: 32px; padding: 0 22px 0 8px;
  border: 1px solid transparent; border-radius: var(--r-sm); background: none;
  font-weight: 500; font-size: var(--fs-14); letter-spacing: -0.01em; color: var(--ink);
  text-overflow: ellipsis;
  transition: background-color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
}
.project-name:hover { background: var(--hover); }
.project-name:focus { background: var(--surface); border-color: var(--line-strong); box-shadow: var(--focus); }
.pn .ico { position: absolute; right: 7px; pointer-events: none; opacity: 0; transition: opacity var(--t-fast); }
.pn:hover .ico { opacity: .7; }
.pn-sizer { position: absolute; visibility: hidden; white-space: pre; font-weight: 500; font-size: var(--fs-14); letter-spacing: -0.01em; }
.tb-collapse .seg { margin-right: 4px; }
.export-btn { margin-left: 4px; }
.drawer-btn { display: none; }
@media (min-width: 760px) and (max-width: 1099.98px) and (orientation: landscape) { .drawer-btn { display: inline-grid; } }
@media (max-width: 759.98px) { .tb-export { display: none; } }

/* ---------- collapsible sections ---------- */
.sec { border-top: 1px solid var(--line); }
.sec-head { display: flex; align-items: center; padding: 0 10px 0 6px; }
.sec-toggle {
  flex: 1; display: flex; align-items: center; gap: 8px; min-height: 48px; padding: 0 8px 0 12px;
  border: 0; background: none; text-align: left; border-radius: var(--r-sm);
}
.sec-title { font-weight: 600; font-size: var(--fs-13); letter-spacing: -0.01em; }
.sec-meta { margin-left: auto; color: var(--muted); font-size: var(--fs-12); font-variant-numeric: tabular-nums; }
.sec-toggle .ico { color: var(--faint); transition: transform var(--t-med) var(--spring); }
.sec[data-open='false'] .sec-toggle .ico { transform: rotate(-90deg); }
.sec-body { display: grid; grid-template-rows: 1fr; transition: grid-template-rows var(--t-med) var(--ease), opacity var(--t-med) var(--ease); }
.sec[data-open='false'] .sec-body { grid-template-rows: 0fr; opacity: 0; }
.sec-inner { min-height: 0; overflow: hidden; padding: 0 18px 18px; }
.sec[data-open='false'] .sec-inner { padding-bottom: 0; }
.sec-note { margin: 10px 0 0; font-size: var(--fs-12); color: var(--muted); line-height: 1.5; text-wrap: pretty; }

/* ---------- fields ---------- */
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.field { min-width: 0; }
.field-label { display: block; font-size: var(--fs-12); color: var(--muted); margin: 0 0 6px 1px; }
.field-box, .stepper {
  display: flex; align-items: center; height: 38px;
  border: 1px solid var(--line-strong); border-radius: var(--r-sm); background: var(--surface);
  box-shadow: var(--inset-hi);
  transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
.field-box:hover, .stepper:hover { border-color: color-mix(in oklab, var(--ink) 26%, transparent); }
.field-box:focus-within, .stepper:focus-within { border-color: var(--accent-line); box-shadow: 0 0 0 3px var(--accent-soft); }
.field-input, .stepper-input {
  flex: 1; min-width: 0; width: 100%; height: 100%; border: 0; background: none; text-align: center;
  font-size: var(--fs-14); padding: 0 2px;
}
.field-input:focus-visible, .stepper-input:focus-visible { box-shadow: none; }
.step-btn {
  display: grid; place-items: center; flex: none; width: 30px; height: 100%; border: 0; background: none;
  color: var(--muted); border-radius: 6px; touch-action: manipulation;
  transition: color var(--t-fast), background-color var(--t-fast);
}
.step-btn:hover { color: var(--ink); background: var(--hover); }
.step-btn:active { background: var(--press); }
.field-hint { min-height: 0; font-size: var(--fs-12); color: var(--muted); margin-top: 6px; }
.field-hint:empty { display: none; }
.field.bad .field-box { border-color: #C2410C; animation: shake 360ms var(--ease); }
.field.bad .field-hint { color: #B4401A; }
:root[data-theme='dark'] .field.bad .field-hint { color: #F0A07A; }
@keyframes shake { 20%, 60% { transform: translateX(-4px); } 40%, 80% { transform: translateX(4px); } }

.stepper { width: 112px; flex: none; }
.stepper-sm { height: 34px; width: 92px; }
.stepper-sm .step-btn { width: 26px; }
.stepper.tick .stepper-input { animation: tick 240ms var(--ease); }
@keyframes tick { 40% { transform: translateY(-1.5px); color: var(--accent-text); } }

.select {
  appearance: none; height: 34px; width: 100%; padding: 0 30px 0 10px;
  border: 1px solid var(--line-strong); border-radius: var(--r-sm); font-size: var(--fs-13);
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='%236E685F' stroke-width='1.5' stroke-linecap='round'%3E%3Cpath d='M6 8l4 4 4-4'/%3E%3C/svg%3E") no-repeat right 8px center / 16px;
}
.select:focus-visible { border-color: var(--accent-line); box-shadow: 0 0 0 3px var(--accent-soft); border-radius: var(--r-sm); }

/* switch */
.switch { position: relative; display: inline-flex; flex: none; width: 36px; height: 22px; }
.switch-sm { width: 30px; height: 18px; }
.switch-input { position: absolute; inset: -11px -4px; width: calc(100% + 8px); height: calc(100% + 22px); margin: 0; opacity: 0; cursor: pointer; z-index: 1; }
.switch-track { position: absolute; inset: 0; border-radius: 999px; background: var(--well-2); box-shadow: inset 0 0 0 1px var(--line-strong); transition: background-color var(--t-med) var(--ease); }
.switch-knob { position: absolute; top: 2px; left: 2px; width: calc(22px - 4px); height: calc(22px - 4px); border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.2), 0 2px 6px -1px rgba(0,0,0,.15); transition: transform var(--t-med) var(--spring); }
.switch-sm .switch-knob { width: 14px; height: 14px; }
.switch-input:checked + .switch-track { background: var(--accent); box-shadow: none; }
.switch-input:checked + .switch-track .switch-knob { transform: translateX(14px); }
.switch-sm .switch-input:checked + .switch-track .switch-knob { transform: translateX(12px); }
.switch-input:focus-visible + .switch-track { box-shadow: var(--focus); }

/* range */
.range-wrap { display: flex; align-items: center; gap: 14px; }
.range { --k: .5; flex: 1; appearance: none; height: 24px; background: none; margin: 0; cursor: pointer; }
.range::-webkit-slider-runnable-track { height: 4px; border-radius: 4px; background: linear-gradient(90deg, var(--ink) calc(var(--k) * 100%), var(--well-2) 0); box-shadow: inset 0 0 0 1px var(--line); }
.range::-moz-range-track { height: 4px; border-radius: 4px; background: linear-gradient(90deg, var(--ink) calc(var(--k) * 100%), var(--well-2) 0); }
.range::-webkit-slider-thumb { appearance: none; width: 18px; height: 18px; margin-top: -7px; border-radius: 50%; background: #fff; border: 0; box-shadow: 0 0 0 1px rgba(0,0,0,.08), 0 1px 3px rgba(0,0,0,.2), 0 4px 10px -2px rgba(0,0,0,.18); transition: transform var(--t-fast) var(--spring); }
.range::-moz-range-thumb { width: 18px; height: 18px; border-radius: 50%; background: #fff; border: 0; box-shadow: 0 0 0 1px rgba(0,0,0,.08), 0 1px 3px rgba(0,0,0,.2); }
.range:active::-webkit-slider-thumb { transform: scale(1.15); }
.range:focus-visible { box-shadow: none; }
.range:focus-visible::-webkit-slider-thumb { box-shadow: var(--focus); }
.range-out { min-width: 74px; text-align: right; font-size: var(--fs-13); color: var(--ink-2); }

/* ---------- summary: the space strip ---------- */
.summary { padding: 4px 18px 20px; }
.cov-head { margin: 0 0 14px; display: grid; gap: 6px; }
.cov-big { display: flex; align-items: baseline; gap: 8px; }
.cov-pct { font-family: var(--font-serif); font-style: italic; font-size: 44px; line-height: .95; letter-spacing: -0.02em; color: var(--ink); }
.cov-pct .num { font-family: inherit; letter-spacing: inherit; }
.cov-of { font-size: var(--fs-13); color: var(--muted); }
.cov-line { font-size: var(--fs-14); color: var(--ink-2); line-height: 1.45; text-wrap: pretty; }
.cov-line strong { font-weight: 600; color: var(--ink); }
.cov-line strong .num, .cov-total .num { font-family: var(--font-sans); font-variant-numeric: tabular-nums; letter-spacing: 0; }
.strip { margin: 0; }
.strip-cap { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); margin: 0 1px 5px; }
.strip-frame { position: relative; border-radius: 3px; overflow: hidden; box-shadow: 0 0 0 1px var(--line-strong), var(--shadow-1); line-height: 0; }
.strip-canvas { display: block; }
.legend { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 5px; font-size: var(--fs-12); }
.legend li { display: grid; grid-template-columns: 10px 1fr auto; align-items: center; gap: 8px; color: var(--ink-2); }
.legend i { width: 10px; height: 10px; border-radius: 2px; box-shadow: inset 0 0 0 1px rgba(0,0,0,.12); }
.legend .num { color: var(--muted); font-size: var(--fs-12); }
.lg-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cov-explain { margin: 14px 0 0; padding: 12px 14px; border-radius: var(--r-md); background: var(--well); font-size: var(--fs-13); line-height: 1.55; color: var(--ink-2); text-wrap: pretty; }
.cov-explain strong { color: var(--ink); font-weight: 600; font-family: var(--font-sans); }
.summary[data-state='over'] .cov-explain { background: var(--accent-soft); }

/* ground textures for small swatches */
[data-ground] { background-color: #B9B2A6; }
[data-ground='gravel'] { background: radial-gradient(circle at 30% 40%, #8F887C 0 1px, transparent 1.5px) 0 0/5px 5px, radial-gradient(circle at 70% 70%, #D8D2C6 0 1px, transparent 1.5px) 0 0/4px 4px, #B9B2A6; }
[data-ground='river-rock'] { background: radial-gradient(circle at 40% 40%, #C8C1B4 0 2px, transparent 2.5px) 0 0/7px 7px, radial-gradient(circle at 60% 60%, #7E776B 0 1.5px, transparent 2px) 2px 3px/6px 6px, #A39C90; }
[data-ground='mulch'] { background: linear-gradient(30deg, transparent 45%, #8A6346 45% 55%, transparent 55%) 0 0/6px 4px, #6E4D36; }
[data-ground='grass'] { background: linear-gradient(80deg, transparent 45%, #86A066 45% 55%, transparent 55%) 0 0/3px 5px, #6F8A55; }
[data-ground='sand'] { background: radial-gradient(circle, #C9B892 0 .6px, transparent 1px) 0 0/3px 3px, #D8C9A6; }
[data-ground='soil'] { background: radial-gradient(circle, #6D5645 0 1px, transparent 1.5px) 0 0/4px 4px, #5B4636; }

/* ---------- pieces ---------- */
.pc-list { display: grid; gap: 8px; }
.pc {
  border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface);
  box-shadow: var(--shadow-1);
  transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-med) var(--ease), opacity var(--t-med) var(--ease), transform var(--t-med) var(--spring);
}
.pc:hover { border-color: var(--line-strong); }
.pc[data-open='true'] { box-shadow: var(--shadow-2); border-color: var(--line-strong); }
.pc.enter { opacity: 0; transform: translateY(6px) scale(.98); }
.pc.leave { opacity: 0; transform: scale(.97); pointer-events: none; }
.pc.is-zero .pc-swatch { opacity: .4; }
.pc-row {
  display: grid; grid-template-columns: 48px minmax(0, 1fr) auto 32px;
  grid-template-areas: 'sw name name more' 'sw sub qty more';
  align-items: center; column-gap: 10px; row-gap: 2px; padding: 9px 6px 9px 9px;
}
.pc-swatch { grid-area: sw; align-self: center; }
.pc-id { display: contents; }
.pc-name { grid-area: name; }
.pc-sub { grid-area: sub; }
.pc-row .stepper { grid-area: qty; }
.pc-more { grid-area: more; }
.pc-swatch { width: 48px; height: 48px; border-radius: 8px; background: var(--well); }
.pc-id { min-width: 0; }
.pc-name {
  display: block; width: 100%; height: 24px; margin-left: -5px; padding: 0 5px; border: 0; border-radius: 5px; background: none;
  font-weight: 550; font-size: var(--fs-14); letter-spacing: -0.01em; text-overflow: ellipsis;
}
.pc-name:hover { background: var(--hover); }
.pc-name:focus { background: var(--well); box-shadow: var(--focus); }
.pc-sub { display: flex; gap: 8px; font-size: var(--fs-12); color: var(--muted); white-space: nowrap; overflow: hidden; min-width: 0; }
.pc-sub span:first-child { flex: none; }
.pc-sub span + span { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.pc-sub span + span::before { content: ''; display: inline-block; width: 3px; height: 3px; margin: 0 8px 2px 0; border-radius: 1px; background: var(--faint); vertical-align: middle; }
.pc-more { width: 32px; height: 32px; }
.pc-more .ico { transition: transform var(--t-med) var(--spring); }
.pc[data-open='true'] .pc-more .ico { transform: rotate(180deg); }
.pc-edit { display: grid; grid-template-rows: 0fr; transition: grid-template-rows var(--t-med) var(--ease); }
.pc-edit[data-open='true'] { grid-template-rows: 1fr; }
.pc-edit-inner { min-height: 0; overflow: hidden; }
.pc-edit[data-open='true'] .pc-edit-inner { overflow: visible; }
.pc-grid { display: grid; grid-template-columns: 70px minmax(0, 1fr); align-items: center; gap: 12px 10px; padding: 12px 12px 4px; border-top: 1px solid var(--line); margin: 0 0 0; }
.pc-k { font-size: var(--fs-12); color: var(--muted); }
.pc-dims { display: flex; align-items: center; gap: 6px; }
.pc-dim { width: 64px; flex: none; height: 34px; border: 1px solid var(--line-strong); border-radius: var(--r-sm); background: var(--surface); }
.pc-dim:focus { border-color: var(--accent-line); box-shadow: 0 0 0 3px var(--accent-soft); }
.pc-dim.bad { border-color: #C2410C; animation: shake 360ms var(--ease); }
.pc-x, .pc-unit { color: var(--muted); font-size: var(--fs-13); }
.pc-rot { display: flex; align-items: center; gap: 9px; font-size: var(--fs-13); color: var(--ink-2); cursor: pointer; }
.pc-actions { display: flex; justify-content: flex-end; gap: 4px; padding: 8px 8px 8px; }
.pc-add { margin-top: 10px; }
.add-btn { width: 100%; height: 40px; border: 1px dashed var(--line-strong); border-radius: var(--r-md); color: var(--ink-2); }
.add-btn:hover { border-style: solid; background: var(--well); }

.swatch-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.swatches { display: contents; }
.sw {
  --c: #999; position: relative; width: 24px; height: 24px; flex: none; border: 0; padding: 0; border-radius: 6px;
  background: var(--c); box-shadow: inset 0 0 0 1px rgba(0,0,0,.14), inset 0 1px 0 rgba(255,255,255,.18);
  transition: transform var(--t-fast) var(--spring), box-shadow var(--t-fast);
}
.sw:hover { transform: scale(1.08); }
.sw.on { box-shadow: 0 0 0 2px var(--surface), 0 0 0 3.5px var(--ink), inset 0 0 0 1px rgba(0,0,0,.14); }
.sw-custom { display: grid; place-items: center; cursor: pointer; background: conic-gradient(from 0deg, #c96, #9a4, #4a9, #49c, #a6c, #c66, #c96); color: #fff; }
.sw-custom.on { background: var(--c); }
.sw-custom .ico { filter: drop-shadow(0 1px 1px rgba(0,0,0,.4)); }
.sw-custom:focus-within { box-shadow: var(--focus); }
.color-input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer; border: 0; padding: 0; }

/* ground chips */
.chips { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.chip {
  display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 6px 8px 6px 6px;
  border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); text-align: left;
  font-size: var(--fs-13); color: var(--ink-2);
  transition: border-color var(--t-fast), background-color var(--t-fast), box-shadow var(--t-fast);
}
.chip:hover { border-color: var(--line-strong); color: var(--ink); }
.chip[aria-checked='true'] { border-color: var(--ink); color: var(--ink); box-shadow: inset 0 0 0 .5px var(--ink); }
.chip-tex { width: 28px; height: 28px; border-radius: 6px; flex: none; box-shadow: inset 0 0 0 1px rgba(0,0,0,.1); }
.chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fill-need { margin: 12px 0 0; font-size: var(--fs-13); color: var(--ink-2); line-height: 1.5; text-wrap: pretty; }
.fill-need strong { font-weight: 600; color: var(--ink); }

/* ---------- empty states ---------- */
.empty { padding: 18px 4px 6px; }
.empty-title { margin: 0 0 6px; font-family: var(--font-serif); font-style: italic; font-size: 24px; line-height: 1.15; color: var(--ink); }
.empty-body { margin: 0; font-size: var(--fs-13); color: var(--muted); line-height: 1.55; max-width: 36ch; }

/* ---------- panel foot & version ---------- */
.ver {
  display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px;
  border: 1px solid var(--line); border-radius: 999px; background: none; color: var(--muted); font-size: 11.5px;
  transition: color var(--t-fast), border-color var(--t-fast), background-color var(--t-fast);
}
.ver:hover { color: var(--ink); border-color: var(--line-strong); background: var(--well); }
.ver-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.foot-saved { flex: 1; font-size: 11.5px; color: var(--faint); text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- rail ---------- */
.rail { display: grid; grid-template-columns: auto minmax(0, 1fr); height: 100%; }
.rail-head { display: flex; flex-direction: column; justify-content: space-between; align-items: flex-start; gap: 8px; padding: 16px 14px 16px 18px; border-right: 1px solid var(--line); width: 128px; }
.rail-title { display: flex; align-items: baseline; gap: 6px; font-weight: 600; font-size: var(--fs-13); }
.rail-count { color: var(--muted); font-weight: 400; font-variant-numeric: tabular-nums; }
.rail-head .shuffle-btn { margin-left: -11px; }
.rail-scroll { position: relative; min-width: 0; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; scroll-snap-type: x proximity; scroll-padding: 0 16px; mask-image: linear-gradient(90deg, transparent, #000 12px, #000 calc(100% - 28px), transparent); }
.rail-scroll::-webkit-scrollbar { display: none; }
.rail-list { display: grid; grid-auto-flow: column; grid-auto-columns: 228px; gap: 10px; padding: 14px 28px 14px 14px; height: 100%; }
.rail-list:empty { display: none; }
.rail-empty { padding: 22px 24px; }
.lc {
  position: relative; display: flex; flex-direction: column; min-width: 0;
  border-radius: var(--r-md); background: var(--surface); cursor: pointer; scroll-snap-align: start;
  box-shadow: 0 0 0 1px var(--line), var(--shadow-1);
  transition: box-shadow var(--t-med) var(--ease), transform var(--t-med) var(--spring), background-color var(--t-fast);
  outline: none;
}
.lc:hover { box-shadow: 0 0 0 1px var(--line-strong), var(--shadow-2); transform: translateY(-1px); }
.lc[aria-selected='true'] { box-shadow: 0 0 0 1.5px var(--accent), 0 0 0 5px var(--accent-soft), var(--shadow-2); }
.lc:focus-visible { box-shadow: 0 0 0 1.5px var(--accent), var(--focus); border-radius: var(--r-md); }
.lc-thumb { position: relative; flex: 1; min-height: 46px; margin: 5px 5px 0; border-radius: 7px; background: var(--well); overflow: hidden; }
.lc-plan { position: absolute; inset: 0; width: 100%; height: 100%; display: block; transition: opacity var(--t-med) var(--ease), transform var(--t-slow) var(--spring); }
.lc-body { padding: 8px 11px 10px; display: grid; gap: 1px; }
.lc-top { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.lc-name { font-weight: 600; font-size: var(--fs-13); letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lc-cov { font-size: var(--fs-12); color: var(--ink-2); }
.lc[aria-selected='true'] .lc-cov { color: var(--accent-text); }
.lc-tag { font-size: var(--fs-12); color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lc-foot { display: flex; align-items: center; gap: 8px; margin-top: 6px; font-size: 11px; color: var(--muted); }
.lc-bar { width: 38px; height: 3px; border-radius: 3px; background: var(--well-2); overflow: hidden; flex: none; }
.lc-bar i { display: block; height: 100%; background: var(--ink-2); border-radius: inherit; transition: width var(--t-slow) var(--ease); }
.lc-used { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lc.intro { animation: cardIn 700ms var(--spring) both; animation-delay: calc(var(--i) * 70ms + 200ms); }
@keyframes cardIn { from { opacity: 0; transform: translateY(14px) scale(.97); } }
.lc.shuffled .lc-plan { animation: reshuffle 520ms var(--spring); }
@keyframes reshuffle { 0% { opacity: .2; transform: scale(.94) rotate(-.6deg); } 100% { opacity: 1; transform: none; } }
.shuffle-btn .ico { transition: transform 520ms var(--spring); }
.shuffle-btn.spin .ico { animation: spin 520ms var(--spring); }
@keyframes spin { from { transform: rotate(-180deg) scale(.8); } }

/* ---------- layout detail ---------- */
.detail { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.ld { padding: 4px 20px 24px; }
.ld-hero { padding: 6px 0 16px; }
.ld-hero.swap { animation: heroIn 520ms var(--spring); }
@keyframes heroIn { from { opacity: 0; transform: translateY(6px); } }
.ld-name { margin: 0; font-family: var(--font-serif); font-style: italic; font-weight: 400; font-size: 36px; line-height: 1.02; letter-spacing: -0.015em; text-wrap: balance; }
.ld-tag { margin: 8px 0 0; color: var(--muted); font-size: var(--fs-14); }
.ld-stats { display: grid; grid-template-columns: minmax(0, .85fr) minmax(0, 1fr) minmax(0, 1.25fr); margin: 0; border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden; }
.ld-stats > div { padding: 10px 12px; min-width: 0; }
.ld-stats > div + div { border-left: 1px solid var(--line); }
.ld-stats dt { font-size: 11.5px; color: var(--muted); margin-bottom: 3px; white-space: nowrap; }
.ld-stats dd { margin: 0; font-size: 17px; font-weight: 550; letter-spacing: -0.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ld-stats dd .num { letter-spacing: -0.02em; }
.ld-stats dd small { font-size: 12px; font-weight: 450; color: var(--muted); margin-left: 3px; letter-spacing: 0; }
.ld-fill { display: grid; grid-template-columns: 14px 1fr; gap: 10px; align-items: start; margin: 12px 0 0; font-size: var(--fs-13); color: var(--ink-2); line-height: 1.5; }
.ld-fill-txt { margin: 0; text-wrap: pretty; }
.ld-fill strong { color: var(--ink); font-weight: 600; }
.fill-sw { display: inline-block; width: 14px; height: 14px; border-radius: 3px; margin-top: 3px; box-shadow: inset 0 0 0 1px rgba(0,0,0,.12); flex: none; }
.ld-desc { margin: 16px 0 0; font-size: var(--fs-13); line-height: 1.6; color: var(--ink-2); text-wrap: pretty; }
.ld-opts { display: grid; gap: 14px; margin: 18px 0 0; padding: 16px 0 0; border-top: 1px solid var(--line); }
.ld-opt { display: grid; gap: 8px; }
.ld-opt[hidden] { display: none; }
.ld-opt .seg { width: 100%; }
.ld-opt .seg-btn { flex: 1; }
.ld-k { font-size: var(--fs-12); color: var(--muted); }
.ld-block { margin-top: 22px; }
.ld-block[hidden] { display: none; }
.ld-h { margin: 0 0 10px; font-size: var(--fs-13); font-weight: 600; letter-spacing: -0.01em; }
.usage { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.u-row { transition: opacity var(--t-med); }
.u-row.off { opacity: .55; }
.u-top { display: grid; grid-template-columns: 10px minmax(0, 1fr) auto auto; align-items: center; gap: 8px; font-size: var(--fs-13); }
.u-sw { width: 10px; height: 10px; border-radius: 2px; box-shadow: inset 0 0 0 1px rgba(0,0,0,.12); }
.u-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.u-count { font-size: var(--fs-12); color: var(--muted); }
.u-bar { display: block; height: 6px; margin-top: 7px; border-radius: 6px; background: var(--well-2); overflow: hidden; box-shadow: inset 0 0 0 1px var(--line); }
.u-bar i { display: block; height: 100%; border-radius: inherit; transition: width var(--t-slow) var(--ease); box-shadow: inset 0 0 0 1px rgba(0,0,0,.1); }
.notes { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.notes li { position: relative; padding-left: 16px; font-size: var(--fs-13); line-height: 1.5; color: var(--ink-2); text-wrap: pretty; }
.notes li::before { content: ''; position: absolute; left: 2px; top: .62em; width: 5px; height: 5px; border-radius: 1px; background: var(--accent); opacity: .7; }

/* ---------- HUD ---------- */
.hud { position: absolute; inset: 0; pointer-events: none; z-index: 2; }
.hud > * { pointer-events: auto; }
.glass {
  background: var(--glass);
  backdrop-filter: blur(20px) saturate(1.5); -webkit-backdrop-filter: blur(20px) saturate(1.5);
  border: 1px solid var(--glass-line);
  box-shadow: var(--shadow-2), var(--inset-hi);
}
.hud-stats {
  position: absolute; top: 16px; left: 16px;
  display: flex; align-items: center; gap: 14px; padding: 12px 18px 12px 12px; border-radius: var(--r-lg);
  max-width: min(400px, calc(100% - 32px));
  animation: hudIn 700ms var(--spring) both 150ms;
}
@keyframes hudIn { from { opacity: 0; transform: translateY(-8px); } }
.ring { position: relative; width: 52px; height: 52px; flex: none; }
.ring svg { display: block; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 4.5; }
.ring-bg { stroke: var(--well-2); }
.ring-fg { stroke: var(--accent); stroke-linecap: round; transition: stroke-dashoffset 900ms var(--ease); }
.ring-label { position: absolute; inset: 0; display: grid; place-items: center; grid-auto-flow: column; justify-content: center; align-items: baseline; padding-top: 17px; font-size: 14px; font-weight: 600; }
.ring-label .num { font-family: var(--font-sans); letter-spacing: -0.03em; }
.ring-label small { font-size: 9.5px; color: var(--muted); font-weight: 500; margin-left: 1px; }
.hs-rows { display: grid; gap: 3px; min-width: 0; }
.hs-row { display: flex; align-items: baseline; justify-content: space-between; gap: 18px; font-size: var(--fs-13); }
.hs-k { display: flex; align-items: center; gap: 7px; color: var(--muted); white-space: nowrap; }
.hs-k .fill-sw { width: 10px; height: 10px; margin: 0; border-radius: 2px; }
.hs-v { font-weight: 600; white-space: nowrap; }
.hs-v .num { font-family: var(--font-sans); font-variant-numeric: tabular-nums; }
.hs-of { color: var(--muted); font-weight: 400; }
.hs-sub { font-size: var(--fs-12); color: var(--muted); line-height: 1.4; max-width: 34ch; text-wrap: pretty; }
.hud-stats.is-empty { opacity: .6; }

.hud-tools { position: absolute; top: 16px; right: 16px; display: flex; align-items: flex-start; gap: 8px; animation: hudIn 700ms var(--spring) both 220ms; }
.hud-group { display: flex; align-items: center; gap: 2px; padding: 4px; border-radius: 12px; }
.hud-div { width: 1px; height: 20px; margin: 0 2px; background: var(--line-strong); }
.hud-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  width: 36px; height: 36px; border: 0; border-radius: 9px; background: none; color: var(--ink-2);
  transition: background-color var(--t-fast), color var(--t-fast), transform var(--t-fast) var(--ease);
}
.hud-btn:hover { background: var(--hover); color: var(--ink); }
.hud-btn:active { transform: scale(.92); }
.hud-btn[aria-pressed='true'] { color: var(--ink); background: color-mix(in oklab, var(--ink) 9%, transparent); }
.hud-btn[aria-pressed='false'] { color: var(--faint); }
.hud-btn-text { width: auto; height: 44px; padding: 0 14px 0 12px; border-radius: 12px; font-weight: 500; font-size: var(--fs-13); }
.hud-btn-text.glass, .hud-btn-text { background: var(--glass); backdrop-filter: blur(20px) saturate(1.5); -webkit-backdrop-filter: blur(20px) saturate(1.5); border: 1px solid var(--glass-line); box-shadow: var(--shadow-2), var(--inset-hi); }
.hud-btn-text.on { color: var(--accent-text); }

.hud-bottom { position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%); display: flex; gap: 8px; animation: hudInB 700ms var(--spring) both 280ms; }
@keyframes hudInB { from { opacity: 0; transform: translate(-50%, 10px); } }
.view-seg { padding: 4px; border-radius: 13px; box-shadow: var(--shadow-2), var(--inset-hi); }
.view-seg .seg-thumb { top: 4px; bottom: 4px; border-radius: 9px; }
.view-seg .seg-btn { height: 36px; padding: 0 14px 0 12px; border-radius: 9px; }

.tip {
  position: absolute; left: 0; top: 0; z-index: 5; pointer-events: none;
  padding: 8px 11px; border-radius: 10px; min-width: 150px;
  background: var(--glass-strong); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-line); box-shadow: var(--shadow-3);
  font-size: var(--fs-12); will-change: transform;
}
.tip-top { display: flex; align-items: center; gap: 7px; font-size: var(--fs-13); }
.tip-top i { width: 10px; height: 10px; border-radius: 2px; box-shadow: inset 0 0 0 1px rgba(0,0,0,.15); }
.tip-idx { margin-left: auto; padding-left: 10px; color: var(--muted); font-size: 11px; }
.tip-sub { display: flex; gap: 8px; margin-top: 2px; color: var(--muted); }
.tip-sub span + span::before { content: ''; display: inline-block; width: 3px; height: 3px; margin: 0 8px 2px 0; border-radius: 1px; background: var(--faint); vertical-align: middle; }

.hint {
  position: absolute; left: 50%; bottom: 78px; transform: translateX(-50%);
  display: flex; align-items: center; gap: 9px; padding: 7px 7px 7px 13px; border-radius: 999px;
  background: var(--ink); color: var(--bg); font-size: var(--fs-13); white-space: nowrap; box-shadow: var(--shadow-3);
  animation: hintIn 800ms var(--spring) both 900ms;
}
.hint .ico { color: color-mix(in oklab, var(--accent) 70%, var(--bg)); flex: none; }
.hint-x { display: grid; place-items: center; width: 26px; height: 26px; border: 0; border-radius: 50%; background: color-mix(in oklab, var(--bg) 14%, transparent); color: inherit; }
.hint-x:hover { background: color-mix(in oklab, var(--bg) 24%, transparent); }
.hint-narrow, .hint-drawer { display: none; }
@media (max-width: 759.98px), (max-width: 1099.98px) and (orientation: portrait) { .hint-wide { display: none; } .hint-narrow { display: inline; } }
@media (min-width: 760px) and (max-width: 1099.98px) and (orientation: landscape) { .hint-wide { display: none; } .app[data-drawer='open'] .hint-drawer { display: inline; } .app[data-drawer='closed'] .hint-narrow { display: inline; } }
.hint { transition: opacity var(--t-med) var(--ease); }
.app[data-sheet='half'] .hint, .app[data-sheet='full'] .hint { opacity: 0; pointer-events: none; }
@keyframes hintIn { from { opacity: 0; transform: translate(-50%, 10px) scale(.96); } }
.scene-status { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); max-width: 320px; padding: 14px 16px; border-radius: var(--r-md); background: var(--glass-strong); border: 1px solid var(--glass-line); box-shadow: var(--shadow-2); font-size: var(--fs-13); text-align: center; color: var(--ink-2); top: auto; bottom: 90px; transform: translateX(-50%); }
.boot-error { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; padding: 24px; }

/* HUD responsive by viewport container size */
@container viewport (max-width: 620px) {
  .hud-stats { top: 10px; left: 10px; gap: 10px; padding: 8px 12px 8px 8px; border-radius: 12px; }
  .ring, .ring svg { width: 42px; height: 42px; }
  .ring-label { font-size: 12px; padding-top: 13px; }
  .hs-row { font-size: var(--fs-12); gap: 10px; }
  .hs-sub { display: none; }
  .hud-tools { top: 10px; right: 10px; }
  .hud-group { flex-direction: column; }
  .hud-div { width: 20px; height: 1px; margin: 2px 0; }
  .hud-btn { width: 40px; height: 40px; }
  .view-seg .seg-btn span { display: none; }
  .view-seg .seg-btn { width: 44px; padding: 0; height: 36px; }
  .hint { white-space: normal; max-width: calc(100% - 32px); width: max-content; border-radius: 14px; }
}
@container viewport (max-width: 400px) {
  .hs-row .hs-k { display: none; }
  .hs-row.hs-fill .hs-k { display: flex; }
  .hs-row.hs-fill .hs-fillname { display: none; }
}

/* ---------- mobile sheet & tablet drawer ---------- */
.sheet {
  position: fixed; z-index: 30; left: 0; right: 0; bottom: 0;
  height: calc(100dvh - var(--topbar-h) - 8px);
  display: flex; flex-direction: column;
  background: color-mix(in oklab, var(--surface) 94%, transparent);
  backdrop-filter: blur(28px) saturate(1.5); -webkit-backdrop-filter: blur(28px) saturate(1.5);
  border-top: 1px solid var(--glass-line);
  border-radius: 20px 20px 0 0;
  box-shadow: 0 -1px 0 var(--line), 0 -12px 40px -12px rgba(40,30,20,.22);
  transform: translate3d(0, calc(100% - 132px), 0);
  will-change: transform;
}
.sheet-grab { display: grid; place-items: center; height: 22px; flex: none; cursor: grab; touch-action: none; border-radius: 20px 20px 0 0; }
.sheet-grab span { width: 38px; height: 5px; border-radius: 5px; background: var(--line-strong); transition: background-color var(--t-fast), width var(--t-med) var(--spring); }
.sheet-grab:hover span, .sheet-grab:focus-visible span { background: var(--muted); width: 46px; }
.sheet-grab:focus-visible { box-shadow: none; }
.sheet-head { display: flex; align-items: center; gap: 10px; padding: 0 12px 6px 18px; touch-action: none; flex: none; }
.sh-text { display: flex; align-items: baseline; gap: 10px; min-width: 0; flex: 1; }
.sh-name { font-family: var(--font-serif); font-style: italic; font-size: 24px; line-height: 1.15; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; letter-spacing: -0.01em; }
.sh-cov { font-size: var(--fs-12); color: var(--muted); white-space: nowrap; font-family: var(--font-sans); }
.sh-shuffle { width: 44px; height: 44px; border-radius: 12px; }
.sheet-tabs { position: relative; display: flex; gap: 2px; padding: 0 10px; border-bottom: 1px solid var(--line); flex: none; overflow-x: auto; scrollbar-width: none; }
.sheet-tab { position: relative; flex: 1; height: 44px; padding: 0 10px; border: 0; background: none; color: var(--muted); font-weight: 500; font-size: var(--fs-13); white-space: nowrap; border-radius: 8px 8px 0 0; }
.sheet-tab[aria-selected='true'] { color: var(--ink); }
.sheet-tab:focus-visible { box-shadow: inset var(--focus); }
.tab-ink { position: absolute; left: 0; bottom: -1px; height: 2px; border-radius: 2px; background: var(--ink); transition: transform var(--t-med) var(--spring), width var(--t-med) var(--spring); }
.sheet-body { --hidden: 0px; flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.sheet-pane { padding-bottom: calc(var(--hidden) + 24px + var(--safe-b)); }
.sheet-pane:focus-visible { box-shadow: none; }
.sheet .sec:first-child { border-top: 0; }
.sheet .summary { padding-top: 16px; }
.sheet .detail .panel-head { display: none; }
.sheet .detail { height: auto; }
.sheet .detail .panel-scroll { overflow: visible; }
.sheet-foot { display: flex; justify-content: center; padding: 8px 0 0; }

/* rail inside the sheet: two-column grid of cards */
.sheet .rail { display: block; height: auto; }
.sheet .rail-head { flex-direction: row; align-items: center; width: auto; border-right: 0; padding: 12px 12px 4px 18px; }
.sheet .rail-head .shuffle-btn { margin-left: 0; }
.sheet .rail-scroll { overflow: visible; mask-image: none; }
.sheet .rail-list { grid-auto-flow: row; grid-template-columns: repeat(auto-fill, minmax(156px, 1fr)); grid-auto-columns: auto; padding: 10px 14px 4px; height: auto; }
.sheet .rail-list { --dir: grid; }
.sheet .lc-thumb { flex: none; height: 64px; }
.sheet .lc-tag { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }

@media (min-width: 760px) and (max-width: 1099.98px) and (orientation: landscape) {
  .sheet {
    left: 12px; right: auto; top: calc(var(--topbar-h) + 12px); bottom: 12px; height: auto;
    width: min(400px, 46vw);
    border: 1px solid var(--glass-line); border-radius: var(--r-xl);
    box-shadow: var(--shadow-3);
    transform: translateX(calc(-100% - 24px)) !important;
    visibility: hidden;
    transition: transform var(--t-med) var(--ease), visibility 0s linear var(--t-med) !important;
  }
  .sheet.drawer-open { transform: none !important; visibility: visible; transition: transform 420ms var(--spring), visibility 0s !important; }
  .sheet-grab { display: none; }
  .sheet-head { padding: 14px 10px 8px 18px; }
  .app[data-drawer='open'] .hud-stats { left: calc(min(400px, 46vw) + 28px); }
  .app[data-drawer='open'] .hs-sub { display: none; }
  .app[data-drawer='open'] .hud-stats { max-width: calc(100% - min(400px, 46vw) - 230px); }
  .app[data-drawer='open'] .hud-bottom { left: calc(50% + min(400px, 46vw) / 2 + 6px); }
  .app[data-drawer='open'] .hint { left: calc(50% + min(400px, 46vw) / 2 + 6px); }
  .hud-stats, .hud-bottom, .hint { transition: left var(--t-med) var(--ease); }
  .sheet-pane { padding-bottom: 24px; }
}
@media (max-width: 759.98px), (max-width: 1099.98px) and (orientation: portrait) {
  .hud-bottom { bottom: calc(var(--sheet-peek, 132px) + 12px); }
  .hint { bottom: calc(var(--sheet-peek, 132px) + 68px); }
  .scene-status { bottom: calc(var(--sheet-peek, 132px) + 70px); }
  .viewport { margin-bottom: 0; }
}

/* ---------- dialogs ---------- */
.dlg { padding: 0; border: 0; background: none; color: var(--ink); max-width: none; max-height: none; overflow: visible; }
.dlg:focus, .dlg:focus-visible { box-shadow: none; outline: none; }
.dlg::backdrop { background: rgba(20,16,12,.0); backdrop-filter: blur(0); transition: background-color var(--t-med) var(--ease), backdrop-filter var(--t-med) var(--ease); }
.dlg.in::backdrop { background: rgba(20,16,12,.32); backdrop-filter: blur(3px); }
.dlg-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-xl); box-shadow: var(--shadow-3);
  display: flex; flex-direction: column; max-height: calc(100dvh - 32px); overflow: hidden;
}
.dlg-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 14px 12px 22px; }
.dlg-title { display: flex; align-items: center; gap: 10px; }
.dlg-title h2 { margin: 0; font-size: var(--fs-16); font-weight: 600; letter-spacing: -0.015em; }
.dlg-body { padding: 0 22px 24px; overflow-y: auto; }
.dlg-side { position: fixed; inset: 12px 12px 12px auto; margin: 0; width: min(420px, calc(100vw - 24px)); height: calc(100dvh - 24px); }
.dlg-side .dlg-card { height: 100%; max-height: none; transform: translateX(calc(100% + 24px)); transition: transform 420ms var(--spring); }
.dlg-side.in .dlg-card { transform: none; }
.dlg-side.out .dlg-card { transform: translateX(calc(100% + 24px)); transition-duration: 220ms; transition-timing-function: var(--ease); }
.dlg-center { position: fixed; inset: 0; margin: auto; width: min(560px, calc(100vw - 24px)); height: fit-content; }
.dlg-center .dlg-card { opacity: 0; transform: scale(.97) translateY(8px); transition: opacity var(--t-fast) var(--ease), transform var(--t-med) var(--spring); }
.dlg-center.in .dlg-card { opacity: 1; transform: none; }
@media (max-width: 759.98px) {
  .dlg-side, .dlg-center { inset: auto 0 0 0; width: 100%; height: auto; max-height: 88dvh; margin: 0; }
  .dlg-side .dlg-card, .dlg-center .dlg-card { border-radius: 20px 20px 0 0; max-height: 88dvh; padding-bottom: var(--safe-b); transform: translateY(100%); opacity: 1; }
  .dlg-side.in .dlg-card, .dlg-center.in .dlg-card { transform: none; }
  .dlg-side.out .dlg-card, .dlg-center.out .dlg-card { transform: translateY(100%); }
}
.wn-hero { padding: 6px 0 18px; border-bottom: 1px solid var(--line); margin-bottom: 18px; }
.wn-ver { display: flex; gap: 12px; margin: 0; font-size: var(--fs-12); color: var(--muted); }
.wn-ver .num { font-family: var(--font-sans); }
.wn-code { margin: 6px 0 0; font-family: var(--font-serif); font-style: italic; font-size: var(--fs-36); line-height: 1.05; letter-spacing: -0.01em; }
.wn-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.wn-list li { position: relative; padding-left: 20px; font-size: var(--fs-14); line-height: 1.55; color: var(--ink-2); text-wrap: pretty; }
.wn-list li::before { content: ''; position: absolute; left: 0; top: .55em; width: 8px; height: 8px; border-radius: 2px; background: var(--accent); opacity: .85; }
.wn-list li:nth-child(3n+2)::before { width: 5px; height: 9px; top: .5em; background: var(--ink); opacity: .7; }
.wn-list li:nth-child(3n)::before { background: var(--muted); opacity: .6; }
.wn-foot { margin: 24px 0 0; padding-top: 16px; border-top: 1px solid var(--line); font-size: var(--fs-12); color: var(--muted); }
.kb-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 20px 28px; }
.kb-group h3 { margin: 0 0 8px; font-size: var(--fs-12); font-weight: 500; color: var(--muted); }
.kb-group dl { margin: 0; display: grid; gap: 6px; }
.kb-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: var(--fs-13); }
.kb-row dt { color: var(--ink-2); }
.kb-row dd { margin: 0; display: flex; gap: 4px; }

/* ---------- toasts ---------- */
.toasts { position: fixed; z-index: 80; left: 50%; top: calc(var(--topbar-h) + 14px); transform: translateX(-50%); display: grid; gap: 8px; justify-items: center; pointer-events: none; }
.toast {
  display: flex; align-items: center; gap: 9px; padding: 9px 15px 9px 12px; border-radius: 999px;
  background: var(--ink); color: var(--bg); font-size: var(--fs-13); box-shadow: var(--shadow-3);
  opacity: 0; transform: translateY(-8px) scale(.97);
  transition: opacity var(--t-fast) var(--ease), transform var(--t-med) var(--spring);
  max-width: calc(100vw - 32px);
}
.toast .ico { color: color-mix(in oklab, var(--accent) 65%, var(--bg)); flex: none; }
.toast.in { opacity: 1; transform: none; }
.toast.out { opacity: 0; transform: translateY(-4px); }

/* theme cross-fade */
.theming *, .theming *::before, .theming *::after { transition-duration: var(--t-med) !important; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-delay: 0ms !important; transition-duration: 1ms !important; }
}
@media (hover: none) {
  .lc:hover { transform: none; }
  .pn .ico { opacity: .5; }
}
@media (pointer: coarse) {
  .icon-btn { width: 44px; height: 44px; }
  .seg-btn { min-height: 36px; }
  .step-btn { width: 40px; }
  .stepper-sm { width: 124px; height: 40px; }
  .stepper-sm .step-btn { width: 38px; }
  .sw { width: 32px; height: 32px; }
  .pc-more { width: 44px; height: 44px; }
  .pc-row { grid-template-columns: 48px minmax(0, 1fr) auto 44px; }
  .chip { min-height: 48px; }
  .menu-item { min-height: 44px; }
  .field-box { height: 44px; }
  .step-btn { width: 40px; }
}
@media (min-width: 760px) and (max-width: 1099.98px) and (orientation: portrait) {
  .sheet { left: max(0px, calc((100vw - 720px) / 2)); right: max(0px, calc((100vw - 720px) / 2)); }
}
@media (min-width: 1100px) and (max-width: 1439.98px) {
  .hud-tools, .hud-bottom, .hint { transition: right var(--t-med) var(--ease), left var(--t-med) var(--ease); }
  .app[data-detail='open'] .hud-tools { right: calc(min(340px, 38vw) + 28px); }
  .app[data-detail='open'] .hud-bottom, .app[data-detail='open'] .hint { left: calc((100% - min(340px, 38vw) - 12px) / 2); }
}
