:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --ink: #1b2130;
  --muted: #6b7488;
  --line: #e2e6ed;
  --brand: #285da8;
  --danger: #b83232;
  --warn: #a65f1b;
  --radius: 10px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171d;
    --panel: #1b1f27;
    --ink: #e7eaf0;
    --muted: #939cae;
    --line: #2b313c;
    --brand: #6ea3e8;
  }
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

.bar {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand h1 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

/* Red i-dot over a dotless-i base (ı, U+0131) so there is no glyph dot to
   collide with. Only the red dot's position/size is tunable here. */
.brand h1 .dot-i {
  position: relative;
}

.brand h1 .dot-i::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 0.12em;
  width: 0.16em;
  height: 0.16em;
  transform: translateX(-50%);
  background: #FF1A1A;
  border-radius: 50%;
}

.logo-icon {
  width: 27px;
  height: 27px;
  flex: none;
  color: var(--ink);
}

.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.field {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
}

select {
  max-width: 260px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  font: inherit;
}

.toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}

.segmented {
  display: flex;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.segmented button {
  padding: 6px 12px;
  border: 0;
  background: var(--panel);
  color: var(--muted);
  font: inherit;
  cursor: pointer;
}

.segmented button.on {
  background: var(--brand);
  color: #fff;
}

button.primary {
  padding: 8px 16px;
  border: 0;
  border-radius: 8px;
  background: var(--brand);
  color: #fff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

button.primary:hover { filter: brightness(1.07); }
button.primary:active { transform: translateY(1px); }

button.secondary {
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  font: inherit;
  cursor: pointer;
}

button.secondary:hover { border-color: var(--muted); }
button.secondary:disabled { opacity: 0.5; cursor: default; }

.split {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 1px;
  min-height: 0;
  background: var(--line);
}

.pane {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--panel);
}

.pane-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
}

.pane-head h2 {
  margin: 0;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.stats {
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

textarea {
  flex: 1;
  padding: 18px 20px;
  border: 0;
  outline: 0;
  resize: none;
  background: transparent;
  color: var(--ink);
  font: 13px/1.7 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  tab-size: 2;
}

.stage {
  flex: 1;
  overflow: auto;
  padding: 24px 16px;
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

.stage.cards {
  padding: 24px;
}

.card-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  justify-content: center;
  align-content: flex-start;
}

/* Cards render at 1080x1440; each is scaled down into a fixed preview frame. */
.card-preview {
  width: 258px;
  height: 344px;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 6px 20px rgba(20, 30, 50, 0.16);
  background: #fff;
  flex: 0 0 auto;
}

.card-preview > div {
  transform: scale(0.238888);
  transform-origin: top left;
}

.hidden { display: none !important; }

/* The [hidden] attribute's UA default (display:none) is overridden by the
   author-level .stage { display:flex } rule, so enforce it explicitly. */
[hidden] { display: none !important; }

iframe {
  width: 375px;
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  transition: width 0.15s ease;
}

.compat {
  border-top: 1px solid var(--line);
  padding: 10px 16px;
  max-height: 34vh;
  overflow: auto;
}

.compat summary {
  cursor: pointer;
  font-size: 12px;
  color: var(--muted);
}

.compat ul {
  margin: 10px 0 4px;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 8px;
}

.compat li {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px;
  align-items: baseline;
  font-size: 13px;
}

.tag {
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.tag.blocking { background: color-mix(in srgb, var(--danger) 16%, transparent); color: var(--danger); }
.tag.warning  { background: color-mix(in srgb, var(--warn) 18%, transparent);   color: var(--warn); }

.compat .detail {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translate(-50%, 12px);
  padding: 9px 18px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--panel);
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (max-width: 860px) {
  .split { grid-template-columns: minmax(0, 1fr); }
  .pane.editor { min-height: 38vh; }
}
