:root {
  color-scheme: light;
  --sand: #f6f0e6;
  --clay: #b56b4e;
  --brick: #7a3b2e;
  --pine: #2f3b2f;
  --ink: #2b2b2b;
  --muted: #6f6257;
  --panel: #fff8ee;
  --border: #e4d6c8;
  --shadow: 0 12px 32px rgba(47, 59, 47, 0.15);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Source Serif 4", "Iowan Old Style", "Georgia", serif;
  color: var(--ink);
  background: radial-gradient(circle at top, #fffaf2 0%, var(--sand) 60%, #f0e5d6 100%);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 28px;
  border-bottom: 1px solid var(--border);
  background: #fffaf2;
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand__title {
  font-size: 1.35rem;
  font-weight: 600;
}

.brand__subtitle {
  display: block;
  font-size: 0.95rem;
  color: var(--muted);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: flex-end;
}

.btn {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--ink);
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 0.95rem;
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.2s ease;
}

.btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(47, 59, 47, 0.12);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn--primary {
  background: var(--brick);
  border-color: var(--brick);
  color: #fffaf2;
}

.authbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px 28px;
  background: #fdf6eb;
  border-bottom: 1px solid var(--border);
}

.auth-help {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.9rem;
}

.auth-controls {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.auth-controls label {
  font-size: 0.9rem;
  color: var(--muted);
}

.auth-controls input {
  min-width: 220px;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 12px;
  background: #fff;
  color: var(--ink);
}

.connection-state {
  color: var(--muted);
  font-size: 0.9rem;
}

.connection-state[data-tone="success"] {
  color: var(--pine);
  font-weight: 600;
}

.connection-state[data-tone="error"] {
  color: var(--brick);
  font-weight: 600;
}

.layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 24px;
  padding: 24px 28px 40px;
}

.sidebar {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 16px;
  box-shadow: var(--shadow);
  height: calc(100vh - 205px);
  overflow: auto;
}

.sidebar__header {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--pine);
}

.sidebar__list {
  display: grid;
  gap: 8px;
}

.page-item {
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid transparent;
  background: #fff;
  cursor: pointer;
  font-size: 0.95rem;
}

.page-item[aria-current="true"] {
  border-color: var(--clay);
  background: #fff4e8;
}

.editor {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.template-picker {
  display: flex;
  gap: 8px;
  align-items: center;
}

.template-select {
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 0.95rem;
  background: #fff;
}

.status {
  font-size: 0.95rem;
  color: var(--muted);
}

.status[data-tone="success"] {
  color: var(--pine);
  font-weight: 600;
}

.status[data-tone="error"] {
  color: var(--brick);
  font-weight: 600;
}

.canvas {
  flex: 1;
  min-height: 70vh;
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: #fff;
  box-shadow: var(--shadow);
}

@media (max-width: 980px) {
  .topbar,
  .authbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .actions,
  .auth-controls {
    justify-content: flex-start;
  }

  .layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    height: auto;
  }
}
