:root{
  --bg:#f7f7fb;
  --panel:#ffffff;
  --card:#ffffff;
  --fg:#0b0c0e;
  --fg-dim:#5b5f6a;
  --accent:#0ea5e9;
  --border:#eaecf0;
  --shadow:0 10px 30px rgba(2,6,23,.08);
  --radius:10px;
  --radius-card:18px;
  --scale:1;
  --shadow-elev:1;
  --font-ui:ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  --pattern-opacity:0;
  --logo-size:18px;
}

html, body { height: 100%; }
body{
  margin:0;
  font-family: var(--font-ui);
  background: var(--bg);
  color: var(--fg);
  display:grid;
  grid-template-columns: 260px 1fr;
  grid-template-rows: 56px 1fr;
  grid-template-areas: "sidebar header" "sidebar main";
  background-image:
    radial-gradient(circle at 20% -10%, rgba(0,0,0, calc(var(--pattern-opacity) * 0.06)) 0 40%, transparent 41%),
    radial-gradient(circle at 110% 30%, rgba(0,0,0, calc(var(--pattern-opacity) * 0.04)) 0 40%, transparent 41%);
  background-blend-mode: multiply;
}

header{
  grid-area: header;
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding:0 16px;
  border-bottom:1px solid var(--border);
  background:var(--panel);
  position:sticky;
  top:0;
  z-index:10;
}

aside{
  grid-area: sidebar;
  border-right:1px solid var(--border);
  background:var(--panel);
  display:flex;
  flex-direction:column;
  padding:12px;
  gap:6px;
}

main{
  grid-area: main;
  padding:18px;
  overflow:auto;
}

main, header, aside { font-size: calc(16px * var(--scale)); }
button, input[type="text"], select {
  padding: calc(8px * var(--scale)) calc(12px * var(--scale));
  border-radius: var(--radius);
}

.brand{ display:flex; gap:8px; align-items:center; font-weight:600; }
.brand--sidebar{ padding:8px 8px 14px 8px; }
.brand-logo{
  display:none;
  vertical-align:middle;
  height: var(--logo-size);
  max-height:none;
  max-width:140px;
  object-fit:contain;
}
.dot{ width:10px; height:10px; border-radius:50%; background:var(--accent); box-shadow:0 0 16px var(--accent); }

.nav a{ display:flex; gap:10px; align-items:center; padding:10px 12px; border-radius:calc(var(--radius) + 2px); color:var(--fg-dim); text-decoration:none; }
.nav a.active, .nav a:hover{ background:#f3f4f6; color:var(--fg); }
.nav-footer{ margin-top:auto; font-size:12px; color:var(--fg-dim); padding:8px; }

.card{
  background:var(--card);
  border:1px solid var(--border);
  border-radius:var(--radius-card);
  box-shadow: 0 calc(10px * var(--shadow-elev)) calc(30px * var(--shadow-elev)) rgba(2,6,23,.08);
  padding:0;
  height:100%;
  overflow:visible;
}
.card .hdr{ padding:12px 16px; border-bottom:1px solid var(--border); display:flex; align-items:center; justify-content:space-between; }
.card .body{ height: calc(100vh - 120px); min-height: 420px; overflow:hidden; }
.card-title-row{ display:flex; gap:8px; align-items:center; }
.badge-muted{ color:#5b5f6a; }
.widget-loading{ display:grid; place-items:center; height:100%; color:#5b5f6a; }

iframe{ width:100%; height:100%; border:0; background:#fff; display:block; }
#widgetInline{ min-height: 420px; }
#widgetInline iframe{ min-height: 420px; }

.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 40; display:none; pointer-events:none; }
.overlay.open { display:block; pointer-events:auto; }

.panel{
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: auto;
  width: 420px;
  max-width: 95vw;
  background: var(--panel);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow);
  transform: translateX(110%);
  transition: transform .25s ease;
  z-index: 60;
  display:flex;
  flex-direction:column;
  border-top-left-radius: var(--radius-card);
  border-bottom-left-radius: var(--radius-card);
}
.panel.open { transform: translateX(0); }
.panel header { padding: 14px 16px; border-bottom: 1px solid var(--border); display:flex; justify-content: space-between; align-items:center; }
.panel .content { padding: 14px 16px; overflow:auto; flex:1; }
.panel-title{ margin:0; }

.gridform { display:grid; gap:10px; grid-template-columns: 1fr; }
label { display:flex; flex-direction:column; gap:6px; font-size: 12px; color:var(--fg-dim); }
input[type="text"], select { border:1px solid var(--border); background:#fff; color:var(--fg); }
input[type="text"], select, input[type="color"], input[type="range"] { border-radius: var(--radius); }
.checkboxes { display:flex; gap:12px; align-items:center; }
.actions { display:flex; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--border); }
button { border:1px solid var(--border); background:#fff; cursor:pointer; }
.primary { background:var(--accent); color:#fff; border-color:transparent; }

.modules-title{ margin-bottom:6px; }
.help-text{ font-size:12px; opacity:.7; margin-top:6px; }
.hr-muted{ margin:6px 0; border:none; border-top:1px solid var(--border); }
.section-title{ font-weight:600; }
.note-small{ font-size:12px; opacity:.7; }
.range-value{ font-size:12px; opacity:.7; }

.grid{ display:grid; }
.grid-cols-1{ grid-template-columns: 1fr; }
.grid-cols-2{ grid-template-columns: 1fr 1fr; }
.grid-gap-10{ gap:10px; }
.grid-gap-8{ gap:8px; }

.palette-preview{ display:flex; gap:8px; align-items:center; flex-wrap:wrap; }
.palette-preview__items{ display:flex; gap:6px; align-items:center; flex-wrap:wrap; }
.preset-actions{ display:flex; gap:8px; flex-wrap:wrap; }
.flex-spacer{ flex:1; }

#backdrop { pointer-events: none; opacity: 0; transition: opacity .2s ease; }
#backdrop.open { pointer-events: auto; opacity: 1; }
#configPanel { pointer-events: none; }
#configPanel.open { pointer-events: auto; }
body.has-logo header .brand .dot { display: none; }

@media (max-width: 980px){
  body{
    grid-template-columns: 1fr;
    grid-template-rows: 56px auto 1fr;
    grid-template-areas: "header" "sidebar" "main";
  }

  aside{
    flex-direction:row;
    align-items:center;
    flex-wrap:wrap;
    gap:8px;
    border-right:0;
    border-bottom:1px solid var(--border);
  }

  .brand--sidebar{ padding:6px 4px; }
  .nav{ display:flex; flex-wrap:wrap; gap:6px; }
  .nav a{ padding:8px 10px; }
  .nav-footer{ margin-left:auto; padding:6px 4px; }
}

@media (max-width: 720px){
  header{ padding:0 12px; }
  main{ padding:12px; }
  .card{ box-shadow: 0 8px 20px rgba(2,6,23,.08); }
  .card .body{ height:auto; min-height: 360px; }
  #widgetInline{ min-height: 360px; }
  #widgetInline iframe{ min-height: 360px; }
  .actions{ flex-wrap:wrap; }
  .flex-spacer{ display:none; }
}

@media (max-width: 520px){
  .panel{ width: 100%; max-width: 100vw; }
  .panel header{ flex-direction:column; align-items:flex-start; gap:8px; }
  .grid-cols-2{ grid-template-columns: 1fr; }
  .nav-footer{ flex: 1 1 100%; margin-left:0; }
  #widgetInline{ min-height: 60vh; }
  #widgetInline iframe{ min-height: 60vh; }
}
