:root {
  color-scheme: light;
  --bg: #f4f1ea;
  --surface: #fbfaf7;
  --surface-2: #eee8dc;
  --line: #d8d0c3;
  --line-strong: #b9ad9c;
  --ink: #191714;
  --muted: #716a60;
  --accent: #7b4f2a;
  --accent-dark: #4d321d;
  --focus: rgba(123, 79, 42, 0.2);
  --danger: #a7352a;
  --font: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
}

button,
input,
textarea {
  font: inherit;
}

button {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
}

button:hover {
  border-color: var(--line-strong);
  background: #fff;
}

button.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #fffaf2;
}

button.primary:hover {
  background: var(--accent-dark);
}

.app-shell {
  display: grid;
  grid-template-columns: 292px minmax(520px, 1fr) 340px;
  height: 100%;
  min-height: 680px;
}

.sidebar,
.inspector {
  display: flex;
  min-height: 0;
  flex-direction: column;
  gap: 14px;
  padding: 18px;
  border-color: var(--line);
  background: var(--surface);
}

.sidebar {
  border-right: 1px solid var(--line);
}

.inspector {
  border-left: 1px solid var(--line);
}

.brand {
  display: grid;
  gap: 3px;
  padding-bottom: 8px;
}

.brand strong {
  font-size: 18px;
  letter-spacing: 0;
}

.brand span,
.status-line,
.selection-info,
.notes {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.structured-editor {
  display: grid;
  gap: 10px;
}

.structured-editor:empty {
  display: none;
}

.inline-editor-row {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  align-items: start;
  gap: 8px;
}

.inline-editor-row b {
  display: grid;
  place-items: center;
  min-height: 34px;
  color: var(--muted);
  font-size: 11px;
}

.inline-editor-row input,
.inline-editor-row textarea {
  min-height: 34px;
}

.table-editor {
  display: grid;
  gap: 6px;
  overflow: auto;
  max-height: 220px;
  padding: 1px;
}

.table-editor-row {
  display: grid;
  gap: 6px;
}

.editor-actions {
  display: flex;
  gap: 6px;
}

.design-panel {
  display: grid;
  gap: 10px;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.design-panel summary {
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
}

.css-token-editor,
.selected-css-editor {
  display: grid;
  gap: 8px;
}

.css-token-row {
  display: grid;
  grid-template-columns: 92px 34px 1fr;
  align-items: center;
  gap: 8px;
  font-size: 11px;
}

.css-token-row input[type="color"] {
  height: 30px;
  padding: 2px;
}

.css-rule-row {
  display: grid;
  gap: 6px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.css-rule-row code {
  color: var(--accent-dark);
  font-size: 11px;
}

.css-editor {
  min-height: 260px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
}

.field {
  display: grid;
  gap: 7px;
}

.field span,
.panel-title {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  outline: none;
}

input {
  height: 38px;
  padding: 0 10px;
}

textarea {
  min-height: 160px;
  resize: vertical;
  padding: 10px;
  line-height: 1.45;
}

textarea.small {
  min-height: 78px;
}

textarea.codex-output {
  min-height: 150px;
}

input:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--focus);
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.button-row button {
  flex: 1 1 auto;
  padding: 0 10px;
}

.path-details {
  display: grid;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
}

.path-details summary {
  cursor: pointer;
  color: var(--ink);
  font-weight: 700;
}

.page-list {
  display: grid;
  min-height: 0;
  gap: 6px;
  overflow: auto;
  padding-right: 2px;
}

.page-list button {
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: 8px;
  min-height: 42px;
  padding: 7px 9px;
  text-align: left;
}

.page-list b {
  color: var(--accent);
  font-size: 12px;
}

.page-list span {
  overflow: hidden;
  color: var(--ink);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.workspace {
  display: grid;
  min-width: 0;
  min-height: 0;
  grid-template-rows: 58px 1fr;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(251, 250, 247, 0.88);
  backdrop-filter: blur(10px);
}

.tool-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.tool-group button {
  min-width: 34px;
  padding: 0 10px;
  font-weight: 700;
}

.divider {
  width: 1px;
  height: 24px;
  margin: 0 4px;
  background: var(--line);
}

.preview-wrap {
  min-height: 0;
  overflow: hidden;
  background:
    linear-gradient(90deg, rgba(25, 23, 20, 0.04) 1px, transparent 1px),
    linear-gradient(0deg, rgba(25, 23, 20, 0.04) 1px, transparent 1px),
    #d8cfc0;
  background-size: 32px 32px;
}

#preview {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  background: #d8cfc0;
}

.codex-status {
  min-height: 34px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.notes {
  border-top: 1px solid var(--line);
  padding-top: 8px;
}

.notes summary {
  color: var(--ink);
  cursor: pointer;
  font-weight: 700;
}

@media (max-width: 1180px) {
  .app-shell {
    grid-template-columns: 250px minmax(420px, 1fr) 300px;
  }
}
