:root {
  --ink: #162b43;
  --muted: #63768d;
  --line: #b7c6dc;
  --soft-line: #d9e3f0;
  --page: #eef3fb;
  --panel: #f7faff;
  --nav: #074293;
  --nav-dark: #04276b;
  --nav-light: #2f69b6;
  --red: #df2429;
  --tan: #c8945c;
  --ok: #2d7b45;
}

* {
  box-sizing: border-box;
}

html {
  font-size: 14px;
}

body {
  margin: 0;
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
  background:
    repeating-linear-gradient(0deg, rgba(255, 255, 255, .42), rgba(255, 255, 255, .42) 1px, transparent 1px, transparent 26px),
    #dfe7f3;
}

a {
  color: #0c4d98;
}

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

button {
  cursor: pointer;
}

textarea {
  resize: vertical;
}

.page-shell {
  width: min(100%, 1036px);
  margin: 0 auto;
  min-height: 100vh;
  background: #fff;
  border-left: 1px solid #c6d2e4;
  border-right: 1px solid #c6d2e4;
  box-shadow: 0 0 18px rgba(30, 58, 92, .18);
}

.masthead {
  display: grid;
  grid-template-columns: 278px 1fr;
  align-items: start;
  gap: 18px;
  min-height: 100px;
  padding: 8px 12px 9px;
  background: linear-gradient(#ffffff 0%, #f7f9fc 72%, #e3eaf5 100%);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: block;
  width: 244px;
  max-width: 100%;
}

.brand img {
  display: block;
  width: 100%;
  height: auto;
}

.login-strip {
  display: block;
  min-height: 100px;
  color: #4f637a;
}

.auth-page {
  display: grid;
  grid-template-columns: 178px minmax(120px, 1fr) minmax(120px, 1fr);
  gap: 8px 10px;
  align-items: end;
  padding-top: 4px;
}

.auth-links {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.auth-links .text-button {
  min-height: 24px;
  padding: 2px 6px;
}

.auth-page .login-title {
  align-self: center;
  grid-column: 1 / -1;
}

.auth-page .panel-note {
  grid-column: 1 / -1;
}

.login-title {
  align-self: center;
  min-width: 0;
  padding-left: 14px;
  color: #8b99aa;
  font-size: 1.38rem;
  border-left: 2px dotted #b7c2d1;
  overflow-wrap: anywhere;
}

.field,
.form-grid label,
.inline-field {
  display: grid;
  gap: 4px;
  font-weight: 700;
  font-size: .86rem;
  color: #2c4058;
}

input,
select,
textarea {
  min-height: 25px;
  border: 1px solid #b8c6d8;
  background: #fff;
  box-shadow: inset 1px 1px 2px rgba(30, 50, 70, .1);
}

input,
select {
  padding: 2px 4px;
}

textarea {
  min-height: 74px;
  padding: 5px;
}

.login-button,
.primary-button,
.home-promo button,
.composer button,
.invite-box button,
.secondary-action {
  min-height: 27px;
  border: 1px solid #092c6c;
  color: #fff;
  font-weight: 700;
  background: linear-gradient(#386fb7, #0b428d 48%, #062a71);
}

.secondary-button,
.small-button,
.text-button {
  min-height: 27px;
  border: 1px solid #aebed4;
  color: #24456d;
  font-weight: 700;
  background: linear-gradient(#fff, #e4edf8);
}

.danger-button {
  border-color: #9c2d2d;
  color: #7c1f1f;
  background: linear-gradient(#fff, #f5dddd);
}

.auth-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
  align-items: center;
}

.admin-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 7px;
  color: #7a211d;
  font-size: .78rem;
  font-weight: 700;
  background: #f8e1de;
  border: 1px solid #d8a39d;
  border-radius: 2px;
}

.remember {
  grid-column: 2 / span 2;
  display: flex;
  align-items: center;
  gap: 6px;
  color: #7e8da1;
  font-size: .84rem;
}

.remember input {
  min-height: auto;
  box-shadow: none;
}

.forgot,
.logout-button {
  align-self: center;
  color: #62748b;
  font-size: .84rem;
}

.logout-button {
  justify-self: start;
  padding: 2px 9px;
}

.main-nav {
  display: flex;
  align-items: stretch;
  flex-wrap: wrap;
  gap: 0;
  min-height: 37px;
  padding-left: 4px;
  background: #0a3a86;
  border-top: 1px solid #356eb8;
  border-bottom: 4px solid #001b5d;
}

.nav-item {
  display: grid;
  grid-template-rows: 17px auto;
  justify-items: center;
  align-items: center;
  min-width: 70px;
  min-height: 37px;
  padding: 2px 5px;
  color: #fff;
  font-size: .72rem;
  font-weight: 700;
  line-height: 1.1;
  text-align: center;
  border: 0;
  border-left: 1px solid #2b65b0;
  border-right: 1px solid #001b5d;
  background: linear-gradient(var(--nav-light), var(--nav) 48%, var(--nav-dark));
}

.nav-item:hover,
.nav-item.is-active {
  background: linear-gradient(#0a2f7b, #001b62);
}

.nav-icon {
  display: grid;
  place-items: center;
  width: 16px;
  height: 14px;
  color: #fff;
  font-size: .78rem;
  line-height: 1;
}

.nav-search {
  display: grid;
  grid-template-columns: minmax(94px, 1fr) 40px;
  gap: 4px;
  align-items: center;
  width: 156px;
  margin-left: auto;
  padding: 2px 6px;
  color: #fff;
  font-size: .72rem;
}

.nav-search label {
  display: grid;
  gap: 1px;
}

.nav-search input {
  width: 100%;
  min-height: 18px;
}

.nav-search button {
  align-self: end;
  height: 20px;
  color: #fff;
  border: 1px solid #00184e;
  background: #07347d;
}

main {
  padding: 0 8px 24px;
}

.status-area {
  display: grid;
  grid-template-columns: 1fr minmax(260px, .75fr) auto;
  gap: 12px;
  min-height: 91px;
  padding: 11px 0 9px;
  border-bottom: 1px solid #e2e8f2;
}

.status-copy,
.user-place {
  font-size: .84rem;
}

.status-copy p,
.user-place p {
  margin: 0 0 3px;
}

.quick-icons {
  display: grid;
  grid-template-columns: repeat(3, 55px);
  gap: 6px;
  align-content: start;
}

.quick-icons button {
  min-height: 54px;
  padding: 4px;
  color: #203a5d;
  font-size: .73rem;
  text-align: center;
  background: #fff;
  border: 1px solid #d2dbe8;
}

.quick-icons span {
  display: block;
  font-size: 1.2rem;
  line-height: 1.2;
}

.notice {
  margin: 8px 0 0;
  padding: 7px 9px;
  color: #173d1f;
  font-size: .88rem;
  background: #e7f4e9;
  border: 1px solid #9bc8a3;
}

.home-promo {
  display: grid;
  grid-template-columns: 250px minmax(220px, 1fr);
  gap: 24px;
  align-items: center;
  min-height: 238px;
  margin-top: 8px;
  padding: 15px 52px 17px;
  background: #edf2fa;
  border: 1px solid #d6e0ee;
}

.home-promo[hidden] {
  display: none;
}

.home-promo img {
  width: 100%;
  max-width: 250px;
  height: auto;
}

.home-promo h1 {
  margin: 0 0 12px;
  color: #29425e;
  font-size: 2rem;
  font-weight: 400;
  letter-spacing: 0;
}

.home-promo p {
  max-width: 360px;
  margin: 0 0 11px;
  color: #243c57;
  font-size: 1rem;
  line-height: 1.25;
}

.app-view {
  margin-top: 10px;
}

.dashboard {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 256px;
  gap: 10px;
}

.panel {
  margin-bottom: 10px;
  background: var(--panel);
  border: 1px solid #cbd7e7;
}

.panel h2 {
  margin: 0;
  padding: 4px 8px;
  color: #fff;
  font-size: .9rem;
  background: #002074;
  border-bottom: 1px solid #001452;
}

.panel-body {
  padding: 8px;
}

.panel-note {
  margin: 0;
  color: var(--muted);
  font-size: .86rem;
}

.composer {
  display: grid;
  gap: 5px;
  padding: 7px 8px;
  color: #657286;
  font-size: .82rem;
  background: #e8eef8;
  border-bottom: 1px solid #cedaea;
}

.composer-row {
  display: grid;
  grid-template-columns: 1fr 78px;
  gap: 6px;
}

.wall-list {
  background: #edf4fc;
}

.wall-entry {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  gap: 6px;
  min-height: 70px;
  padding: 7px 8px;
  border-bottom: 1px solid #d5dfed;
}

.wall-entry p {
  margin: 0 0 4px;
  overflow-wrap: anywhere;
  font-size: .83rem;
}

.wall-entry time,
.meta {
  color: #6b7d92;
  font-size: .78rem;
}

.entry-name {
  color: #233b5a;
  font-weight: 700;
}

.entry-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin: 5px 0;
}

.entry-actions button,
.relation-actions button,
.inline-form button {
  min-height: 23px;
  padding: 1px 7px;
  font-size: .78rem;
}

.comments {
  display: grid;
  gap: 4px;
  margin-top: 5px;
  padding-left: 8px;
  border-left: 2px solid #d4deed;
}

.comment {
  margin: 0;
  color: #304963;
  font-size: .8rem;
}

.inline-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 5px;
  margin-top: 6px;
}

.avatar,
.portrait,
.tiny-face,
.photo-tile {
  border: 1px solid #8da5c4;
  background:
    linear-gradient(135deg, rgba(255,255,255,.45), transparent 45%),
    #8cb2dc;
}

.avatar {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  color: #fff;
  font-size: .74rem;
  font-weight: 700;
}

.avatar-blue {
  background-color: #82aed9;
}

.avatar-red {
  background-color: #c8848a;
}

.avatar-green {
  background-color: #89b58a;
}

.avatar-gold {
  background-color: #c6a45f;
}

.pending-panel h2 {
  background: var(--tan);
}

.profile-mini {
  display: grid;
  grid-template-columns: 66px 1fr;
  gap: 8px;
  padding: 8px;
  font-size: .84rem;
}

.profile-mini p {
  margin: 0 0 4px;
}

.portrait {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  color: #fff;
  font-size: 1.25rem;
  font-weight: 700;
  background:
    radial-gradient(circle at 50% 34%, rgba(255,255,255,.42) 0 15%, transparent 16%),
    linear-gradient(90deg, #4b6f9a, #a6bed9);
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  padding: 0 8px 8px;
}

.tabs button {
  min-height: 24px;
  padding: 2px 7px;
  color: #23466f;
  border: 1px solid #afc0d6;
  background: #fff;
  font-size: .78rem;
}

.tabs button.is-active {
  background: #e2ebf7;
  font-weight: 700;
}

.people-list,
.classified-list,
.topic-list,
.code-list,
.city-list,
.result-list {
  display: grid;
  gap: 7px;
  margin: 0;
  padding: 8px;
  list-style: none;
}

.person-row,
.classified-row,
.topic-row,
.code-row,
.city-row,
.result-row {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  min-height: 42px;
  padding: 7px;
  background: #fff;
  border: 1px solid #d3deec;
}

.classified-row,
.topic-row,
.code-row,
.city-row,
.result-row {
  grid-template-columns: minmax(0, 1fr) auto;
}

.person-row p,
.classified-row p,
.topic-row p,
.code-row p,
.city-row p,
.result-row p {
  margin: 0 0 3px;
  overflow-wrap: anywhere;
}

.relation-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 5px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding: 8px;
  background: #e8eef8;
  border-bottom: 1px solid #cedaea;
}

.form-grid .wide {
  grid-column: 1 / -1;
}

.form-grid .form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  grid-column: 1 / -1;
}

.message-layout {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 10px;
  padding: 8px;
}

.message-sidebar {
  display: grid;
  gap: 8px;
  align-content: start;
}

.thread {
  display: grid;
  gap: 6px;
  min-height: 230px;
  max-height: 430px;
  overflow: auto;
  padding: 8px;
  background: #fff;
  border: 1px solid #d3deec;
}

.message-bubble {
  max-width: 76%;
  padding: 6px 8px;
  color: #213a57;
  background: #e8f0fb;
  border: 1px solid #c8d7e9;
}

.message-bubble.mine {
  justify-self: end;
  background: #fff7dc;
  border-color: #e2c879;
}

.message-bubble p {
  margin: 0 0 4px;
  overflow-wrap: anywhere;
}

.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 8px;
  padding: 8px;
}

