/* Text-input + "Начать" control for feeding custom text into the 3D graph. */
.semantic-input-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin: 8px 0 6px;
}

.semantic-text-input {
  flex: 1 1 auto;
  min-width: 0;
  padding: 7px 10px;
  font: inherit;
  font-size: 13px;
  color: #f4f4f4;
  background: rgba(20, 20, 24, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 6px;
  outline: none;
}

.semantic-text-input::placeholder {
  color: rgba(255, 255, 255, 0.4);
}

.semantic-text-input:focus {
  border-color: rgba(120, 180, 255, 0.7);
  box-shadow: 0 0 0 2px rgba(120, 180, 255, 0.2);
}

.cities-node-info {
  margin: 0 0 6px;
  padding: 6px 10px;
  font: 11px/1.35 "Martian Mono", ui-monospace, monospace;
  color: rgba(234, 243, 255, 0.92);
  background: rgba(20, 20, 24, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 6px;
  white-space: pre-wrap;
  word-break: break-word;
}

.cities-node-info[hidden] {
  display: none !important;
}

body.cities-graph-page.hide-info2 .cities-node-info {
  display: none !important;
}

.bot-action.is-primary {
  background: rgba(120, 180, 255, 0.22);
  border-color: rgba(120, 180, 255, 0.55);
  color: #eaf3ff;
}

.bot-action.is-primary:hover {
  background: rgba(120, 180, 255, 0.34);
}

.bot-action.is-busy {
  opacity: 0.6;
  pointer-events: none;
}

.semantic-motion-toggles {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
}

.semantic-motion-toggle {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 12px;
  line-height: 1.35;
  color: rgba(255, 255, 255, 0.82);
  cursor: pointer;
  user-select: none;
}

.semantic-motion-toggle input {
  margin-top: 2px;
  flex-shrink: 0;
  accent-color: rgba(120, 180, 255, 0.9);
}

/* Jamming Bot dashboard: status grid (cities graph) */
body.cities-graph-page .bot-status-panel {
  margin: 0 0 8px;
  padding: 0;
}

body.cities-graph-page .bot-status-grid {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
}

body.cities-graph-page .semantic-demo-row {
  display: flex !important;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

body.cities-graph-page .semantic-log-row #log_semantic {
  overflow-y: auto;
}

body.cities-graph-page .bot-link-chip.is-primary {
  opacity: 1;
  color: var(--bot-text);
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--bot-accent);
}

.cities-metric-bar {
  position: fixed;
  top: 25%;
  left: 50%;
  transform: translateX(-50%);
  z-index: 249;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 3px;
  max-width: min(720px, calc(100vw - 32px));
  pointer-events: auto;
  padding: 0;
}

.cities-metric-btn {
  flex: 1 1 auto;
  font-family: var(--mono, "Martian Mono", ui-monospace, monospace);
  font-size: 9px;
  padding: 5px 9px;
  border-radius: 3px;
  border: 0.5px solid var(--border2, rgba(255, 255, 255, 0.1));
  background: var(--bg2, #131316);
  color: var(--muted, rgba(221, 216, 204, 0.32));
  cursor: pointer;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  transition: color 0.1s, border-color 0.1s, background 0.1s;
}

.cities-metric-btn:hover {
  color: var(--text, #ddd8cc);
  border-color: var(--accent, rgba(255, 255, 255, 0.55));
}

.cities-metric-btn.is-on {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text, #ddd8cc);
  border-color: var(--accent, rgba(255, 255, 255, 0.55));
}

/* One-sentence gloss of the active metric, under the button row. */
.cities-metric-note {
  position: fixed;
  top: calc(25% + 30px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 249;
  margin: 0;
  max-width: min(46ch, calc(100vw - 32px));
  text-align: center;
  font-family: var(--mono, "Martian Mono", ui-monospace, monospace);
  font-size: 9px;
  line-height: 1.5;
  letter-spacing: 0.02em;
  color: var(--muted, rgba(221, 216, 204, 0.32));
  pointer-events: none;
  text-wrap: balance;
}

.cities-step-word {
  position: fixed;
  inset: 0;
  z-index: 2147483000;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  padding: 4vmin;
  font-size: 10vmin;
  font-weight: 400;
  font-style: italic;
  line-height: 1.1;
  letter-spacing: 0.3px;
  text-align: center;
  color: var(--bot-text, #ddd8cc);
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.7);
  font-family: "Instrument Serif", serif;
  word-break: break-word;
}

.cities-step-word[hidden] {
  display: none !important;
}

/* Granular-video chrome: warm dark tokens, ghost buttons, white knobs. */
html.cities-graph-page {
  --bg: #0b0b0d;
  --bg2: #131316;
  --bg3: #1a1a1f;
  --border: rgba(255, 255, 255, 0.055);
  --border2: rgba(255, 255, 255, 0.1);
  --text: #ddd8cc;
  --muted: rgba(221, 216, 204, 0.32);
  --accent: rgba(255, 255, 255, 0.55);
  --danger: #e84a4a;
  --mono: "Martian Mono", ui-monospace, monospace;
  --serif: "Instrument Serif", serif;
  --knob-track: rgba(255, 255, 255, 0.07);
  --knob-active: rgba(255, 255, 255, 0.55);
  --knob-needle: #ffffff;
  --bot-bg: #0b0b0d;
  --bot-surface: #131316;
  --bot-surface-strong: #1a1a1f;
  --bot-border: rgba(255, 255, 255, 0.055);
  --bot-border-strong: rgba(255, 255, 255, 0.1);
  --bot-text: #ddd8cc;
  --bot-muted: rgba(221, 216, 204, 0.32);
  --bot-accent: rgba(255, 255, 255, 0.55);
  --bot-accent-strong: rgba(255, 255, 255, 0.55);
  --bot-danger: #e84a4a;
  --bot-shadow: none;
}

body.cities-graph-page,
body.cities-graph-page table {
  background: #000000;
  color: var(--text);
  font-family: var(--mono);
  font-size: 10px;
}

body.cities-graph-page #debug,
body.cities-graph-page #login-overlay,
body.cities-graph-page #login-form {
  font-family: var(--mono);
}

body.cities-graph-page .bot-metric {
  padding: 2px 8px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.04em;
}

body.cities-graph-page .bot-metric-label {
  color: var(--muted);
  font-size: 8px;
  font-weight: 400;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

body.cities-graph-page .bot-metric-value {
  color: var(--text);
  font-size: 10px;
  font-weight: 500;
}

body.cities-graph-page .bot-action {
  font-family: var(--mono);
  background: transparent;
  color: var(--muted);
  border: 0.5px solid var(--border2);
  border-radius: 5px;
  padding: 7px 12px;
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  user-select: none;
  transition: color 0.13s, border-color 0.13s, background 0.13s;
}

body.cities-graph-page .bot-action:hover {
  color: var(--text);
  border-color: var(--accent);
  background: transparent;
}

body.cities-graph-page .bot-action.is-primary {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--accent);
  color: var(--text);
}

body.cities-graph-page .bot-action.is-primary:hover {
  background: rgba(255, 255, 255, 0.12);
}

body.cities-graph-page .semantic-text-input {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text);
  background: transparent;
  border: 0.5px solid transparent;
  border-radius: 0;
  cursor: default;
}

body.cities-graph-page .semantic-text-input::placeholder {
  color: var(--muted);
}

body.cities-graph-page .semantic-text-input:focus {
  border-color: transparent;
  box-shadow: none;
  outline: none;
}

body.cities-graph-page .semantic-demo-meta,
body.cities-graph-page .semantic-worker-row,
body.cities-graph-page #semantic-source-panel {
  font-family: var(--mono);
  color: var(--muted);
  font-size: 9px;
  letter-spacing: 0.05em;
}

body.cities-graph-page .semantic-motion-toggle {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.04em;
  color: var(--muted);
}

body.cities-graph-page .semantic-motion-toggle input {
  accent-color: var(--accent);
}

body.cities-graph-page .semantic-log-row #log_semantic {
  font-family: var(--mono);
  font-size: 9px;
  color: var(--muted);
}

