:root {
  color-scheme: dark;
  --bg: #101214;
  --panel: #181b1f;
  --panel-2: #20252b;
  --line: #39414a;
  --text: #eef3f6;
  --muted: #9ba8b3;
  --accent: #68d4c8;
  --accent-2: #f2c14e;
  --warn: #ff6b6b;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  height: 100vh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
}

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

button,
.ghost-link {
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  min-height: 38px;
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
  text-decoration: none;
}

button:hover,
.ghost-link:hover {
  border-color: var(--accent);
}

button.primary-action {
  border-color: rgba(104, 212, 200, 0.72);
  background: rgba(104, 212, 200, 0.16);
}

button.gated-action {
  border-style: dashed;
  border-color: rgba(155, 168, 179, 0.7);
  background: #14181c;
  color: var(--muted);
}

button.gated-action:hover {
  border-color: var(--accent-2);
  color: var(--text);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  background: #14171a;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 21px;
  font-weight: 700;
}

h2 {
  font-size: 15px;
  margin-bottom: 10px;
}

h3 {
  font-size: 13px;
  margin: 0 0 10px;
}

.topbar p,
#mapStatus,
.result {
  color: var(--muted);
  font-size: 13px;
}

.status-line {
  margin-top: 3px;
}

.status-line.signed-out,
.status-line.no-guild,
.status-line.pending {
  color: var(--accent-2);
}

.status-line.active,
.status-line.manager,
.status-line.owner {
  color: var(--accent);
}

.status-line.owner {
  font-weight: 700;
}

.top-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.guild-context,
.language-context {
  min-width: 220px;
  max-width: 320px;
}

.app-shell {
  min-height: 0;
  overflow: hidden;
}

.panel {
  border-bottom: 1px solid var(--line);
  padding: 12px 0 16px;
}

.panel:first-child {
  padding-top: 0;
}

.stack {
  display: grid;
  gap: 10px;
}

label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

input,
select,
textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #0f1113;
  color: var(--text);
  padding: 9px;
}

textarea {
  resize: vertical;
  min-height: 66px;
}

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

.map-workspace {
  min-width: 0;
  min-height: 0;
  height: 100%;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) minmax(118px, 28vh);
  background: #0d0f11;
}

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

.filters {
  display: flex;
  align-items: end;
  gap: 8px;
  flex-wrap: wrap;
}

.filters label {
  min-width: 130px;
}

.filters label:first-child {
  min-width: 220px;
}

.check-filter {
  align-items: center;
  grid-template-columns: auto 1fr;
  min-height: 38px;
  min-width: 0 !important;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #0f1113;
}

.check-filter input {
  width: auto;
}

.map-meta {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.source-link {
  color: var(--accent);
  font-size: 13px;
}

.segmented {
  display: flex;
  gap: 0;
}

.segmented button {
  border-radius: 0;
}

.segmented button:first-child {
  border-radius: 6px 0 0 6px;
}

.segmented button:last-child {
  border-radius: 0 6px 6px 0;
}

.segmented button.active {
  border-color: var(--accent);
  color: #061614;
  background: var(--accent);
}

#mapCanvas {
  width: 100%;
  height: 100%;
  min-height: 0;
  display: block;
  background: #15191c;
  cursor: grab;
  touch-action: none;
}

#mapCanvas.is-dragging {
  cursor: grabbing;
}

.bases-panel {
  border-top: 1px solid var(--line);
  background: var(--panel);
  padding: 12px;
  min-height: 0;
  max-height: none;
  overflow: auto;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.bases-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 10px;
}

.base-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  padding: 10px;
  display: grid;
  gap: 5px;
  text-align: left;
  cursor: pointer;
}

.base-item:hover,
.base-item.active {
  border-color: var(--accent);
}

.base-item.redacted {
  border-style: dashed;
  background: #16191d;
}

.base-summary {
  color: var(--accent-2);
  font-size: 13px;
}

.base-item strong,
.pin-label {
  color: var(--accent);
}

.meta {
  color: var(--muted);
  font-size: 13px;
}

.empty {
  color: var(--muted);
  padding: 12px;
  border: 1px dashed var(--line);
  border-radius: 8px;
}

.compact-list {
  display: grid;
  gap: 8px;
  margin: 10px 0;
}

.compact-row {
  display: grid;
  gap: 6px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #12161a;
}

.compact-row.pending {
  border-color: rgba(242, 193, 78, 0.72);
}

.compact-row.revoked,
.compact-row.rejected {
  opacity: 0.72;
}

.audit-row {
  background: #101417;
}

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

.row-actions button,
.row-actions select {
  min-height: 32px;
  padding: 5px 8px;
  font-size: 13px;
}

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

.error {
  color: var(--warn);
}

[hidden] {
  display: none !important;
}

.overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(3, 5, 7, 0.62);
}

.modal,
.drawer {
  z-index: 30;
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: 0 18px 56px rgba(0, 0, 0, 0.45);
}

.modal {
  position: fixed;
  top: 50%;
  left: 50%;
  width: min(420px, calc(100vw - 24px));
  max-height: calc(100vh - 32px);
  transform: translate(-50%, -50%);
  border-radius: 8px;
  padding: 16px;
  overflow: auto;
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: min(440px, calc(100vw - 12px));
  height: 100vh;
  padding: 16px;
  overflow: auto;
}

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

.surface-note {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
  margin-bottom: 12px;
}

.icon-button {
  width: 36px;
  min-height: 36px;
  padding: 0;
}

.modal .result {
  margin-top: 10px;
}

@media (max-width: 860px) {
  body {
    height: auto;
    min-height: 100vh;
    display: block;
    overflow: auto;
  }

  .app-shell {
    overflow: visible;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .top-actions,
  .guild-context,
  .language-context {
    width: 100%;
  }

  .guild-context select,
  .language-context select,
  .top-actions button {
    flex: 1 1 auto;
  }

  .toolbar,
  .panel-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .filters,
  .filters label {
    width: 100%;
  }

  .map-workspace {
    height: auto;
    min-height: calc(100vh - 164px);
    grid-template-rows: auto minmax(420px, 1fr) auto;
  }

  #mapCanvas {
    min-height: 420px;
  }

  .bases-panel {
    max-height: none;
  }
}
