:root {
  color-scheme: light;
  --page: #f8f6f1;
  --paper: #fff;
  --ink: #181d27;
  --muted: #575965;
  --border: #dfdcd6;
  --accent: #b34724;
  --accent-dark: #923816;
  --accent-light: #ffede2;
  --mono: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-family: "Avenir Next", Avenir, "Segoe UI", system-ui, sans-serif;
}
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; color: var(--ink); background: radial-gradient(ellipse at 85% 0%, #fbdfce 0%, transparent 35rem), var(--page); line-height: 1.55; }
[hidden] { display: none !important; }
button, select, input { color: inherit; font: inherit; }
button, select, label[for="file"] { cursor: pointer; }
button:disabled, select:disabled, input:disabled { cursor: default; }
:focus-visible { outline: 3px solid #bd552e; outline-offset: 3px; }
h1, h2, h3, p { margin: 0; }
.width { width: min(100% - 2.75rem, 72rem); margin-inline: auto; }
.header { border-bottom: 1px solid #e2d9d3; }
.header-inner { min-height: 4.05rem; display: flex; justify-content: space-between; align-items: center; gap: .55rem; }
.brand { display: flex; align-items: center; gap: .63rem; color: var(--ink); text-decoration: none; font-size: 1.05rem; font-weight: 760; }
.brand-mark, .empty-mark { display: flex; flex-direction: column; align-items: center; justify-content: center; }
.brand-mark { width: 2.22rem; height: 2.12rem; gap: .15rem; background: #252b37; border-radius: .53rem; }
.brand-mark i { width: .8rem; height: .13rem; border-radius: 1rem; background: #d6d5d1; }
.brand-mark i:nth-child(2) { width: 1.15rem; height: .28rem; border-radius: .1rem; background: #ff8d64; }
.header-link { color: #494b56; text-decoration: none; font-size: .92rem; font-weight: 670; }
.header-link:hover { text-decoration: underline; text-underline-offset: .18em; }
.hero { padding: clamp(2.2rem, 6vw, 4.25rem) 0 clamp(1.35rem, 3.3vw, 1.95rem); }
h1 { font-size: clamp(2.55rem, 7.1vw, 5.25rem); line-height: 1.02; letter-spacing: -.065em; font-weight: 775; }
h1 span { color: var(--accent); }
.hero p { max-width: 40rem; margin-top: .85rem; font-size: clamp(1rem, 2.35vw, 1.12rem); color: var(--muted); }

.source {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: .75rem;
  padding: .75rem .9rem;
  border: 1px dashed #c8bcb1;
  border-radius: .68rem;
  background: #ffffffb8;
}
.source:focus-within, .source.dropping { outline: 2px solid #bd552e; outline-offset: 2px; }
.source-label { min-width: 0; max-width: 100%; }
.source-label h2 { color: var(--muted); font-size: .87rem; font-weight: 710; }
#image-name { font-size: 1.12rem; font-weight: 740; overflow-wrap: anywhere; }
.small { color: var(--muted); font-size: .88rem; }
.source-actions, .editor-tools, .block-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .45rem; }
.button {
  min-height: 2.65rem;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: .4rem;
  padding: .48rem .79rem;
  border: 1px solid transparent;
  border-radius: .5rem;
  font-weight: 720;
  font-size: .92rem;
  line-height: 1.2;
  text-align: center;
  white-space: nowrap;
}
.primary { background: var(--accent); color: #fff; }
.primary:hover:not(:disabled) { background: var(--accent-dark); }
.primary:disabled, .source-actions:has(input:disabled) label { background: #eee4df; color: #654d45; }
.source-actions:has(input:disabled) label { cursor: default; }
.secondary { background: #fff; border-color: var(--border); color: #393944; }
.secondary:hover:not(:disabled) { background: #fff3eb; border-color: #d3b7aa; }
.secondary:disabled { color: #74747a; }
.problem { color: #963b24; border: 1px solid #edc4b3; background: #fff1eb; border-radius: .42rem; padding: .4rem .55rem; font-size: .89rem; }
#source-error, #source-status { flex: 0 0 100%; }
.workspace { display: grid; grid-template-columns: minmax(0, 1fr) minmax(17rem, .39fr); align-items: start; gap: .85rem; margin-top: .85rem; }
.panel { min-width: 0; padding: clamp(.78rem, 2.3vw, 1.15rem); border: 1px solid var(--border); border-radius: .85rem; background: var(--paper); box-shadow: 0 12px 27px #35313b09; }
.panel h2 { font-size: 1.18rem; line-height: 1.3; letter-spacing: -.026em; }
.editor-head, .blocks-head { display: flex; align-items: center; justify-content: space-between; gap: .58rem; flex-wrap: wrap; }
.editor-head { margin-bottom: .65rem; }
.modes { display: flex; gap: .1rem; padding: .17rem; border: 1px solid var(--border); border-radius: .5rem; background: #f7f5f2; }
.mode { min-height: 2.01rem; padding: .26rem .54rem; border: 0; background: transparent; color: #51525e; }
.mode[aria-pressed="true"] { background: #fff; color: var(--accent-dark); box-shadow: 0 2px 6px #5e2c1714; }
.mode:disabled { color: #70717a; }
#zoom {
  appearance: none;
  min-height: 2.45rem;
  border: 1px solid var(--border);
  border-radius: .5rem;
  padding: .31rem 1.62rem .31rem .49rem;
  font-size: .88rem;
  font-weight: 670;
  background:
    linear-gradient(45deg, transparent 52%, #666573 53%) right .75rem center / .28rem .28rem no-repeat,
    linear-gradient(135deg, #666573 53%, transparent 54%) right .48rem center / .28rem .28rem no-repeat, #fff;
}
#zoom:disabled { color: #72737b; }
.frame {
  max-height: 31rem;
  min-height: 14rem;
  overflow: auto;
  overscroll-behavior: contain;
  padding: .75rem;
  border: 1px solid #454852;
  border-radius: .55rem;
  background-color: #252a34;
  background-image:
    linear-gradient(45deg, #2d333e 25%, transparent 25%), linear-gradient(-45deg, #2d333e 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #2d333e 75%), linear-gradient(-45deg, transparent 75%, #2d333e 75%);
  background-size: 1.05rem 1.05rem;
  background-position: 0 0, 0 .525rem, .525rem -.525rem, -.525rem 0;
}
.frame.has-image { min-height: 0; }
.frame.dropping { outline: 2px solid #bd552e; outline-offset: 2px; }
.empty {
  min-height: clamp(12rem, 22vw, 19rem);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .2rem;
  color: #fff;
  text-align: center;
}
.empty p { font-weight: 730; }
.empty span { color: #d4d4dc; font-size: .88rem; }
.empty-mark { width: 3.7rem; height: 3rem; margin-bottom: .35rem; gap: .21rem; border-radius: .55rem; border: 1px solid #848993; background: #333943; }
.empty-mark i { width: 1.2rem; height: .13rem; border-radius: 1rem; background: #cbcbd1; }
.empty-mark i:nth-child(2) { width: 1.65rem; height: .36rem; border-radius: .09rem; background: #ff9d79; }
#preview { display: block; margin: 0 auto; cursor: crosshair; touch-action: none; }
#preview.pan { cursor: grab; touch-action: pan-x pan-y; }
#preview.panning { cursor: grabbing; }
.editor-hint { margin-top: .46rem; }

.text-button { padding: .15rem 0; border: 0; background: transparent; color: var(--accent-dark); font-size: .88rem; font-weight: 700; text-underline-offset: .18em; }
.text-button:hover:not(:disabled) { text-decoration: underline; }
.text-button:disabled { color: #74747b; }
.block-list { display: grid; gap: .32rem; margin-top: .55rem; max-height: 11rem; overflow: auto; }
.block-list:empty { display: none; }
.block-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: .4rem;
  border: 1px solid #e2dedb;
  border-radius: .4rem;
  background: #fff;
  padding: .37rem .5rem;
  text-align: left;
  font-size: .88rem;
}
.block-row[aria-pressed="true"] { border-color: #d29073; background: #fff4eb; }
.block-row span { color: var(--muted); font-family: var(--mono); font-size: .79rem; }
#blocks-empty { margin-top: .53rem; }
#block-form { border-top: 1px solid var(--border); margin-top: .75rem; padding-top: .55rem; }
.coordinate-heading { font-size: .99rem; font-weight: 750; }
.coordinate-help { margin: .14rem 0 .4rem; }
.coordinate-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .32rem .5rem; }
.coordinate-grid label { min-width: 0; color: #4e4f57; font-size: .88rem; font-weight: 640; }
.coordinate-grid input {
  display: block;
  width: 100%;
  min-height: 2.4rem;
  margin-top: .12rem;
  padding: .34rem .46rem;
  border: 1px solid var(--border);
  border-radius: .43rem;
  background: #fcfbfa;
  font: .91rem var(--mono);
}
.coordinate-grid input:disabled { color: #71717a; }
.block-actions { gap: .6rem; margin-top: .64rem; }
.danger { color: #943e2f; }
#coordinate-error { margin-top: .58rem; }
.export { margin-top: .9rem; padding-top: .73rem; border-top: 1px solid var(--border); }
.export-button { width: 100%; white-space: normal; }
#export-note { margin-top: .32rem; }
.guide { margin: 2.05rem 0; scroll-margin: 1rem; }
.guide h2 { font-size: 1.45rem; letter-spacing: -.03em; }
.guide-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; margin-top: .63rem; }
.guide article { border-top: 2px solid #e9ac93; padding-top: .62rem; }
.guide h3 { font-size: 1rem; margin-bottom: .29rem; }
.guide p { color: var(--muted); }
.footer { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .62rem; border-top: 1px solid var(--border); padding: .7rem 0 1.25rem; color: var(--muted); font-size: .87rem; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; border: 0; clip-path: inset(50%); white-space: nowrap; }

@media (max-width: 49rem) {
  .workspace { grid-template-columns: minmax(0, 1fr); }
  .guide-grid { grid-template-columns: 1fr; }
  .frame { max-height: 26rem; }
  .coordinate-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (max-width: 26rem) {
  .width { width: calc(100% - 1.35rem); }
  .source { padding: .7rem; }
  .source-actions { gap: .3rem; }
  .source-actions .button { padding-inline: .48rem; }
  .frame { padding: .5rem; }
  .coordinate-grid { grid-template-columns: 1fr 1fr; }
}