.photo-tile {
  display: grid;
  align-content: end;
  min-height: 110px;
  padding: 6px;
  color: #fff;
  font-weight: 700;
  background-size: cover;
  background-position: center;
  text-shadow: 0 1px 2px rgba(0, 0, 0, .45);
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  padding: 8px;
}

.stat {
  padding: 7px;
  background: #fff;
  border: 1px solid #d3deec;
}

.stat strong {
  display: block;
  color: #002074;
  font-size: 1.25rem;
}

.empty {
  margin: 0;
  padding: 8px;
  color: var(--muted);
  font-size: .86rem;
}

.apps-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(168px, 1fr));
  gap: 8px;
  padding: 8px;
}

.app-switcher {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 8px 0;
}

.app-switcher .small-button.is-active,
.palette-swatch.is-active {
  box-shadow: inset 0 0 0 2px #001b5d;
}

.mini-app-shell {
  padding: 8px;
}

.mini-app {
  display: grid;
  gap: 8px;
}

.mini-app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.bubble-board {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.bubble {
  aspect-ratio: 1;
  border: 1px solid #c6d2e4;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #ffffff 0 20%, #9dd4ff 21%, #5aa6e6 100%);
}

.bubble.is-popped {
  opacity: .2;
  transform: scale(.88);
}

.memory-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.memory-card {
  aspect-ratio: 1;
  border: 1px solid #c6d2e4;
  background: linear-gradient(#f8fbff, #d8e6f4);
  color: #002074;
  font-size: 1.6rem;
  font-weight: 700;
}

.memory-card.is-open {
  background: #fff7dc;
}

.pixel-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}

.pixel-cell {
  aspect-ratio: 1;
  border: 1px solid #c6d2e4;
}

.palette {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.palette-swatch {
  width: 26px;
  height: 26px;
  border: 1px solid #b7c6dc;
}

.app-card {
  display: grid;
  gap: 8px;
  padding: 10px;
  background: #fff;
  border: 1px solid #d3deec;
}

.app-card h3 {
  margin: 0;
  color: #002074;
  font-size: .95rem;
}

.app-card p {
  margin: 0;
  color: #46607e;
  font-size: .84rem;
}

.app-card .small-button {
  justify-self: start;
}

.admin-console {
  display: grid;
  gap: 8px;
  padding: 8px;
}

.admin-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 6px;
}

.admin-stat {
  padding: 8px;
  background: #fff;
  border: 1px solid #d3deec;
}

.admin-stat strong {
  display: block;
  color: #002074;
  font-size: 1.2rem;
}

.search-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.city-meter {
  width: 140px;
  height: 10px;
  overflow: hidden;
  background: #e2eaf5;
  border: 1px solid #b9c7d9;
}

.city-meter span {
  display: block;
  height: 100%;
  background: #386fb7;
}

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

  .auth-page {
    grid-template-columns: 1fr 1fr;
  }

  .auth-page .login-title {
    grid-column: 1 / -1;
    border-left: 0;
    padding-left: 0;
  }

  .auth-actions,
  .auth-links {
    grid-column: auto;
  }

  .status-area,
  .dashboard,
  .message-layout {
    grid-template-columns: 1fr;
  }

  .quick-icons {
    grid-template-columns: repeat(3, minmax(55px, 1fr));
  }

  .home-promo {
    grid-template-columns: 1fr;
    padding: 14px 18px;
  }
}

@media (max-width: 580px) {
  html {
    font-size: 13px;
  }

  main {
    padding-left: 4px;
    padding-right: 4px;
  }

  .auth-page,
  .composer-row,
  .form-grid,
  .inline-form {
    grid-template-columns: 1fr;
  }

  .nav-item {
    flex: 1 1 92px;
    min-width: 92px;
  }

  .nav-search {
    width: 100%;
    margin-left: 0;
  }

  .person-row,
  .classified-row,
  .topic-row,
  .code-row,
  .city-row,
  .result-row {
    grid-template-columns: minmax(0, 1fr);
  }

  .relation-actions {
    justify-content: flex-start;
  }
}
