/* Creator Studio + login page */
:root {
  --c-navy: #27457f;
  --c-navy-deep: #1b3263;
  --c-blue: #5a84e0;
  --c-sky: #cddaf5;
  --c-mist: #f2f6fd;
  --c-orange: #e8a14c;
  --c-ink: #2e3443;
  --c-soft: #687087;
  --c-line: #dde4f2;
  --c-panel: #ffffff;
  --c-bg: #e9eef8;
  --c-danger: #b42318;
  --c-ok: #1f7a4d;
  --c-font: "Nunito", system-ui, -apple-system, "Segoe UI", sans-serif;
}
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

/* ---- buttons ---- */
.b {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: 700 .92rem/1 var(--c-font); color: var(--c-navy); background: #fff;
  border: 1.5px solid var(--c-line); border-radius: 999px; padding: 10px 18px;
  cursor: pointer; text-decoration: none; transition: background .15s, border-color .15s, color .15s;
}
.b:hover { border-color: var(--c-blue); }
.b:focus-visible, .seg button:focus-visible, .tabs button:focus-visible, .bar-link:focus-visible { outline: 3px solid var(--c-orange); outline-offset: 2px; }
.b:disabled { opacity: .55; cursor: default; }
.b--primary { background: var(--c-orange); border-color: var(--c-orange); color: #fff; }
.b--primary:hover { background: #d98b2f; border-color: #d98b2f; }
.b--sm { padding: 8px 14px; font-size: .85rem; }
.b--xs { padding: 5px 10px; font-size: .78rem; border-width: 1px; }
.b--ghost { border-style: dashed; width: 100%; margin: 6px 0 14px; }
.b--quiet { border-color: transparent; color: var(--c-soft); }
.b--danger { color: var(--c-danger); }
.b--danger:hover { border-color: var(--c-danger); }
.icon-btn { border: 0; background: none; font-size: 1.6rem; line-height: 1; color: var(--c-soft); cursor: pointer; padding: 2px 6px; border-radius: 8px; }
.icon-btn:hover { background: var(--c-mist); }
.linklike { border: 0; background: none; padding: 0; font: inherit; color: var(--c-blue); font-weight: 800; cursor: pointer; text-decoration: underline; }

/* ---- gate ---- */
.studio { margin: 0; font-family: var(--c-font); color: var(--c-ink); background: var(--c-bg); }
.gate { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.gate-card { background: #fff; border-radius: 26px; box-shadow: 0 10px 40px rgba(39,69,127,.14); padding: 40px 36px; max-width: 440px; text-align: center; }
.gate-card h1 { color: var(--c-navy); font-weight: 900; margin: 16px 0 8px; font-size: 1.8rem; }
.gate-card p { color: var(--c-soft); line-height: 1.55; margin: 0 0 22px; }
.spinner { display: inline-block; width: 34px; height: 34px; border-radius: 50%; border: 4px solid var(--c-sky); border-top-color: var(--c-orange); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- app frame ---- */
.app { display: flex; flex-direction: column; height: 100vh; }
.bar {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  background: var(--c-navy-deep); color: #fff; padding: 10px 16px; flex-wrap: wrap;
}
.bar-left, .bar-mid, .bar-right { display: flex; align-items: center; gap: 10px; }
.bar-logo { background: #fff; border-radius: 10px; padding: 3px; object-fit: contain; }
.bar-name { font-weight: 900; font-size: 1.05rem; letter-spacing: .01em; }
.page-pick { display: flex; align-items: center; gap: 8px; background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.25); border-radius: 12px; padding: 0 10px; }
.page-pick svg { width: 18px; height: 18px; flex: none; }
.page-pick select { appearance: none; background: transparent url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='white' stroke-width='2'/%3E%3C/svg%3E") no-repeat right 2px center / 12px; border: 0; color: #fff; font: 800 .98rem var(--c-font); padding: 10px 22px 10px 0; min-width: 190px; cursor: pointer; }
.page-pick select option { color: var(--c-ink); }
.seg { display: inline-flex; background: rgba(255,255,255,.1); border-radius: 12px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: transparent; color: #cfdaf3; border-radius: 9px; padding: 7px 10px; font: 700 .88rem var(--c-font); cursor: pointer; display: inline-flex; align-items: center; }
.seg button svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.seg button[aria-pressed="true"] { background: #fff; color: var(--c-navy); }
.seg--mode button { padding: 7px 14px; }
.bar-link { display: inline-flex; align-items: center; gap: 6px; color: #fff; text-decoration: none; font: 700 .9rem var(--c-font); background: none; border: 0; cursor: pointer; padding: 8px 6px; border-radius: 8px; }
.bar-link svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.bar-link:hover { background: rgba(255,255,255,.1); }

.body { flex: 1; display: flex; min-height: 0; }
.side { width: 330px; flex: none; background: var(--c-panel); border-right: 1px solid var(--c-line); display: flex; flex-direction: column; min-height: 0; }
.tabs { display: flex; border-bottom: 1px solid var(--c-line); padding: 0 8px; }
.tabs button { flex: 1; border: 0; background: none; font: 800 .86rem var(--c-font); color: var(--c-soft); padding: 14px 4px 12px; border-bottom: 3px solid transparent; cursor: pointer; }
.tabs button[aria-selected="true"] { color: var(--c-navy); border-bottom-color: var(--c-orange); }
.panel { padding: 16px 16px 24px; overflow-y: auto; flex: 1; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.panel h2, .inspector h2 { margin: 0; font-size: 1.15rem; font-weight: 900; color: var(--c-navy); }
.hint { color: var(--c-soft); font-size: .84rem; line-height: 1.5; margin: 6px 0 12px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; }
.row--end { justify-content: flex-end; margin-top: 14px; }
.side label, .inspector label { display: block; font-weight: 700; font-size: .85rem; color: var(--c-ink); margin: 10px 0; }
.side input:not([type=checkbox]):not([type=color]), .side select, .inspector input[type=url], .inspector input:not([type]), .inspector input[maxlength] {
  display: block; width: 100%; box-sizing: border-box; margin-top: 5px; font: 600 .92rem var(--c-font); color: var(--c-ink);
  border: 1.5px solid var(--c-line); border-radius: 10px; padding: 9px 11px; background: #fff;
}
.side input:focus, .side select:focus, .inspector input:focus { outline: none; border-color: var(--c-blue); box-shadow: 0 0 0 3px rgba(90,132,224,.2); }

/* site map tree */
.add-page { background: var(--c-mist); border-radius: 14px; padding: 4px 12px 12px; margin-bottom: 14px; }
.tree-root { position: relative; padding-bottom: 18px; }
.tree-root::after { content: ""; position: absolute; left: 22px; bottom: 0; height: 18px; border-left: 2px solid var(--c-sky); }
.tree-kids { position: relative; margin-left: 22px; border-left: 2px solid var(--c-sky); padding-left: 0; }
.kid { position: relative; padding: 0 0 12px 18px; }
.kid::before { content: ""; position: absolute; left: 0; top: 24px; width: 16px; border-top: 2px solid var(--c-sky); }
.tree-kids .kid:last-child { padding-bottom: 0; }
.tree-kids .kid:last-child::after { content: ""; position: absolute; left: -2px; top: 26px; bottom: 0; border-left: 2px solid #fff; }
.node { background: #fff; border: 1.5px solid var(--c-line); border-radius: 14px; padding: 10px 12px; box-shadow: 0 2px 6px rgba(39,69,127,.06); }
.node.is-current { border-color: var(--c-orange); box-shadow: 0 0 0 3px rgba(232,161,76,.18); }
.node.is-hidden { background: #fafbfd; }
.node.is-hidden .node-title { color: var(--c-soft); }
.node-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.node-title { border: 0; background: none; padding: 0; font: 800 .98rem var(--c-font); color: var(--c-navy); cursor: pointer; text-align: left; }
.node-title:hover { text-decoration: underline; }
.node-meta { font-size: .76rem; color: var(--c-soft); margin: 2px 0 8px; }
.in-menu { color: var(--c-ok); font-weight: 700; }
.node-actions { display: flex; flex-wrap: wrap; gap: 5px; }
.badge { font-size: .7rem; font-weight: 800; border-radius: 999px; padding: 3px 9px; text-transform: uppercase; letter-spacing: .04em; flex: none; }
.badge--live { background: #e3f5eb; color: var(--c-ok); }
.badge--hidden { background: #eef0f5; color: var(--c-soft); }
.secs { margin-top: 8px; }
.secs summary { font-size: .8rem; font-weight: 800; color: var(--c-blue); cursor: pointer; }
.secs ul { list-style: none; margin: 6px 0 0; padding: 0; }
.sec { border: 0; background: none; width: 100%; text-align: left; font: 600 .84rem var(--c-font); color: var(--c-ink); padding: 5px 8px; border-radius: 8px; cursor: pointer; }
.sec:hover { background: var(--c-mist); color: var(--c-navy); }

/* menu editor */
.mrow { border: 1.5px solid var(--c-line); border-radius: 14px; padding: 4px 12px 10px; margin-bottom: 10px; }
.mrow input, .mrow select { margin-top: 8px !important; }
.mrow-foot { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.m-style { display: flex !important; align-items: center; gap: 6px; margin: 0 !important; font-size: .8rem !important; }
.mrow-btns { display: inline-flex; gap: 4px; }

/* colors */
.color { display: flex !important; align-items: center; gap: 12px; padding: 8px; border-radius: 12px; border: 1.5px solid var(--c-line); }
.color input[type=color] { width: 46px; height: 46px; border: 0; padding: 0; background: none; cursor: pointer; flex: none; }
.color-text { flex: 1; min-width: 0; }
.color-name { display: block; font-size: .8rem; color: var(--c-soft); font-weight: 700; }
.color .hex { margin-top: 4px !important; padding: 6px 9px !important; font-family: ui-monospace, monospace !important; font-size: .85rem !important; }

.help { padding-left: 18px; margin: 0; line-height: 1.55; font-size: .9rem; }
.help li { margin-bottom: 10px; }

/* stage */
.stage { flex: 1; min-width: 0; overflow: auto; display: flex; justify-content: center; padding: 18px; }
.frame-wrap { width: 100%; height: 100%; flex: none; background: #fff; border-radius: 14px; overflow: hidden; overflow: clip; box-shadow: 0 8px 30px rgba(39,69,127,.16); transition: width .3s ease; }
.frame-wrap[data-device="tablet"] { width: 820px; max-width: 100%; }
.frame-wrap[data-device="phone"] { width: 390px; max-width: 100%; border-radius: 28px; border: 8px solid #1b2440; }
#frame { width: 100%; height: 100%; border: 0; display: block; }

/* image inspector */
.inspector { width: 320px; flex: none; background: var(--c-panel); border-left: 1px solid var(--c-line); padding: 16px; overflow-y: auto; }
.img-preview { background: var(--c-mist); border-radius: 14px; aspect-ratio: 16 / 10; display: grid; place-items: center; overflow: hidden; margin-bottom: 8px; }
.img-preview img { max-width: 100%; max-height: 100%; object-fit: contain; }
.mini { font-size: .85rem; margin: 12px 0 6px; color: var(--c-ink); }
.media-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
.media { border: 1.5px solid var(--c-line); background: #fff; border-radius: 10px; padding: 3px; aspect-ratio: 1; cursor: pointer; min-width: 0; }
.media:hover { border-color: var(--c-orange); }
.media img { width: 100%; height: 100%; object-fit: contain; }
.fit { border: 0; padding: 0; margin: 12px 0 4px; }
.fit legend { font-weight: 700; font-size: .85rem; margin-bottom: 4px; }
.fit label { display: inline-flex !important; align-items: center; gap: 5px; margin: 4px 12px 4px 0 !important; font-weight: 600 !important; }
.inspector input[type=range] { width: 100%; accent-color: var(--c-orange); margin-top: 6px; }
.inspector output { float: right; color: var(--c-soft); font-weight: 700; }

/* floating text toolbar */
.textbar {
  position: fixed; z-index: 50; display: flex; align-items: center; gap: 6px; background: #fff;
  border-radius: 14px; box-shadow: 0 10px 30px rgba(27,50,99,.25); padding: 6px; border: 1px solid var(--c-line);
}
.tb-rich { display: flex; align-items: center; gap: 2px; }
.tb-rich button { width: 34px; height: 34px; border: 0; border-radius: 9px; background: none; font: 800 1rem Georgia, serif; color: var(--c-navy); cursor: pointer; }
.tb-rich button:hover { background: var(--c-mist); }
.tb-ul { border-bottom: 3px solid var(--c-orange); line-height: 1; }
.tb-sep { width: 1px; height: 22px; background: var(--c-line); margin: 0 4px; }
.tb-label { display: none; margin: 0 !important; }
.tb-label input { border: 1.5px solid var(--c-line); border-radius: 9px; padding: 7px 10px; font: 700 .9rem var(--c-font); width: 220px; }
.textbar.is-label .tb-rich { display: none; }
.textbar.is-label .tb-label { display: block; }

.toast {
  position: fixed; left: 50%; bottom: 22px; transform: translate(-50%, 30px); opacity: 0; pointer-events: none; z-index: 60;
  background: var(--c-navy-deep); color: #fff; font-weight: 700; padding: 12px 20px; border-radius: 999px; transition: .25s ease; max-width: 90vw; text-align: center;
}
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }
.toast.is-bad { background: var(--c-danger); }

@media (max-width: 1100px) {
  .side { width: 290px; }
  .inspector { position: fixed; right: 0; top: 0; bottom: 0; z-index: 40; box-shadow: -10px 0 30px rgba(27,50,99,.2); }
}
@media (max-width: 820px) {
  .app { height: auto; min-height: 100vh; }
  .body { flex-direction: column; }
  .side { width: auto; border-right: 0; border-bottom: 1px solid var(--c-line); max-height: 50vh; }
  .stage { padding: 10px; height: 75vh; flex: none; }
  .inspector { width: 100%; box-sizing: border-box; }
  .bar-mid { order: 3; width: 100%; }
  .page-pick { flex: 1; }
  .page-pick select { min-width: 0; width: 100%; }
}

/* ---- login page ---- */
.auth-page { background: var(--c-mist); min-height: 100vh; margin: 0; font-family: var(--c-font); }
.auth-wrap { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 32px 16px; box-sizing: border-box; }
.auth-brand { margin-bottom: 22px; }
.auth-card { background: #fff; width: 100%; max-width: 430px; border-radius: 28px; box-shadow: 0 10px 40px rgba(39,69,127,.12); padding: 34px 30px; box-sizing: border-box; }
.auth-card h1 { color: var(--c-navy); font-weight: 900; font-size: 1.8rem; margin: 0 0 4px; }
.auth-sub { color: var(--c-soft); margin: 0 0 18px; }
.auth-card label { display: block; font-weight: 700; font-size: .9rem; color: var(--c-ink); margin-bottom: 14px; }
.auth-card input { display: block; width: 100%; box-sizing: border-box; margin-top: 6px; font: 600 1rem var(--c-font); border: 1.5px solid var(--c-line); border-radius: 12px; padding: 12px 14px; }
.auth-card input:focus { outline: none; border-color: var(--c-blue); box-shadow: 0 0 0 3px rgba(90,132,224,.2); }
.auth-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.auth-error { color: var(--c-danger); font-weight: 700; font-size: .9rem; min-height: 1.2em; margin: 0 0 10px; }
.auth-submit { width: 100%; justify-content: center; }
.auth-switch { text-align: center; color: var(--c-soft); margin: 16px 0 0; font-size: .92rem; }