:root {
  color-scheme: light;
  --panel-bg: #fbfaf8;
  --panel-border: #ded7cc;
  --ink: #241f1a;
  --muted: #70685f;
  --accent: #b95628;
  --accent-dark: #7a3418;
  --surface: #ffffff;
  --shadow: 0 14px 38px rgba(39, 29, 19, 0.12);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  background: #ebe7df;
}

button,
input,
select {
  font: inherit;
}

button {
  min-height: 40px;
  border: 1px solid #c7bbaa;
  border-radius: 7px;
  color: var(--ink);
  background: #fffaf1;
  cursor: pointer;
}

button:hover {
  border-color: #ab8f70;
  background: #fff4df;
}

button:disabled {
  color: #9d968d;
  background: #e5dfd6;
  cursor: not-allowed;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(340px, 1fr) minmax(280px, 1fr) minmax(280px, 1fr);
  height: 100vh;
  min-height: 720px;
  overflow: hidden;
}

.control-panel {
  height: 100vh;
  overflow-y: auto;
  padding: 20px;
  background: var(--panel-bg);
  border-right: 1px solid var(--panel-border);
}

.puzzle-name {
  display: block;
  width: 100%;
  margin: 0 0 20px;
  padding: 0;
  border: 0;
  outline: 0;
  color: var(--ink);
  background: transparent;
  font-size: 34px;
  line-height: 1.1;
  font-weight: 800;
  letter-spacing: 0;
}

.panel-section {
  margin: 0 0 18px;
  padding: 16px;
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  background: var(--surface);
}

.panel-section h2,
.preview-title {
  margin: 0 0 12px;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0;
}

.field {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.field input,
.field select {
  width: 100%;
  min-height: 38px;
  padding: 7px 9px;
  border: 1px solid #cbbfac;
  border-radius: 7px;
  color: var(--ink);
  background: #fff;
}

.field input[type="color"] {
  padding: 3px;
}

.field input[type="file"] {
  min-height: 42px;
  padding: 8px;
}

.checkbox-field {
  grid-template-columns: 20px 1fr;
  align-items: center;
  gap: 8px;
}

.checkbox-field input {
  min-height: auto;
  padding: 0;
}

.inline-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.button-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.export-section .button-row {
  grid-template-columns: 1fr;
}

.mode-tabs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  margin-bottom: 10px;
}

.mode-tab {
  min-height: 36px;
  padding: 5px;
}

.mode-tab.is-active {
  border-color: var(--accent);
  color: #fff;
  background: var(--accent);
}

.board-editor {
  display: block;
  width: 100%;
  aspect-ratio: 18 / 13;
  border: 1px solid #cbbfac;
  border-radius: 8px;
  background: #fffdfa;
}

.helper-text,
.status {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.status.is-error {
  color: #a12820;
}

.status.is-ok {
  color: #286c38;
}

.advanced-panel summary {
  cursor: pointer;
  color: var(--ink);
  font-size: 15px;
  font-weight: 800;
}

.advanced-panel[open] summary {
  margin-bottom: 14px;
}

.preview-pane {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-width: 0;
  padding: 18px;
  overflow: hidden;
  background: #f2eee7;
  border-right: 1px solid #ddd3c6;
}

.preview-pane:last-child {
  border-right: 0;
}

.card-preview {
  display: block;
  max-width: 100%;
  max-height: calc(100vh - 64px);
  place-self: center;
  border-radius: 6px;
  background: white;
  box-shadow: var(--shadow);
}

@media (max-width: 1020px) {
  .app-shell {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 100vh;
    overflow: visible;
  }

  .control-panel {
    height: auto;
    overflow: visible;
    border-right: 0;
    border-bottom: 1px solid var(--panel-border);
  }

  .preview-pane {
    min-height: 720px;
    border-right: 0;
    border-bottom: 1px solid #ddd3c6;
  }

  .card-preview {
    max-height: 650px;
  }
}
