/* Northern Cartographer — mesa de cartografia: ardósia de fiorde, latão de bússola, osso. */

:root {
  color-scheme: dark;
  --ground: #11171a;
  --hull: #172024;
  --hull-2: #1d272b;
  --hull-3: #243136;
  --seam: #2b373b;
  --seam-2: #3a484c;
  --bone: #e6dfcc;
  --bone-2: #bcb6a5;
  --lichen: #8a968e;
  --brass: #c9a24f;
  --brass-2: #e0bd72;
  --brass-wash: rgba(201, 162, 79, 0.12);
  --brass-ink: #1b1609;
  --ember: #d27150;
  --desk-hi: #1b2427;
  --desk-lo: #0b1012;

  --font-display: "IM Fell English SC", "Iowan Old Style", Georgia, serif;
  --font-ui: "Alegreya Sans", "Segoe UI", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;

  --rail-w: 60px;
  --panel-w: 284px;
  --top-h: 56px;
}

html,
body {
  height: 100%;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--ground);
  color: var(--bone);
  font: 15px/1.45 var(--font-ui);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

:focus-visible {
  outline: 2px solid var(--brass-2);
  outline-offset: 2px;
}

kbd {
  font: 500 11px/1 var(--font-mono);
  padding: 2px 5px 3px;
  border: 1px solid var(--seam-2);
  border-bottom-width: 2px;
  border-radius: 4px;
  color: var(--bone-2);
  background: var(--hull-2);
}

/* ---------- Estrutura ---------- */

.app {
  height: 100%;
  display: grid;
  grid-template-columns: var(--rail-w) var(--panel-w) minmax(0, 1fr);
  grid-template-rows: var(--top-h) minmax(0, 1fr);
  grid-template-areas:
    "top top top"
    "rail panel stage";
}

.topbar {
  grid-area: top;
  display: flex;
  align-items: center;
  gap: 16px;
  padding-inline: 16px 14px;
  background: var(--hull);
  border-bottom: 1px solid var(--seam);
  min-width: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
  margin-right: auto;
}

.brand-mark {
  width: 30px;
  height: 30px;
  color: var(--brass);
  flex: none;
}

.brand-text {
  display: grid;
  line-height: 1.05;
  min-width: 0;
}

.wordmark {
  font-family: var(--font-display);
  font-size: 22px;
  letter-spacing: 0.02em;
  color: var(--bone);
  white-space: nowrap;
}

.brand-sub {
  font-size: 12.5px;
  color: var(--lichen);
  font-style: italic;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.actions {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
}

.sep {
  width: 1px;
  height: 22px;
  background: var(--seam-2);
  margin-inline: 6px;
  flex: none;
}

.save-state {
  font: 12px var(--font-mono);
  color: var(--lichen);
  margin-right: 6px;
  white-space: nowrap;
}

.save-state::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  margin-right: 7px;
  vertical-align: 1px;
  background: var(--lichen);
}

.save-state[data-kind="ok"]::before { background: #8fb07a; }
.save-state[data-kind="pending"]::before { background: var(--brass); }
.save-state[data-kind="warn"]::before { background: var(--ember); }

/* Seletor de idioma */

.lang {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 2px;
  background: var(--hull-2);
  border: 1px solid var(--seam);
  border-radius: 6px;
  flex: none;
}

.lang svg {
  width: 16px;
  height: 16px;
  margin-inline: 5px 3px;
  color: var(--lichen);
  flex: none;
}

.lang button {
  height: 28px;
  min-width: 32px;
  padding: 0 6px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--bone-2);
  font: 500 12px var(--font-mono);
  letter-spacing: 0.04em;
  cursor: pointer;
}

.lang button:hover {
  color: var(--bone);
}

.lang button[aria-pressed="true"] {
  background: var(--hull-3);
  color: var(--brass-2);
  box-shadow: inset 0 0 0 1px var(--seam-2);
}

