/* web-ui-studio base.css : 変数・リセット・共通部品・iOS必須対策 */
:root {
  --bg: #10151f; --surface: #182030; --surface-2: #212b40; --line: rgba(255, 255, 255, .09);
  --text: #eef1f6; --text-dim: #9aa6bd; --accent: #ffc857; --accent-2: #5ad1c8;
  --ok: #34c759; --warn: #ff9f0a; --danger: #ff453a;
  --radius-s: 10px; --radius-m: 16px; --radius-l: 26px;
  --font: ui-rounded, "SF Pro Rounded", -apple-system, "Hiragino Sans", "Hiragino Kaku Gothic ProN", sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, monospace;
  --sat: env(safe-area-inset-top, 0px); --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px); --sar: env(safe-area-inset-right, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --app-h: 100vh;
  --nav-h: 58px;
}
@supports (height: 100dvh) { :root { --app-h: 100dvh; } }
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
input, select, textarea, .selectable, .selectable * { -webkit-user-select: text; user-select: text; -webkit-touch-callout: default; }
img { -webkit-user-drag: none; }
html, body { height: 100%; overflow: hidden; background: var(--bg); color: var(--text);
  font-family: var(--font); font-size: 16px; line-height: 1.5; caret-color: var(--accent);
  -webkit-text-size-adjust: 100%; }
button, .btn, .tap, [data-press], a, input[type=range], summary { touch-action: manipulation; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; caret-color: var(--accent); }
a { color: var(--accent-2); }
.ic { flex: none; vertical-align: middle; }
.is-pressed { transform: scale(.97); opacity: .82; }

#app { position: fixed; top: 0; left: 0; right: 0; height: var(--app-h); display: flex; flex-direction: column; overflow: hidden; }
#screen { flex: 1; min-height: 0; position: relative; }
.screen { position: absolute; inset: 0; overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch; padding: calc(var(--sat) + 14px) 16px 24px; }
.screen[hidden] { display: none; }
#overlays { position: absolute; inset: 0; pointer-events: none; z-index: 50; }
.ov { position: absolute; inset: 0; background: var(--bg); pointer-events: auto; display: flex; flex-direction: column;
  transform: translateX(100%); transition: transform .32s cubic-bezier(.25, .1, .25, 1); }
.ov.in { transform: translateX(0); }
.ov.settled { transform: none; }
.nav { flex: none; display: flex; background: rgba(16, 21, 31, .92); -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px);
  border-top: .5px solid var(--line); padding-bottom: var(--sab); z-index: 40; }
