@font-face {
  font-family: "Kalmykia";
  src: url("../assets/fonts/Kalmykia.otf") format("opentype");
  font-weight: 400 900;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "BellotaText";
  src: url("../assets/fonts/BellotaText-Light.ttf") format("truetype");
  font-weight: 300;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "BellotaText";
  src: url("../assets/fonts/BellotaText-Regular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "BellotaText";
  src: url("../assets/fonts/BellotaText-Bold.ttf") format("truetype");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "BellotaTextLight";
  src: url("../assets/fonts/BellotaText-Light.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "BellotaTextRegular";
  src: url("../assets/fonts/BellotaText-Regular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "BellotaTextBold";
  src: url("../assets/fonts/BellotaText-Bold.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "SofiaSans";
  src: url("../assets/fonts/SofiaSans-VariableFont_wght.ttf") format("truetype");
  font-weight: 1 1000;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "SofiaSans";
  src: url("../assets/fonts/SofiaSans-Bold.ttf") format("truetype");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #ece7d8;
  --panel: #fffaf0;
  --ink: #2b211f;
  --muted: #77695d;
  --line: #d9cbb7;
  --brand: #84090a;
  --accent: #b75202;
  --soft: #f2dfc2;
  --focus: #237f75;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
}

[hidden] {
  display: none !important;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
label.file-btn {
  cursor: pointer;
}

.editor-chooser {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 28px;
  background: var(--bg);
}

.editor-chooser-panel {
  width: min(980px, 100%);
}

.editor-chooser-head {
  margin-bottom: 22px;
}

.editor-chooser-head p {
  margin: 0 0 8px;
  color: var(--brand);
  font-weight: 700;
}

.editor-chooser-head h1 {
  margin: 0;
  color: var(--ink);
  font-size: 36px;
  line-height: 1.08;
}

.editor-choice-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.editor-choice {
  display: grid;
  gap: 10px;
  min-height: 190px;
  padding: 18px;
  align-content: start;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffaf0;
}

.editor-choice strong {
  color: var(--brand);
  font-size: 19px;
  line-height: 1.15;
}

.editor-choice span {
  color: var(--muted);
  line-height: 1.35;
}

.editor-choice.is-primary {
  border-color: var(--brand);
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  background: var(--panel);
  border-right: 1px solid var(--line);
  padding: 20px;
  overflow-x: hidden;
  overflow-y: auto;
  max-height: 100vh;
}

.brand {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 18px;
}

.brand h1 {
  margin: 0;
  color: var(--brand);
  font-family: "Kalmykia", Georgia, serif;
  font-size: 44px;
  line-height: 0.95;
}

.brand p {
  margin: 6px 0 0;
  color: var(--muted);
}

.status-pill {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

.status-pill.ok {
  border-color: #7cad8a;
  color: #24663a;
  background: #edf7ef;
}

.status-pill.warn {
  border-color: #c58b54;
  color: #8d4b08;
  background: #fff1df;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  margin-bottom: 18px;
}

.tab,
.small-btn,
.main-btn,
.icon-btn,
.file-btn {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 8px;
}

.tab {
  min-height: 38px;
  padding: 6px 4px;
  font-size: 13px;
}

.tab.is-active {
  border-color: var(--brand);
  color: var(--brand);
  background: #fff4ea;
}

.panel {
  display: none;
}

.panel.is-active {
  display: block;
}

label {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
}

label span,
.compact-label {
  color: var(--muted);
  font-size: 13px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 10px;
  background: #fff;
  color: var(--ink);
}

input[type="color"] {
  min-height: 42px;
  padding: 4px;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus,
button:focus-visible,
.file-btn:focus-within {
  outline: 2px solid var(--focus);
  outline-offset: 1px;
}

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

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.section-head h2 {
  margin: 0;
  font-size: 18px;
}

.icon-btn {
  width: 36px;
  height: 36px;
  font-size: 22px;
  line-height: 1;
}

.small-btn {
  min-height: 34px;
  padding: 7px 12px;
}

.main-btn,
.file-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 9px 12px;
  text-align: center;
}

.main-btn.accent {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
}

.file-btn input {
  display: none;
}

.action-grid {
  display: grid;
  gap: 10px;
}

.stack {
  display: grid;
  gap: 12px;
}

.item-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fffdf8;
}

.item-card header {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
  margin-bottom: 10px;
}

.item-card h3 {
  margin: 0;
  color: var(--brand);
  font-size: 15px;
}

.event-card header {
  margin-bottom: 0;
}

.event-card.is-expanded header {
  margin-bottom: 10px;
}

.event-collapse {
  color: var(--brand);
  font-size: 15px;
  font-weight: 700;
}

.event-summary {
  display: grid;
  grid-template-columns: 58px 1fr;
  gap: 10px;
  align-items: center;
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
}

.event-summary-date {
  display: grid;
  place-items: center;
  min-height: 34px;
  border-radius: 6px;
  background: var(--soft);
  color: var(--brand);
  font-weight: 700;
}

.event-summary-main {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.event-summary-main strong,
.event-summary-main small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.event-summary-main small {
  color: var(--muted);
}

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

.mini {
  min-width: 30px;
  height: 30px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 6px;
}

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

.event-form[hidden] {
  display: none;
}

.event-field {
  margin: 0;
}

.event-field-category select {
  min-height: 40px;
}

.event-meta-grid {
  display: grid;
  grid-template-columns: 1fr 0.85fr 1fr 0.85fr;
  gap: 8px;
}

.event-meta-grid input,
.event-pin input {
  min-height: 38px;
}

.event-placement {
  display: grid;
  grid-template-columns: minmax(160px, auto) minmax(120px, 160px);
  gap: 10px;
  align-items: end;
  justify-content: start;
  padding-top: 2px;
}

.event-pin {
  margin: 0;
}

.event-tools {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}

.bulk-actions {
  display: grid;
  grid-template-columns: 1fr auto 1fr auto 1fr auto;
  gap: 8px;
}

.bulk-actions button {
  min-height: 38px;
}

.type-group {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff8eb;
}

.type-group summary {
  cursor: pointer;
  padding: 10px 12px;
  color: var(--brand);
  font-weight: 700;
}

.type-group-body {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding: 0 10px 10px;
}

.type-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(116px, 1fr));
  gap: 8px;
  align-items: end;
}

.type-row-compact {
  grid-template-columns: 1fr;
}

.type-row label {
  margin: 0;
}

.checkline {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 0;
  min-height: 42px;
}

.checkline input {
  width: auto;
}

.range-pair {
  display: block;
}

.range-field input[type="number"] {
  width: 100%;
}

.workspace {
  display: grid;
  grid-template-rows: auto auto 1fr;
  min-width: 0;
  max-height: 100vh;
}

.toolbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 14px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 250, 240, 0.82);
}

.toolbar select {
  min-width: 280px;
}

.toolbar-actions {
  display: flex;
  align-items: end;
  gap: 8px;
}

.guide-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  margin: 0;
  color: var(--muted);
}

.guide-toggle input {
  width: auto;
}

.page-thumbs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 10px 20px;
  border-bottom: 1px solid var(--line);
  background: #fff8eb;
}

