:root {
  --bg: #f5f6f8; --surface: #fff; --line: #dfe3e8; --line-strong: #c4cad3;
  --text: #1c2430; --muted: #5b6676;
  --accent: #2f6f73; --accent-dark: #24575a; --accent-soft: #e4f1f1;
  --green: #1f7a4d; --green-soft: #e3f4ea; --amber: #8a5a00; --amber-soft: #fdf1d6;
  --red: #b3261e; --red-soft: #fde8e6; --grey-soft: #eceff3;
  --radius: 10px; --shadow: 0 1px 2px rgba(20, 30, 45, .06), 0 2px 8px rgba(20, 30, 45, .05);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 15px/1.5 var(--font); color: var(--text); background: var(--bg); }
h1 { font-size: 1.5rem; margin: 0; } h2 { font-size: 1.1rem; margin: 0 0 .6rem; } h3 { font-size: 1rem; margin: 0 0 .4rem; }
p { margin: 0 0 .7rem; } a { color: var(--accent-dark); }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .86em; }
.muted { color: var(--muted); } .small { font-size: .85rem; } .text-warn { color: var(--red); font-weight: 600; }
.skip-link { position: absolute; left: -999px; } .skip-link:focus { left: 8px; top: 8px; background: #fff; padding: 6px 10px; z-index: 100; }
:focus-visible { outline: 3px solid #7fb6ba; outline-offset: 2px; }
.boot { display: grid; place-items: center; min-height: 100vh; color: var(--muted); }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 230px 1fr; grid-template-rows: auto auto 1fr; min-height: 100vh; }
.topbar { grid-column: 1 / -1; display: flex; align-items: center; gap: 12px; padding: 10px 18px; background: var(--surface); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; margin-right: auto; }
.brand-mark { width: 30px; height: 30px; border-radius: 8px; background: var(--accent); color: #fff; display: grid; place-items: center; font-weight: 800; }
.brand small { display: block; font-weight: 400; color: var(--muted); font-size: .75rem; line-height: 1.1; }
.game-switch { display: flex; align-items: center; gap: 8px; min-width: 0; max-width: 100%; }
.game-switch select { width: auto; min-width: 0; max-width: 300px; flex: 0 1 auto; }
.shell > * { min-width: 0; }
.game-switch label { color: var(--muted); font-size: .85rem; }
.demo-banner { grid-column: 1 / -1; background: var(--amber-soft); color: #5c3c00; border-bottom: 1px solid #f0d9a0; padding: 7px 18px; font-size: .9rem; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.nav { background: var(--surface); border-right: 1px solid var(--line); padding: 12px 10px; }
.nav a { display: flex; align-items: center; gap: 9px; padding: 8px 10px; border-radius: 8px; color: var(--text); text-decoration: none; font-size: .93rem; }
.nav a:hover { background: var(--grey-soft); }
.nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent-dark); font-weight: 600; }
.nav .nav-group { margin: 12px 10px 4px; font-size: .72rem; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.nav-ico { width: 18px; text-align: center; }
.main { padding: 22px 26px 60px; min-width: 0; }
.page-head { display: flex; align-items: flex-start; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head > div:first-child { margin-right: auto; }
.page-head p { color: var(--muted); margin: 2px 0 0; max-width: 70ch; }

/* ---------- basic controls ---------- */
.btn { font: inherit; padding: 7px 13px; border-radius: 8px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--text); cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--grey-soft); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; } .btn-primary:hover { background: var(--accent-dark); }
.btn-danger { background: var(--red); border-color: var(--red); color: #fff; } .btn-danger:hover { background: #8f1d17; }
.btn-small { padding: 3px 9px; font-size: .85rem; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.is-busy { position: relative; color: transparent !important; }
.btn.is-busy::after { content: ""; position: absolute; inset: 0; margin: auto; width: 14px; height: 14px; border: 2px solid currentColor; border-color: #888 transparent #888 transparent; border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.icon-btn { font: inherit; border: 0; background: transparent; cursor: pointer; padding: 4px 7px; border-radius: 6px; color: var(--muted); }
.icon-btn:hover { background: var(--grey-soft); color: var(--text); }
input[type=text], input[type=email], input[type=password], input[type=number], select, textarea {
  font: inherit; width: 100%; padding: 7px 9px; border: 1px solid var(--line-strong); border-radius: 8px; background: #fff; color: var(--text); }
textarea { min-height: 70px; resize: vertical; }
input[type=file] { font: inherit; max-width: 100%; }
.field { margin-bottom: 12px; } .field > label { display: block; font-weight: 600; font-size: .88rem; margin-bottom: 3px; }
.hint { color: var(--muted); font-size: .82rem; margin-top: 3px; }
.check { display: flex; gap: 8px; align-items: flex-start; margin-bottom: 10px; } .check input { margin-top: 4px; width: 16px; height: 16px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; } .row > * { flex: 1 1 160px; min-width: 0; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 16px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.cards .card { margin: 0; }
.stat { font-size: 1.7rem; font-weight: 700; line-height: 1.1; } .stat-label { color: var(--muted); font-size: .85rem; }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 12px; }
.stats a { text-decoration: none; color: inherit; display: block; padding: 12px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.stats a:hover { border-color: var(--accent); }

.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: .75rem; font-weight: 600; white-space: nowrap; }
.badge-green { background: var(--green-soft); color: var(--green); } .badge-amber { background: var(--amber-soft); color: var(--amber); }
.badge-grey { background: var(--grey-soft); color: var(--muted); } .badge-red { background: var(--red-soft); color: var(--red); }
.badge-blue { background: var(--accent-soft); color: var(--accent-dark); }

.notice { border-radius: 8px; padding: 9px 12px; margin-bottom: 12px; border: 1px solid; font-size: .92rem; }
.notice-warn { background: var(--amber-soft); border-color: #f0d9a0; color: #5c3c00; }
.notice-danger { background: var(--red-soft); border-color: #f3b8b3; color: #7d1a14; font-weight: 600; }
.notice-info { background: var(--accent-soft); border-color: #bfdcdd; color: #1d4a4d; }
.notice-ok { background: var(--green-soft); border-color: #b5dfc6; color: #155737; }

.report { border-radius: 8px; padding: 9px 12px; margin: 8px 0; border: 1px solid; font-size: .9rem; }
.report ul { margin: 6px 0 0; padding-left: 20px; }
.report-ok { background: var(--green-soft); border-color: #b5dfc6; color: #155737; }
.report-warn { background: var(--amber-soft); border-color: #f0d9a0; color: #5c3c00; }
.report-bad { background: var(--red-soft); border-color: #f3b8b3; color: #7d1a14; }
.report-bad .report-warnings { color: #5c3c00; }

.usage { margin-bottom: 14px; } .usage-head { display: flex; justify-content: space-between; gap: 10px; font-size: .9rem; margin-bottom: 4px; flex-wrap: wrap; }
.bar { height: 10px; background: var(--grey-soft); border-radius: 999px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--accent); border-radius: 999px; } .bar-warn { background: var(--red); }

table { border-collapse: collapse; width: 100%; font-size: .9rem; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; }
.table-wrap { overflow-x: auto; }

/* ---------- asset grid ---------- */
.group-title { display: flex; align-items: baseline; gap: 8px; margin: 18px 0 8px; } .group-title h2 { margin: 0; }
.asset-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; }
.asset { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); display: flex; flex-direction: column; overflow: hidden; }
.asset[draggable=true] { cursor: grab; }
.asset.dragging { opacity: .4; } .asset.drop-target { outline: 3px dashed var(--accent); outline-offset: 2px; }
.asset-thumb { aspect-ratio: 1 / 1; background: #fafbfc; display: grid; place-items: center; border-bottom: 1px solid var(--line); overflow: hidden; position: relative; }
.asset-thumb.tall { aspect-ratio: 9 / 12; } .asset-thumb.flat { aspect-ratio: auto; min-height: 70px; padding: 10px; }
.asset-thumb img { width: 100%; height: 100%; object-fit: contain; } .asset-thumb.tall img { object-fit: cover; }
.asset-thumb audio { width: 100%; }
.img-missing { visibility: hidden; }
.asset-thumb:has(.img-missing)::after { content: "No image"; color: var(--muted); font-size: .8rem; position: absolute; }
.asset-body { padding: 9px 11px; flex: 1; }
.asset-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.asset-id { color: var(--muted); font-size: .78rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.asset-meta { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 6px; }
.asset-foot { display: flex; flex-wrap: wrap; gap: 4px; padding: 6px 8px; border-top: 1px solid var(--line); align-items: center; }
.asset-foot select { width: auto; padding: 2px 6px; font-size: .82rem; flex: 1 1 96px; min-width: 96px; }
.strip { display: flex; flex-wrap: wrap; gap: 3px; } .strip span { width: 22px; height: 22px; border-radius: 5px; border: 1px solid rgba(0, 0, 0, .15); }
.empty { text-align: center; padding: 36px 16px; color: var(--muted); border: 2px dashed var(--line-strong); border-radius: var(--radius); background: var(--surface); }

.swatches { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.swatch { display: flex; align-items: center; gap: 2px; border: 1px solid var(--line); border-radius: 8px; padding: 3px; background: #fff; }
.swatch input[type=color] { width: 30px; height: 30px; border: 0; padding: 0; background: none; cursor: pointer; }
.swatch .hex { width: 82px; padding: 3px 5px; font-family: ui-monospace, Menlo, monospace; font-size: .82rem; }

/* ---------- modal / toast ---------- */
.overlay { position: fixed; inset: 0; background: rgba(15, 23, 35, .5); display: grid; place-items: start center; padding: 4vh 12px; overflow-y: auto; z-index: 50; }
.modal { background: var(--surface); border-radius: 12px; width: min(560px, 100%); box-shadow: 0 20px 60px rgba(0, 0, 0, .3); }
.modal-wide { width: min(980px, 100%); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--line); } .modal-head h2 { margin: 0; }
.modal-body { padding: 16px 18px; } .modal-foot { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.editor { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }
.file-slot { border: 1px solid var(--line); border-radius: 10px; padding: 10px; margin-bottom: 12px; }
.file-slot-head { display: flex; justify-content: space-between; gap: 8px; font-weight: 600; font-size: .9rem; margin-bottom: 6px; flex-wrap: wrap; }
.file-preview { background: repeating-conic-gradient(#f1f3f5 0% 25%, #fff 0% 50%) 50% / 16px 16px; border: 1px solid var(--line); border-radius: 8px; display: grid; place-items: center; min-height: 60px; margin-bottom: 8px; overflow: hidden; }
.file-preview img, .file-preview video { max-width: 100%; max-height: 190px; display: block; } .file-preview audio { width: 100%; }
.toasts { position: fixed; right: 16px; bottom: 16px; display: grid; gap: 8px; z-index: 100; max-width: min(420px, 90vw); }
.toast { background: #1c2430; color: #fff; padding: 10px 14px; border-radius: 8px; box-shadow: var(--shadow); font-size: .92rem; }
.toast-error { background: var(--red); } .toast-success { background: var(--green); }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login .card { width: min(400px, 100%); padding: 26px; }

/* ---------- phone frame ---------- */
.phone { width: 270px; height: 540px; border-radius: 34px; background: #111; padding: 10px; box-shadow: 0 10px 30px rgba(0, 0, 0, .25); flex: none; margin: 0 auto; }
.phone-screen { width: 100%; height: 100%; border-radius: 26px; overflow: hidden; background: #fff; position: relative; display: flex; flex-direction: column; }
.call { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: space-between; padding: 34px 16px 26px; color: #fff; background: linear-gradient(180deg, #1d3557, #0b1a2e); text-align: center; position: relative; }
.call video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.call > * { position: relative; }
.call-avatar { width: 120px; height: 120px; border-radius: 50%; overflow: hidden; background: #33506f; border: 4px solid rgba(255, 255, 255, .25); margin: 14px auto; }
.call-avatar img { width: 100%; height: 100%; object-fit: cover; }
.call-avatar.pulse { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 16px rgba(255, 255, 255, .12); } }
.call-name { font-size: 1.25rem; font-weight: 700; } .call-sub { opacity: .8; font-size: .9rem; }
.call-buttons { display: flex; gap: 46px; }
.call-btn { width: 62px; height: 62px; border-radius: 50%; border: 0; color: #fff; font-size: 1.5rem; cursor: pointer; }
.call-btn.answer { background: #2bb673; animation: pulse 1.2s ease-in-out infinite; } .call-btn.hangup { background: #e5383b; }
.ob { flex: 1; display: flex; flex-direction: column; padding: 16px 14px; background-size: cover; background-position: center; background-color: #eef6f6; }
.ob-top { display: flex; align-items: center; gap: 8px; font-size: .8rem; color: #33475b; }
.ob-top button { font: inherit; border: 0; background: rgba(255, 255, 255, .85); border-radius: 999px; padding: 3px 10px; cursor: pointer; }
.ob-progress { flex: 1; height: 6px; background: rgba(0, 0, 0, .12); border-radius: 9px; overflow: hidden; } .ob-progress div { height: 100%; background: var(--accent); }
.ob-title { font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: #4b6075; margin: 14px 0 2px; text-align: center; }
.ob-q { font-size: 1.1rem; font-weight: 700; text-align: center; margin-bottom: 12px; color: #14263a; }
.ob-opts { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; overflow-y: auto; }
.ob-opt { border: 2px solid transparent; border-radius: 14px; background: #fff; box-shadow: var(--shadow); padding: 6px; cursor: pointer; font: inherit; text-align: center; font-weight: 600; font-size: .85rem; }
.ob-opt.sel { border-color: var(--accent); }
.ob-opt .ob-img { aspect-ratio: 1 / 1; border-radius: 9px; overflow: hidden; background: #f1f3f5; display: grid; place-items: center; margin-bottom: 4px; font-size: 1.6rem; }
.ob-opt .ob-img img { width: 100%; height: 100%; object-fit: cover; }
.ob-opt .strip { justify-content: center; padding: 6px; }
.split { display: grid; grid-template-columns: 1fr 300px; gap: 22px; align-items: start; }
.sticky { position: sticky; top: 14px; }
.q-card { border: 1px solid var(--line); border-radius: 10px; padding: 12px; margin-bottom: 12px; background: var(--surface); }
.q-card.active { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.q-head { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; } .q-head strong { margin-right: auto; }
.opt-row { display: grid; grid-template-columns: 46px 1fr 1fr auto; gap: 8px; align-items: center; margin-bottom: 6px; }
.opt-img { width: 46px; height: 46px; border-radius: 8px; border: 1px solid var(--line); overflow: hidden; background: #f1f3f5; display: grid; place-items: center; cursor: pointer; position: relative; font-size: .7rem; color: var(--muted); }
.opt-img img { width: 100%; height: 100%; object-fit: cover; position: absolute; inset: 0; }
.opt-img input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.diff-add { color: var(--green); } .diff-del { color: var(--red); } .diff-chg { color: var(--amber); }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; } .kv dt { color: var(--muted); } .kv dd { margin: 0; overflow-wrap: anywhere; }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .nav { border-right: 0; border-bottom: 1px solid var(--line); display: flex; overflow-x: auto; padding: 6px 8px; gap: 2px; }
  .nav a { white-space: nowrap; } .nav .nav-group { display: none; }
  .main { padding: 16px 14px 50px; }
  .editor, .split { grid-template-columns: 1fr; }
  .sticky { position: static; }
  .opt-row { grid-template-columns: 46px 1fr auto; } .opt-row > :nth-child(3) { grid-column: 2 / 3; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; } }