/* ---------- Botões ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 34px;
  padding: 0 12px;
  border: 1px solid var(--seam-2);
  border-radius: 6px;
  background: var(--hull-2);
  color: var(--bone);
  font-weight: 500;
  font-size: 14.5px;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 0.12s, border-color 0.12s, color 0.12s;
}

.btn svg {
  width: 18px;
  height: 18px;
  flex: none;
}

.btn:hover {
  border-color: #56666a;
  background: var(--hull-3);
}

.btn:disabled {
  opacity: 0.38;
  cursor: default;
  pointer-events: none;
}

.btn.ghost {
  background: transparent;
  border-color: transparent;
  color: var(--bone-2);
}

.btn.ghost:hover {
  background: var(--hull-2);
  color: var(--bone);
  border-color: var(--seam);
}

.btn.icon {
  width: 34px;
  padding: 0;
}

.btn.primary {
  background: var(--brass);
  border-color: var(--brass);
  color: var(--brass-ink);
  font-weight: 700;
}

.btn.primary:hover {
  background: var(--brass-2);
  border-color: var(--brass-2);
}

.btn.danger {
  color: var(--ember);
}

.btn.small {
  height: 30px;
  font-size: 14px;
  padding: 0 10px;
}

.export {
  display: flex;
  align-items: stretch;
}

.export .btn.primary {
  border-radius: 6px 0 0 6px;
}

.export select {
  height: 34px;
  border: 1px solid var(--brass);
  border-left: 1px solid rgba(27, 22, 9, 0.35);
  border-radius: 0 6px 6px 0;
  background: var(--brass);
  color: var(--brass-ink);
  font: 700 13px var(--font-mono);
  padding: 0 6px;
  cursor: pointer;
}

/* ---------- Trilho de ferramentas ---------- */

.rail {
  grid-area: rail;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding-block: 12px;
  background: var(--hull);
  border-right: 1px solid var(--seam);
}

.rail-sep {
  width: 26px;
  height: 1px;
  background: var(--seam-2);
  margin-block: 6px;
  flex: none;
}

.tool {
  position: relative;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--lichen);
  cursor: pointer;
  flex: none;
  transition: background-color 0.12s, color 0.12s;
}

.tool svg {
  width: 22px;
  height: 22px;
}

.tool:hover {
  color: var(--bone);
  background: var(--hull-2);
}

.tool[aria-pressed="true"] {
  color: var(--brass-2);
  background: var(--brass-wash);
  border-color: rgba(201, 162, 79, 0.4);
}

.tool .tip {
  position: absolute;
  left: calc(100% + 10px);
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 8px 5px 10px;
  background: #0c1113;
  border: 1px solid var(--seam-2);
  border-radius: 5px;
  color: var(--bone);
  font-size: 13.5px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  z-index: 30;
  transition: opacity 0.1s;
}

.tool:hover .tip,
.tool:focus-visible .tip {
  opacity: 1;
}

/* ---------- Painel ---------- */

.panel {
  grid-area: panel;
  background: var(--hull);
  border-right: 1px solid var(--seam);
  overflow-y: auto;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.tool-pane,
.selection,
.sheet {
  padding: 18px 18px 20px;
  display: grid;
  gap: 16px;
  align-content: start;
}

.tool-pane[hidden],
.selection[hidden] {
  display: none;
}

.pane-head {
  display: grid;
  gap: 4px;
}

.pane-head h2 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 23px;
  letter-spacing: 0.01em;
  line-height: 1.1;
  text-wrap: balance;
}

.pane-head p,
.hint {
  margin: 0;
  color: var(--lichen);
  font-size: 14px;
  line-height: 1.45;
}

.field {
  display: grid;
  gap: 7px;
}

.field[hidden] {
  display: none;
}

.field-label,
.cat-label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  font-size: 11.5px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--lichen);
}

.field-label output {
  font: 500 12px var(--font-mono);
  letter-spacing: 0;
  text-transform: none;
  color: var(--bone-2);
  font-variant-numeric: tabular-nums;
}

.keys {
  margin: 0;
  font-size: 13px;
  color: var(--lichen);
  line-height: 2;
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.row .btn {
  flex: 1 1 auto;
}

.subsection {
  display: grid;
  gap: 10px;
  padding-top: 16px;
  border-top: 1px solid var(--seam);
}

.subsection h3,
.sel-head h3 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 18px;
}

/* Biomas */

.swatches {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
}

.swatch {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 6px 7px;
  border: 1px solid transparent;
  border-radius: 5px;
  background: var(--hull-2);
  color: var(--bone-2);
  font-size: 13.5px;
  line-height: 1.15;
  text-align: left;
  cursor: pointer;
}

.swatch i {
  width: 20px;
  height: 20px;
  flex: none;
  border-radius: 4px;
  background: var(--c);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.35), inset 0 -5px 7px rgba(0, 0, 0, 0.2), inset 0 3px 4px rgba(255, 255, 255, 0.14);
}

