
:root {
  color-scheme: dark;
  --bg: #0d141b; --panel: #131d26; --line: #24313d;
  --ink: #d6e0e8; --muted: #8497a6; --accent: #3ec8dc; --warn: #e8a24a; --good: #5cbb86;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", sans-serif;
}
header { padding: 1rem 1.1rem; border-bottom: 1px solid var(--line); }
.brand { color: var(--accent); text-decoration: none; font-weight: 650; letter-spacing: .02em; }
main { max-width: 46rem; margin: 0 auto; padding: 1.1rem 1.1rem 4rem; }
h1 { font-size: 1.35rem; margin: .2rem 0 1rem; }
h2 { font-size: 1rem; margin: 1.8rem 0 .5rem; }
p { margin: .5rem 0; }
.muted { color: var(--muted); font-size: .9rem; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: .9rem 1rem; margin: .8rem 0; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: .88rem; word-break: break-all; }
.copy { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; background: #0b1219; border: 1px solid var(--line); border-radius: 4px; padding: .55rem .7rem; margin: .4rem 0; }
.copy .mono { flex: 1 1 12rem; }
label { display: block; margin: .8rem 0 .25rem; font-size: .92rem; }
input[type=text], input[type=number], select { width: 100%; padding: .6rem .7rem; border-radius: 4px; border: 1px solid var(--line); background: #0b1219; color: var(--ink); font-size: 1rem; }
button, .btn { display: inline-block; padding: .6rem 1rem; border-radius: 4px; cursor: pointer; border: 1px solid var(--accent); background: var(--accent); color: #06222a; font-size: .95rem; font-weight: 600; text-decoration: none; }
button.secondary, .btn.secondary { background: transparent; color: var(--accent); }
button.danger, .btn.danger { background: transparent; border-color: var(--warn); color: var(--warn); }
.row { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; margin-top: .8rem; }
.status { display: inline-block; padding: .15rem .5rem; border-radius: 3px; font-size: .8rem; }
.status.ok { background: rgba(92,187,134,.15); color: var(--good); }
.status.wait { background: rgba(232,162,74,.15); color: var(--warn); }
.notice { border-left: 3px solid var(--accent); padding-left: .8rem; margin: 1rem 0; }
.notice.warn { border-left-color: var(--warn); }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: .45rem .5rem .45rem 0; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; }
ol.steps { padding-left: 1.2rem; }
ol.steps li { margin: .6rem 0; }

/* Zone preview. A 3x3 grid of 256px tiles (768px) cropped to the centre 640px;
   all constants, because style-src 'self' rules out inline styles. */
.mapwrap {
  position: relative;
  width: 100%;
  max-width: 640px;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 6px;
  margin-top: .6rem;
  background: var(--panel);
}
.map {
  position: absolute;
  top: -64px;
  left: -64px;
  width: 768px;
  height: 768px;
  display: grid;
  grid-template-columns: repeat(3, 256px);
  grid-template-rows: repeat(3, 256px);
  line-height: 0;
}
.map img,
.map .tile-blank { display: block; width: 256px; height: 256px; }
.map .tile-blank { background: var(--panel); }
.map-overlay { position: absolute; top: 0; left: 0; pointer-events: none; }
.zone-fill { fill: rgba(62, 200, 220, .18); stroke: #3ec8dc; stroke-width: 2; }
.zone-dot { fill: #3ec8dc; }
.attribution { margin-top: .35rem; font-size: .75rem; }
/* The tiles carry their own light imagery either way, so the preview keeps a
   light frame in dark mode rather than inverting the map. */

/* Zone centre picker. The whole block stays hidden until map.js marks it
   ready, so with scripting off the form falls back to the paste field alone
   rather than showing a dead box and an attribution for tiles nobody loaded. */
.picker-block { display: none; }
.picker-block.picker-ready { display: block; }
.picker {
  position: relative;
  width: 100%;
  height: 340px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  touch-action: none;          /* we handle the drag ourselves */
  cursor: grab;
  user-select: none;
}
.picker:active { cursor: grabbing; }
.picker-tiles { position: absolute; inset: 0; }
.picker-tiles img {
  position: absolute;
  top: 0;
  left: 0;
  width: 256px;
  height: 256px;
  pointer-events: none;
}
/* The crosshair is fixed at the centre; the map moves under it. */
.picker-ring,
.picker::after {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
}
.picker-ring {
  border: 2px solid #3ec8dc;
  background: rgba(62, 200, 220, .18);
  border-radius: 50%;
}
.picker::after {
  content: '';
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #3ec8dc;
  box-shadow: 0 0 0 2px rgba(0, 0, 0, .45);
}
.picker-zoom { position: absolute; top: 8px; right: 8px; display: grid; gap: 4px; }
.picker-zoom button {
  width: 32px;
  height: 32px;
  padding: 0;
  font-size: 1.1rem;
  line-height: 1;
}

/* Radius: a number input that works on its own, with the slider inserted
   beside it by map.js when scripting is available. */
.radius-row { display: flex; align-items: center; gap: .75rem; margin: .3rem 0; }
#zradslider { flex: 1 1 auto; display: flex; }
#zradslider:empty { display: none; }
.radius-slider { width: 100%; accent-color: var(--accent); }
.radius-num { display: flex; align-items: center; gap: .35rem; flex: 0 0 auto; }
.radius-num input[type=number] {
  width: 6.5rem;
  margin: 0;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.zone-actions { display: flex; flex-direction: column; gap: .4rem; align-items: stretch; }
.zone-actions .btn { text-align: center; }

/* Navigation. Sign out is a form so it can be a POST; the button is styled to
   sit with the links rather than shouting. */
header { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem 1rem; }
header nav { display: flex; flex-wrap: wrap; align-items: center; gap: .25rem 1rem; margin-left: auto; }
header nav a, header nav .linkish {
  color: var(--muted);
  text-decoration: none;
  font-size: .95rem;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  font-family: inherit;
}
header nav a:hover, header nav .linkish:hover { color: var(--ink); text-decoration: underline; }
header nav form { display: inline; margin: 0; }
header nav .navlinks { display: flex; flex-wrap: wrap; align-items: center; gap: .25rem 1rem; }

/* The narrow-width menu. Off-screen rather than display:none so the control
   stays keyboard reachable; the label is what is actually visible. */
.navtoggle { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.navburger { display: none; }

@media (max-width: 34rem) {
  .navburger {
    display: inline-block;
    color: var(--muted);
    font-size: .95rem;
    cursor: pointer;
    padding: .2rem .4rem;
    border: 1px solid var(--line);
    border-radius: 4px;
  }
  .navtoggle:focus-visible + .navburger { outline: 2px solid var(--accent); outline-offset: 2px; }
  header nav { margin-left: auto; }
  header nav .navlinks { display: none; }
  .navtoggle:checked ~ .navlinks {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: .5rem;
    width: 100%;
    padding-top: .6rem;
  }
}

/* Unsaved changes. The note is server-rendered hidden and revealed by the
   guard script, so a browser with no JS shows no promise we cannot keep. */
.dirty-note {
  margin: .6rem 0 0;
  padding: .5rem .7rem;
  border-left: 3px solid var(--warn);
  background: var(--panel);
  color: var(--ink);
  font-size: .95rem;
}
form.is-dirty { scroll-margin-top: 1rem; }

/* Trustmaster's button, rebuilt natively. Their hosted version is a
   cross-origin iframe injected by a third-party script, which would need both
   script-src and frame-src exceptions on the anonymous sign-in page; this
   keeps the mark and the colour and stays a plain link to our own route. */
.tm-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: navy;
  border-radius: 2px;
  padding: 1px;
  text-decoration: none;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  color: #fff;
  line-height: 1;
}
.tm-btn:hover { color: #eee; text-decoration: none; }
.tm-btn img {
  background: #fff;
  border-radius: 1px 0 0 1px;
  height: 24px;
  width: 24px;
  padding: 2px;
  display: block;
}
.tm-btn span { padding-right: 5px; }
.roster-flag { color: var(--warn); font-weight: 600; }
