:root {
  color-scheme: dark;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  font-family: 'Courier New', monospace;
  background: #102b36;
  color: #f4f0d7;
}
* { box-sizing: border-box; }
html, body, .editor { height: 100%; height: 100dvh; min-height: -webkit-fill-available; }
body { margin: 0; overflow: hidden; overscroll-behavior: none; }
.editor { position: fixed; inset: 0; overflow: hidden; }
#boundary-canvas { display: block; width: 100%; height: 100%; touch-action: none; cursor: grab; }
#boundary-canvas:active { cursor: grabbing; }
#boundary-canvas:focus-visible { outline: 2px solid #df9c55; outline-offset: -3px; }
.editor-header {
  position: absolute; top: calc(12px + var(--safe-top)); left: calc(16px + var(--safe-left)); right: calc(16px + var(--safe-right));
  display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; pointer-events: none;
}
.editor-header > * { pointer-events: auto; }
.editor-header > div { padding: 10px 14px; border: 1px solid #879a85; border-radius: 6px; background: #173d37; }
a { color: #e3cc91; font-size: 11px; }
h1, h2, h3 { font-family: Georgia, serif; font-weight: normal; }
h1 { margin: 5px 0 0; font-size: 23px; }
h2 { margin: 0 0 14px; font-size: 20px; }
h3 { margin: 18px 0 8px; font-size: 17px; }
nav, .editor-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.editor-tools {
  position: absolute; top: calc(103px + var(--safe-top)); left: calc(16px + var(--safe-left));
  width: min(350px, calc(100% - 32px - var(--safe-left) - var(--safe-right)));
  max-height: calc(100dvh - 240px - var(--safe-top) - var(--safe-bottom)); overflow: auto;
  border: 1px solid #879a85; border-radius: 6px; background: #173d37; scrollbar-width: thin;
}
summary { padding: 12px 14px; cursor: pointer; font-weight: bold; }
.editor-controls { padding: 6px 14px 14px; }
label { display: block; margin-bottom: 5px; font-size: 12px; }
select, input, button, textarea { font: inherit; font-size: 12px; color: #f4f0d7; border: 1px solid #92a18a; border-radius: 4px; background: #244b42; }
select, input, textarea { width: 100%; padding: 9px 8px; }
select, input, button { min-height: 40px; }
button { padding: 8px 10px; cursor: pointer; }
button:hover:not(:disabled) { background: #37614f; }
button:disabled { opacity: .5; cursor: default; }
button:focus-visible, a:focus-visible, summary:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid #df9c55; outline-offset: 3px; }
.settings-row { display: grid; grid-template-columns: 1fr 120px; gap: 10px; margin-top: 12px; }
.editor-actions { margin-top: 8px; }
.editor-actions button { flex: 1 1 120px; }
.editor-help { font-size: 11px; line-height: 1.6; color: #d4debf; }
#selection-label { font-size: 12px; color: #f0c77d; }
.reset-button { width: 100%; margin-top: 8px; }
.editor-footer {
  position: absolute; bottom: calc(10px + var(--safe-bottom)); left: calc(16px + var(--safe-left)); right: calc(16px + var(--safe-right));
  width: fit-content; max-width: calc(100% - 32px - var(--safe-left) - var(--safe-right));
  padding: 9px 12px; border: 1px solid #879a85; border-radius: 5px; background: #173d37; pointer-events: none; font-size: 11px;
}
.editor-footer p { margin: 5px 0 0; line-height: 1.5; }
#editor-position { color: #e3cc91; }
dialog { width: min(680px, calc(100% - 32px - var(--safe-left) - var(--safe-right))); max-height: calc(100dvh - 40px - var(--safe-top) - var(--safe-bottom)); padding: 20px; overflow: auto; border: 1px solid #879a85; border-radius: 6px; color: #f4f0d7; background: #173d37; }
dialog::backdrop { background: #051c23c7; }
textarea { resize: vertical; margin-bottom: 12px; background: #102b36; }
@media (max-width: 600px) {
  .editor-header { left: calc(10px + var(--safe-left)); right: calc(10px + var(--safe-right)); }
  h1 { font-size: 20px; }
  .editor-tools { left: calc(10px + var(--safe-left)); width: min(320px, calc(100% - 20px - var(--safe-left) - var(--safe-right))); }
  .editor-footer { left: calc(10px + var(--safe-left)); right: calc(10px + var(--safe-right)); }
  #navigation-help { display: none; }
}
@media (max-height: 500px) {
  .editor-header > div { padding: 6px 10px; }
  h1 { font-size: 18px; }
  .editor-tools { top: calc(80px + var(--safe-top)); max-height: calc(100dvh - 150px - var(--safe-top) - var(--safe-bottom)); }
  #navigation-help { display: none; }
}