.swatch.is-ocean i {
  background:
    repeating-linear-gradient(-28deg, transparent 0 4px, rgba(210, 228, 226, 0.28) 4px 5px),
    var(--c);
}

.swatch span {
  flex: 1;
  min-width: 0;
}

.swatch kbd {
  font-size: 10px;
  padding: 1px 4px 2px;
  opacity: 0.7;
}

.swatch:hover {
  background: var(--hull-3);
  color: var(--bone);
}

.swatch[aria-pressed="true"] {
  border-color: var(--brass);
  background: var(--hull-3);
  color: var(--bone);
}

/* Carimbos */

.stamp-grid {
  display: grid;
  gap: 12px;
}

.stamp-cat {
  display: grid;
  gap: 6px;
}

.stamps {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 5px;
}

.stamp-btn {
  aspect-ratio: 1;
  max-width: 100%;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid rgba(0, 0, 0, 0.3);
  border-radius: 5px;
  background: radial-gradient(circle at 40% 35%, #9aa56e, #7e8a57 75%);
  cursor: pointer;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}

.stamp-btn canvas {
  display: block;
  pointer-events: none;
}

.stamp-btn:hover {
  filter: brightness(1.08);
}

.stamp-btn[aria-pressed="true"] {
  outline: 2px solid var(--brass-2);
  outline-offset: 1px;
}

/* Controles */

.seg {
  display: flex;
  gap: 2px;
  padding: 2px;
  background: var(--hull-2);
  border: 1px solid var(--seam);
  border-radius: 6px;
}

.seg button {
  flex: 1 1 0;
  min-width: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 6px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--bone-2);
  font-size: 14px;
  cursor: pointer;
}

.seg button:hover {
  color: var(--bone);
}

.seg button[aria-pressed="true"] {
  background: var(--hull-3);
  color: var(--brass-2);
  box-shadow: inset 0 0 0 1px var(--seam-2);
}

.seg svg {
  width: 26px;
  height: 10px;
  flex: none;
}

.inks {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
}

.inks button {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  border: 1px solid transparent;
  border-radius: 5px;
  background: var(--hull-2);
  color: var(--bone-2);
  font-size: 13.5px;
  cursor: pointer;
  text-align: left;
}

.inks i {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--c);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.5), 0 0 0 3px rgba(255, 255, 255, 0.08);
  flex: none;
}

.inks button[aria-pressed="true"] {
  border-color: var(--brass);
  color: var(--bone);
  background: var(--hull-3);
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 18px;
  margin: 0;
  background: transparent;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 3px;
  border-radius: 2px;
  background: var(--seam-2);
}

input[type="range"]::-moz-range-track {
  height: 3px;
  border-radius: 2px;
  background: var(--seam-2);
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 15px;
  height: 15px;
  margin-top: -6px;
  border-radius: 50%;
  background: var(--brass);
  border: 2px solid var(--ground);
  box-shadow: 0 0 0 1px var(--brass);
}

input[type="range"]::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--brass);
  border: 2px solid var(--ground);
  box-shadow: 0 0 0 1px var(--brass);
}

input[type="range"]:focus-visible {
  outline-offset: 4px;
}

.check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 14.5px;
  color: var(--bone-2);
  cursor: pointer;
  line-height: 1.35;
}

.check[hidden] {
  display: none;
}

.check input {
  accent-color: var(--brass);
  width: 16px;
  height: 16px;
  margin: 1px 0 0;
  flex: none;
}

select,
textarea,
input[type="text"] {
  width: 100%;
  box-sizing: border-box;
  background: var(--hull-2);
  border: 1px solid var(--seam-2);
  border-radius: 6px;
  color: var(--bone);
  padding: 7px 9px;
  font-size: 14.5px;
}

textarea {
  resize: vertical;
  min-height: 56px;
  font-family: var(--font-ui);
}

select:hover,
textarea:hover,
input[type="text"]:hover {
  border-color: #56666a;
}

/* Seleção */

.selection {
  background: var(--hull-2);
  border-block: 1px solid var(--seam);
}

.sel-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}

.sel-coord {
  font: 12px var(--font-mono);
  color: var(--lichen);
  font-variant-numeric: tabular-nums;
}

/* Folha */

.sheet {
  display: block;
  margin-top: auto;
  border-top: 1px solid var(--seam);
  padding-block: 0;
  gap: 0;
}