body.cities-graph-page .semantic-force-panel {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text);
  background: var(--bg2);
  border: 0.5px solid var(--border);
  border-radius: 8px;
  box-shadow: none;
  backdrop-filter: none;
  padding: 14px 16px 16px;
}

body.cities-graph-page .semantic-force-head {
  font-weight: 400;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  font-size: 8px;
}

body.cities-graph-page .semantic-force-toggle {
  width: 26px;
  height: 26px;
  color: var(--muted);
  background: transparent;
  border: 0.5px solid var(--border2);
  border-radius: 5px;
}

body.cities-graph-page .semantic-force-toggle:hover {
  color: var(--text);
  border-color: var(--accent);
}

body.cities-graph-page .semantic-knob-grid {
  gap: 14px 12px;
  margin: 6px 0 12px;
}

body.cities-graph-page .semantic-force-panel .kw {
  gap: 4px;
}

body.cities-graph-page .semantic-force-panel .kl {
  font-size: 8px;
  letter-spacing: 0.06em;
  color: var(--muted);
  position: relative;
  cursor: help;
}

body.cities-graph-page .semantic-force-panel .kl.has-hint:hover,
body.cities-graph-page .semantic-force-panel .kl.has-hint:focus {
  color: var(--text);
}

body.cities-graph-page .semantic-force-panel .kl.has-hint::after {
  content: attr(data-hint);
  position: absolute;
  right: 50%;
  bottom: calc(100% + 8px);
  transform: translateX(50%);
  width: min(240px, 55vw);
  padding: 8px 10px;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 400;
  letter-spacing: 0.02em;
  line-height: 1.45;
  text-transform: none;
  text-align: left;
  color: var(--text);
  background: rgba(12, 12, 14, 0.96);
  border: 0.5px solid var(--border);
  border-radius: 4px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
  transition: opacity 0.12s ease;
  z-index: 40;
  white-space: normal;
}

