/* Ὁρμή — base tokens, reset and shared components (launcher + studio). */
:root {
  --accent: #d6dbe4;
  --accent2: #8d9db3;
  --glow1: rgba(120, 136, 160, 0.12);
  --glow2: rgba(80, 96, 120, 0.12);
  --base: #07090d;
  --fg: #eef0f7;
  --sub: #a7abbf;
  --muted: #858a9f;
  --line: rgba(225, 231, 255, 0.13);
  --line-strong: rgba(225, 231, 255, 0.24);
  --fill: rgba(255, 255, 255, 0.06);
  --fill-2: rgba(255, 255, 255, 0.1);
  --panel: linear-gradient(150deg, rgba(34, 38, 56, 0.97), rgba(13, 16, 27, 0.98));
  --danger: #ff9b9b;
  --radius: 24%;
  --spring: cubic-bezier(0.24, 0.78, 0.2, 1);
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Apple SD Gothic Neo", "Pretendard", "Noto Sans KR", "Segoe UI", Roboto, sans-serif;
  --font-serif: "New York", ui-serif, "Iowan Old Style", Georgia, "Noto Serif KR", serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --font-round: ui-rounded, "SF Pro Rounded", -apple-system, "Apple SD Gothic Neo", sans-serif;
  color-scheme: dark;
  font-family: var(--font);
  color: var(--fg);
  background: var(--base);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  font-synthesis: none;
}
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--base); }
body { -webkit-tap-highlight-color: transparent; line-height: 1.45; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
button:disabled { opacity: 0.38; cursor: not-allowed; }
a { color: inherit; }
img { max-width: 100%; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid color-mix(in srgb, var(--accent) 80%, white); outline-offset: 3px; }
::selection { background: color-mix(in srgb, var(--accent) 45%, transparent); }

/* glyph svg */
.g { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; display: block; }
.g.inline { display: inline-block; width: 16px; height: 16px; vertical-align: -3px; }

.muted { color: var(--muted); }
.small { font-size: 12px; }
.center { text-align: center; }
.mono { font-family: var(--font-mono); font-size: 15px; }
.spacer { flex: 1; }
.hint { color: var(--muted); font-size: 12.5px; line-height: 1.5; margin: 0; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 42px; padding: 0 15px; border-radius: 13px;
  background: var(--fill); border: 1px solid var(--line);
  color: var(--fg); font-size: 14px; font-weight: 560; letter-spacing: -0.01em;
  text-decoration: none; white-space: nowrap; transition: background 0.15s, border-color 0.15s, transform 0.1s;
}
.btn .g { width: 17px; height: 17px; }
.btn:hover { background: var(--fill-2); border-color: var(--line-strong); }
.btn:active { transform: scale(0.97); }
.btn.primary { background: var(--accent); color: #10121b; border-color: transparent; }
.btn.primary:hover { background: color-mix(in srgb, var(--accent) 88%, white); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); }
.btn.danger:not(.ghost) { background: rgba(255, 120, 120, 0.12); border-color: rgba(255, 140, 140, 0.25); }
.btn.small { min-height: 34px; padding: 0 11px; font-size: 13px; border-radius: 10px; }
.link-btn { display: inline-flex; align-items: center; gap: 6px; color: var(--sub); font-size: 13px; padding: 8px 0; text-decoration: underline; text-underline-offset: 3px; text-decoration-color: rgba(255,255,255,.2); }
.link-btn .g { width: 15px; height: 15px; }
.icon-btn {
  width: 44px; height: 44px; border-radius: 50%; display: inline-grid; place-items: center; flex: none;
  color: var(--fg); background: transparent; transition: background 0.15s;
}
.icon-btn:hover { background: var(--fill); }
.icon-btn.danger { color: var(--danger); }
.pill-btn {
  display: inline-flex; align-items: center; gap: 8px; height: 42px; padding: 0 16px; border-radius: 999px;
  border: 1px solid var(--line); background: rgba(255, 255, 255, 0.05);
  -webkit-backdrop-filter: blur(18px); backdrop-filter: blur(18px);
  font-size: 13.5px; font-weight: 560; text-decoration: none; white-space: nowrap; color: var(--fg);
}
.pill-btn .g { width: 17px; height: 17px; }
.pill-btn:hover { background: rgba(255, 255, 255, 0.1); border-color: var(--line-strong); }
.pill-btn.primary { background: var(--accent); color: #10121b; border-color: transparent; font-weight: 650; }

/* ---------- forms ---------- */
.form { display: grid; gap: 18px; }
.form-h { margin: 10px 0 -6px; font-size: 12px; font-weight: 650; letter-spacing: 0.12em; color: var(--muted); text-transform: uppercase; }
.field { display: grid; gap: 8px; min-width: 0; }
.field > span { font-size: 13.5px; color: var(--sub); font-weight: 520; }
.field > span small, .field > small { color: var(--muted); font-weight: 400; font-size: 12px; }
.input {
  width: 100%; min-height: 46px; padding: 10px 13px; border-radius: 13px;
  background: rgba(255, 255, 255, 0.055); border: 1px solid var(--line); color: var(--fg);
  font-size: 16px; outline: none; transition: border-color 0.15s, background 0.15s;
}
.input:focus { border-color: color-mix(in srgb, var(--accent) 60%, transparent); background: rgba(255, 255, 255, 0.08); }
textarea.input { resize: vertical; min-height: 120px; line-height: 1.5; }
select.input { appearance: none; -webkit-appearance: none; padding-right: 36px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23a7abbf' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; background-size: 16px; }
select.input option { background: #1b1f2c; }
.input[type="range"], input[type="range"] { accent-color: var(--accent); width: 100%; height: 30px; padding: 0; background: none; border: 0; }
.row { display: flex; gap: 10px; align-items: center; min-width: 0; }
.row > .input { flex: 1; min-width: 0; }
.row.wrap { flex-wrap: wrap; }
.mini-field { display: grid; gap: 4px; font-size: 12px; color: var(--muted); }
.mini-field .input { min-height: 40px; width: 96px; }

.field > .seg, .seg { justify-self: start; }
.seg { display: inline-flex; flex-wrap: wrap; gap: 3px; padding: 3px; border-radius: 13px; background: rgba(255, 255, 255, 0.06); border: 1px solid var(--line); max-width: 100%; }
.seg button { min-height: 36px; padding: 0 13px; border-radius: 10px; font-size: 13.5px; color: var(--sub); font-weight: 540; transition: background 0.15s, color 0.15s; }
.seg button.on { background: rgba(255, 255, 255, 0.15); color: var(--fg); box-shadow: 0 1px 6px rgba(0, 0, 0, 0.2); }

.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 48px; cursor: pointer; }
.switch-row > span { display: grid; gap: 2px; }
.switch-row b { font-weight: 540; font-size: 14.5px; }
.switch-row small { color: var(--muted); font-size: 12.5px; }
.switch-row.inline { min-height: 44px; }
.switch {
  appearance: none; -webkit-appearance: none; width: 50px; height: 30px; border-radius: 99px; flex: none;
  background: rgba(255, 255, 255, 0.16); position: relative; cursor: pointer; transition: background 0.2s; margin: 0;
}
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3); transition: transform 0.22s var(--ease); }
.switch:checked { background: var(--accent); }
.switch:checked::after { transform: translateX(20px); }

/* ---------- app icons (shared) ---------- */
.icon {
  --sz: var(--icon, 64px);
  width: var(--sz); height: var(--sz); border-radius: var(--radius); position: relative; flex: none;
  display: grid; place-items: center; overflow: hidden; isolation: isolate;
  background: linear-gradient(143deg, rgba(78, 85, 110, 0.66), rgba(17, 22, 36, 0.86) 68%), linear-gradient(30deg, var(--tint, transparent), transparent);
  border: 1px solid rgba(223, 226, 255, 0.2);
  box-shadow: 0 7px 22px rgba(0, 0, 0, 0.18), inset 0 1px 1px rgba(255, 255, 255, 0.13);
  color: #ecebf8;
}
.icon::after { content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; background: linear-gradient(135deg, rgba(255, 255, 255, 0.11), transparent 40%, transparent 76%, rgba(185, 170, 238, 0.07)); }
.icon > .g { width: 46%; height: 46%; stroke-width: 1.55; filter: drop-shadow(0 1px 6px rgba(220, 210, 255, 0.16)); }
body[data-gtint="accent"] .icon > .g { color: var(--accent); }
.icon.custom { background: #10131c; border-color: rgba(255, 255, 255, 0.1); }
.icon.custom::after { background: linear-gradient(135deg, rgba(255, 255, 255, 0.08), transparent 35%); }
.icon img { width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; -webkit-user-drag: none; user-select: none; }
.icon.sm { --sz: 40px; border-radius: 26%; }
.icon.mini { --sz: 100%; border-radius: 28%; box-shadow: none; }
.icon.mini > .g { stroke-width: 2; }

/* ---------- sheets ---------- */
.sheet-layer { position: fixed; inset: 0; display: grid; place-items: center; padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom)); }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(3, 5, 11, 0.55); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); opacity: 0; transition: opacity 0.22s; }
.sheet {
  position: relative; width: min(560px, 100%); max-height: min(88dvh, 900px); display: flex; flex-direction: column;
  border-radius: 26px; background: var(--panel); border: 1px solid rgba(225, 228, 255, 0.14);
  box-shadow: 0 30px 120px rgba(0, 0, 0, 0.55); outline: none;
  opacity: 0; transform: translateY(18px) scale(0.96); transition: opacity 0.2s, transform var(--sheet-ms, 0.3s) var(--ease-sheet, var(--spring));
}
.sheet.size-sm { width: min(440px, 100%); }
.sheet.size-lg { width: min(860px, 100%); }
.sheet-layer.open .sheet-backdrop { opacity: 1; }
.sheet-layer.open .sheet { opacity: 1; transform: none; }
.sheet-grab { display: none; }
.sheet-head { display: flex; align-items: flex-start; gap: 12px; padding: 22px 18px 6px 24px; }
.sheet-titles { flex: 1; min-width: 0; }
.sheet-head h2 { margin: 0; font-size: 20px; font-weight: 680; letter-spacing: -0.02em; }
.sheet-head p { margin: 5px 0 0; color: var(--muted); font-size: 13px; line-height: 1.5; }
.sheet-close { margin: -6px -2px 0 0; color: var(--sub); }
.sheet-body { padding: 14px 24px 22px; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.sheet-foot { display: flex; align-items: center; gap: 10px; padding: 14px 20px calc(14px + env(safe-area-inset-bottom) * 0); border-top: 1px solid var(--line); flex-wrap: wrap; }
.sheet-msg { margin: 0; color: var(--sub); font-size: 14.5px; line-height: 1.6; }
@media (max-width: 600px) {
  .sheet-layer { place-items: end center; padding: 0; }
  .sheet, .sheet.size-sm, .sheet.size-lg { width: 100%; max-height: 92dvh; border-radius: 26px 26px 0 0; transform: translateY(40px); border-bottom: 0; padding-bottom: env(safe-area-inset-bottom); }
  .sheet-grab { display: block; width: 38px; height: 5px; border-radius: 9px; background: rgba(255, 255, 255, 0.2); margin: 8px auto -8px; }
  .sheet-head { padding: 18px 14px 4px 20px; }
  .sheet-body { padding: 12px 20px 20px; }
}

/* ---------- context menu ---------- */
.ctx-menu {
  position: fixed; z-index: 500; min-width: 236px; max-width: min(320px, calc(100vw - 20px)); padding: 6px;
  border-radius: 18px; background: rgba(28, 31, 45, 0.9); border: 1px solid rgba(230, 233, 255, 0.14);
  -webkit-backdrop-filter: blur(30px) saturate(1.3); backdrop-filter: blur(30px) saturate(1.3);
  box-shadow: 0 22px 70px rgba(0, 0, 0, 0.5); opacity: 0; transform: scale(0.86); transition: opacity 0.14s, transform var(--snap-ms, 0.3s) var(--ease-snap, var(--spring));
}
.ctx-menu.open { opacity: 1; transform: none; }
.menu-title { padding: 8px 12px 6px; font-size: 12px; color: var(--muted); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.menu-item { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 18px; min-height: 44px; padding: 0 12px; border-radius: 11px; font-size: 15px; text-align: left; color: var(--fg); }
.menu-item .g { width: 18px; height: 18px; color: var(--sub); }
.menu-item:hover, .menu-item:focus-visible { background: rgba(255, 255, 255, 0.09); outline: none; }
.menu-item.danger, .menu-item.danger .g { color: var(--danger); }
.menu-sep { height: 1px; margin: 5px 8px; background: var(--line); }
.menu-row { display: flex; gap: 5px; padding: 5px 6px; flex-wrap: wrap; }
.menu-chip { flex: 1; min-width: 46px; min-height: 36px; border-radius: 10px; background: rgba(255, 255, 255, 0.07); font-size: 13px; color: var(--sub); }
.menu-chip.on { background: rgba(255, 255, 255, 0.2); color: var(--fg); font-weight: 600; }

/* ---------- toast ---------- */
.toast {
  position: fixed; z-index: 600; left: 50%; bottom: calc(132px + env(safe-area-inset-bottom)); max-width: min(560px, calc(100vw - 32px));
  display: flex; align-items: center; gap: 12px; padding: 11px 12px 11px 18px; border-radius: 16px;
  background: rgba(30, 34, 48, 0.94); border: 1px solid rgba(232, 235, 255, 0.14); color: #f1f2fa; font-size: 14px;
  -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px); box-shadow: 0 16px 50px rgba(0, 0, 0, 0.4);
  transform: translate(-50%, 24px) scale(0.94); opacity: 0; pointer-events: none; transition: opacity 0.2s, transform var(--sheet-ms, 0.3s) var(--ease-sheet, var(--spring));
}
.toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.toast-act { flex: none; min-height: 34px; padding: 0 12px; border-radius: 10px; background: rgba(255, 255, 255, 0.12); color: var(--accent); font-weight: 650; font-size: 13.5px; }
.toast-msg { padding: 4px 0; }

/* ---------- lists & misc ---------- */
.rows { display: grid; gap: 4px; }
.glyph-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); gap: 6px; max-height: 196px; overflow-y: auto; padding: 2px; }
.glyph-grid.compact { max-height: 150px; }
.glyph-pick { aspect-ratio: 1; border-radius: 12px; display: grid; place-items: center; background: rgba(255, 255, 255, 0.04); border: 1px solid transparent; color: var(--sub); }
.glyph-pick .g { width: 22px; height: 22px; }
.glyph-pick:hover { background: rgba(255, 255, 255, 0.09); color: var(--fg); }
.glyph-pick.on { border-color: var(--accent); color: var(--fg); background: rgba(255, 255, 255, 0.1); }
.steps-list { margin: 0; padding-left: 20px; display: grid; gap: 6px; color: var(--sub); font-size: 14px; }
.steps-list b { color: var(--fg); font-weight: 600; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; }
}

