:root {
  color-scheme: light;
  font-family: "Segoe UI", system-ui, sans-serif;
  color: #191b20;
  background: #f4f5f7;
  --muted: #58616c;
  --line: #e2e5e9;
  --ink: #171a20;
  --accent: #9f3d24;
  --accent-soft: #fff1ec;
}
* { box-sizing: border-box; }
body { margin: 0; }
[hidden] { display: none !important; }
button, .button {
  font: inherit;
  font-weight: 650;
  font-size: .9rem;
  min-height: 41px;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: .58rem 1rem;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}
button:focus-visible, a:focus-visible, input:focus-visible {
  outline: 3px solid #ad563d;
  outline-offset: 3px;
}
button:disabled { cursor: default; }
.topbar {
  height: 68px;
  padding: 0 clamp(.9rem, 4vw, 2.75rem);
  border-bottom: 1px solid var(--line);
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .8rem;
}
.brand { display: flex; align-items: center; gap: .65rem; font-weight: 700; letter-spacing: -.02em; }
.brand-mark {
  display: grid;
  place-items: center;
  height: 33px;
  width: 33px;
  flex: 0 0 auto;
  color: #fff;
  background: var(--accent);
  font-family: Georgia, serif;
  font-size: 1.3rem;
  border-radius: 9px;
}
.file-actions { display: flex; align-items: center; gap: .55rem; }
.primary { color: white; background: var(--accent); }
.primary:hover { background: #83321e; }
.primary:disabled { background: #e9e5e3; color: #6b625e; }
.secondary { color: var(--ink); background: white; border-color: #d8dce1; }
.secondary:hover { background: #f6f7f8; }
main { padding: 24px clamp(.8rem, 3.1vw, 2.25rem) 32px; }
.intro {
  max-width: 700px;
  margin: clamp(2.5rem, 9vh, 7rem) auto;
  padding: clamp(1.25rem, 5vw, 3.75rem);
  border: 1px solid var(--line);
  border-radius: 20px;
  background: #fff;
  text-align: center;
}
.intro h1 { margin: 0; font-size: clamp(2rem, 5vw, 3.25rem); line-height: 1.05; letter-spacing: -.055em; }
.intro p { margin: .95rem 0 1.75rem; color: var(--muted); }
.drop {
  width: 100%;
  min-height: 195px;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: .45rem;
  border: 1px dashed #bfc5cd;
  background: #f9fafb;
  color: var(--ink);
  border-radius: 12px;
  padding: 1rem;
}
.drop:hover, .drop.drag { border-color: var(--accent); background: var(--accent-soft); }
.drop > span:last-child { font-weight: 400; color: var(--muted); }
.file-icon { display: grid; place-items: center; margin-bottom: .3rem; width: 45px; height: 50px; border-radius: 7px; border: 1px solid #e6c0b4; background: var(--accent-soft); color: var(--accent); font-size: .75rem; font-weight: 750; }
.prepare { color: var(--muted); text-align: left; margin-top: 1.15rem; font-size: .9rem; }
.prepare summary { cursor: pointer; }
.prepare p { margin: .65rem 0; }
.workspace { display: grid; grid-template-columns: minmax(0, 1fr) minmax(275px, 330px); gap: 18px; max-width: 1500px; margin: 0 auto; }
.viewer, .editor { border: 1px solid var(--line); border-radius: 14px; background: #fff; overflow: hidden; min-width: 0; }
.viewer-top, .editor-head { padding: .9rem 1.15rem; min-height: 64px; border-bottom: 1px solid var(--line); }
.viewer-top { display: flex; align-items: center; justify-content: space-between; gap: .7rem; }
.viewer-top h1, .editor h2 { font-size: 1rem; margin: 0; font-weight: 700; }
.viewer-top h1 { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.zoom { display: flex; align-items: center; gap: .1rem; }
.zoom button { border: 0; background: transparent; color: var(--muted); min-height: 34px; min-width: 34px; padding: .25rem; }
.zoom button:hover { background: #f0f1f3; }
.stage {
  background: #e8ebef;
  height: max(450px, calc(100dvh - 184px));
  overflow: auto;
  display: flex;
  align-items: flex-start;
  padding: 20px;
}
.sheet { position: relative; flex: 0 0 auto; margin: auto; background: #fff; box-shadow: 0 2px 10px #1c273021; }
.sheet img { width: 100%; height: 100%; display: block; }
.targets { position: absolute; inset: 0; pointer-events: none; }
.target {
  position: absolute;
  transform: translate(-50%, -50%);
  min-width: 22px;
  min-height: 18px;
  padding: 0;
  border: 1px solid #ae4b33;
  background: #fff4ee35;
  border-radius: 4px;
  pointer-events: auto;
  cursor: pointer;
}
.target:hover, .target.selected { outline: 2px solid var(--accent); background: #ffb89b45; }
.editor { display: flex; flex-direction: column; height: max(515px, calc(100dvh - 118px)); }
.editor-head p { margin: .25rem 0 0; font-size: .875rem; color: var(--muted); }
.fields { padding: .5rem .85rem; overflow: auto; flex: 1; }
.field { padding: .75rem .45rem; border-bottom: 1px solid #eceef0; }
.field:last-child { border-bottom: 0; }
.field label { display: block; font-size: .875rem; color: #343b45; margin-bottom: .38rem; overflow-wrap: anywhere; }
.field input {
  display: block;
  width: 100%;
  font: inherit;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  padding: .65rem .68rem;
  border: 1px solid #cbd1d9;
  border-radius: 7px;
  background: #fff;
}
.field input[aria-invalid="true"] { border-color: #b03226; }
.field.active label { color: var(--accent); }
.editor-actions { padding: .86rem; border-top: 1px solid var(--line); }
.editor-actions button { width: 100%; }
.notice {
  position: fixed;
  z-index: 2;
  left: 50%;
  transform: translateX(-50%);
  bottom: 18px;
  margin: 0;
  width: max-content;
  max-width: calc(100vw - 2rem);
  padding: .8rem 1.15rem;
  color: #fff;
  background: #222832;
  border-radius: 10px;
  box-shadow: 0 4px 16px #1114;
}
.notice.error { background: #923127; }
.editor .notice {
  position: static;
  transform: none;
  margin: .65rem 0 0;
  width: auto;
  max-width: none;
  padding: 0;
  color: var(--muted);
  background: transparent;
  box-shadow: none;
  font-size: .875rem;
}
.editor .notice.error { color: #923127; }
@media (max-width: 740px) {
  .workspace { grid-template-columns: 1fr; gap: 12px; }
  .stage { height: min(56dvh, 590px); min-height: 240px; padding: 13px; }
  .editor { height: auto; }
  .fields { max-height: 365px; }
  .topbar { height: 61px; }
  main { padding-top: 14px; }
}
@media (max-width: 425px) {
  .brand { font-size: .83rem; gap: .36rem; }
  .brand-mark { width: 27px; height: 27px; }
  .file-actions { gap: .25rem; }
  .file-actions > * { font-size: .76rem; padding-inline: .52rem; }
}
