* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; font-family: Arial, sans-serif; }
body { background: var(--living-canvas-background, #eef2f6); color: #17202a; overflow: hidden; }
#app {
  display: grid;
  grid-template-columns: 280px 1fr;
  grid-template-rows: 50px 1fr;
  height: 100vh;
}
#topbar {
  grid-column: 1 / 3;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  background: #101828;
  color: white;
  border-bottom: 1px solid #344054;
}
.pill {
  padding: 5px 9px;
  border-radius: 999px;
  background: #344054;
  font-size: 12px;
}
#sidebar {
  padding: 14px;
  overflow: auto;
  background: #ffffff;
  border-right: 1px solid #d0d5dd;
}
#sidebar h2 { margin-top: 0; }
#sidebar button {
  display: block;
  width: 100%;
  margin: 7px 0;
  padding: 9px 10px;
  border: 1px solid #98a2b3;
  border-radius: 5px;
  background: white;
  cursor: pointer;
}
#sidebar button:hover { background: #f2f4f7; }
#sidebar pre {
  min-height: 100px;
  padding: 8px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  border: 1px solid #d0d5dd;
  background: #f9fafb;
  font-size: 11px;
}
#sidebar dl {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px 12px;
}
#sidebar dt { color: #475467; }
#sidebar dd { margin: 0; font-weight: bold; }
.note {
  font-size: 12px;
  color: #475467;
  border-left: 3px solid #1570ef;
  padding-left: 9px;
}
#canvasWrap { position: relative; min-width: 0; min-height: 0; overflow: hidden; }
#livingCanvas { display: block; width: 100%; height: 100%; cursor: default; }
#status {
  position: absolute;
  left: 12px;
  bottom: 10px;
  padding: 6px 9px;
  border-radius: 5px;
  background: rgba(16, 24, 40, 0.85);
  color: white;
  font-size: 12px;
  pointer-events: none;
}

.theme-picker {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  font-size: 12px;
}
.theme-picker select {
  min-width: 135px;
  padding: 5px 7px;
  border-radius: 5px;
  border: 1px solid #667085;
  background: #ffffff;
  color: #17202a;
}
[hidden] { display: none !important; }

/* Keep the canvas in the main grid column even when technical detail is hidden. */
#sidebar {
  grid-column: 1;
  grid-row: 2;
}
#canvasWrap {
  grid-column: 2;
  grid-row: 2;
}
#technicalDetails[hidden] {
  display: none !important;
}
#sidebar section { margin-top: 18px; }
#sidebar label { display: block; margin: 8px 0; font-size: 12px; color: #344054; }
#sidebar input,
#sidebar select,
#sidebar textarea {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 7px 8px;
  border: 1px solid #98a2b3;
  border-radius: 5px;
  background: #fff;
  color: #17202a;
  font: inherit;
}
#sidebar textarea { resize: vertical; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 11px; }
#sidebar input[readonly] { background: #f2f4f7; color: #475467; }
#status[data-error="true"] { background: rgba(180, 35, 24, 0.92); }
.button-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
#sidebar .button-grid button { margin: 0; padding: 7px 5px; font-size: 12px; }

#dirtyReadout[data-dirty="true"] {
  background: #b54708;
  font-weight: bold;
}
#livingCanvas[data-placement="true"] { cursor: crosshair; }

