:root {
  --bg: #f6f6f6;
  --panel: #ffffff;
  --line: #d8d8d8;
  --text: #111111;
  --muted: #666666;
  --accent: #111111;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  overflow: hidden;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
}

button,
input,
select {
  font: inherit;
}

code {
  font-family: "SFMono-Regular", Consolas, monospace;
}

.shell {
  height: 100dvh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 12px;
  padding: 12px;
}

.topbar {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}

.title-block h1,
.panel h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
}

.topbar-note,
.panel-note,
.status-message,
.empty-state,
.layer-copy span,
.asset-card span {
  color: var(--muted);
}

.topbar-note,
.panel-note,
.status-message,
.empty-state {
  margin: 0;
  font-size: 0.87rem;
}

.title-meta {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: baseline;
}

.topbar-actions {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 8px;
  align-items: start;
  min-width: 0;
}

.share-stack {
  min-width: 0;
  display: grid;
  gap: 8px;
}

.share-toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
}

.topbar-buttons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.share-field {
  min-width: 0;
}

.workspace {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(320px, 34vw) minmax(0, 1fr);
  gap: 12px;
}

.preview-panel {
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 12px;
}

.controls-panel {
  min-height: 0;
  display: grid;
  grid-template-rows: minmax(180px, 34%) minmax(0, 1fr);
  gap: 12px;
}

.stack-section {
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 10px;
}

.stack-section-fill {
  grid-template-rows: auto minmax(0, 1fr);
}

.flag-stage {
  min-height: 0;
}

.status-message {
  min-height: 1.2em;
}

@media (max-width: 980px) {
  body {
    overflow: auto;
  }

  .shell {
    height: auto;
    min-height: 100dvh;
  }

  .topbar,
  .workspace {
    grid-template-columns: 1fr;
  }

  .topbar-actions {
    grid-template-columns: 1fr;
  }

  .title-meta {
    flex-direction: column;
    gap: 4px;
    align-items: flex-start;
  }

  .topbar-buttons {
    justify-content: stretch;
  }

  .workspace {
    display: grid;
  }

  .controls-panel {
    grid-template-rows: auto auto;
  }
}
