:root {
  color-scheme: dark;
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic", sans-serif;
  background: #050711;
  color: #eef3ff;
  --muted: #9daec9;
  --rule: #3a485d;
  --border: #334156;
  --accent: #51eced;
  --mono: ui-monospace, "SF Mono", Menlo, monospace;
}
* { box-sizing: border-box; }
body { margin: 0; min-width: 280px; }
body[data-edition="space"] { --accent: #c3a8ff; }
body[data-edition="forest"] { --accent: #b6e78a; }
body[data-edition="crimson"] { --accent: #ff8698; }
button, input { font: inherit; }
button { cursor: pointer; }
button:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}
button, a { -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
.shell {
  width: min(calc(100% - 40px), 1550px);
  min-height: 100svh;
  margin-inline: auto;
  display: grid;
  grid-template-rows: auto 1fr;
}
.header {
  min-height: clamp(76px, 9.38svh, 96px);
  display: grid;
  grid-template-columns: minmax(150px, 1fr) minmax(250px, 644px) minmax(150px, 1fr);
  grid-template-areas: "brand url language";
  align-items: center;
  column-gap: clamp(16px, 2.5vw, 38px);
  padding-inline: clamp(18px, 2.3vw, 35px);
  border-bottom: 1px solid var(--rule);
}
.header h1 {
  grid-area: brand;
  display: flex;
  align-items: center;
  gap: clamp(12px, 1.53vw, 24px);
  margin: 0;
  font: 520 clamp(1.15rem, 1.90vw, 1.8rem)/1 "Avenir Next", system-ui, sans-serif;
  letter-spacing: .09em;
  white-space: nowrap;
}
.header h1 img { width: clamp(19px, 1.72vw, 26px); height: auto; }
.url-editor { grid-area: url; position: relative; min-width: 0; }
.url-field {
  display: flex;
  align-items: center;
  min-height: 50px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #090d17;
  transition: border-color 130ms, background-color 130ms;
}
.url-field:focus-within { border-color: var(--accent); background: #0c1220; }
.url-field:has(input[aria-invalid="true"]) { border-color: #e48b9a; }
.url-field label {
  flex: none;
  padding: 3px clamp(11px, 1.45vw, 22px);
  border-right: 1px solid var(--border);
  color: var(--muted);
  font-size: clamp(.75rem, 1.1vw, 1.02rem);
  white-space: nowrap;
}
.url-field input {
  min-width: 0;
  width: 100%;
  min-height: 46px;
  border: 0;
  border-radius: 0 9px 9px 0;
  outline: none;
  padding: 0 clamp(10px, 1.45vw, 22px);
  background: transparent;
  color: #f2f6ff;
  font: 400 clamp(.95rem, 1.43vw, 1.33rem)/1.3 var(--mono);
  caret-color: var(--accent);
  direction: ltr;
}
.feedback { margin: 0; padding-top: 5px; color: #ffc2c7; font-size: .8rem; }
.languages {
  grid-area: language;
  justify-self: end;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  min-width: clamp(89px, 9.6vw, 148px);
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #090d17;
}
.languages button {
  min-height: 43px;
  border: 0;
  padding: 0 9px;
  background: transparent;
  color: var(--muted);
  font: 500 clamp(.82rem, 1.13vw, 1.05rem)/1 var(--mono);
  letter-spacing: .035em;
  transition: color 130ms, background-color 130ms;
}
.languages button[aria-pressed="true"] { background: #2a303c; color: #f6f8ff; }
.languages button:hover { color: #fff; background: #242c3d; }
.languages button:focus-visible { outline-offset: -4px; }
main {
  min-height: 0;
  display: grid;
  grid-template-rows: minmax(230px, 1fr) auto auto;
}
.stage {
  min-height: 0;
  min-width: 0;
  position: relative;
  cursor: grab;
  touch-action: none;
}
.stage:active { cursor: grabbing; }
.stage canvas { display: block; position: absolute; inset: 0; width: 100%; height: 100%; }
.view-heading {
  min-height: clamp(119px, 17.1svh, 175px);
  padding: clamp(16px, 3.1svh, 32px) 12px 20px;
  display: flex;
  align-items: center;
  flex-direction: column;
  gap: clamp(7px, 1.4svh, 14px);
  text-align: center;
}
.view-heading h2 { font-size: clamp(1.6rem, 2.55vw, 2.4rem); line-height: 1.2; font-weight: 540; margin: 0; }
.view-heading p, .view-heading a { margin: 0; font-size: clamp(.86rem, 1.22vw, 1.15rem); color: var(--muted); }
.view-heading a { color: #dde7fa; text-underline-offset: 4px; }
.view-tools {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  column-gap: clamp(11px, 1.4vw, 20px);
}
.about-trigger {
  min-height: 36px;
  border: 0;
  border-radius: 4px;
  padding: 0 3px;
  background: transparent;
  color: #becce1;
  font-size: .87rem;
  text-decoration: underline;
  text-decoration-color: #71829f;
  text-underline-offset: 4px;
}
.about-trigger:hover { color: var(--accent); }

.qr-actions { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; column-gap: 15px; }
.qr-actions button {
  min-height: 36px;
  border: 0;
  border-radius: 4px;
  padding: 0 4px;
  background: transparent;
  color: var(--muted);
  font-size: .87rem;
}
.qr-actions button:hover, .qr-actions button[aria-pressed="true"] { color: var(--accent); }
.dock {
  min-height: clamp(84px, 12svh, 123px);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: clamp(16px, 2.85svh, 29px) clamp(0px, 1.3vw, 20px) max(15px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--rule);
}
.editions, .views { display: flex; align-items: stretch; gap: clamp(7px, 1.45vw, 22px); }
.editions button, .views button {
  min-height: 46px;
  border: 1px solid transparent;
  padding: 0 clamp(9px, 1.25vw, 19px);
  background: transparent;
  color: #e4ecfb;
  font-size: clamp(.85rem, 1.18vw, 1.125rem);
  font-weight: 460;
  white-space: nowrap;
  transition: background-color 140ms, border-color 140ms, color 140ms;
}
.editions button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(7px, 1.2vw, 17px);
  background: #090d17;
  border: 1px solid var(--border);
  border-radius: 8px;
}
.editions button::before {
  content: '';
  flex: none;
  width: clamp(8px, .93vw, 14px);
  height: clamp(8px, .93vw, 14px);
  border-radius: 50%;
  background: #41e5eb;
}
.editions [data-edition="space"]::before { background: #a17ef6; }
.editions [data-edition="forest"]::before { background: #9cdb73; }
.editions [data-edition="crimson"]::before { background: #f46778; }
.editions button[aria-pressed="true"] { border-color: var(--accent); background: #1b232c; color: #fff; }
.editions button:hover, .views button:hover { background: #141c2d; }
.views button { border-bottom: 2px solid transparent; }
.views button[aria-pressed="true"] { border-bottom-color: var(--accent); color: #fff; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.about-dialog {
  width: min(570px, calc(100% - 28px));
  max-height: calc(100dvh - 32px);
  margin: auto;
  overflow: auto;
  overscroll-behavior: contain;
  padding: clamp(19px, 4.2vw, 32px);
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #0c1220;
  color: #eef3ff;
  box-shadow: 0 24px 70px #0009;
}
.about-dialog::backdrop { background: #03060ac9; }
.about-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.about-heading h2 { margin: 0; font-size: clamp(1.35rem, 2.5vw, 1.6rem); font-weight: 590; }
.about-close {
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #151e30;
  color: #e0e9f8;
  font-size: .87rem;
  white-space: nowrap;
}
.about-close:hover { border-color: #8b9ebd; }
.about-dialog > p, .about-logic li { color: #c7d4ea; line-height: 1.65; }
.about-dialog > p { margin: 16px 0 20px; }
.about-logic { border-top: 1px solid var(--border); }
.about-logic summary {
  padding: 14px 2px 2px;
  border-radius: 3px;
  cursor: pointer;
  color: #eef3ff;
  font-weight: 550;
}
.about-logic summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.about-logic ol { margin: 13px 0 20px; padding-inline-start: 1.4rem; font-size: .93rem; }
.about-logic li + li { margin-top: 8px; }
.about-references h3 { margin: 0 0 6px; color: var(--muted); font-size: .86rem; font-weight: 550; }
.about-references ul { display: flex; flex-wrap: wrap; gap: 4px 18px; margin: 0; padding: 0; list-style: none; }
.about-references li + li { margin-top: 0; }
.about-references a { color: #d5e4f9; font-size: .86rem; text-underline-offset: 3px; }

@media (max-width: 880px) {
  .shell { width: calc(100% - 32px); }
  .header {
    padding: 13px 0 12px;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "brand language" "url url";
    row-gap: 10px;
  }
  .url-field, .url-field input { min-height: 42px; }
  .url-field input { font-size: 1rem; }
  .languages button { min-height: 40px; }
  .view-heading { min-height: 91px; padding-top: 5px; padding-bottom: 12px; }
}

@media (max-width: 1000px) {
  .dock { flex-direction: column; align-items: center; gap: 5px; padding: 9px 0 max(13px, env(safe-area-inset-bottom)); }
  .editions { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); width: min(100%, 615px); gap: 6px; }
  .editions button { min-width: 0; padding-inline: 6px; line-height: 1.22; white-space: normal; }
  .views { gap: 4px; }
  .views button { min-width: 47px; padding-inline: 9px; }
}

@media (max-width: 565px) {
  .editions { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (min-width: 881px) and (max-height: 650px) {
  .header { min-height: 70px; }
  .view-heading { min-height: 89px; padding-top: 8px; }
  .dock { min-height: 72px; }
}
