:root {
  color-scheme: dark;
  font-family: "Geist", "Instrument Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  --chrome: #11151b;
  --panel: #14191f;
  --surface: #171c22;
  --canvas: #10151b;
  --line: #343b44;
  --strong-line: #515b65;
  --text: #f1f3f5;
  --muted: #b6bec8;
  --faint: #929ca8;
  --mint: #9aefc5;
  --mint-hover: #b0f7d5;
  --ink: #071b13;
  --mono: "Geist Mono", ui-monospace, SFMono-Regular, Consolas, monospace;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  height: 100vh;
  height: 100dvh;
  background: var(--chrome);
  color: var(--text);
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  overflow: hidden;
}
button, input, select { font: inherit; }
button { touch-action: manipulation; }
button:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--mint);
  outline-offset: 3px;
}
svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.65; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.masthead, .toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  border-bottom: 1px solid var(--line);
}
.masthead { min-height: 56px; gap: 16px; }
.identity, .brand, .header-actions, .tool-group { display: flex; align-items: center; }
.identity { min-width: 0; gap: 26px; }
.brand { gap: 12px; }
.brand svg { width: 29px; height: 29px; color: var(--mint); stroke-width: 1.8; }
.brand h1 { margin: 0; font-size: 23px; font-weight: 690; letter-spacing: -.55px; }
.app-name { border-left: 1px solid var(--strong-line); padding-left: 26px; color: var(--muted); white-space: nowrap; font-size: 16px; }
.header-actions { gap: 10px; }
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 37px;
  padding: 0 13px;
  border: 1px solid var(--strong-line);
  border-radius: 7px;
  background: var(--surface);
  color: var(--text);
  white-space: nowrap;
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease;
}
.button:hover:not(:disabled) { background: #252c34; border-color: #73808d; }
.button:disabled { opacity: .39; cursor: default; }
.button.primary, .toolbar .button[aria-pressed="true"]:not(:disabled) { background: var(--mint); border-color: var(--mint); color: var(--ink); font-weight: 650; }
.button.primary:hover:not(:disabled), .toolbar .button[aria-pressed="true"]:hover:not(:disabled) { background: var(--mint-hover); border-color: var(--mint-hover); }
.button.secondary { background: transparent; border-color: #83aa9a; }
.button.plain { border-color: transparent; background: transparent; color: var(--muted); }
.button.icon-button { padding: 0; width: 43px; }
.toolbar { min-height: 52px; justify-content: flex-start; gap: 17px; background: var(--panel); }
.tool-group { gap: 8px; }
.toolbar .button { border-color: var(--line); }
.history { position: relative; padding-left: 17px; }
.history::before { content: ""; position: absolute; left: 0; height: 24px; width: 1px; background: var(--line); }
.tool-hint { margin: 0 0 0 auto; color: var(--muted); font-size: 13px; }
.editor { display: grid; grid-template-columns: minmax(0, 1fr) clamp(235px, 22.55vw, 350px); min-height: 0; }
.stage {
  position: relative;
  overflow: hidden;
  touch-action: none;
  isolation: isolate;
  display: grid;
  place-items: center;
  background-color: var(--canvas);
  background-image: radial-gradient(circle at center, #303741 0.7px, transparent 0.8px);
  background-size: 15px 15px;
  user-select: none;
}
.stage[data-mode="pan"] { cursor: grab; }
.stage[data-mode="crop"] { cursor: crosshair; }
.stage[data-mode="drag"] { cursor: grabbing; }
.stage[data-mode="nwse"] { cursor: nwse-resize; }
.stage[data-mode="nesw"] { cursor: nesw-resize; }
#viewport { position: absolute; inset: 0; width: 100%; height: 100%; }
.empty {
  display: grid;
  justify-items: center;
  text-align: center;
  width: min(390px, calc(100% - 32px));
  padding: 39px 18px 34px;
  border: 1px dashed #47545f;
  border-radius: 15px;
  background: #14191f;
  box-shadow: 0 14px 52px #080b1042;
}
.empty-mark { display: grid; place-items: center; width: 56px; height: 56px; border: 1px solid #39564b; border-radius: 14px; background: #1a2b27; color: var(--mint); }
.empty-mark svg { width: 27px; height: 27px; }
.empty h2 { margin: 19px 0 6px; font-size: 25px; font-weight: 680; letter-spacing: -.55px; }
.empty p { margin: 0 0 22px; color: var(--muted); line-height: 1.45; }
.empty .button { min-height: 41px; padding-inline: 16px; }
.empty small { margin-top: 18px; color: var(--faint); font-size: 12px; }
.drop-label { position: absolute; inset: 12px; display: grid; place-items: center; z-index: 3; border: 2px dashed var(--mint); border-radius: 14px; background: #10231de8; color: var(--mint); font-size: 23px; font-weight: 650; pointer-events: none; }
.zoom-bar {
  position: absolute;
  display: flex;
  gap: 7px;
  align-items: center;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 5px;
  background: #14191ff5;
  box-shadow: 0 5px 15px #0008;
  cursor: default;
}
.zoom-bar .button { min-height: 32px; }
.zoom-bar .icon-button { width: 36px; }
.zoom-bar .zoom-level { min-width: 69px; padding: 0 4px; border-color: transparent; background: transparent; font-family: var(--mono); color: var(--mint); font-size: 13px; font-variant-numeric: tabular-nums; }
.zoom-bar .icon-button[aria-pressed="true"] { color: var(--mint); }
.zoom-divider { width: 1px; height: 22px; background: var(--line); margin: 0 4px; }
.notice { position: absolute; z-index: 4; top: 12px; left: 50%; transform: translateX(-50%); max-width: calc(100% - 24px); width: max-content; margin: 0; padding: 10px 14px; background: #1d2827; color: var(--mint); border: 1px solid #476b5a; border-radius: 8px; text-align: center; cursor: default; }
.notice[data-kind="error"] { background: #2d2024; color: #ffd4da; border-color: #905f68; }
.inspector { min-width: 0; overflow: auto; background: var(--panel); border-left: 1px solid var(--line); padding: 22px 18px; }
.inspector h2 { margin: 0 0 16px; font-size: 18px; letter-spacing: -.2px; font-weight: 670; }
.panel-hint { color: var(--faint); margin: 0; line-height: 1.5; }
.coordinates { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
.coordinates label { display: grid; gap: 3px; padding: 7px 9px; border: 1px solid var(--strong-line); border-radius: 8px; color: var(--muted); font-size: 13px; }
.coordinates label:focus-within { border-color: var(--mint); }
.coordinates input { border: 0; outline: none; background: transparent; color: var(--text); font-family: var(--mono); width: 100%; min-width: 0; font-size: 16px; }
.coordinates input:focus-visible { outline: none; }
.selection-actions { display: grid; gap: 8px; margin-top: 20px; }
.selection-actions .button { min-height: 40px; }
.selection-actions .button.plain { min-height: 32px; }
.image-panel { border-top: 1px solid var(--strong-line); padding-top: 18px; margin-top: 20px; }
.image-panel h2 { margin-bottom: 10px; }
.image-panel p { margin: 0 0 5px; color: var(--muted); overflow-wrap: anywhere; line-height: 1.4; }
.image-panel p.image-zoom { color: var(--faint); }
#minimap { display: block; width: 100%; aspect-ratio: 1.76; border: 1px solid var(--strong-line); border-radius: 6px; margin-top: 16px; cursor: crosshair; touch-action: none; }
.statusbar { display: flex; justify-content: space-between; gap: 14px; align-items: center; min-height: 34px; padding: 0 20px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; }
.status-group { display: flex; align-items: center; min-width: 0; }
.status-group span { padding: 0 12px; white-space: nowrap; }
.status-group span:first-child { padding-left: 0; overflow: hidden; text-overflow: ellipsis; }
.status-group span + span:not([hidden]) { border-left: 1px solid var(--strong-line); }
.status-group span:last-child { padding-right: 0; }
#status-origin, #status-pointer { font-family: var(--mono); }
dialog { width: min(420px, calc(100% - 28px)); padding: 23px; border: 1px solid var(--strong-line); border-radius: 12px; background: var(--panel); color: var(--text); box-shadow: 0 15px 60px #0009; }
dialog::backdrop { background: #0009; }
dialog h2 { margin: 0 0 10px; font-size: 20px; }
dialog p { color: var(--muted); line-height: 1.5; margin: 0 0 16px; }
.resize-label { display: block; color: var(--muted); margin-bottom: 6px; }
dialog select { width: 100%; min-height: 38px; border-radius: 7px; border: 1px solid var(--strong-line); background: var(--surface); color: var(--text); padding: 0 9px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }
@media (max-width: 720px) {
  .masthead, .toolbar, .statusbar { padding-inline: 12px; }
  .app-name, .tool-hint, .selection-status { display: none; }
  .editor { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; }
  .inspector { border-left: 0; border-top: 1px solid var(--line); padding: 10px 12px; max-height: 41dvh; }
  .inspector h2 { margin-bottom: 8px; font-size: 15px; }
  .image-panel { display: none; }
  .coordinates { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 5px; }
  .coordinates label { padding: 4px 6px; font-size: 12px; }
  .coordinates input { font-size: 16px; }
  .selection-actions { display: grid; grid-template-columns: 1fr 1fr auto; margin-top: 8px; gap: 5px; }
  .selection-actions .button { min-height: 34px; gap: 5px; padding-inline: 6px; font-size: 12px; }
  .selection-actions .button svg { width: 15px; height: 15px; }
  .zoom-bar { bottom: 8px; }
}
@media (max-width: 375px) {
  .header-actions { gap: 5px; }
  .header-actions .button { padding-inline: 7px; gap: 5px; font-size: 12px; }
  .brand { gap: 6px; }
  .brand h1 { font-size: 20px; }
  .brand svg { width: 23px; height: 23px; }
  .statusbar { font-size: 11px; }
  .status-group span { padding-inline: 6px; }
}
@media (max-height: 500px) {
  .empty { padding-block: 16px; }
  .empty-mark { width: 37px; height: 37px; }
  .empty h2 { margin-top: 8px; }
  .empty p { margin-bottom: 9px; }
  .empty small { margin-top: 8px; }
}
@media (prefers-reduced-motion: reduce) { .button { transition: none; } }
