:root {
  --bg: #F4F3EF; --surface: #FFFFFF; --ink: #1C1B19; --muted: #6B6862; --line: #E2E0DA; --line-strong: #CFCCC4;
  --accent: #1F4E4A; --accent-ink: #FFFFFF; --accent-soft: #E4EEEC; --danger: #B4362D; --danger-soft: #F8E5E2; --ok: #2E7D57; --ok-soft: #E3F1E9; --warn: #9A6B12; --warn-soft: #FBF0D9;
  --radius: 10px; --shadow: 0 1px 2px rgba(28,27,25,.06), 0 8px 24px -12px rgba(28,27,25,.18);
  --font: -apple-system, BlinkMacSystemFont, "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.55 var(--font); -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
a { color: var(--accent); }
h1, h2, h3 { margin: 0; line-height: 1.25; text-wrap: balance; }
h1 { font-size: 22px; font-weight: 700; } h2 { font-size: 16px; font-weight: 700; } h3 { font-size: 15px; font-weight: 700; }
p { margin: 0; }
.muted { color: var(--muted); } .tiny { font-size: 12px; } .req { color: var(--danger); }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; background: var(--accent-soft); padding: 1px 5px; border-radius: 4px; }
input, select, textarea, button { font: inherit; color: inherit; }
input[type=text], input[type=search], input[type=password], input[type=url], input[type=number], input:not([type]), textarea, select { width: 100%; border: 1px solid var(--line-strong); border-radius: 8px; background: #fff; padding: 8px 10px; min-height: 38px; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
textarea { resize: vertical; min-height: 72px; }
label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin: 10px 0 4px; letter-spacing: .02em; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 38px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--line-strong); background: #fff; color: var(--ink); cursor: pointer; white-space: nowrap; transition: background .12s, border-color .12s, transform .06s; }
.btn:hover { background: #FAF9F6; border-color: #B8B4AA; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover { background: #17403C; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: rgba(28,27,25,.06); }
.btn.danger { color: var(--danger); border-color: #E7C2BD; }
.btn.danger:hover { background: var(--danger-soft); }
.btn.small { min-height: 32px; padding: 0 10px; font-size: 13px; }
.btn.icon { width: 32px; min-height: 32px; padding: 0; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

.topbar { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 20px; background: var(--surface); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.brand-mark { display: inline-flex; align-items: center; justify-content: center; height: 28px; padding: 0 8px; border-radius: 6px; background: var(--ink); color: #fff; font-weight: 700; font-size: 13px; letter-spacing: .06em; }
.brand-name { font-weight: 700; font-size: 15px; }
.brand-sub { font-size: 12px; color: var(--muted); }
.topnav { display: flex; align-items: center; gap: 10px; font-size: 13px; }

.main { min-height: calc(100% - 50px); }
.login { display: grid; place-items: center; padding: 48px 16px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); }
.login-card { width: min(420px, 100%); padding: 28px 28px 24px; display: grid; gap: 6px; }
.login-card .btn { margin-top: 12px; }
.form-err { color: var(--danger); font-size: 13px; min-height: 18px; }

.work { display: grid; grid-template-columns: 320px minmax(0, 1fr); min-height: calc(100vh - 50px); }
.sidebar { border-right: 1px solid var(--line); background: var(--surface); display: flex; flex-direction: column; min-height: 0; }
.side-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px 8px; }
.side-search { padding: 0 16px 10px; }
.project-list { list-style: none; margin: 0; padding: 0 8px 8px; overflow: auto; flex: 1; }
.project-item { display: grid; grid-template-columns: 64px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 8px; border-radius: 10px; cursor: pointer; border: 1px solid transparent; }
.project-item:hover { background: var(--bg); }
.project-item[aria-current="true"] { background: var(--accent-soft); border-color: #C7DBD8; }
.project-item img, .project-item .noimg { width: 64px; aspect-ratio: 16 / 9; border-radius: 6px; object-fit: cover; background: #DAD8D1; display: block; }
.project-item .t { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.project-item .s { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }
.side-foot { padding: 8px 16px 14px; }
.pill { display: inline-flex; align-items: center; gap: 4px; height: 20px; white-space: nowrap; padding: 0 8px; border-radius: 10px; font-size: 11px; font-weight: 600; letter-spacing: .02em; }
.pill.on { background: var(--ok-soft); color: var(--ok); } .pill.off { background: #ECEAE4; color: var(--muted); } .pill.lock { background: var(--warn-soft); color: var(--warn); }

.editor { padding: 20px 24px 60px; min-width: 0; }
.empty { max-width: 560px; margin: 60px auto; text-align: center; display: grid; gap: 10px; }
.ed-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.ed-head h1 { font-size: 20px; }
.ed-head .actions { display: flex; flex-wrap: wrap; gap: 8px; }
.ed-grid { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 18px; align-items: start; }
.stack { display: grid; gap: 18px; min-width: 0; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px 18px; }
.panel > h2 { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 4px; }
.panel > h2 .hint { font-size: 12px; font-weight: 400; color: var(--muted); }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 0 14px; }
.fld { min-width: 0; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.check { display: flex; align-items: center; gap: 8px; margin: 8px 0; font-size: 14px; color: var(--ink); font-weight: 400; }
.check input { width: 18px; height: 18px; margin: 0; accent-color: var(--accent); }
.save-row { display: flex; align-items: center; gap: 10px; margin-top: 14px; }
.save-note { font-size: 12px; color: var(--muted); }

.logo-box { display: grid; grid-template-columns: 1fr auto; gap: 14px; align-items: center; }
.logo-preview { background: #2B2A27 url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16'%3E%3Crect width='8' height='8' fill='%23333' /%3E%3Crect x='8' y='8' width='8' height='8' fill='%23333' /%3E%3C/svg%3E"); border-radius: 8px; padding: 14px; display: flex; align-items: center; min-height: 80px; }
.logo-preview img { max-height: 59px; max-width: 100%; }

.drop { border: 2px dashed var(--line-strong); border-radius: 12px; padding: 22px; text-align: center; background: #FBFAF8; transition: background .12s, border-color .12s; cursor: pointer; }
.drop.over { background: var(--accent-soft); border-color: var(--accent); }
.drop strong { display: block; font-size: 15px; }
.drop input { display: none; }
.uploads { display: grid; gap: 8px; margin-top: 12px; }
.up { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; font-size: 13px; }
.up .bar { grid-column: 1 / -1; height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.up .bar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.up.err { color: var(--danger); }

.scenes { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 8px; }
.scene { display: grid; grid-template-columns: 120px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 8px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.scene img { width: 120px; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 6px; background: #DAD8D1; display: block; }
.scene .meta { display: grid; gap: 6px; min-width: 0; }
.scene .meta input { min-height: 34px; padding: 6px 8px; }
.scene .meta .dims { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.scene .ops { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; max-width: 150px; }
.scene .idx { position: absolute; }
.scene-num { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }

.share { display: grid; gap: 10px; }
.share .link { display: flex; gap: 8px; }
.share .link input { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; }
.qr { display: grid; place-items: center; padding: 10px; background: #fff; border: 1px solid var(--line); border-radius: 8px; }
.qr canvas, .qr img { width: 180px; height: 180px; image-rendering: pixelated; }
.status-line { display: flex; align-items: center; gap: 8px; }
.switch { position: relative; width: 44px; height: 26px; border-radius: 13px; background: #CFCCC4; border: 0; cursor: pointer; transition: background .15s; flex: none; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch[aria-checked="true"] { background: var(--ok); }
.switch[aria-checked="true"]::after { transform: translateX(18px); }

.dlg { border: 0; border-radius: 14px; padding: 0; width: min(520px, calc(100vw - 32px)); box-shadow: 0 24px 60px -20px rgba(0,0,0,.35); }
.dlg::backdrop { background: rgba(28,27,25,.45); }
.dlg form, .dlg-view-body { padding: 22px 22px 18px; display: grid; gap: 4px; }
.dlg-actions { display: flex; justify-content: flex-end; align-items: center; gap: 8px; margin-top: 14px; }
.dlg-view { width: min(980px, calc(100vw - 32px)); }
.view-pano { width: 100%; aspect-ratio: 16 / 9; max-height: 60vh; background: #000; border-radius: 8px; overflow: hidden; margin-top: 8px; }
.view-pano .pnlm-container { background: #000; }

.toast { position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom, 0px) + 22px); transform: translate(-50%, 20px); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 13px; opacity: 0; transition: opacity .2s, transform .2s; pointer-events: none; max-width: calc(100vw - 32px); z-index: 50; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { background: var(--danger); }

@media (max-width: 1100px) { .ed-grid { grid-template-columns: 1fr; } }
@media (max-width: 860px) {
  .work { grid-template-columns: 1fr; }
  .sidebar { border-right: 0; border-bottom: 1px solid var(--line); max-height: 40vh; }
  .editor { padding: 16px 16px 60px; }
  .brand-sub { display: none; }
  .scene { grid-template-columns: 96px minmax(0, 1fr); }
  .scene .ops { grid-column: 1 / -1; justify-content: flex-start; max-width: none; }
  .logo-box { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

.brand{align-items:center}.topbar .pure-brandmark{--brand-size:45px}.logo-box{grid-template-columns:180px minmax(0,1fr);margin:16px 0 10px}.logo-preview{justify-content:center;min-height:176px;background:#faf8f3;border:1px solid var(--line)}.logo-preview .pure-brandmark{--brand-size:132px}.logo-preview .pure-brandmark img{max-width:none;max-height:none}.work{min-height:calc(100vh - 72px)}@media(max-width:640px){.topbar .pure-brandmark{--brand-size:36px}.brand-name{font-size:13px}.brand-sub{display:none}.logo-box{grid-template-columns:1fr}.logo-preview{min-height:176px}}
