:root {
  color-scheme: dark;
  --bg: var(--theme-background);
  --surface: var(--theme-surface);
  --border: #ffffff13;
  --muted: var(--theme-muted);
  --mint: var(--theme-accent);
  --text: var(--theme-text);
}
* {
  box-sizing: border-box;
}
[hidden] {
  display: none !important;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font:
    14px/1.65 var(--font-sans);
}
a {
  color: inherit;
  text-decoration: none;
}
button,
input,
textarea,
select {
  font: inherit;
}
button {
  cursor: pointer;
}
h1 {
  font-size: 30px;
  letter-spacing: -0.6px;
  margin: 0;
}
h2 {
  font-size: 20px;
  margin: 28px 0 16px;
}
h3 {
  margin: 0;
  font-size: 19px;
}
small {
  color: var(--muted);
  font-size: 13px;
  font-weight: 400;
  margin-left: 8px;
}
p {
  color: var(--muted);
}
main {
  max-width: 1180px;
  margin: 32px auto;
  padding: 0 26px 70px;
}
.breadcrumb {
  display: flex;
  gap: 12px;
  font-size: 12px;
  color: #84968e;
  margin-bottom: 30px;
}
.title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 25px;
}
.primary,
.secondary,
.text-button {
  display: inline-block;
  padding: 10px 16px;
  border: 1px solid #ffffff22;
  border-radius: 5px;
  background: transparent;
  color: #c8d9d0;
  font-size: 12px;
  cursor: pointer;
}
.primary {
  background: var(--mint);
  border-color: var(--mint);
  color: #153b2b;
  font-weight: 600;
}
.secondary:hover {
  border-color: color-mix(in srgb, var(--theme-accent) 43.92%, transparent);
}
.text-button {
  border: 0;
  padding: 8px 0;
  color: var(--mint);
}
button:disabled {
  opacity: 0.5;
  cursor: wait;
}
.search,
input:not([type='file']),
textarea,
select {
  background: var(--theme-surface);
  border: 1px solid #ffffff20;
  border-radius: 5px;
  padding: 10px 12px;
  color: var(--text);
  min-width: 0;
}
.search {
  width: 100%;
  margin: 0 0 20px;
}
.community-list {
  display: flex;
  flex-direction: column;
  gap: 15px;
}
.community-card {
  display: grid;
  grid-template-columns: 76px 200px 1fr;
  gap: 24px;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 18px;
  transition: border-color 0.15s;
}
.community-card:hover {
  border-color: color-mix(in srgb, var(--theme-accent) 30.98%, transparent);
}
.card-banner {
  height: 110px;
  display: grid;
  place-items: center;
}
.card-banner svg {
  height: 100%;
  max-width: 100%;
}
.card-photo {
  width: 200px;
  height: 115px;
  object-fit: cover;
  border-radius: 5px;
}
.card-description {
  margin: 8px 0;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  font-size: 13px;
}
.card-meta {
  font-size: 12px;
  color: #82998b;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.crown {
  width: 17px;
  height: 17px;
  flex-shrink: 0;
  stroke: #deb552;
  stroke-width: 1.5;
  fill: none;
  vertical-align: middle;
}
.crown.leader {
  fill: #deb552;
}
.detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 44px;
}
.gallery > img {
  width: 100%;
  aspect-ratio: 16/9;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border);
}
#photo-thumbs {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  flex-wrap: wrap;
}
#photo-thumbs button {
  background: none;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 5px;
  overflow: hidden;
  width: 84px;
  height: 55px;
}
#photo-thumbs button.active {
  border-color: var(--mint);
}
#photo-thumbs img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.description {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.coordinate-card {
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: #ffffff02;
}
.coordinate-card p {
  font-family: var(--font-mono);
  font-size: 13px;
}
.large-banner {
  height: 230px;
  display: grid;
  place-items: center;
}
.large-banner svg {
  height: 100%;
  max-width: 100%;
  filter: drop-shadow(0 5px 10px #0005);
}
#discord-link a {
  display: block;
  color: var(--mint);
  margin: 16px 0;
}
.member {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.member > span {
  overflow-wrap: anywhere;
}
.member img,
.member-avatar {
  width: 30px;
  height: 30px;
  border-radius: 4px;
  object-fit: cover;
  background: #234032;
  display: grid;
  place-items: center;
  color: var(--mint);
}
.member-name {
  flex: 1;
  min-width: 70px;
}
.member-controls {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  width: 100%;
  padding-left: 40px;
}
.member-controls button {
  font-size: 10px;
  padding: 5px 8px;
}
.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.empty {
  padding: 30px 0;
  color: var(--muted);
}
#error,
#form-error {
  border: 1px solid #d0847540;
  background: #d084750a;
  padding: 13px;
  border-radius: 5px;
  color: #d49b8f;
}
dialog {
  width: min(820px, calc(100vw - 28px));
  max-height: 92svh;
  border: 1px solid #466252;
  border-radius: 10px;
  background: #101b1e;
  color: var(--text);
  padding: 26px;
  box-shadow: 0 30px 160px #0009;
}
dialog::backdrop {
  background: #020b0dce;
}
.dialog-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 22px;
}
.dialog-heading h2 {
  margin: 0;
}
.icon-button {
  border: 0;
  background: none;
  color: #a4bfb0;
  font-size: 27px;
  line-height: 1;
  cursor: pointer;
}
label {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 12px;
  color: #b7cbc0;
  margin-bottom: 18px;
}
label input,
label textarea,
label select {
  width: 100%;
}
textarea {
  resize: vertical;
}
.hint {
  font-size: 11px;
  color: #728e80;
  margin: 0 0 12px;
}
.form-columns {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 30px;
  margin-bottom: 22px;
}
.form-banner {
  height: 150px;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 10px;
}
.form-banner svg {
  height: 100%;
}
.photo-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 15px;
}
.photo-item {
  position: relative;
}
.photo-item img {
  width: 100%;
  height: 80px;
  object-fit: cover;
  border-radius: 5px;
}
.photo-item .photo-buttons {
  display: flex;
  justify-content: space-between;
  gap: 4px;
}
.photo-item button {
  font-size: 10px;
  border: 0;
  background: transparent;
  color: #9dc9b0;
  padding: 3px 0;
}
.photo-item button.remove {
  color: #c99d93;
}
.photo-item span {
  display: block;
  font-size: 10px;
  color: var(--mint);
}
fieldset {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 18px;
  margin: 0 0 22px;
}
legend {
  font-size: 12px;
  color: #a9c3b4;
  padding: 0 7px;
}
.coords-fields {
  display: grid;
  grid-template-columns: 1.5fr 1fr 1fr 1fr;
  gap: 12px;
}
.coords-fields label {
  margin-bottom: 10px;
}
.form-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  padding-top: 15px;
  border-top: 1px solid var(--border);
}
.banner-builder {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 30px;
}
.banner-builder .large-banner {
  height: 330px;
}
.banner-builder label {
  margin-bottom: 12px;
}
.banner-builder li {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 9px 0;
  font-size: 12px;
  flex-wrap: wrap;
}
.banner-builder ol {
  padding: 0;
}
.banner-builder li span {
  flex: 1;
  min-width: 110px;
}
.banner-builder li button {
  padding: 4px 8px;
  background: #23392e;
  border: 1px solid var(--border);
  color: #c1d4c7;
  border-radius: 3px;
}
.banner-builder li button:disabled {
  cursor: default;
}
.banner-builder .swatch {
  width: 12px;
  height: 12px;
  display: inline-block;
  border: 1px solid #ffffff30;
  flex: none;
  min-width: 0;
}
#toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  padding: 12px 18px;
  border: 1px solid #6f927c;
  background: #244032;
  color: #d3e6d9;
  border-radius: 5px;
  font-size: 12px;
  max-width: 90vw;
  z-index: 100;
}
#load-more,
#show-all-members {
  margin-top: 18px;
}
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--mint);
  outline-offset: 3px;
}
@media (max-width: 760px) {
  main {
    padding: 0 18px;
  }
  .community-card {
    grid-template-columns: 50px 1fr;
    gap: 12px;
    padding: 14px;
  }
  .card-photo {
    display: none;
  }
  .card-banner {
    height: 85px;
  }
  .community-card h3 {
    font-size: 17px;
  }
  .detail-grid {
    grid-template-columns: 1fr;
    gap: 24px;
  }
  .detail-grid aside {
    border-top: 1px solid var(--border);
    padding-top: 24px;
  }
  .title-row {
    align-items: flex-start;
    flex-wrap: wrap;
  }
  .large-banner {
    height: 170px;
  }
  .form-columns {
    grid-template-columns: 1fr;
  }
  .form-banner {
    height: 110px;
  }
  .coords-fields {
    grid-template-columns: 1fr 1fr;
  }
  .banner-builder {
    grid-template-columns: 90px 1fr;
    gap: 18px;
  }
  .banner-builder .large-banner {
    height: 180px;
  }
  dialog {
    padding: 20px;
  }
  .photo-grid {
    grid-template-columns: repeat(3, 1fr);
  }
  h1 {
    font-size: 27px;
  }
  .banner-builder li span {
    min-width: 80px;
  }
}

