:root {
  --ink: #1e3037;
  --muted: #5c7078;
  --panel: #ffffff;
  --page: #eef5f3;
  --line: #c9dadd;
  --blue: #17495f;
  --blue-2: #1f5f7a;
  --teal-soft: #edf7fa;
  --amber: #b76418;
  --amber-soft: #fff7ed;
  --gold-soft: #fff4d8;
  --red: #a63d32;
  --red-soft: #fff2f0;
  --green: #459765;
  --green-soft: #e9f7ef;
  --shadow: 0 18px 45px rgba(18, 49, 63, 0.13);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
}

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

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

.preview-pane,
.editor-pane {
  min-width: 0;
}

.preview-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 58px;
  margin-bottom: 12px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 24px;
  line-height: 1.1;
  letter-spacing: 0;
}

h2 {
  font-size: 20px;
  letter-spacing: 0;
}

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

.icon-button {
  min-width: 58px;
  height: 38px;
  border: 1px solid #16465a;
  border-radius: 6px;
  background: var(--blue);
  color: #ffffff;
  cursor: pointer;
  font-weight: 700;
}

.icon-button.secondary {
  min-width: 70px;
  background: #ffffff;
  color: var(--blue);
  border-color: #a9c3ca;
}

.icon-button:focus-visible,
.small-button:focus-visible,
.mini-button:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 3px solid rgba(31, 95, 122, 0.28);
  outline-offset: 2px;
}

.chart-frame {
  height: calc(100vh - 106px);
  min-height: 680px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7faf9;
  box-shadow: var(--shadow);
}

.chart-frame svg {
  display: block;
  width: min(100%, 1280px);
  height: auto;
  margin: 0 auto;
}

.editor-pane {
  align-self: start;
  max-height: calc(100vh - 36px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.editor-header {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  background: #ffffff;
  border-bottom: 1px solid var(--line);
}

#saveStatus {
  color: var(--muted);
  font-size: 13px;
}

.editor-form {
  display: grid;
  gap: 12px;
  padding: 16px;
}

.editor-section {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid #d7e4e6;
  border-radius: 8px;
  background: #f8fbfb;
}

.section-title,
.card-editor-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.section-title h3 {
  margin: 0;
  color: #24424b;
  font-size: 15px;
  letter-spacing: 0;
}

.card-editor {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid #cfe0e3;
  border-radius: 8px;
  background: #ffffff;
}

.card-editor-header strong {
  color: #36515a;
  font-size: 13px;
}

.mini-actions {
  display: flex;
  gap: 5px;
}

.small-button,
.mini-button {
  border: 1px solid #a9c3ca;
  border-radius: 6px;
  background: #ffffff;
  color: var(--blue);
  cursor: pointer;
  font-weight: 700;
}

.small-button {
  min-width: 58px;
  height: 32px;
}

.mini-button {
  width: 30px;
  height: 28px;
  padding: 0;
  line-height: 1;
}

.mini-button:disabled {
  cursor: not-allowed;
  opacity: 0.4;
}

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

.field span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.field textarea,
.field select {
  width: 100%;
  border: 1px solid #b8cdd2;
  border-radius: 6px;
  padding: 10px 11px;
  color: var(--ink);
  background: #fbfdfd;
}

.field textarea {
  min-height: 62px;
  resize: vertical;
  line-height: 1.35;
}

.field select {
  height: 40px;
}

.field textarea[data-kind="label"] {
  min-height: 42px;
  resize: none;
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .editor-pane {
    max-height: none;
  }

  .chart-frame {
    height: auto;
    min-height: 0;
  }

  .chart-frame svg {
    width: 980px;
    max-width: none;
  }
}

@media (max-width: 620px) {
  .app-shell {
    padding: 10px;
  }

  .preview-toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .toolbar-actions {
    width: 100%;
  }

  .icon-button {
    flex: 1;
  }
}
