:root {
  --bg-top: #f9f4eb;
  --bg-bottom: #e4edf5;
  --card: #ffffff;
  --text: #1f2b35;
  --muted: #5f6f7d;
  --accent: #1b7f6b;
  --accent-2: #145546;
  --line: #d5dee7;
  --warn: #9c5a0f;
  --ok: #1f7a3d;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  color: var(--text);
  background: linear-gradient(160deg, var(--bg-top), var(--bg-bottom));
}

.shell {
  max-width: 980px;
  margin: 0 auto;
  padding: 24px 16px 40px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 20px;
}

.brand-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand h1 {
  margin: 0;
  font-size: 1.5rem;
}

.brand p {
  margin: 2px 0 0;
  color: var(--muted);
}

.page-title-inline {
  margin: 0 0 0 auto;
  text-align: right;
  white-space: nowrap;
  line-height: 1;
  font-size: clamp(1.4rem, 3.2vw, 2.2rem);
}

.logo {
  width: 44px;
  height: 44px;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 20px;
  box-shadow: 0 10px 24px rgba(30, 50, 80, 0.08);
}

.card h2 {
  margin-top: 0;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.section-head h2 {
  margin: 0;
}

.top-gap {
  margin-top: 14px;
}

label {
  display: block;
  margin-bottom: 6px;
  font-weight: 600;
}

input,
textarea {
  width: 100%;
  box-sizing: border-box;
  border-radius: 10px;
  border: 1px solid var(--line);
  padding: 10px 12px;
  font: inherit;
  color: inherit;
  background: #fff;
}

textarea[readonly] {
  background: #f8fafc;
}

input:focus,
textarea:focus {
  outline: 2px solid rgba(27, 127, 107, 0.2);
  border-color: var(--accent);
}

button {
  border: 0;
  border-radius: 10px;
  padding: 10px 14px;
  cursor: pointer;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
}

button:hover {
  background: var(--accent-2);
}

button:disabled,
button:disabled:hover {
  background: #d6dbe1;
  color: #5b6672;
  cursor: not-allowed;
}

.secondary {
  background: #eef3f7;
  color: var(--text);
  border: 1px solid var(--line);
}

.secondary:hover {
  background: #e2ebf2;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.field-with-action {
  display: grid;
  grid-template-columns: 3fr 1fr;
  gap: 8px;
}

.candidate-list,
.message-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.candidate-item {
  border-bottom: 1px solid var(--line);
  padding: 12px 4px;
}

.candidate-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.candidate-item details {
  border-top: 1px dashed var(--line);
  padding-top: 8px;
}

.candidate-item summary {
  cursor: pointer;
  color: var(--accent, #1f6feb);
  font-size: 0.9rem;
}

.message-item {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  margin-bottom: 10px;
}

.message-body {
  white-space: pre-wrap;
  word-break: break-word;
  background: #f8fbfd;
  border-radius: 6px;
  padding: 8px;
  margin-top: 8px;
  font-size: 0.85rem;
}

.venue-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: 1px solid var(--line);
}

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

.add-button {
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 700;
  color: #fff;
  background: var(--accent);
  padding: 7px 12px;
  line-height: 1;
}

.add-button:hover {
  background: var(--accent-2);
}

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

.venue-actions {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  text-decoration: none;
  color: inherit;
  padding: 12px 4px;
  flex: 1;
  min-width: 0;
}

.venue-actions:hover {
  background: #f8fbfd;
}

.line-left {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}

.line-main {
  font-weight: 700;
}

.line-sub {
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.line-sub.right {
  max-width: 260px;
}

.danger-button {
  border: 1px solid #e2b2b2;
  background: #fff2f2;
  color: #8a2222;
  border-radius: 10px;
  padding: 8px 10px;
  font-weight: 600;
  cursor: pointer;
}

.danger-button:hover {
  background: #ffe6e6;
}

.detail-grid {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  gap: 10px 14px;
  align-items: center;
}

.detail-grid textarea {
  resize: vertical;
}

.detail-grid pre {
  margin: 0;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #f8fafc;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.size-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.editable-checkbox {
  width: 24px;
  height: 24px;
  accent-color: var(--accent);
}

.action-row {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: space-between;
}

.primary-action {
  min-width: 160px;
  padding: 12px 18px;
  font-size: 1rem;
}

.active-toggle {
  display: inline-flex;
  align-items: center;
  margin: 0;
}

.map-frame {
  width: 100%;
  height: 260px;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.venue-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  align-items: stretch;
  margin-bottom: 12px;
}

.venue-fields {
  align-content: start;
}

.venue-map-col {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.venue-map-col .map-wrapper {
  flex: 1;
}

.venue-map-col .map-frame {
  height: 100%;
  min-height: 220px;
}

.address-label-cell {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.map-coordinates {
  margin: 0;
  font-size: 0.8rem;
  line-height: 1.2;
}

.criteria-row {
  display: flex;
  gap: 1.5rem;
  align-items: center;
}

.criteria-row > .criteria-list {
  flex: 1;
  min-width: 0;
  /* Cap to the map frame height (.map-frame) so a long list scrolls instead
     of stretching the row taller than the map column. */
  max-height: 260px;
  overflow-y: auto;
}

.criteria-row > .criteria-list ul {
  margin: 0;
}

.criteria-map {
  flex: 1;
  min-width: 0;
}

.map-wrapper {
  position: relative;
}

.map-pin {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -100%);
  font-size: 2rem;
  z-index: 1000;
  pointer-events: none;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.4));
}

.save-status {
  min-height: 20px;
  color: var(--muted);
}

.save-status.saved {
  color: var(--ok);
}

.save-status.error {
  color: #8a2222;
}

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

.form-field {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 4px 10px 8px;
  margin: 0;
}

.form-field legend {
  font-size: 0.8rem;
  color: var(--muted);
  padding: 0 4px;
}

.form-field input,
.form-field textarea {
  border: none;
  border-radius: 0;
  padding: 4px 0;
  width: 100%;
  outline: none;
}

.form-field input:focus,
.form-field textarea:focus {
  outline: none;
  border-color: transparent;
  box-shadow: none;
}

.form-field:focus-within {
  border-color: var(--accent);
}

.warn,
.alert {
  border-radius: 10px;
  padding: 8px 10px;
  border: 1px solid transparent;
}

.warn {
  background: #fff6e8;
  color: var(--warn);
  border-color: #f0d8b3;
}

.alert {
  background: #ffefef;
  border-color: #f3c4c4;
  color: #8a2222;
  margin-bottom: 12px;
}

.toast {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  margin-bottom: 0;
  max-width: 90%;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.18);
}

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

.hidden {
  display: none;
}

.spinner-overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.32);
  backdrop-filter: blur(1px);
  z-index: 2500;
}

.spinner-overlay.hidden {
  display: none;
}

.spinner-circle {
  width: 58px;
  height: 58px;
  border-radius: 999px;
  border: 6px solid rgba(27, 127, 107, 0.24);
  border-top-color: var(--accent);
  animation: vc-spin 0.85s linear infinite;
}

@keyframes vc-spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 700px) {
  .brand {
    flex-direction: column;
    align-items: flex-start;
  }

  .page-title-inline {
    margin-left: 0;
    text-align: left;
  }

  .detail-grid,
  .size-row,
  .form-row,
  .field-with-action,
  .venue-split {
    grid-template-columns: 1fr;
  }

  .venue-list-item {
    flex-direction: column;
    align-items: stretch;
  }

  .venue-actions {
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
  }

  .line-left {
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
  }
}