body.cities-graph-page .semantic-force-panel .kl.has-hint:hover::after,
body.cities-graph-page .semantic-force-panel .kl.has-hint:focus::after {
  opacity: 1;
  visibility: visible;
}

body.cities-graph-page .semantic-force-panel .kv {
  font-size: 9px;
  font-weight: 500;
  color: var(--text);
  min-width: 40px;
}

body.cities-graph-page .semantic-force-actions {
  padding-top: 12px;
  border-top: 0.5px solid var(--border);
  margin-top: 4px;
}

body.cities-graph-page .semantic-zoom-minus {
  font-family: var(--mono);
  color: var(--muted);
  background: var(--bg2);
  border: 0.5px solid var(--border);
  border-radius: 5px;
}

/* info1–info4 — top-left blocks, toggled from the Timing panel. */
body.cities-graph-page.hide-info1 .bot-status-panel,
body.cities-graph-page.hide-info1 .semantic-worker-row,
body.cities-graph-page.hide-info2 .semantic-input-row,
body.cities-graph-page.hide-info3 .semantic-log-row,
body.cities-graph-page.hide-info4 .semantic-demo-row {
  display: none !important;
}

/* Static demo: socket metrics stay off even if an old localStorage flag re-enables info1. */
body.cities-graph-page:not(.cities-socket-on) .bot-status-panel,
body.cities-graph-page:not(.cities-socket-on) .semantic-worker-row {
  display: none !important;
}

/* PWA + iOS: dynamic viewport, safe areas, install chrome. Desktop layout stays. */
html.cities-graph-page {
  --gc-safe-top: env(safe-area-inset-top, 0px);
  --gc-safe-right: env(safe-area-inset-right, 0px);
  --gc-safe-bottom: env(safe-area-inset-bottom, 0px);
  --gc-safe-left: env(safe-area-inset-left, 0px);
  height: 100%;
  height: 100dvh;
  -webkit-text-size-adjust: 100%;
}

