:root {
  color-scheme: light;
  --ink: #153349;
  --subtle: #526779;
  --line: #dce6ea;
  --paper: #fff;
  --canvas: #eaf0f3;
  --accent: #17645f;
  --accent-light: #e7f5ef;
  --focus: #258478;
  font: 14px / 1.5 system-ui, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--canvas);
}
* { box-sizing: border-box; }
body { margin: 0; }
[hidden] { display: none !important; }
button, input, textarea, select { font: inherit; }
button, select { cursor: pointer; }
button {
  border: 1px solid var(--line);
  background: var(--paper);
  border-radius: 9px;
  padding: .55rem .8rem;
  color: var(--ink);
  font-weight: 620;
}
button:hover:not(:disabled) { border-color: #82a9a8; background: #f1f8f6; }
button:disabled { opacity: .4; cursor: default; }
:is(button, a, input, textarea, select, summary):focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
button.primary { background: var(--accent); color: white; border-color: var(--accent); }
button.primary:hover:not(:disabled) { color: white; background: #10534d; }
button.quiet { border-color: transparent; background: transparent; }
button.danger { color: #9d3538; }
a { color: var(--accent); font-weight: 650; text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, p, ol { margin: 0; }
h2 { font-size: 1rem; letter-spacing: -.01em; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; }
.identity { display: flex; align-items: center; gap: .55rem; white-space: nowrap; }
.identity img { width: 37px; height: 37px; border-radius: 9px; object-fit: contain; }
.identity strong { font-size: 1.12rem; letter-spacing: -.045em; }
.identity span { color: var(--accent); font-weight: 580; }
.workspace {
  height: 100dvh; display: grid; grid-template: auto minmax(0, 1fr) / 210px minmax(270px, 1fr) 320px;
  grid-template-areas: "header header header" "sidebar stage inspector";
}
.app-header {
  grid-area: header; display: flex; min-height: 68px; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .75rem 1.3rem; border-bottom: 1px solid var(--line); background: var(--paper); z-index: 2;
}
.app-header .actions, .app-header .page-control { display: flex; align-items: center; gap: .55rem; }
#status { font-size: .82rem; color: var(--subtle); }
#status[data-error] { color: #9d3538; }
.sidebar, .inspector { min-height: 0; overflow: auto; background: #f9fbfb; }
.sidebar { grid-area: sidebar; display: flex; flex-direction: column; border-right: 1px solid var(--line); padding: 1.15rem .8rem; }
.sidebar-top { display: flex; align-items: center; justify-content: space-between; padding: 0 .25rem; }
.sidebar-top button { font-size: 1.3rem; line-height: 1; padding: .35rem .58rem; }
#publication { color: var(--subtle); font-size: .78rem; padding: .4rem .25rem .85rem; }
.section-list { list-style: none; padding: 0; display: grid; gap: .3rem; }
.section-list li { min-width: 0; }
.section-list li[data-drop] { border-top: 2px solid var(--accent); }
.section-list button { width: 100%; display: flex; gap: .5rem; text-align: left; align-items: center; padding: .58rem; font-size: .85rem; border-color: transparent; background: transparent; }
.section-list button[aria-current="true"] { color: #104b47; background: var(--accent-light); border-color: #b9ded3; }
.section-list button:disabled { cursor: default; }
.section-list button .grip { color: #657e87; font-family: monospace; }
.section-list button .muted { margin-left: auto; color: var(--subtle); font-size: .71rem; }
.sidebar-bottom { margin-top: auto; padding: 1rem .2rem 0; display: grid; gap: .45rem; }
.sidebar-bottom button { text-align: left; font-size: .79rem; }
.stage { grid-area: stage; min-width: 0; min-height: 0; display: flex; flex-direction: column; overflow: auto; }
.toolstrip { background: #f3f7f8; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; gap: .55rem; padding: .65rem .85rem; }
.toolstrip button { font-size: .78rem; padding: .42rem .6rem; white-space: nowrap; }
.devices, .history-controls { display: flex; gap: .25rem; }
.devices button[aria-pressed="true"], #toggle-preview[aria-pressed="true"] { background: var(--accent-light); border-color: #aed4c8; color: #124e47; }
.viewport { display: flex; justify-content: center; min-height: 0; flex: 1; padding: 1.1rem; }
.device-frame { position: relative; flex: none; width: 100%; height: 100%; overflow: hidden; border-radius: 12px; background: white; box-shadow: 0 8px 24px #15334914, 0 0 0 1px #bfcdd3; }
iframe { display: block; width: 100%; height: 100%; border: 0; transform-origin: top left; }
.workspace[data-preview-only] { grid-template-columns: 0 minmax(0, 1fr) 0; }
.workspace[data-preview-only] :is(.sidebar, .inspector) { visibility: hidden; padding: 0; border: 0; }
.inspector { grid-area: inspector; border-left: 1px solid var(--line); }
.inspector-head { position: sticky; top: 0; padding: 1.15rem 1rem .75rem; background: #f9fbfb; z-index: 1; border-bottom: 1px solid var(--line); }
.tabs { display: flex; gap: .3rem; margin-top: .75rem; }
.tabs button { flex: 1; font-size: .84rem; }
.tabs button[aria-selected="true"] { background: var(--accent-light); border-color: #b9ded3; }
.fields { padding: 1rem; display: grid; gap: .8rem; align-content: start; }
.fields label, .login label { display: grid; gap: .35rem; font-size: .84rem; font-weight: 645; }
input, textarea, select { width: 100%; min-width: 0; border: 1px solid #ccdce1; color: var(--ink); background: white; border-radius: 8px; padding: .55rem .63rem; }
input:is([type="checkbox"], [type="color"]) { width: auto; }
input[type="color"] { min-height: 37px; }
textarea { resize: vertical; min-height: 69px; }
select#page { min-width: 110px; max-width: 195px; font-weight: 650; padding-right: 1.6rem; }
.group { border: 1px solid var(--line); border-radius: 10px; background: white; padding: .7rem; min-width: 0; }
.group summary { cursor: pointer; font-size: .83rem; font-weight: 675; }
.group-content, .list-item { display: grid; gap: .7rem; min-width: 0; }
.group-content { margin-top: .76rem; }
.list-item { padding: .6rem; border: 1px solid var(--line); border-radius: 9px; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem; }
.row button { font-size: .77rem; padding: .36rem .48rem; }
.thumbnail { display: block; width: 100%; height: 90px; border-radius: 7px; object-fit: cover; background: var(--canvas); }
.hint { color: var(--subtle); font-size: .83rem; }
.fields .highlight { border-color: var(--focus); box-shadow: 0 0 0 2px #b9ded3; }
dialog { width: min(480px, calc(100% - 30px)); border: 1px solid var(--line); padding: 1.15rem; border-radius: 14px; color: var(--ink); max-height: 85dvh; overflow: auto; }
dialog::backdrop { background: #102b3f80; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: .9rem; }
.dialog-head h2 { font-size: 1.15rem; }
#dialog-body { display: grid; gap: .75rem; }
.library { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; }
.library button { padding: .2rem; min-width: 0; }
.login { min-height: 100dvh; display: grid; place-items: center; padding: 1.3rem; background: radial-gradient(circle at 12% 10%, #d5efea, transparent 55%), var(--canvas); }
.login-card { width: min(100%, 415px); padding: 2rem; background: white; border: 1px solid var(--line); border-radius: 20px; box-shadow: 0 18px 70px #15334918; }
.login h1 { margin: 1.35rem 0 1rem; line-height: 1.12; letter-spacing: -.05em; font-size: 2.1rem; }
.login form { display: grid; gap: .9rem; }
.login p { margin: .6rem 0; color: #9d3538; }
.login a { display: inline-block; margin-top: .6rem; }
@media (max-width: 1110px) {
  .workspace { grid-template-columns: 175px minmax(240px, 1fr) 280px; }
  #status { max-width: 100px; }
}
@media (max-width: 870px) {
  .workspace { height: auto; min-height: 100dvh; grid-template: auto minmax(480px, 68vh) auto / minmax(130px, 30%) 1fr; grid-template-areas: "header header" "stage stage" "sidebar inspector"; }
  .workspace[data-preview-only] { grid-template-columns: 1fr 1fr; }
  .app-header { flex-wrap: wrap; gap: .55rem; padding: .65rem; }
  .app-header .identity { margin-right: auto; }
  .app-header .actions { flex: 1 1 100%; justify-content: flex-end; }
  #status { max-width: none; margin-right: auto; }
  .stage { min-height: 480px; }
  .viewport { padding: .55rem; }
}
@media (max-width: 420px) {
  .toolstrip { flex-wrap: wrap; padding: .42rem; }
  .sidebar { padding: .75rem .35rem; }
  .inspector-head, .fields { padding: .66rem; }
  .section-list button { padding: .38rem; }
}