/* ---------- design pack (launcher + studio) ---------- */
.pk-list { list-style: none; margin: 0 0 14px; padding: 0; display: grid; gap: 8px; }
.pk-list li { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 13px; background: rgba(255, 255, 255, 0.045); border: 1px solid var(--line); font-size: 14px; }
.pk-list .g { width: 18px; height: 18px; color: var(--accent); flex: none; }
.pk-list .sw { display: inline-block; width: 14px; height: 14px; border-radius: 50%; margin-left: 6px; vertical-align: -2px; box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.25); }
.pk-icons { display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 12px 8px; margin: 4px 0 16px; max-height: 260px; overflow-y: auto; }
.pk-icon { display: grid; justify-items: center; gap: 4px; min-width: 0; }
.pk-icon img { width: 48px; height: 48px; border-radius: 24%; object-fit: cover; box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35); }
.pk-icon small { font-size: 11px; color: var(--sub); max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pk-notes { margin-top: 12px; font-size: 13px; color: var(--sub); }
.pk-notes summary { cursor: pointer; color: #f5d394; }
.pk-notes ul { margin: 8px 0 0; padding-left: 18px; }
.pk-rules { list-style: none; margin: 4px 0 14px; padding: 0; display: grid; gap: 6px; font-size: 13px; color: var(--sub); }
.pk-rules li { display: grid; grid-template-columns: 96px minmax(0, 1fr); align-items: baseline; gap: 4px 8px; }
.pk-rules li > span { display: flex; flex-wrap: wrap; align-items: baseline; gap: 5px; line-height: 1.7; }
.pk-rules b { color: var(--fg); font-weight: 600; }
.pk-rules code { font-family: var(--font-mono); font-size: 12px; background: rgba(255, 255, 255, 0.08); padding: 1px 6px; border-radius: 6px; }
.pack-drop { border-style: dashed; transition: border-color 0.15s, background 0.15s; }
.pack-drop.over { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, transparent); }
@media (hover: none) { .pack-drop .drop-hint { display: none; } }