html.cities-graph-page,
html.cities-graph-page body {
  overscroll-behavior: none;
}

body.cities-graph-page {
  height: 100%;
  height: 100dvh;
  height: -webkit-fill-available;
  width: 100%;
}

body.cities-graph-page #debug {
  top: max(20px, var(--gc-safe-top));
  left: max(20px, var(--gc-safe-left));
  right: max(20px, var(--gc-safe-right));
}

body.cities-graph-page .semantic-log-row {
  left: max(24px, var(--gc-safe-left));
}

body.cities-graph-page .semantic-side-panels {
  right: max(20px, var(--gc-safe-right));
  bottom: max(56px, calc(12px + var(--gc-safe-bottom)));
  max-height: calc(100dvh - 80px - var(--gc-safe-top) - var(--gc-safe-bottom));
}

body.cities-graph-page .bot-action,
body.cities-graph-page .cities-metric-btn,
body.cities-graph-page .semantic-force-toggle,
body.cities-graph-page .pwa-install {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.pwa-install {
  position: fixed;
  top: max(12px, var(--gc-safe-top));
  right: max(12px, var(--gc-safe-right));
  z-index: 260;
  font-family: var(--mono, "Martian Mono", ui-monospace, monospace);
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted, rgba(221, 216, 204, 0.32));
  background: var(--bg2, #131316);
  border: 0.5px solid var(--border2, rgba(255, 255, 255, 0.1));
  border-radius: 5px;
  padding: 7px 12px;
  min-height: 32px;
  cursor: pointer;
}

.pwa-install:hover {
  color: var(--text, #ddd8cc);
  border-color: var(--accent, rgba(255, 255, 255, 0.55));
}

.pwa-ios-tip {
  position: fixed;
  top: max(52px, calc(var(--gc-safe-top) + 40px));
  right: max(12px, var(--gc-safe-right));
  z-index: 261;
  width: min(260px, calc(100vw - 24px));
  padding: 12px 14px;
  box-sizing: border-box;
  font-family: var(--mono, "Martian Mono", ui-monospace, monospace);
  font-size: 11px;
  line-height: 1.45;
  letter-spacing: 0.03em;
  color: var(--text, #ddd8cc);
  background: var(--bg2, #131316);
  border: 0.5px solid var(--border2, rgba(255, 255, 255, 0.1));
  border-radius: 8px;
}

.pwa-ios-tip p {
  margin: 0 0 10px;
}

.pwa-ios-tip strong {
  color: #fff;
  font-weight: 500;
}

html.cities-graph-page.is-standalone .pwa-install,
html.cities-graph-page.is-standalone .pwa-ios-tip {
  display: none !important;
}

/* iOS Safari zooms inputs under 16px; keep desktop size, bump on WebKit touch. */
@supports (-webkit-touch-callout: none) {
  body.cities-graph-page .semantic-text-input {
    font-size: 16px;
  }
}

/* Phone / small tablet: reflow chrome so it fits a notch + home indicator. */
@media screen and (max-width: 844px) {
  body.cities-graph-page #debug {
    top: calc(max(8px, var(--gc-safe-top)) + 108px);
    left: max(8px, var(--gc-safe-left));
    right: auto;
    width: min(100%, calc(100vw - 16px - var(--gc-safe-left) - var(--gc-safe-right)));
    max-width: 420px;
    box-sizing: border-box;
    pointer-events: none;
  }

  body.cities-graph-page #debug > * {
    pointer-events: auto;
  }

  body.cities-graph-page .bot-primary-panel {
    padding: 6px;
    max-width: min(100%, 420px);
  }

  body.cities-graph-page .bot-status-grid {
    gap: 2px 4px;
  }

  body.cities-graph-page .semantic-input-row {
    flex-wrap: wrap;
    margin: 6px 0 4px;
    gap: 6px;
  }

  body.cities-graph-page .semantic-text-input {
    flex: 1 1 100%;
    min-height: 40px;
    box-sizing: border-box;
  }

  body.cities-graph-page .bot-action {
    min-height: 40px;
    padding: 8px 12px;
  }

  body.cities-graph-page .semantic-demo-row {
    gap: 6px;
  }

  .cities-metric-bar {
    top: max(8px, var(--gc-safe-top));
    left: max(8px, var(--gc-safe-left));
    right: max(104px, calc(92px + var(--gc-safe-right)));
    transform: none;
    justify-content: flex-start;
    max-width: none;
    width: auto;
    gap: 4px;
    padding: 0;
  }

  /* Installed: no Install button, so the metric row reclaims the right edge. */
  html.is-standalone .cities-metric-bar,
  html.is-standalone .cities-metric-note {
    right: max(8px, var(--gc-safe-right));
  }

  .cities-metric-btn {
    flex: 1 1 calc(25% - 4px);
    min-width: 0;
    min-height: 32px;
    padding: 7px 6px;
    font-size: 8px;
  }

  .cities-metric-note {
    top: calc(max(8px, var(--gc-safe-top)) + 68px);
    left: max(8px, var(--gc-safe-left));
    right: max(104px, calc(92px + var(--gc-safe-right)));
    transform: none;
    max-width: none;
    width: auto;
    text-align: left;
    font-size: 8px;
    line-height: 1.35;
  }

  /* Panels own the bottom strip, so the log sits above them, not under them. */
  body.cities-graph-page .semantic-log-row {
    top: auto;
    bottom: calc(max(8px, var(--gc-safe-bottom)) + 124px);
    left: max(8px, var(--gc-safe-left));
    right: auto;
    width: min(220px, calc(60vw - 12px));
    max-width: 220px;
  }

  body.cities-graph-page .semantic-log-row #log_semantic {
    height: min(132px, 20dvh);
    padding: 8px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  body.cities-graph-page .semantic-side-panels {
    right: max(8px, var(--gc-safe-right));
    bottom: max(8px, var(--gc-safe-bottom));
    width: min(300px, calc(100vw - 16px - var(--gc-safe-left) - var(--gc-safe-right)));
    max-height: min(68dvh, calc(100dvh - 96px - var(--gc-safe-top) - var(--gc-safe-bottom)));
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
  }

  /* Without this the flex children shrink and clip their own tail instead of
     letting the stack scroll — the reset button becomes unreachable. */
  body.cities-graph-page .semantic-side-panels > .semantic-force-panel {
    flex: 0 0 auto;
  }

  body.cities-graph-page .semantic-force-panel {
    padding: 10px 12px 12px;
  }

  body.cities-graph-page .semantic-knob-grid {
    gap: 10px 8px;
  }

  .pwa-install {
    min-height: 36px;
    padding: 7px 10px;
    font-size: 9px;
  }
}

@media screen and (max-width: 844px) and (orientation: landscape) {
  body.cities-graph-page #debug {
    top: max(8px, var(--gc-safe-top));
    max-width: min(40vw, 330px);
    width: min(40vw, calc(100vw - 24px));
  }

  .cities-metric-bar {
    left: auto;
    right: max(104px, calc(92px + var(--gc-safe-right)));
    max-width: min(44vw, 400px);
    width: min(44vw, 400px);
  }

  .cities-metric-note {
    display: none;
  }

  body.cities-graph-page .semantic-log-row {
    bottom: max(8px, var(--gc-safe-bottom));
    width: min(180px, 36vw);
  }

  body.cities-graph-page .semantic-log-row #log_semantic {
    height: min(88px, 26dvh);
  }

  body.cities-graph-page .semantic-side-panels {
    max-height: min(78dvh, calc(100dvh - 16px - var(--gc-safe-top) - var(--gc-safe-bottom)));
    width: min(280px, 42vw);
  }
}

