:root {
  color-scheme: light;
  font-family:
    Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-synthesis: none;
  --ink: #1d211c;
  --muted: #6f766d;
  --line: #dfe3dc;
  --panel: #ffffff;
  --canvas: #ecefe9;
  --accent: #2f6b3a;
  --accent-hover: #245b30;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

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

body {
  margin: 0;
  background: #f4f5f1;
  color: var(--ink);
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

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

.controls {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding: 28px 24px 24px;
  background: var(--panel);
  border-right: 1px solid var(--line);
}

.app-header {
  display: grid;
  gap: 5px;
}

.app-mark {
  margin: 0;
  color: var(--accent);
  font-size: 11px;
  font-weight: 750;
  line-height: 1;
  letter-spacing: 0.12em;
}

.app-header h1,
.workspace-heading h2,
.section-heading h2,
.preview-item h3 {
  margin: 0;
  letter-spacing: 0;
}

.app-header h1 {
  font-size: 21px;
  line-height: 1.25;
}

.tool-tabs,
.segmented-control {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 3px;
  padding: 3px;
  background: #eef1ec;
  border: 1px solid #e0e4dd;
  border-radius: 7px;
}

.tool-tab,
.segment-button {
  min-width: 0;
  height: 34px;
  padding: 0 10px;
  background: transparent;
  border: 0;
  border-radius: 5px;
  cursor: pointer;
  color: var(--muted);
  font-size: 13px;
  font-weight: 680;
}

.tool-tab.is-active,
.segment-button.is-active {
  color: var(--ink);
  background: #fff;
  box-shadow: 0 1px 3px rgb(24 32 22 / 10%);
}

.control-panel {
  display: grid;
  gap: 24px;
}

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

.field label,
.field-label,
.section-heading h2 {
  font-size: 13px;
  font-weight: 680;
}

.field input[type="text"] {
  width: 100%;
  height: 42px;
  padding: 0 11px;
  color: var(--ink);
  background: #fff;
  border: 1px solid #cfd5cc;
  border-radius: 6px;
  outline: none;
  transition:
    border-color 140ms ease,
    box-shadow 140ms ease;
}

.field input[type="text"]:focus {
  border-color: #5d8b65;
  box-shadow: 0 0 0 3px rgb(47 107 58 / 12%);
}

.color-controls {
  display: grid;
  gap: 10px;
}

.section-heading,
.preview-item > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.icon-button {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  padding: 0;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 5px;
  cursor: pointer;
  font-size: 19px;
  line-height: 1;
}

.icon-button:hover {
  background: #f1f3ee;
}

.color-list {
  border-top: 1px solid var(--line);
}

.color-row {
  min-height: 48px;
  display: grid;
  grid-template-columns: 1fr auto 34px;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  font-size: 13px;
}

.color-value {
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
}

input[type="color"] {
  width: 34px;
  height: 34px;
  padding: 3px;
  background: #fff;
  border: 1px solid #cfd5cc;
  border-radius: 6px;
  cursor: pointer;
}

input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 0;
}

input[type="color"]::-webkit-color-swatch {
  border: 0;
  border-radius: 3px;
}

input[type="color"]::-moz-color-swatch {
  border: 0;
  border-radius: 3px;
}

.font-state {
  min-height: 24px;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: auto;
  color: var(--muted);
  font-size: 12px;
}

.status-dot {
  width: 7px;
  height: 7px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: #b7bdb4;
}

.font-state[data-status="ready"] .status-dot {
  background: #3a8b4c;
}

.font-state[data-status="error"] .status-dot {
  background: #b95144;
}

.text-button {
  margin-left: auto;
  padding: 2px 0;
  color: var(--accent);
  background: transparent;
  border: 0;
  cursor: pointer;
  font-size: 12px;
  font-weight: 650;
}

.primary-button,
.download-button {
  border: 0;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 680;
  transition:
    background-color 140ms ease,
    opacity 140ms ease;
}

.primary-button {
  min-height: 44px;
  padding: 0 18px;
  color: #fff;
  background: var(--accent);
}

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

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.workspace {
  min-width: 0;
  padding: 28px clamp(20px, 3vw, 44px) 48px;
}

.workspace-heading {
  margin-bottom: 18px;
}

.workspace-heading h2 {
  font-size: 18px;
}

.preview-grid {
  display: grid;
  grid-template-columns: minmax(260px, 0.72fr) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.course-preview-grid {
  display: grid;
}

.preview-item {
  min-width: 0;
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 7px;
}

.preview-item--header {
  grid-column: 1 / -1;
}

.preview-item > header {
  min-height: 58px;
  padding: 10px 13px 10px 15px;
  border-bottom: 1px solid var(--line);
}

.preview-item h3 {
  font-size: 14px;
  line-height: 1.35;
}

.preview-item p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.2;
}

.download-button {
  min-width: 58px;
  height: 32px;
  padding: 0 12px;
  color: var(--accent);
  background: #edf4ed;
  font-size: 12px;
}

.download-button:hover:not(:disabled) {
  background: #e0ede1;
}

.canvas-frame {
  display: grid;
  place-items: center;
  padding: 14px;
  background:
    linear-gradient(45deg, #e5e8e2 25%, transparent 25%) 0 0 / 18px 18px,
    linear-gradient(45deg, transparent 75%, #e5e8e2 75%) 0 0 / 18px 18px,
    linear-gradient(45deg, transparent 75%, #e5e8e2 75%) 9px -9px / 18px 18px,
    linear-gradient(45deg, #e5e8e2 25%, var(--canvas) 25%) 9px -9px / 18px 18px;
}

.canvas-frame--loading {
  min-height: 560px;
}

.canvas-frame--course {
  min-height: 300px;
  padding: clamp(22px, 4vw, 52px);
  background:
    linear-gradient(45deg, #b9beb6 25%, transparent 25%) 0 0 / 18px 18px,
    linear-gradient(45deg, transparent 75%, #b9beb6 75%) 0 0 / 18px 18px,
    linear-gradient(45deg, transparent 75%, #b9beb6 75%) 9px -9px / 18px 18px,
    linear-gradient(45deg, #b9beb6 25%, #d4d8d1 25%) 9px -9px / 18px 18px;
}

.canvas-frame canvas {
  display: block;
  max-width: 100%;
  height: auto;
  box-shadow: 0 1px 6px rgb(23 31 20 / 12%);
}

.canvas-frame--header canvas,
.canvas-frame--share canvas,
.canvas-frame--course canvas {
  width: 100%;
}

.canvas-frame--loading canvas {
  width: min(100%, 330px);
}

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

  .controls {
    position: static;
    height: auto;
    display: flex;
    gap: 20px;
    padding: 22px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .font-state {
    margin-top: 0;
  }

  .primary-button {
    align-self: stretch;
  }
}

@media (max-width: 680px) {
  .preview-grid {
    grid-template-columns: 1fr;
  }

  .preview-item--header {
    grid-column: auto;
  }

  .workspace {
    padding: 22px 14px 36px;
  }

  .canvas-frame--loading {
    min-height: 0;
  }

  .canvas-frame--course {
    min-height: 190px;
    padding: 20px 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
