:root {
  color-scheme: dark;
  --accent: #8db5d6;
  --accent-2: #8db5d6;
  --theme-glow: rgba(141, 181, 214, 0.18);
  --title-color: #f4f8fb;
  --bg: #0d1217;
  --panel: #121b22;
  --panel-2: #16212a;
  --panel-3: #1b2731;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.14);
  --text: #e8edf2;
  --muted: #9db0be;
  --gold: #c8a96a;
  --danger: #b55b5b;
  --success: #6fb48f;
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

html,
body,
#appRoot {
  min-height: 100%;
}

body.app-page {
  margin: 0;
  background:
    radial-gradient(circle at top, var(--theme-glow), transparent 36%),
    linear-gradient(180deg, #10171d 0%, var(--bg) 52%, #0a0e12 100%);
  color: var(--text);
  font-family: Inter, "Segoe UI", system-ui, sans-serif;
}

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

a {
  color: inherit;
  text-decoration: none;
}

.app-shell {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  padding-bottom: 8.5rem;
}

.app-topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) auto;
  gap: 1rem;
  align-items: center;
  padding: 0.85rem 1.1rem;
  border-bottom: 1px solid var(--line-strong);
  background:
    linear-gradient(180deg, rgba(8, 12, 16, 0.94), rgba(8, 12, 16, 0.88)),
    linear-gradient(90deg, rgba(255, 255, 255, 0.02), transparent);
  backdrop-filter: blur(18px);
}

.app-topbar-left {
  min-width: 0;
}

.app-brandline {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin-bottom: 0.35rem;
  color: var(--muted);
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.app-brand-mark {
  width: 0.65rem;
  height: 0.65rem;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 18px color-mix(in srgb, var(--accent) 55%, transparent);
}

.app-title-row {
  display: flex;
  align-items: baseline;
  gap: 0.85rem;
  min-width: 0;
}

.app-title {
  margin: 0;
  color: var(--title-color);
  font-size: clamp(1.35rem, 2vw, 2.2rem);
  line-height: 1.05;
}

.app-subtitle {
  margin: 0.4rem 0 0;
  color: var(--muted);
  max-width: 72rem;
  font-size: 0.93rem;
  line-height: 1.45;
}

.app-view-kicker {
  color: var(--gold);
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  white-space: nowrap;
}

.app-topbar-right {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.app-login-accent {
  color: var(--title-color);
  font-size: 0.74rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.app-chip,
.app-deadline,
.app-quiet-pill,
.app-stat {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  border-radius: 8px;
}

.app-chip {
  display: grid;
  gap: 0.15rem;
  padding: 0.6rem 0.8rem;
  min-width: 11rem;
}

.app-faction-preview {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.8rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.035);
}

.app-faction-swatch {
  width: 1.1rem;
  height: 1.1rem;
  border-radius: 50%;
  box-shadow: 0 0 18px rgba(255, 255, 255, 0.12);
  flex: 0 0 auto;
}

.app-chip-label,
.app-stat-label,
.app-micro-label {
  color: var(--muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.app-chip-value,
.app-stat-value {
  font-size: 0.96rem;
  font-weight: 700;
}

.app-deadline {
  padding: 0.65rem 0.85rem;
  min-width: 13.5rem;
}

.app-deadline strong {
  display: block;
  color: var(--title-color);
  font-size: 0.95rem;
}

.app-deadline span {
  display: block;
  margin-top: 0.25rem;
  color: var(--muted);
  font-size: 0.82rem;
}

.app-main {
  padding: 1.1rem;
}

.app-notice-stack {
  display: grid;
  gap: 0.65rem;
  margin-bottom: 1rem;
}

.app-alert {
  padding: 0.85rem 1rem;
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.035);
  box-shadow: var(--shadow);
}

.app-alert.error {
  border-left-color: var(--danger);
}

.app-alert.success {
  border-left-color: var(--success);
}

.app-command-grid,
.app-comms-grid,
.app-admin-grid {
  display: grid;
  gap: 1rem;
}

.app-command-grid {
  grid-template-columns: minmax(20rem, 1.2fr) minmax(19rem, 1fr) minmax(19rem, 1fr);
}

.app-comms-grid {
  grid-template-columns: 16rem minmax(17rem, 22rem) minmax(0, 1fr);
}

.app-admin-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.app-column {
  display: grid;
  gap: 1rem;
  align-content: start;
}

.app-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.035), rgba(255, 255, 255, 0.015)),
    linear-gradient(180deg, var(--panel-2), var(--panel));
  box-shadow: var(--shadow);
  overflow: hidden;
}