.page-thumb {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 2px 8px;
  min-width: 170px;
  padding: 8px 10px;
  text-align: left;
}

.page-thumb span {
  grid-row: 1 / 3;
  color: var(--brand);
  font-weight: 700;
}

.page-thumb strong,
.page-thumb small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.page-thumb small {
  color: var(--muted);
}

.page-thumb.is-active {
  border-color: var(--brand);
  background: var(--soft);
}

.preview-wrap {
  display: grid;
  place-items: center;
  padding: 24px;
  overflow: auto;
}

canvas {
  width: min(540px, calc(100vw - 500px));
  max-width: 100%;
  height: auto;
  background: #f8f3dd;
  box-shadow: 0 22px 60px rgba(49, 37, 28, 0.2);
}

.validation {
  margin-top: 16px;
  display: grid;
  gap: 8px;
}

.message {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 10px;
  background: #fff;
  color: var(--muted);
  font-size: 13px;
}

.message.error {
  border-color: #c96969;
  color: #9b2424;
  background: #fff3f3;
}

.message.warn {
  border-color: #d4a268;
  color: #8b4b06;
  background: #fff5e7;
}

@media (max-width: 960px) {
  .editor-choice-grid {
    grid-template-columns: 1fr;
  }

  .editor-choice {
    min-height: 132px;
  }

  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar,
  .workspace {
    max-height: none;
  }

  canvas {
    width: min(100%, 540px);
  }

  .toolbar {
    flex-wrap: wrap;
  }

  .toolbar select {
    min-width: min(280px, calc(100vw - 40px));
  }

  .toolbar-actions {
    flex-wrap: wrap;
  }

  .type-row {
    grid-template-columns: 1fr;
  }

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

  .tabs {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 560px) {
  .sidebar {
    padding: 14px;
  }

  .bulk-actions,
  .event-form,
  .event-meta-grid,
  .event-placement,
  .grid-two,
  .type-group-body {
    grid-template-columns: 1fr;
  }

  .event-summary {
    grid-template-columns: 48px 1fr;
  }

  .range-pair {
    display: block;
  }
}