.sheet summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-block: 14px;
  font-family: var(--font-display);
  font-size: 18px;
  color: var(--bone);
}

.sheet summary::-webkit-details-marker {
  display: none;
}

.sheet summary::after {
  content: "";
  width: 7px;
  height: 7px;
  border-right: 1.5px solid var(--lichen);
  border-bottom: 1.5px solid var(--lichen);
  transform: rotate(-135deg);
  margin-right: 4px;
}

.sheet[open] summary::after {
  transform: rotate(45deg);
  margin-top: -4px;
}

.sheet-body {
  display: grid;
  gap: 14px;
  padding-bottom: 20px;
}

.sheet-info {
  font: 12px var(--font-mono);
  color: var(--lichen);
  font-variant-numeric: tabular-nums;
}

/* ---------- Palco ---------- */

.stage {
  grid-area: stage;
  position: relative;
  overflow: hidden;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  background:
    linear-gradient(rgba(255, 255, 255, 0.022) 1px, transparent 1px) 0 0 / 40px 40px,
    linear-gradient(90deg, rgba(255, 255, 255, 0.022) 1px, transparent 1px) 0 0 / 40px 40px,
    radial-gradient(ellipse at 50% 40%, var(--desk-hi), var(--desk-lo) 80%);
  cursor: crosshair;
}

.stage[data-tool="select"] { cursor: default; }
.stage[data-tool="label"] { cursor: text; }
.stage[data-tool="pan"],
.stage.grab { cursor: grab; }
.stage.panning { cursor: grabbing; }

.view {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.brush-cursor {
  position: absolute;
  left: 0;
  top: 0;
  border-radius: 50%;
  border: 1px solid rgba(246, 241, 228, 0.92);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.55), inset 0 0 0 1px rgba(0, 0, 0, 0.3);
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 5;
}

.brush-cursor.erase {
  border-style: dashed;
  border-color: rgba(255, 210, 190, 0.95);
}

.overlay {
  position: absolute;
  z-index: 10;
}

.statusbar {
  left: 14px;
  bottom: 14px;
  display: flex;
  align-items: center;
  gap: 14px;
  max-width: calc(100% - 200px);
  padding: 7px 12px;
  background: rgba(15, 21, 24, 0.86);
  border: 1px solid var(--seam);
  border-radius: 6px;
  font: 12px var(--font-mono);
  color: var(--bone-2);
  font-variant-numeric: tabular-nums;
  backdrop-filter: blur(6px);
  white-space: nowrap;
  overflow: hidden;
}

.statusbar #stCoord {
  color: var(--bone);
  min-width: 15ch;
}

.statusbar #stBiome {
  color: var(--brass-2);
}

.statusbar #stHint {
  color: var(--lichen);
  font-family: var(--font-ui);
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.zoombar {
  right: 14px;
  bottom: 14px;
  display: flex;
  background: rgba(15, 21, 24, 0.86);
  border: 1px solid var(--seam);
  border-radius: 6px;
  overflow: hidden;
  backdrop-filter: blur(6px);
}

.zoombar button {
  height: 32px;
  min-width: 34px;
  border: 0;
  background: transparent;
  color: var(--bone-2);
  cursor: pointer;
  font: 500 16px var(--font-mono);
}

.zoombar button:hover {
  color: var(--bone);
  background: var(--hull-3);
}

.zoombar #zoomFit {
  font-size: 12px;
  min-width: 88px;
  border-inline: 1px solid var(--seam);
  font-variant-numeric: tabular-nums;
}

.note {
  top: 14px;
  left: 14px;
  width: min(360px, calc(100% - 28px));
  box-sizing: border-box;
  display: grid;
  gap: 10px;
  padding: 13px 15px 14px;
  background: rgba(21, 29, 32, 0.94);
  border: 1px solid var(--seam-2);
  border-radius: 7px;
  box-shadow: 0 14px 40px -12px rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(6px);
}

.note[hidden],
.busy[hidden] {
  display: none;
}

.note p {
  margin: 0;
  font-size: 14.5px;
  color: var(--bone-2);
}

.note strong {
  color: var(--bone);
  font-weight: 700;
}

.note em {
  font: normal 13px var(--font-mono);
  color: var(--brass-2);
}

.note-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.busy {
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  padding: 11px 18px;
  background: rgba(15, 21, 24, 0.92);
  border: 1px solid var(--seam-2);
  border-radius: 999px;
  font-family: var(--font-display);
  font-size: 18px;
  color: var(--bone);
  pointer-events: none;
}