#community-markers {
  display: grid;
  gap: 12px;
}
.coordinate-card b {
  overflow-wrap: anywhere;
}
.marker-editor {
  border-bottom: 1px solid var(--border);
  padding-bottom: 16px;
  margin-bottom: 18px;
}
.marker-editor:last-child {
  border-bottom: 0;
}
.marker-editor button:disabled,
#add-marker:disabled {
  cursor: default;
}

.coordinate-card > small {
  display: block;
  margin: 0 0 5px;
  color: var(--muted);
}

/* Общины плиткой по одному шаблону: картинка, баннер, название, два ряда описания, владелец. */
.community-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 14px;
}
.community-card {
  grid-template-columns: 36px minmax(0, 1fr);
  grid-template-areas:
    'photo photo'
    'banner content';
  gap: 12px;
  align-items: start;
  padding: 12px;
  min-width: 0;
}
.community-card .card-photo {
  grid-area: photo;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  object-fit: cover;
}
.community-card .card-banner {
  grid-area: banner;
  width: 36px;
  height: 72px;
}
.community-card > div:last-child {
  grid-area: content;
  min-width: 0;
}
.community-card h3 {
  margin: 0 0 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.community-card .card-description {
  min-height: 2.8em;
  margin: 0 0 6px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}
.community-card .card-meta {
  flex-wrap: nowrap;
  overflow: hidden;
  white-space: nowrap;
}
.community-card .card-meta span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Метки общины: подписи X/Y/Z отдельно от чисел, строка портала в аду ниже. */
.coordinate-card > b {
  display: block;
  margin-bottom: 12px;
  font-size: 16px;
}
.coordinate-cells {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.coordinate-cell {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  min-width: 84px;
  padding: 7px 12px;
  border-radius: 8px;
  background: #ffffff0a;
}
.coordinate-cell small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}
.coordinate-cell b {
  font-size: 14px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.coordinate-cells.nether .coordinate-cell {
  background: #ef444414;
}
.coordinate-caption {
  min-width: 96px;
  color: var(--muted);
  font-size: 13px;
}
.coordinate-card > button {
  margin-top: 6px;
}