.app-panel-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.95rem 1rem 0.8rem;
  border-bottom: 1px solid var(--line);
}

.app-panel-header h2,
.app-panel-header h3,
.app-thread-heading,
.app-newspaper-title,
.app-map-stage-title {
  margin: 0.12rem 0 0;
  color: var(--title-color);
  line-height: 1.1;
}

.app-panel-header p {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.app-panel-body {
  padding: 1rem;
}

.app-panel-body.tight {
  padding: 0;
}

.app-map-frame {
  position: relative;
  width: 100%;
  min-height: 28rem;
  border: 0;
  display: block;
  background: #091015;
}

.app-map-frame iframe {
  width: 100%;
  min-height: 28rem;
  border: 0;
  display: block;
}

.app-map-frame.compact,
.app-map-frame.compact iframe {
  min-height: 22rem;
}

.app-selection-grid,
.app-summary-grid,
.app-stat-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.7rem;
}

.app-stat {
  padding: 0.8rem 0.85rem;
}

.app-list,
.app-activity-list,
.app-thread-list,
.app-conversation-list,
.app-turn-list {
  display: grid;
  gap: 0.7rem;
}

.app-list-item,
.app-activity-item,
.app-thread-item,
.app-conversation-item,
.app-turn-row {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.025);
}

.app-list-button,
.app-route-link,
.app-toolbar-button,
.app-drawer-button,
.app-action-button,
.app-thread-link {
  cursor: pointer;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  transition: background 120ms ease, border-color 120ms ease, transform 120ms ease;
}

.app-list-button:hover,
.app-route-link:hover,
.app-toolbar-button:hover,
.app-drawer-button:hover,
.app-action-button:hover,
.app-thread-link:hover {
  background: rgba(255, 255, 255, 0.065);
  border-color: var(--line-strong);
}

.app-list-button {
  width: 100%;
  padding: 0.8rem 0.85rem;
  text-align: left;
}

.app-list-button.tone-high {
  border-color: rgba(181, 91, 91, 0.45);
  background: rgba(181, 91, 91, 0.14);
}

.app-list-button.tone-medium {
  border-color: rgba(200, 169, 106, 0.4);
  background: rgba(200, 169, 106, 0.12);
}

.app-list-button.tone-low {
  border-color: rgba(141, 181, 214, 0.32);
  background: rgba(141, 181, 214, 0.08);
}

.app-list-button strong,
.app-thread-link strong,
.app-conversation-item h3 {
  display: block;
  margin-bottom: 0.25rem;
  color: var(--title-color);
}

.app-gm-faction-watch {
  padding: 0.85rem;
}

.app-gm-faction-watch summary {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0.35rem 0.65rem;
  align-items: center;
  cursor: pointer;
  list-style: none;
}

.app-gm-faction-watch summary::-webkit-details-marker {
  display: none;
}

.app-gm-faction-watch summary .app-turn-meta {
  grid-column: 2;
}

.app-gm-flag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin: 0.75rem 0;
}

.app-gm-flag {
  display: inline-flex;
  width: fit-content;
  max-width: 100%;
  padding: 0.24rem 0.48rem;
  border: 1px solid rgba(200, 169, 106, 0.42);
  border-radius: 999px;
  background: rgba(200, 169, 106, 0.11);
  color: var(--title-color);
  font-size: 0.74rem;
  line-height: 1.25;
}

.app-activity-list.compact {
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.app-gm-activity-row {
  display: grid;
  gap: 0.2rem;
  padding: 0.62rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.14);
}

.app-gm-unit-row strong {
  text-transform: capitalize;
}

.app-list-meta,
.app-item-meta,
.app-thread-meta,
.app-conversation-meta,
.app-newspaper-meta,
.app-turn-meta {
  color: var(--muted);
  font-size: 0.79rem;
  line-height: 1.35;
}

.app-list-note,
.app-empty,
.app-note,
.app-helper {
  color: var(--muted);
  line-height: 1.5;
}

.app-form {
  display: grid;
  gap: 0.85rem;
}

