:root {
  color-scheme: light;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  --bg: #f6f7f8;
  --surface: #ffffff;
  --surface-2: #f0f4f7;
  --ink: #17212b;
  --muted: #657383;
  --line: #d9e0e6;
  --accent: #167f7b;
  --accent-2: #d85a36;
  --ad-bg: #fff3d8;
  --ad-border: #dba54f;
  --shadow: 0 14px 40px rgba(38, 50, 56, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.72), rgba(255, 255, 255, 0)),
    var(--bg);
  color: var(--ink);
}

button,
select,
textarea {
  font: inherit;
}

button,
select {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
}

button {
  cursor: pointer;
}

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

.page-stack {
  grid-column: 2;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.ad-slot-left {
  grid-column: 1;
}

.ad-slot-right {
  grid-column: 3;
}

.ad-slot {
  display: flex;
  min-height: 88px;
  border: 1px dashed var(--ad-border);
  background:
    repeating-linear-gradient(
      135deg,
      rgba(216, 90, 54, 0.1) 0,
      rgba(216, 90, 54, 0.1) 10px,
      rgba(255, 255, 255, 0.45) 10px,
      rgba(255, 255, 255, 0.45) 20px
    ),
    var(--ad-bg);
  color: #80551c;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0;
}

.ad-slot span {
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(219, 165, 79, 0.35);
}

.ad-slot-left,
.ad-slot-right {
  min-height: calc(100vh - 36px);
  writing-mode: vertical-rl;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.86);
  box-shadow: var(--shadow);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(24px, 3vw, 34px);
  line-height: 1.12;
  letter-spacing: 0;
}

h2 {
  font-size: 17px;
  line-height: 1.25;
  letter-spacing: 0;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

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

.field.compact {
  min-width: 110px;
}

select {
  height: 38px;
  min-width: 92px;
  padding: 0 34px 0 12px;
  border-radius: 6px;
}

.workspace {
  min-height: calc(100vh - 210px);
  display: grid;
  grid-template-columns: minmax(320px, 0.84fr) minmax(420px, 1.16fr);
  gap: 14px;
}

.panel {
  min-width: 0;
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.panel-head {
  min-height: 74px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.panel-head p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.editor-panel {
  display: flex;
  flex-direction: column;
}

textarea {
  flex: 1;
  min-height: 480px;
  width: 100%;
  resize: none;
  border: 0;
  outline: 0;
  padding: 16px;
  background: #111820;
  color: #eef6f7;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 14px;
  line-height: 1.58;
  tab-size: 2;
}

.hint-row,
.status-bar {
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 14px;
  color: var(--muted);
  font-size: 12px;
  border-top: 1px solid var(--line);
}

.hint-row span:first-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.preview-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
}

.preview-stage {
  min-height: 480px;
  overflow: auto;
  display: grid;
  place-items: center;
  padding: 28px;
  background:
    linear-gradient(90deg, rgba(23, 33, 43, 0.045) 1px, transparent 1px),
    linear-gradient(rgba(23, 33, 43, 0.045) 1px, transparent 1px),
    var(--surface-2);
  background-size: 20px 20px;
}

canvas {
  max-width: none;
  background: #fff;
  border: 1px solid #c3ccd4;
  box-shadow: 0 18px 38px rgba(38, 50, 56, 0.18);
}

.tool-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.icon-button {
  width: 38px;
  height: 38px;
  border-radius: 6px;
  display: inline-grid;
  place-items: center;
  font-size: 21px;
  line-height: 1;
  font-weight: 700;
}

.ghost-button {
  min-height: 38px;
  border-radius: 6px;
  padding: 0 14px;
  font-weight: 800;
}

.ghost-button:hover,
.icon-button:hover,
select:hover {
  border-color: var(--accent);
}

.zoom-label {
  width: 54px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.site-footer {
  min-height: 46px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  flex-wrap: wrap;
  padding: 12px 16px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.82);
  color: var(--muted);
  font-size: 13px;
}

.site-footer a {
  color: var(--muted);
  text-decoration: none;
}

.site-footer a:hover {
  color: var(--accent);
  text-decoration: underline;
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 48px minmax(0, 1fr) 48px;
    gap: 8px;
    padding: 10px;
  }

  .ad-slot-left,
  .ad-slot-right {
    min-height: calc(100vh - 20px);
  }

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

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

  .topbar-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .field.compact {
    flex: 1;
    min-width: 130px;
  }

  select {
    width: 100%;
  }

  textarea,
  .preview-stage {
    min-height: 390px;
  }

  .hint-row {
    align-items: flex-start;
    flex-direction: column;
    padding: 10px 14px;
  }

  .hint-row span:first-child {
    white-space: normal;
  }
}

@media (max-width: 560px) {
  .panel-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .tool-group {
    justify-content: flex-start;
  }

  .preview-stage {
    padding: 16px;
  }
}
