:root {
  --ink: #1b1420;
  --ink-2: #24182c;
  --surface: #2c2236;
  --line: #4d3d5c;
  --text: #f6eef4;
  --muted: #b5a3b8;
  --brand: #ff5c8a;
  --mint: #45e3c8;
  --gold: #ffc24a;
  --font: "Jersey 10", "Segoe UI", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  min-height: 100%;
  background: var(--ink);
  color: var(--text);
  font: calc(18px * 18 / 14)/1.4 var(--font);
  letter-spacing: 2px;
}

a {
  color: var(--mint);
}

.gate,
.app {
  min-height: 100vh;
}

.gate {
  display: grid;
  place-items: center;
  padding: 24px;
}

.card {
  width: min(420px, 100%);
  background: var(--ink-2);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 28px;
}

.card h1 {
  font-size: calc(32px * 18 / 14);
  margin-bottom: 8px;
}

.card p,
.hint {
  color: var(--muted);
  margin-bottom: 16px;
}

.field {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
  color: var(--muted);
}

.field input,
.field select,
.field textarea {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--ink);
  color: var(--text);
  padding: 10px 12px;
  font: inherit;
  letter-spacing: 2px;
}

.field textarea {
  min-height: 220px;
  resize: vertical;
  line-height: 1.35;
  font-size: calc(15px * 18 / 14);
}

.field textarea[readonly] {
  opacity: 0.92;
  color: var(--mint);
  cursor: default;
}

.btn {
  border: 0;
  border-radius: 10px;
  padding: 10px 16px;
  font: inherit;
  letter-spacing: 2px;
  cursor: pointer;
}

.btn--pink {
  background: var(--brand);
  color: var(--ink);
  width: 100%;
}

.btn--ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
}

.btn--danger {
  background: var(--brand);
  color: var(--ink);
}

.btn--danger:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.err {
  color: var(--brand);
  margin: 8px 0;
}

.qr {
  display: block;
  margin: 12px auto;
  border-radius: 8px;
  background: #fff;
}

.app {
  display: grid;
  grid-template-columns: 88px 1fr;
  min-height: 100vh;
}

.side {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 16px 8px;
  background: var(--ink-2);
  border-right: 1px solid var(--line);
}

.brand {
  font-size: calc(22px * 18 / 14);
  margin-bottom: 8px;
}

.brand b {
  color: var(--brand);
}

.side__nav {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  width: 100%;
  flex: 1;
}

.side__nav button,
.side__out {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  width: 100%;
  border: 0;
  border-radius: 12px;
  padding: 10px 4px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  letter-spacing: 2px;
  cursor: pointer;
}

.side__nav button i,
.side__out i {
  font-size: calc(18px * 18 / 14);
}

.side__nav button span,
.side__out span {
  font-size: calc(12px * 18 / 14);
}

.side__nav button.is-on {
  color: var(--ink);
  background: var(--mint);
}

.side__nav button:hover,
.side__out:hover {
  color: var(--text);
  background: var(--surface);
}

.side__foot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: 100%;
}

#who {
  font-size: calc(12px * 18 / 14);
  color: var(--muted);
  max-width: 72px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.main {
  min-width: 0;
  min-height: 100vh;
}

.panel {
  padding: 20px;
  overflow: auto;
  max-height: 100vh;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: calc(16px * 18 / 14);
}

th,
td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

th {
  color: var(--mint);
  font-weight: 400;
}

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

@media (max-width: 720px) {
  .grid {
    grid-template-columns: 1fr;
  }
}

.box {
  background: var(--ink-2);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
}

.box__sub {
  margin: 22px 0 8px;
  font-size: calc(18px * 18 / 14);
  color: var(--text);
}

.iso-guide {
  display: block;
  width: min(640px, 100%);
  height: auto;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}

.hidden {
  display: none !important;
}

.secret {
  font-size: calc(14px * 18 / 14);
  word-break: break-all;
  color: var(--gold);
}

.drawer {
  position: sticky;
  bottom: 0;
  margin-top: 16px;
}

.drawer .btn--pink {
  width: auto;
}

.row {
  display: flex;
  gap: 10px;
  align-items: center;
}

.check {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  margin-top: 22px;
}

.check input {
  width: auto;
}

.linkish {
  border: 0;
  background: transparent;
  color: var(--mint);
  font: inherit;
  cursor: pointer;
  text-decoration: none;
}

a.linkish:hover {
  text-decoration: underline;
}

.linkish--danger {
  color: var(--brand);
}

.row-actions {
  display: flex;
  gap: 12px;
  white-space: nowrap;
}

.modal-back {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 24px;
  background: #0b0710cc;
}

.modal-back .card {
  width: min(440px, 100%);
}

.modal-back .row {
  margin-top: 16px;
}

tr.is-on td {
  background: #45e3c814;
}

.live-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

.live-stats article {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px 18px;
  background: var(--ink-2);
}

.live-stats b {
  display: block;
  font-size: calc(36px * 18 / 14);
  line-height: 1;
  color: var(--mint);
  margin-bottom: 6px;
}

.live-stats span {
  color: var(--muted);
  font-size: calc(14px * 18 / 14);
}

.live-form {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: end;
}

.live-form .field {
  margin: 0;
  min-width: 160px;
}