.app-form-row {
  display: grid;
  gap: 0.85rem;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.app-form label {
  display: grid;
  gap: 0.38rem;
}

.app-form input,
.app-form select,
.app-form textarea {
  width: 100%;
  padding: 0.78rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.22);
  color: var(--text);
  resize: vertical;
}

.app-form textarea {
  min-height: 7rem;
}

.app-primary,
.app-secondary,
.app-danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 2.6rem;
  padding: 0.7rem 1rem;
  border-radius: 8px;
  border: 1px solid transparent;
  font-weight: 700;
  cursor: pointer;
}

.app-primary {
  background: color-mix(in srgb, var(--accent) 25%, #131d25);
  color: var(--title-color);
  border-color: color-mix(in srgb, var(--accent) 42%, transparent);
}

.app-secondary {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  border-color: var(--line);
}

.app-danger {
  background: rgba(181, 91, 91, 0.18);
  color: #ffd8d8;
  border-color: rgba(181, 91, 91, 0.45);
}

.app-primary:disabled,
.app-secondary:disabled,
.app-danger:disabled {
  opacity: 0.55;
  cursor: wait;
}

.app-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
}

.app-inline-link {
  color: var(--accent);
}

.app-rail-nav {
  display: grid;
  gap: 0.55rem;
}

.app-mailbox-link,
.app-thread-link {
  display: block;
  width: 100%;
  padding: 0.8rem 0.85rem;
}

.app-mailbox-link.is-active,
.app-thread-link.is-active,
.app-route-link.is-active,
.app-drawer-button.is-active,
.app-list-button.is-active {
  border-color: color-mix(in srgb, var(--accent) 45%, transparent);
  background: color-mix(in srgb, var(--accent) 14%, rgba(255, 255, 255, 0.03));
}

.app-composer {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}

.app-conversation-item {
  padding: 0.8rem 0.9rem;
}

.app-conversation-item.outbound {
  border-color: color-mix(in srgb, var(--accent) 35%, transparent);
  background: color-mix(in srgb, var(--accent) 10%, rgba(255, 255, 255, 0.03));
}

.app-newspaper {
  display: grid;
  gap: 1rem;
}

.app-newspaper-shell {
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(15, 20, 24, 0.96), rgba(11, 16, 20, 0.95)),
    linear-gradient(180deg, #f0e7c6 0%, #d4c59a 100%);
  box-shadow: var(--shadow);
}

.app-newspaper-head {
  padding: 1.2rem 1.2rem 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  text-align: center;
}

.app-newspaper-head .app-view-kicker,
.app-newspaper-head .app-note {
  color: #d7c797;
}

.app-newspaper-title {
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2.1rem, 4vw, 4.2rem);
}

.app-newspaper-grid {
  display: grid;
  gap: 0;
  grid-template-columns: minmax(0, 1.45fr) minmax(20rem, 1fr);
}

.app-newspaper-lead,
.app-newspaper-side {
  padding: 1.15rem 1.2rem 1.3rem;
}

.app-newspaper-side {
  border-left: 1px solid var(--line);
  display: grid;
  gap: 1rem;
}

.app-newspaper-story h3,
.app-newspaper-lead h2 {
  margin: 0.3rem 0 0.5rem;
  color: var(--title-color);
  font-family: Georgia, "Times New Roman", serif;
}

.app-admin-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.app-map-shell {
  display: grid;
  gap: 1rem;
}

.app-full-map iframe {
  min-height: calc(100vh - 16.5rem);
}

.app-login-shell {
  display: grid;
  gap: 1.2rem;
  max-width: 80rem;
  margin: 0 auto;
}

.app-login-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: minmax(18rem, 25rem) minmax(0, 1fr);
}

.app-login-stats {
  display: grid;
  gap: 1rem;
  align-content: start;
}

.app-public-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr) minmax(0, 1.1fr);
}

.app-scoreboard-list,
.app-press-stack {
  display: grid;
  gap: 0.7rem;
}

.app-scoreboard-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.75rem;
  align-items: center;
  padding: 0.75rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255,255,255,.028);
}

.app-scoreboard-name,
.app-faction-card {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  min-width: 0;
}

.app-scoreboard-metrics {
  color: var(--muted);
  font-size: 0.84rem;
  text-align: right;
}

.app-faction-strip {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.7rem;
}

.app-faction-card {
  padding: 0.75rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255,255,255,.024);
}

.app-press-item {
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--line);
}