.nav-b { flex: 1; min-height: var(--nav-h); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--text-dim); font-size: 11px; font-weight: 600; position: relative; }
.nav-b.on { color: var(--accent); }
.nav-b .dot { position: absolute; top: 8px; right: calc(50% - 20px); background: var(--danger); color: #fff; font-size: 10px; border-radius: 9px; padding: 0 5px; min-width: 16px; text-align: center; }

.title { font-size: 1.7rem; font-weight: 800; letter-spacing: .01em; line-height: 1.25; }
.sub { color: var(--text-dim); font-size: .9rem; }
.h2 { font-size: 1.05rem; font-weight: 700; margin: 22px 0 10px; display: flex; align-items: center; gap: 8px; }
.h2 .sp { flex: 1; }
.h2 button.more { color: var(--accent-2); font-size: .85rem; font-weight: 600; }
.muted { color: var(--text-dim); }
.small { font-size: .82rem; }
.row-flex { display: flex; align-items: center; gap: 10px; }
.grow { flex: 1; min-width: 0; }
.stack > * + * { margin-top: 10px; }

.card { background: var(--surface); border-radius: var(--radius-m); padding: 14px; border: .5px solid var(--line); }
.card.tap { cursor: pointer; }
.list { background: var(--surface); border-radius: var(--radius-m); overflow: hidden; border: .5px solid var(--line); }
.li { display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 8px 14px; border-top: .5px solid var(--line); }
.li:first-child { border-top: 0; }
.li.tap { cursor: pointer; }
.li .ic.chev { color: var(--text-dim); }
.li-t { font-weight: 600; font-size: .98rem; }
.li-s { color: var(--text-dim); font-size: .82rem; line-height: 1.35; }

.btn { white-space: nowrap; display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 0 18px; border-radius: 14px;
  font-weight: 700; font-size: .95rem; background: var(--surface-2); color: var(--text); border: .5px solid var(--line); }
.btn.primary { background: var(--accent); color: #1b1503; border-color: transparent; }
.btn.accent2 { background: var(--accent-2); color: #04211f; border-color: transparent; }
.btn.danger { background: var(--danger); color: #fff; border-color: transparent; }
.btn.ghost { background: transparent; }
.btn.small { min-height: 36px; padding: 0 12px; font-size: .85rem; border-radius: 11px; }
.btn.block { display: flex; width: 100%; white-space: normal; }
.btn[disabled] { opacity: .45; }
.icon-btn { width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center; border-radius: 12px; color: var(--text); flex: none; }
.icon-btn.on { color: var(--accent); }
.chip { display: inline-flex; align-items: center; gap: 6px; min-height: 34px; padding: 0 12px; border-radius: 17px; background: var(--surface-2);
  font-size: .85rem; font-weight: 600; border: .5px solid var(--line); white-space: nowrap; color: var(--text); }
.chip.on { background: var(--accent); color: #1b1503; border-color: transparent; }
.chips { display: flex; gap: 8px; overflow-x: auto; overscroll-behavior-x: contain; padding: 2px 0 6px; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.pill { display: inline-block; padding: 1px 8px; border-radius: 9px; font-size: .72rem; font-weight: 700; background: var(--surface-2); color: var(--text-dim); }
.pill.warn { background: rgba(255, 159, 10, .18); color: var(--warn); }
.pill.ok { background: rgba(52, 199, 89, .18); color: var(--ok); }
.pill.must { background: rgba(255, 69, 58, .18); color: var(--danger); }
.pill.info { background: rgba(90, 209, 200, .16); color: var(--accent-2); }

.field { width: 100%; min-height: 44px; padding: 10px 14px; border-radius: 12px; background: var(--surface-2); border: .5px solid var(--line);
  font-size: 16px; outline: none; }
.field:focus { border-color: var(--accent); }
textarea.field { min-height: 120px; resize: none; line-height: 1.5; }
.search { position: relative; }
.search .ic { position: absolute; left: 12px; top: 11px; color: var(--text-dim); }
.search .field { padding-left: 40px; }

.seg { display: flex; background: var(--surface-2); border-radius: 11px; padding: 3px; gap: 2px; overflow-x: auto; scrollbar-width: none; }
.seg::-webkit-scrollbar { display: none; }
.seg-b { flex: 1 0 auto; min-height: 34px; padding: 0 12px; border-radius: 9px; font-size: .85rem; font-weight: 700; color: var(--text-dim); white-space: nowrap; }
.seg-b.on { background: var(--bg); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, .35); }
.tg { position: relative; width: 51px; height: 31px; border-radius: 16px; background: var(--surface-2); border: .5px solid var(--line); flex: none; transition: background .2s; }
.tg i { position: absolute; top: 2px; left: 2px; width: 25px; height: 25px; border-radius: 50%; background: #fff; box-shadow: 0 2px 4px rgba(0, 0, 0, .35); transition: transform .2s; }
.tg.on { background: var(--ok); }
.tg.on i { transform: translateX(20px); }
.kv { display: flex; gap: 10px; padding: 8px 0; border-top: .5px solid var(--line); font-size: .88rem; }
.kv:first-child { border-top: 0; }
.kv b { flex: none; width: 38%; color: var(--text-dim); font-weight: 600; }
.kv span { flex: 1; min-width: 0; word-break: break-all; }
.codebox { display: block; width: 100%; background: #0b0f17; border: .5px solid var(--line); border-radius: 12px; padding: 12px;
  font-family: var(--font-mono); font-size: 12.5px; line-height: 1.55; white-space: pre-wrap; word-break: break-all; max-height: 46vh; overflow: auto;
  overscroll-behavior: contain; color: #d8e1f2; }
.empty { text-align: center; color: var(--text-dim); padding: 28px 12px; font-size: .92rem; }
.banner { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--radius-m); background: rgba(255, 200, 87, .12); border: .5px solid rgba(255, 200, 87, .35); font-size: .88rem; }
.banner.info { background: rgba(90, 209, 200, .1); border-color: rgba(90, 209, 200, .3); }
.banner .ic { color: var(--accent); margin-top: 2px; }
.banner.info .ic { color: var(--accent-2); }

.topbar { flex: none; display: flex; align-items: center; gap: 4px; padding: calc(var(--sat) + 4px) 8px 4px; border-bottom: .5px solid var(--line); background: var(--bg); min-height: calc(52px + var(--sat)); }
.topbar .tt { flex: 1; min-width: 0; font-weight: 800; font-size: 1.02rem; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* シート */
.sheet-bd { position: fixed; inset: 0; background: rgba(0, 0, 0, .5); opacity: 0; transition: opacity .3s; z-index: 90; }
.sheet-bd.on { opacity: 1; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; max-height: 88%; background: var(--surface); border-radius: 24px 24px 0 0; z-index: 100;
  display: flex; flex-direction: column; transform: translateY(100%); transition: transform .32s cubic-bezier(.25, .1, .25, 1); padding-bottom: var(--sab);
  max-width: 640px; margin: 0 auto; }
.sheet.full { height: 92%; }
.sheet.open { transform: translateY(0); }
.sheet.settled { transform: none; }
.sheet-grab { flex: none; height: 26px; display: flex; align-items: center; justify-content: center; touch-action: none; }
.sheet-grab i { width: 38px; height: 5px; border-radius: 3px; background: var(--text-dim); opacity: .5; }
.sheet-head { flex: none; display: flex; align-items: center; padding: 0 6px 0 18px; touch-action: none; }
.sheet-title { flex: 1; font-weight: 800; font-size: 1.1rem; }
.sheet-body { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; padding: 6px 16px 18px; }
.dlg-bd { position: fixed; inset: 0; background: rgba(0, 0, 0, .55); z-index: 120; display: flex; align-items: center; justify-content: center; padding: 24px; opacity: 0; transition: opacity .2s; }
.dlg-bd.on { opacity: 1; }
.dlg { width: 100%; max-width: 340px; background: var(--surface-2); border-radius: 20px; padding: 20px 18px 14px; }
.dlg-t { font-weight: 800; font-size: 1.05rem; text-align: center; }
.dlg-m { color: var(--text-dim); font-size: .9rem; margin: 8px 0 4px; text-align: center; white-space: pre-wrap; }
.dlg .field { margin-top: 12px; }
.dlg-a { display: flex; gap: 8px; margin-top: 16px; }
.dlg-a .btn { flex: 1; }
.toast-wrap { position: fixed; left: 0; right: 0; top: calc(var(--sat) + 8px); z-index: 200; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; padding: 0 16px; }
.toast { display: flex; align-items: center; gap: 10px; background: rgba(40, 48, 66, .96); border: .5px solid var(--line); padding: 11px 16px; border-radius: 16px; font-size: .92rem; font-weight: 600;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .35); opacity: 0; transform: translateY(-14px); transition: opacity .25s, transform .25s; max-width: 100%; }
.toast.on { opacity: 1; transform: none; }
.toast i { width: 9px; height: 9px; border-radius: 50%; background: var(--accent-2); flex: none; }
.toast.ok i { background: var(--ok); } .toast.error i { background: var(--danger); } .toast.warn i { background: var(--warn); }
.pbar { height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.pbar i { display: block; height: 100%; background: var(--accent); }
.spin { width: 22px; height: 22px; border-radius: 50%; border: 3px solid var(--surface-2); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .ov, .sheet, .toast { transition-duration: .01s; } .spin { animation-duration: 2s; } }
