/* ---------- Drawer & dialogs ---------- */
.scrim { position: fixed; inset: 0; z-index: 40; background: var(--scrim); }
.drawer {
  position: fixed; z-index: 41; top: 0; right: 0; bottom: 0; width: min(100%, clamp(340px, 40vw, 560px));
  background: var(--bg); box-shadow: var(--shadow-2); display: flex; flex-direction: column;
  padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px); padding-right: env(safe-area-inset-right, 0px);
}
.dr-head { display: flex; align-items: center; gap: 10px; padding: 14px var(--space-m); border-bottom: 1px solid var(--line); background: var(--surface); }
.dr-head h2 { margin: 0; flex: 1; font-size: var(--step-0); font-weight: 600; letter-spacing: -0.015em; }
.dr-body { overflow-y: auto; padding: var(--space-m); display: flex; flex-direction: column; gap: var(--space-m); flex: 1; }
.dr-tabs { display: flex; gap: 4px; padding: 10px var(--space-m) 0; background: var(--surface); border-bottom: 1px solid var(--line); overflow-x: auto; }
.dr-tabs button { border: 0; background: none; padding: 8px 10px 10px; font-size: var(--step--1); font-weight: 500; color: var(--ink-2); border-bottom: 2px solid transparent; white-space: nowrap; }
.dr-tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--ink); }
.fgroup { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-1); display: flex; flex-direction: column; }
.fgroup-h { font-size: var(--step--2); font-weight: 600; color: var(--ink-3); letter-spacing: 0.06em; text-transform: uppercase; padding: 0 4px; margin-bottom: -8px; }
.field { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); gap: 10px; align-items: center; padding: 9px 14px; min-height: 46px; }
.field + .field { border-top: 1px solid var(--line); }
.field.col { grid-template-columns: minmax(0, 1fr); gap: 4px; }
.field label { font-size: var(--step--1); color: var(--ink-2); }
.field label small { display: block; color: var(--ink-3); font-size: var(--step--2); }
.field input[type=text], .field input[type=url], .field input[type=number], .field select, .field textarea {
  width: 100%; border: 1px solid transparent; border-radius: 8px; background: var(--hover); padding: 7px 10px; font-size: var(--step--1); outline: none; transition: border-color 0.2s, background 0.2s;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--focus); background: var(--surface); }
.field textarea { min-height: 76px; resize: vertical; line-height: 1.5; }
.field input.num { font-family: var(--font-num); }
.tagset { display: flex; flex-wrap: wrap; gap: 6px; }
.tagset button { border: 0; border-radius: 999px; padding: 5px 11px; font-size: var(--step--2); font-weight: 500; background: var(--hover); color: var(--ink-2); transition: background 0.2s, color 0.2s, transform 0.15s; }
.tagset button[aria-pressed="true"] { background: var(--ink); color: var(--on-ink); }
.tagset button:active { transform: scale(0.95); }
.switch { position: relative; width: 40px; height: 24px; justify-self: end; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.switch span { position: absolute; inset: 0; border-radius: 12px; background: var(--line-2); transition: background 0.25s; pointer-events: none; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,0.2); transition: transform 0.3s var(--ease); }
.switch input:checked + span { background: var(--ink); }
.switch input:checked + span::after { transform: translateX(16px); }
.switch input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 2px; }
.seg.tri { justify-self: end; }
.vrow { display: grid; grid-template-columns: 64px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 10px 14px; }
.vrow + .vrow { border-top: 1px solid var(--line); }
.thumb { width: 64px; height: 48px; border-radius: 8px; background-color: var(--canvas); background-image: radial-gradient(circle, var(--canvas-dot) 1px, transparent 1.2px); background-size: 8px 8px; display: grid; place-items: center; overflow: hidden; border: 0; padding: 0; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb svg { width: 18px; height: 18px; color: var(--ink-3); }
.vrow .vf { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.vrow .vf input { width: 100%; border: 1px solid transparent; border-radius: 8px; background: var(--hover); padding: 6px 9px; font-size: var(--step--1); outline: none; }
.vrow .vf input:focus { border-color: var(--focus); background: var(--surface); }
.vrow .vact { display: flex; flex-direction: column; gap: 4px; align-items: flex-end; }
.icon-btn { width: 30px; height: 30px; border-radius: 50%; border: 0; background: none; color: var(--ink-2); display: grid; place-items: center; transition: background 0.2s; }
.icon-btn:hover { background: var(--hover); color: var(--ink); }
.icon-btn svg { width: 15px; height: 15px; }
.icon-btn[aria-pressed="true"] { color: var(--pos); }

.modal-wrap { position: fixed; inset: 0; z-index: 41; display: grid; place-items: center; padding: max(16px, env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) max(16px, env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px)); pointer-events: none; }
.modal { pointer-events: auto; width: min(100%, 600px); max-height: 100%; overflow: auto; background: var(--bg); border-radius: var(--radius-card); box-shadow: var(--shadow-2); }
.status-line { display: flex; gap: 8px; align-items: center; font-size: var(--step--1); color: var(--ink-2); min-height: 22px; }
.spin { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--line-2); border-top-color: var(--ink); animation: spin 0.8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.lightbox { position: fixed; inset: 0; z-index: 50; background: color-mix(in srgb, var(--bg) 92%, transparent); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); display: grid; place-items: center; padding: max(24px, env(safe-area-inset-top, 0px)) max(24px, env(safe-area-inset-right, 0px)) max(24px, env(safe-area-inset-bottom, 0px)) max(24px, env(safe-area-inset-left, 0px)); cursor: zoom-out; }
.lightbox img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 12px; box-shadow: var(--shadow-2); }
.toast { position: fixed; z-index: 60; left: 50%; bottom: calc(22px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); background: var(--ink); color: var(--on-ink); padding: 10px 18px; border-radius: 999px; font-size: var(--step--1); font-weight: 500; box-shadow: var(--shadow-2); white-space: nowrap; max-width: calc(100% - 32px); overflow: hidden; text-overflow: ellipsis; }
.confirm-row { display: flex; gap: 8px; align-items: center; justify-content: flex-end; flex-wrap: wrap; font-size: var(--step--1); color: var(--ink-2); }