.app-press-item:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.app-shell-pip {
  position: fixed;
  top: 6.35rem;
  left: 1rem;
  z-index: 36;
  width: 5.25rem;
  border: 1px solid color-mix(in srgb, var(--accent) 45%, rgba(255,255,255,.16) 55%);
  border-radius: 10px;
  overflow: hidden;
  background: rgba(8, 12, 16, 0.88);
  box-shadow: 0 14px 28px rgba(0,0,0,.28);
  backdrop-filter: blur(10px);
}

.app-shell-pip img,
.app-shell-pip-fallback {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
}

.app-shell-pip-fallback {
  display: grid;
  place-items: center;
  padding: 0.45rem;
  color: var(--title-color);
  text-align: center;
  font-size: 0.72rem;
}

.app-shell-pip-label {
  padding: 0.35rem 0.45rem 0.42rem;
  color: var(--title-color);
  font-size: 0.66rem;
  line-height: 1.2;
  text-align: center;
}

.app-bottom {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 50;
  pointer-events: none;
}

.app-drawer {
  pointer-events: auto;
  margin: 0 1rem 0.7rem;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(13, 18, 23, 0.98), rgba(10, 14, 18, 0.98)),
    linear-gradient(90deg, rgba(255, 255, 255, 0.02), transparent);
  box-shadow: var(--shadow);
}

.app-drawer-header,
.app-drawer-body,
.app-bottom-bar {
  pointer-events: auto;
}

.app-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.8rem 1rem;
  border-bottom: 1px solid var(--line);
}

.app-drawer-body {
  display: grid;
  gap: 0.75rem;
  padding: 0.9rem 1rem 1rem;
}

.app-drawer-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
}

.app-route-link,
.app-toolbar-button,
.app-drawer-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.5rem;
  padding: 0.65rem 0.95rem;
  font-weight: 700;
}

.app-bottom-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin: 0 1rem 1rem;
  padding: 0.7rem 0.85rem;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: rgba(7, 10, 14, 0.96);
  box-shadow: var(--shadow);
}

.app-bottom-bar-left,
.app-bottom-bar-right {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-width: 0;
}

.app-bottom-status {
  color: var(--muted);
  font-size: 0.82rem;
  white-space: nowrap;
}

.app-muted {
  color: var(--muted);
}

.app-stack {
  display: grid;
  gap: 1rem;
}

.app-hidden {
  display: none !important;
}

@media (max-width: 1220px) {
  .app-command-grid,
  .app-admin-grid,
  .app-login-grid,
  .app-public-grid,
  .app-newspaper-grid {
    grid-template-columns: 1fr;
  }

  .app-comms-grid {
    grid-template-columns: 14rem minmax(0, 1fr);
  }

  .app-topbar {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 900px) {
  .app-main,
  .app-topbar {
    padding-left: 0.85rem;
    padding-right: 0.85rem;
  }

  .app-comms-grid {
    grid-template-columns: 1fr;
  }

  .app-selection-grid,
  .app-summary-grid,
  .app-stat-grid,
  .app-form-row {
    grid-template-columns: 1fr;
  }

  .app-map-frame,
  .app-map-frame iframe {
    min-height: 18rem;
  }

  .app-full-map iframe {
    min-height: calc(100vh - 18rem);
  }

  .app-bottom-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .app-bottom-bar-left,
  .app-bottom-bar-right,
  .app-drawer-row {
    flex-wrap: wrap;
  }

  .app-route-link,
  .app-toolbar-button,
  .app-drawer-button,
  .app-primary,
  .app-secondary,
  .app-danger {
    flex: 1 1 9rem;
  }
}

@media (max-width: 640px) {
  .app-shell {
    padding-bottom: 11rem;
  }

  .app-brandline {
    flex-wrap: wrap;
  }

  .app-title-row {
    flex-direction: column;
    align-items: start;
    gap: 0.35rem;
  }

  .app-topbar-right {
    justify-content: start;
  }

  .app-shell-pip {
    top: 5.8rem;
    left: 0.75rem;
    width: 4.2rem;
  }

  .app-chip,
  .app-deadline {
    width: 100%;
    min-width: 0;
  }

  .app-bottom-bar {
    margin-left: 0.7rem;
    margin-right: 0.7rem;
  }

  .app-drawer {
    margin-left: 0.7rem;
    margin-right: 0.7rem;
  }

}