.live-form .btn--pink {
  width: auto;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  height: 42px;
  padding: 0 14px 0 6px;
  border: 1px solid var(--line);
  border-radius: 99px;
  background: var(--ink);
  color: var(--muted);
  font: inherit;
  cursor: pointer;
}

.toggle__knob {
  width: 38px;
  height: 22px;
  border-radius: 99px;
  background: var(--line);
  position: relative;
  flex-shrink: 0;
}

.toggle__knob::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
}

.toggle.is-on {
  color: var(--mint);
  border-color: #45e3c866;
}

.toggle.is-on .toggle__knob {
  background: var(--mint);
}

.toggle.is-on .toggle__knob::after {
  left: 18px;
}

@media (max-width: 720px) {
  .live-stats {
    grid-template-columns: 1fr;
  }
}

.filters {
  display: grid;
  grid-template-columns: minmax(220px, 2fr) repeat(5, minmax(110px, 1fr));
  gap: 10px;
  align-items: end;
  margin-bottom: 8px;
}

.filters .field {
  margin-bottom: 0;
}

@media (max-width: 1100px) {
  .filters {
    grid-template-columns: 1fr 1fr;
  }
}

.suggest {
  position: relative;
}

.suggest__list {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% - 2px);
  z-index: 5;
  max-height: 240px;
  overflow: auto;
  margin: 0;
  padding: 6px;
  list-style: none;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--ink);
}

.suggest__list button {
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.suggest__list button:hover,
.suggest__list button.is-on {
  background: var(--surface);
}

.suggest__list em {
  color: var(--muted);
  font-style: normal;
  font-size: calc(13px * 18 / 14);
}

.mail-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  align-items: stretch;
  margin-bottom: 12px;
}

.mail-split .field {
  margin-bottom: 0;
}

.mail-split textarea {
  min-height: 62vh;
  font-size: 13px;
  letter-spacing: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.mail-preview-wrap {
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 6px;
  min-height: 62vh;
}

.mail-preview {
  width: 100%;
  min-height: 62vh;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}

@media (max-width: 980px) {
  .mail-split {
    grid-template-columns: 1fr;
  }
}

.mail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.mail-head h2 {
  margin: 0;
}

.mail-head .btn--ghost {
  width: auto;
}

.row .btn--pink {
  width: auto;
}

.mail-use {
  color: var(--mint);
  font-size: calc(13px * 18 / 14);
}

.mail-test {
  margin-top: 8px;
  flex-wrap: wrap;
}

.mail-test .field {
  margin: 0;
  min-width: 220px;
  flex: 1;
}

.mail-test .btn {
  width: auto;
  align-self: end;
  height: 42px;
}

/* —— City map editor —— */
.ced-back {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: var(--ink);
}

.ced-shell {
  display: grid;
  grid-template-rows: auto 1fr;
  height: 100%;
  min-height: 100vh;
}

.ced-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--ink-2);
}

.ced-bar__left,
.ced-bar__right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.ced-title {
  margin: 0;
  font-size: calc(22px * 18 / 14);
}

.ced-dirty {
  color: var(--gold);
  font-size: calc(13px * 18 / 14);
}

.ced-msg {
  margin: 0;
  max-width: 280px;
}

.ced-bar .btn {
  width: auto;
}

.ced-body {
  display: grid;
  grid-template-columns: 220px 1fr;
  min-height: 0;
  height: 100%;
}

.ced-palette {
  overflow: auto;
  padding: 12px;
  border-right: 1px solid var(--line);
  background: var(--ink-2);
}

.ced-palette h3 {
  margin: 12px 0 8px;
  font-size: calc(16px * 18 / 14);
  color: var(--muted);
}

.ced-palette h3:first-child {
  margin-top: 0;
}

.ced-swatches {
  display: grid;
  gap: 6px;
}

.ced-swatch {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--ink);
  color: var(--text);
  font: inherit;
  letter-spacing: 1px;
  text-align: left;
  cursor: pointer;
}

.ced-swatch:hover,
.ced-swatch.is-on {
  border-color: var(--brand);
  background: var(--surface);
}

.ced-swatch--sm {
  font-size: calc(14px * 18 / 14);
  padding: 6px 8px;
}

.ced-swatch__chip {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  flex-shrink: 0;
}

.ced-swatch__chip--grass,
.ced-swatch__chip--park {
  background: #4a9a3e;
}

.ced-swatch__chip--street,
.ced-swatch__chip--plaza,
.ced-swatch__chip--plot {
  background: #8a8490;
}

.ced-swatch__chip--water {
  background: #3a7ec8;
}

.ced-palette-note {
  margin-top: 14px;
  font-size: calc(12px * 18 / 14);
}

.ced-stage {
  position: relative;
  min-width: 0;
  min-height: 0;
  background: #120c18;
}

.ced-stage canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
  touch-action: none;
}

.ced-hint {
  position: absolute;
  left: 10px;
  bottom: 10px;
  margin: 0;
  padding: 6px 10px;
  border-radius: 8px;
  background: rgba(20, 14, 28, 0.75);
  color: var(--muted);
  font-size: calc(12px * 18 / 14);
  letter-spacing: 1px;
  pointer-events: none;
}

@media (max-width: 800px) {
  .ced-body {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }

  .ced-palette {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    max-height: 180px;
  }
}