.lifecycle-tools { display:flex; gap:6px; align-items:center; margin-left:8px; }
.lifecycle-tools button { padding:6px 9px; border:1px solid #667085; border-radius:5px; background:#fff; color:#17202a; cursor:pointer; font-size:12px; }
.lifecycle-tools button.primary { background:#1570ef; color:#fff; border-color:#1570ef; }
.lifecycle-tools button.compile { background:#067647; color:#fff; border-color:#067647; }
.lifecycle-tools button:disabled { opacity:.45; cursor:not-allowed; }
#dirtyReadout[data-dirty="true"] { cursor:default; }


.schema-property-fields { border: 1px solid #c8d0dc; border-radius: 5px; padding: 8px; margin: 8px 0; }
.schema-property-fields legend { font-weight: 600; padding: 0 4px; }
.schema-property-field { display: grid; gap: 4px; margin-bottom: 8px; }
.schema-property-field input, .schema-property-field select { width: 100%; box-sizing: border-box; }
.advanced-properties { margin: 8px 0; }
.validation-error { color: #b42318; min-height: 1.2em; margin: 4px 0; }

#presentationDesigner { border-top: 1px solid #d0d5dd; padding-top: 8px; }
#presentationDesigner .inline-check { display:flex; align-items:center; gap:8px; }
#presentationDesigner .inline-check input { width:auto; margin:0; }
#presentationDesigner select, #presentationDesigner input { width:100%; }
.visual-import-preview { min-height:110px; border:1px dashed #98a2b3; border-radius:5px; background:#f9fafb; display:flex; align-items:center; justify-content:center; overflow:hidden; padding:8px; font-size:11px; color:#475467; }
.visual-import-preview img, .visual-import-preview object { display:block; max-width:100%; max-height:180px; }

.auth-gate {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  background: var(--living-canvas-background, #eef2f6);
}
.auth-gate[hidden] { display: none; }
.auth-card {
  width: min(360px, calc(100vw - 40px));
  padding: 24px;
  border: 1px solid #d0d5dd;
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 16px 40px rgba(16, 24, 40, 0.15);
}
.auth-card h1 { margin-top: 0; }
.auth-card label { display: grid; gap: 6px; margin: 14px 0; }
.auth-card input { min-height: 36px; padding: 6px 8px; }

#presentationWorkspace {
  border-top: 1px solid #d0d5dd;
  padding-top: 8px;
}
#presentationWorkspace select[multiple] {
  min-height: 110px;
}
#presentationWorkspace .button-grid button {
  min-height: 34px;
}
#presentationModelReadout[data-dirty="true"] {
  border-left-color: #b54708;
}

.site-dialog { width:min(520px,calc(100vw - 40px)); border:1px solid #98a2b3; border-radius:8px; padding:20px; }
.site-dialog::backdrop { background:rgba(16,24,40,.55); }
.site-dialog label { display:block; margin:10px 0; font-size:12px; }
.site-dialog input,.site-dialog select { display:block; width:100%; margin-top:4px; padding:8px; }
.site-dialog fieldset { border:1px solid #d0d5dd; border-radius:6px; margin:12px 0; }
.dialog-actions { display:flex; gap:8px; justify-content:flex-end; }
.dialog-actions button { padding:8px 12px; }

.topbar-site-action { padding:5px 9px; border:1px solid #667085; border-radius:5px; background:#fff; color:#17202a; cursor:pointer; font-size:12px; }
.topbar-site-action.primary { background:#1570ef; color:#fff; border-color:#1570ef; }
.designer-start { position:absolute; inset:0; display:flex; flex-direction:column; align-items:center; justify-content:center; gap:12px; background:#f2f4f7; z-index:4; text-align:center; padding:32px; }
.designer-start[hidden] { display:none; }
.designer-start h1 { margin:0; }
.designer-start p { max-width:620px; margin:0; }
.designer-start-actions { display:flex; gap:12px; margin-top:8px; }
.designer-start-actions button { min-width:140px; padding:10px 16px; }
html[data-canvas-mode="designer-start"] #sidebar { display:none; }
html[data-canvas-mode="designer-start"] #canvasWrap { grid-column:1 / 3; }
html[data-canvas-mode="designer-start"] #livingCanvas,
html[data-canvas-mode="designer-start"] #status,
html[data-canvas-mode="designer-start"] .lifecycle-tools,
html[data-canvas-mode="designer-start"] #themeSelect,
html[data-canvas-mode="designer-start"] .theme-picker,
html[data-canvas-mode="designer-start"] #zoomReadout,
html[data-canvas-mode="designer-start"] #selectionReadout,
html[data-canvas-mode="designer-start"] #dirtyReadout,
html[data-canvas-mode="designer-start"] #liveReadout { display:none; }

.history-time-editor {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 30;
  min-width: 300px;
  padding: 12px;
  border: 1px solid #98a2b3;
  border-radius: 6px;
  background: #ffffff;
  box-shadow: 0 8px 24px rgba(16, 24, 40, 0.18);
  font: 13px Arial, sans-serif;
}

.history-time-editor label {
  display: grid;
  gap: 6px;
  font-weight: 600;
}

.history-time-editor input[type="datetime-local"] {
  min-width: 260px;
  padding: 6px;
  font: inherit;
}

.history-time-editor-zone {
  margin-top: 7px;
  color: #475467;
  font-size: 12px;
}

.history-time-editor-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 10px;
}
