:root{
  --bg:#f4f7fb;
  --surface:#ffffff;
  --surface-soft:#f8fafc;
  --surface-dark:#0f172a;
  --surface-dark-2:#111c31;
  --text:#172033;
  --muted:#6b7485;
  --line:#e3e8f0;
  --line-strong:#d4dbe7;
  --primary:#2563eb;
  --primary-dark:#1d4ed8;
  --primary-soft:#eff6ff;
  --danger:#dc2626;
  --danger-soft:#fff1f2;
  --success:#059669;
  --success-soft:#ecfdf5;
  --warning:#b45309;
  --warning-soft:#fff7ed;
  --radius:14px;
  --shadow:0 8px 28px rgba(15,23,42,.06);
  --sidebar:246px;
}

*{box-sizing:border-box}
html,body{margin:0;min-height:100%;background:var(--bg)}
body{
  color:var(--text);
  font-family:"Segoe UI","Microsoft YaHei",Arial,sans-serif;
  font-size:14px;
  line-height:1.55;
}
a{color:inherit;text-decoration:none}
button,input,select,textarea{font:inherit}
button{border:0}
h1,h2,h3{color:#111827}
h1{font-size:28px;line-height:1.2;margin:0 0 7px}
h2{font-size:18px;margin:0 0 12px}
h3{font-size:16px;margin:0 0 10px}
p{color:var(--muted);margin:5px 0}
small,.hint{color:var(--muted)}

.app-shell{min-height:100vh}
.sidebar{
  position:fixed;
  inset:0 auto 0 0;
  width:var(--sidebar);
  background:linear-gradient(180deg,#101a2d 0%,#0b1323 100%);
  color:#d9e2f0;
  padding:18px 14px;
  display:flex;
  flex-direction:column;
  z-index:30;
}
.sidebar-brand{
  display:flex;
  align-items:center;
  gap:11px;
  padding:5px 8px 20px;
  border-bottom:1px solid rgba(255,255,255,.08);
}
.brand-mark{
  width:40px;height:40px;border-radius:12px;
  display:flex;align-items:center;justify-content:center;
  color:white;font-weight:800;letter-spacing:.5px;
  background:linear-gradient(135deg,#3b82f6,#6366f1);
  box-shadow:0 7px 20px rgba(37,99,235,.3);
}
.sidebar-brand strong{display:block;color:#fff;font-size:15px}
.sidebar-brand span{display:block;color:#8492a8;font-size:11px;margin-top:1px}

.side-nav{padding-top:14px;overflow:auto;min-height:0}
.nav-section{
  color:#64748b;
  font-size:11px;
  font-weight:700;
  letter-spacing:.09em;
  text-transform:uppercase;
  padding:14px 10px 7px;
}
.side-nav a{
  display:flex;
  align-items:center;
  gap:10px;
  min-height:42px;
  padding:9px 10px;
  border-radius:10px;
  color:#abb7c9;
  margin:2px 0;
  transition:.15s ease;
}
.side-nav a:hover{background:rgba(255,255,255,.06);color:#fff}
.side-nav a.active{
  color:#fff;
  background:linear-gradient(90deg,rgba(37,99,235,.25),rgba(37,99,235,.08));
  box-shadow:inset 3px 0 0 #60a5fa;
}
.nav-icon{
  width:22px;
  text-align:center;
  font-size:16px;
  color:#8fa1bb;
}
.side-nav a.active .nav-icon{color:#93c5fd}
.sidebar-logout{margin-top:auto;padding-top:12px}
.sidebar-logout button{
  width:100%;
  padding:10px 12px;
  border-radius:10px;
  background:rgba(255,255,255,.05);
  color:#9eabc0;
  cursor:pointer;
}
.sidebar-logout button:hover{background:rgba(220,38,38,.13);color:#fecaca}

.main-shell{margin-left:var(--sidebar);min-width:0}
.app-topbar{
  height:66px;
  position:sticky;
  top:0;
  z-index:20;
  background:rgba(255,255,255,.93);
  backdrop-filter:blur(14px);
  border-bottom:1px solid var(--line);
  display:flex;
  align-items:center;
  padding:0 28px;
  gap:14px;
}
.app-topbar>div:first-of-type{display:flex;flex-direction:column}
.app-topbar strong{font-size:15px}
.app-topbar span{font-size:12px;color:var(--muted)}
.topbar-user{
  margin-left:auto;
  display:flex!important;
  flex-direction:row!important;
  align-items:center;
  gap:8px;
  padding:7px 10px;
  border:1px solid var(--line);
  border-radius:999px;
  background:#fff;
}
.online-dot{width:8px;height:8px;border-radius:50%;background:#10b981;box-shadow:0 0 0 4px #d1fae5}
.mobile-nav-button{display:none;background:transparent;font-size:22px;cursor:pointer}

.content{max-width:1650px;margin:0 auto;padding:26px 28px 42px}
.public-content{max-width:460px;margin:9vh auto;padding:20px}

.card{
  background:var(--surface);
  border:1px solid var(--line);
  border-radius:var(--radius);
  padding:18px;
  box-shadow:var(--shadow);
  margin-bottom:18px;
}
.page-head{
  display:flex;
  justify-content:space-between;
  align-items:flex-start;
  gap:18px;
  margin-bottom:20px;
}
.page-head>div:first-child{min-width:0}
.eyebrow{
  color:var(--primary);
  font-weight:800;
  letter-spacing:.12em;
  font-size:11px;
  margin-bottom:6px;
}

input,select,textarea{
  width:100%;
  border:1px solid var(--line-strong);
  background:#fff;
  color:var(--text);
  border-radius:9px;
  padding:10px 11px;
  outline:none;
  transition:border .15s,box-shadow .15s;
}
input:focus,select:focus,textarea:focus{
  border-color:#93c5fd;
  box-shadow:0 0 0 3px #dbeafe;
}
input[type="color"].color-input{
  height:42px;
  padding:4px;
  cursor:pointer;
}
label{
  display:block;
  color:#384152;
  font-size:13px;
  font-weight:650;
  margin:10px 0 5px;
}

.btn{
  min-height:38px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:6px;
  border:1px solid var(--line-strong);
  background:#fff;
  color:#344054;
  border-radius:9px;
  padding:8px 13px;
  cursor:pointer;
  transition:.15s ease;
}
.btn:hover{border-color:#b9c4d4;background:#f8fafc}
.btn.primary{color:#fff;background:var(--primary);border-color:var(--primary)}
.btn.primary:hover{background:var(--primary-dark)}
.btn.danger{color:#b91c1c;background:#fff;border-color:#fecaca}
.btn.danger:hover{background:var(--danger-soft)}
.btn.small,.btn.tiny{min-height:31px;padding:5px 9px;font-size:12px}
.btn.large{min-height:44px;font-weight:700}
.btn.full{width:100%}
.actions{display:flex;gap:8px;flex-wrap:wrap}
.button-grid{display:grid;grid-template-columns:1fr 1fr;gap:8px}
.field-row,.row{display:grid;grid-template-columns:1fr 1fr;gap:9px}

.alert{
  padding:11px 13px;
  border-radius:10px;
  margin-bottom:14px;
  border:1px solid var(--line);
  background:#fff;
}
.alert.success{background:var(--success-soft);color:#047857;border-color:#a7f3d0}
.alert.danger{background:var(--danger-soft);color:#b91c1c;border-color:#fecdd3}

.stats{display:grid;grid-template-columns:repeat(5,minmax(0,1fr));gap:14px}
.stat{position:relative;overflow:hidden}
.stat strong{display:block;font-size:30px;letter-spacing:-.02em;margin:4px 0}
.stat span{color:var(--muted);font-size:13px}

.grid2{display:grid;grid-template-columns:1fr 1fr;gap:18px}
.inline-form{display:grid;grid-template-columns:1fr 1fr auto;gap:10px;align-items:end}
.form-grid{display:grid;grid-template-columns:repeat(4,1fr) auto;gap:10px;align-items:end}

table{
  width:100%;
  border-collapse:separate;
  border-spacing:0;
  background:#fff;
  border:1px solid var(--line);
  border-radius:12px;
  overflow:hidden;
}
th,td{
  text-align:left;
  padding:11px 12px;
  border-bottom:1px solid var(--line);
  vertical-align:top;
}
th{
  background:#f8fafc;
  color:#667085;
  font-size:12px;
  font-weight:700;
  white-space:nowrap;
}
tr:last-child td{border-bottom:0}
tr:hover td{background:#fbfdff}

.badge{
  display:inline-flex;
  align-items:center;
  padding:4px 8px;
  border-radius:999px;
  background:#eef2f7;
  color:#475467;
  font-size:11px;
  font-weight:700;
}
.badge.success{background:#d1fae5;color:#047857}
.badge.danger{background:#fee2e2;color:#b91c1c}

.wallpaper-grid,.history-grid{
  display:grid;
  grid-template-columns:repeat(3,minmax(0,1fr));
  gap:16px;
}
.wallpaper-card,.history-card{padding:0;overflow:hidden}
.wallpaper-card img,.history-card>img{
  width:100%;
  height:210px;
  object-fit:cover;
  background:#0f172a;
  display:block;
}
.wallpaper-body,.history-card>div{padding:15px}

.login-card{
  max-width:420px;
  margin:9vh auto;
  padding:28px;
}
.login-card .btn{width:100%;margin-top:14px}

/* Designer */
.designer-page-head{margin-bottom:16px}
.designer-layout{
  display:grid;
  grid-template-columns:290px minmax(440px,1fr) 310px;
  gap:14px;
  align-items:start;
}
.designer-panel{
  background:#fff;
  border:1px solid var(--line);
  border-radius:14px;
  box-shadow:var(--shadow);
  overflow:hidden;
}
.designer-left,.designer-right{
  position:sticky;
  top:82px;
  max-height:calc(100vh - 100px);
  overflow:auto;
}
.panel-title{
  padding:14px 15px;
  border-bottom:1px solid var(--line);
  background:#fbfcfe;
}
.panel-title strong{display:block;font-size:14px}
.panel-title span{display:block;color:var(--muted);font-size:11px;margin-top:2px}

.tool-section{border-bottom:1px solid var(--line)}
.tool-section:last-child{border-bottom:0}
.tool-section summary{
  list-style:none;
  cursor:pointer;
  padding:12px 14px;
  font-weight:700;
  color:#344054;
  display:flex;
  align-items:center;
  gap:9px;
}
.tool-section summary::-webkit-details-marker{display:none}
.tool-section summary span{
  width:24px;height:24px;border-radius:7px;
  display:inline-flex;align-items:center;justify-content:center;
  background:var(--primary-soft);color:var(--primary);
  font-size:10px;
}
.tool-section[open] summary{background:#fbfdff}
.tool-body{padding:0 14px 14px}
.tool-body .btn{margin-top:8px}

.designer-center{min-width:0}
.canvas-toolbar{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  padding:10px 12px;
  background:#fff;
  border:1px solid var(--line);
  border-radius:12px 12px 0 0;
}
.canvas-meta{display:flex;flex-direction:column;min-width:0}
.canvas-meta strong{font-size:13px}
.canvas-meta span{color:var(--muted);font-size:11px}
.zoom-controls{display:flex;align-items:center;gap:5px;flex-wrap:wrap;justify-content:flex-end}
#zoomLabel{color:var(--muted);font-size:11px;margin-left:3px;min-width:52px}

.designer-stage{
  min-height:560px;
  max-height:calc(100vh - 190px);
  overflow:auto;
  background:#172033;
  border:1px solid #18253b;
  border-top:0;
  padding:28px;
  display:flex;
  align-items:flex-start;
  justify-content:center;
}
.canvas-checker{
  min-width:min-content;
  padding:14px;
  border-radius:10px;
  background-color:#d9dee7;
  background-image:
    linear-gradient(45deg,#c8ced9 25%,transparent 25%),
    linear-gradient(-45deg,#c8ced9 25%,transparent 25%),
    linear-gradient(45deg,transparent 75%,#c8ced9 75%),
    linear-gradient(-45deg,transparent 75%,#c8ced9 75%);
  background-size:22px 22px;
  background-position:0 0,0 11px,11px -11px,-11px 0;
}
#designerCanvas{
  display:block;
  max-width:100%;
  height:auto;
  background:#1f2937;
  box-shadow:0 9px 30px rgba(0,0,0,.28);
  touch-action:none;
  outline:none;
}
.designer-status{
  margin-top:10px;
  min-height:40px;
  padding:10px 12px;
  border:1px solid var(--line);
  border-radius:10px;
  background:#fff;
  color:var(--muted);
  font-size:12px;
}

.inspector-section{padding:14px;border-bottom:1px solid var(--line)}
.inspector-section:last-child{border-bottom:0}
.inspector-heading strong{display:block}
.inspector-heading span{color:var(--muted);font-size:11px}
.layer-list{
  display:grid;
  gap:7px;
  max-height:260px;
  overflow:auto;
  margin:11px 0;
}
.layer-empty{
  padding:14px 10px;
  border:1px dashed var(--line-strong);
  border-radius:9px;
  text-align:center;
  color:var(--muted);
  font-size:12px;
}
.layer-row{
  display:grid;
  grid-template-columns:minmax(0,1fr) auto auto;
  gap:5px;
  align-items:center;
  padding:5px;
  border:1px solid var(--line);
  border-radius:9px;
}
.layer-row.selected{border-color:#93c5fd;background:#eff6ff}
.layer-name{
  border:0;
  background:transparent;
  text-align:left;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
  cursor:pointer;
  padding:6px;
  color:var(--text);
}
.output-card{position:relative}
.output-card h3{padding-right:54px}
.output-badge{
  position:absolute;
  top:13px;right:13px;
  padding:3px 7px;border-radius:999px;
  background:#dbeafe;color:#1d4ed8;
  font-size:10px;font-weight:800;
}
.output-badge.secondary{background:#ede9fe;color:#6d28d9}
.template-output{background:#fcfbff}

hr{border:0;border-top:1px solid var(--line);margin:16px 0}

@media(max-width:1350px){
  .designer-layout{grid-template-columns:270px minmax(430px,1fr)}
  .designer-right{
    grid-column:1/-1;
    position:static;
    max-height:none;
    display:grid;
    grid-template-columns:1fr 1fr 1fr;
  }
  .designer-right .inspector-section{border-bottom:0;border-right:1px solid var(--line)}
  .designer-right .inspector-section:last-child{border-right:0}
}
@media(max-width:1100px){
  .stats{grid-template-columns:repeat(2,1fr)}
  .wallpaper-grid,.history-grid{grid-template-columns:repeat(2,1fr)}
  .designer-layout{grid-template-columns:1fr}
  .designer-left,.designer-right{position:static;max-height:none}
  .designer-right{grid-column:auto;display:grid;grid-template-columns:1fr 1fr}
  .designer-right .inspector-section:first-child{grid-column:1/-1;border-right:0;border-bottom:1px solid var(--line)}
  .designer-stage{max-height:none;min-height:440px}
}
@media(max-width:900px){
  :root{--sidebar:236px}
  .sidebar{
    transform:translateX(-105%);
    transition:transform .2s ease;
    box-shadow:20px 0 40px rgba(15,23,42,.2);
  }
  .sidebar.open{transform:translateX(0)}
  .main-shell{margin-left:0}
  .mobile-nav-button{display:inline-flex}
  .content{padding:20px}
}
@media(max-width:700px){
  .page-head{flex-direction:column}
  .grid2,.inline-form,.form-grid{grid-template-columns:1fr}
  .wallpaper-grid,.history-grid,.stats{grid-template-columns:1fr}
  .designer-right{grid-template-columns:1fr}
  .designer-right .inspector-section:first-child{grid-column:auto}
  .designer-right .inspector-section{border-right:0;border-bottom:1px solid var(--line)}
  .canvas-toolbar{align-items:flex-start;flex-direction:column}
  .zoom-controls{justify-content:flex-start}
  .designer-stage{padding:14px}
  .button-grid,.field-row,.row{grid-template-columns:1fr}
  .app-topbar{padding:0 16px}
  .content{padding:16px}
}


.remote-action-note{
  display:flex;
  align-items:center;
  gap:12px;
  padding:12px 14px;
  margin-bottom:14px;
  border:1px solid #bfdbfe;
  background:#eff6ff;
  border-radius:12px;
  color:#1e40af;
}
.remote-action-note strong{white-space:nowrap}
.remote-action-note span{font-size:12px;color:#49648f}
.table-scroll{overflow:auto}
.page-head.compact{margin-bottom:12px}
button:disabled{opacity:.45;cursor:not-allowed}


.privacy-banner{
  display:flex;align-items:center;gap:12px;
  padding:12px 14px;margin-bottom:16px;
  background:#fff7ed;border:1px solid #fed7aa;border-radius:12px;
}
.privacy-banner strong{color:#9a3412;white-space:nowrap}
.privacy-banner span{color:#7c4a2c;font-size:12px}
.camera-device-picker{padding:14px}
.camera-device-row{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:10px;align-items:center}
.camera-layout{display:grid;grid-template-columns:minmax(0,1fr) 290px;gap:16px;margin-bottom:18px}
.camera-preview-card,.camera-side-card{
  background:#fff;border:1px solid var(--line);border-radius:14px;box-shadow:var(--shadow);
}
.camera-preview-head{display:flex;justify-content:space-between;align-items:center;padding:13px 15px;border-bottom:1px solid var(--line)}
.camera-preview-head>div{display:flex;flex-direction:column}
.camera-preview-head span{color:var(--muted);font-size:12px}
.live-pill{display:none;align-items:center;background:#fee2e2;color:#b91c1c;font-size:10px;font-weight:800;padding:4px 8px;border-radius:999px}
.camera-preview{
  position:relative;min-height:480px;background:#05080f;
  display:flex;align-items:center;justify-content:center;overflow:hidden;
}
.camera-preview img{width:100%;height:100%;max-height:650px;object-fit:contain;display:block}
.camera-preview-empty{
  position:absolute;inset:0;display:flex;align-items:center;justify-content:center;
  color:#94a3b8;font-size:14px;pointer-events:none;
}
.camera-controls{display:flex;flex-wrap:wrap;gap:8px;padding:13px 15px;border-top:1px solid var(--line)}
.camera-side-card{padding:16px}
.camera-kv{display:flex;justify-content:space-between;gap:12px;padding:9px 0;border-bottom:1px solid var(--line)}
.camera-kv span{color:var(--muted)}
.snapshot-grid{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:12px}
.snapshot-card{border:1px solid var(--line);border-radius:11px;overflow:hidden;background:#fff}
.snapshot-card img{width:100%;height:170px;object-fit:cover;background:#111827}
.snapshot-card>div{padding:10px;display:grid;gap:8px}
.empty-state{padding:28px;text-align:center;color:var(--muted);border:1px dashed var(--line-strong);border-radius:12px}
@media(max-width:1100px){
  .camera-layout{grid-template-columns:1fr}
  .snapshot-grid{grid-template-columns:repeat(2,minmax(0,1fr))}
}
@media(max-width:650px){
  .camera-device-row{grid-template-columns:1fr}
  .snapshot-grid{grid-template-columns:1fr}
  .camera-preview{min-height:280px}
}