/* ---------- Diálogos ---------- */

dialog {
  width: min(460px, calc(100vw - 32px));
  box-sizing: border-box;
  padding: 0;
  background: var(--hull);
  color: var(--bone);
  border: 1px solid var(--seam-2);
  border-radius: 9px;
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.65);
}

dialog::backdrop {
  background: rgba(5, 8, 9, 0.62);
}

dialog form {
  display: grid;
  gap: 18px;
  padding: 22px 22px 20px;
}

.dlg-head {
  display: grid;
  gap: 6px;
}

.dlg-head h2 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 26px;
  line-height: 1.1;
}

.dlg-head p {
  margin: 0;
  color: var(--lichen);
  font-size: 14.5px;
}

.seed-row {
  display: flex;
  gap: 6px;
}

.seed-row input {
  font-family: var(--font-mono);
  letter-spacing: 0.04em;
}

.choice {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(118px, 1fr));
  gap: 6px;
}

.choice label {
  position: relative;
  display: grid;
  gap: 2px;
  padding: 9px 10px;
  border: 1px solid var(--seam-2);
  border-radius: 6px;
  background: var(--hull-2);
  cursor: pointer;
  font-size: 14.5px;
  color: var(--bone);
}

.choice label small {
  color: var(--lichen);
  font-size: 12.5px;
  font-family: var(--font-mono);
}

.choice input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.choice label:has(input:checked) {
  border-color: var(--brass);
  background: var(--hull-3);
}

.choice .choice-full {
  grid-column: 1 / -1;
  background:
    radial-gradient(circle at 88% 50%, rgba(201, 162, 79, 0.16), transparent 55%),
    var(--hull-2);
}

.choice label:has(input:focus-visible) {
  outline: 2px solid var(--brass-2);
  outline-offset: 2px;
}

.fine {
  margin: 0;
  font-size: 13px;
  color: var(--lichen);
  line-height: 1.45;
}

.dlg-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding-top: 4px;
}

/* ---------- Aviso ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  transform: translate(-50%, 12px);
  max-width: calc(100vw - 32px);
  box-sizing: border-box;
  padding: 10px 16px;
  background: #0c1113;
  border: 1px solid var(--seam-2);
  border-radius: 7px;
  color: var(--bone);
  font-size: 14.5px;
  box-shadow: 0 16px 40px -12px rgba(0, 0, 0, 0.8);
  opacity: 0;
  pointer-events: none;
  z-index: 100;
  transition: opacity 0.18s, transform 0.18s;
}

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

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
  }
}

/* ---------- Telas menores ---------- */

@media (max-width: 1180px) {
  .brand-sub { display: none; }
  .actions .btn.ghost .lbl { display: none; }
  .actions .btn.ghost { width: 34px; padding: 0; }
}

@media (max-width: 820px) {
  :root {
    --top-h: 52px;
  }

  .app {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: var(--top-h) minmax(0, 1fr) auto minmax(0, 36%);
    grid-template-areas:
      "top"
      "stage"
      "rail"
      "panel";
  }

  .topbar {
    gap: 8px;
    padding-inline: 12px 10px;
  }

  .wordmark { font-size: 18px; }
  .brand-mark { width: 24px; height: 24px; }
  .save-state { display: none; }
  .sep { margin-inline: 2px; }
  .lang svg { display: none; }
  .lang button { min-width: 28px; padding: 0 4px; }
  .actions { overflow-x: auto; scrollbar-width: none; }
  .actions .btn.primary .lbl { display: none; }
  .actions .btn.primary { width: 36px; padding: 0; }

  .rail {
    flex-direction: row;
    justify-content: flex-start;
    overflow-x: auto;
    padding: 6px 12px;
    border-right: 0;
    border-top: 1px solid var(--seam);
    scrollbar-width: none;
  }

  .rail-sep {
    width: 1px;
    height: 26px;
    margin-inline: 4px;
  }

  .tool .tip { display: none; }

  .panel {
    border-right: 0;
    border-top: 1px solid var(--seam);
  }

  .tool-pane,
  .selection,
  .sheet {
    padding-inline: 16px;
  }

  .statusbar #stHint { display: none; }
  .statusbar { max-width: calc(100% - 170px); }
  .stamps { grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); }
}

@media (max-width: 420px) {
  .wordmark { display: none; }
}
