:root {
  color-scheme: light;
  --bg: #f5f7f8;
  --panel: #ffffff;
  --text: #20242a;
  --muted: #66707a;
  --line: #d9e0e5;
  --primary: #1f7a6f;
  --primary-dark: #155b53;
  --danger: #b33030;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
}

a {
  color: var(--primary-dark);
}

.map-link-icon {
  display: inline-flex;
  margin-left: 6px;
  text-decoration: none;
  vertical-align: -0.08em;
}

.cursor-toast {
  position: fixed;
  z-index: 1000;
  pointer-events: none;
  transform: translate(22px, -125%);
  border: 1px solid #bde7c9;
  border-radius: 6px;
  padding: 6px 10px;
  background: #f0fff4;
  color: #16803a;
  font-weight: 800;
  box-shadow: 0 10px 24px rgb(22 128 58 / 18%);
  white-space: nowrap;
}

.cursor-toast::after {
  content: "";
  position: absolute;
  left: -6px;
  top: 50%;
  width: 10px;
  height: 10px;
  border-left: 1px solid #bde7c9;
  border-bottom: 1px solid #bde7c9;
  background: #f0fff4;
  transform: translateY(-50%) rotate(45deg);
}

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 14px clamp(16px, 4vw, 40px);
  background: #ffffff;
  border-bottom: 1px solid var(--line);
}

.brand {
  color: var(--text);
  font-size: 18px;
  font-weight: 700;
  text-decoration: none;
}

nav {
  display: flex;
  gap: 16px;
}

.page {
  width: min(1120px, calc(100% - 32px));
  margin: 28px auto 56px;
}

.panel,
.party,
.guest-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px;
}

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

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

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.party > .toolbar {
  margin-bottom: 4px;
}

.party-title-row {
  align-items: flex-start;
  display: flex;
  gap: 12px;
  justify-content: space-between;
}

.party-title-row h2 {
  min-width: 0;
}

.planning-status {
  border-radius: 999px;
  display: inline-flex;
  flex: 0 0 auto;
  font-size: 13px;
  font-weight: 750;
  line-height: 1.2;
  padding: 5px 9px;
}

.planning-status-planning {
  background: #fff4d6;
  color: #8a5b00;
}

.planning-status-active {
  background: #e4f6ea;
  color: #1b7d3a;
}

h1,
h2,
h3 {
  line-height: 1.15;
  margin: 0 0 14px;
}

p {
  margin: 0 0 12px;
}

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

label {
  display: grid;
  gap: 6px;
  font-weight: 650;
}

input,
select,
textarea,
button,
.button {
  min-height: 40px;
  border-radius: 6px;
  font: inherit;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  padding: 8px 10px;
  background: #fff;
}

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

.editor-field {
  display: grid;
  gap: 8px;
  font-weight: 650;
}

.editor-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.icon-button {
  width: 42px;
  min-height: 40px;
  padding: 8px;
}

.editor-select {
  width: auto;
  min-width: 118px;
}

.color-picker,
.emoji-picker {
  position: relative;
}

.color-button {
  gap: 8px;
}

.color-swatch {
  width: 24px;
  height: 24px;
  border: 2px solid #fff;
  border-radius: 5px;
  box-shadow: 0 0 0 1px var(--line);
}

.color-palette {
  position: absolute;
  z-index: 20;
  top: calc(100% + 8px);
  left: 0;
  display: grid;
  grid-template-columns: repeat(6, 34px);
  gap: 8px;
  width: max-content;
  max-width: min(278px, calc(100vw - 32px));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fff;
  box-shadow: 0 16px 36px rgb(15 23 42 / 18%);
}

.color-choice {
  width: 34px;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0;
}

.color-choice.active {
  outline: 3px solid color-mix(in srgb, var(--primary) 30%, transparent);
  outline-offset: 2px;
}

.custom-color {
  grid-column: 1 / -1;
  display: flex;
  grid-template-columns: none;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 4px;
  font-size: 14px;
}

.custom-color input {
  width: 42px;
  min-height: 32px;
  padding: 0;
}

.emoji-palette {
  position: absolute;
  z-index: 20;
  top: calc(100% + 8px);
  right: 0;
  display: grid;
  grid-template-columns: repeat(6, 42px);
  gap: 6px;
  width: max-content;
  max-width: min(318px, calc(100vw - 32px));
  max-height: 260px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fff;
  box-shadow: 0 16px 36px rgb(15 23 42 / 18%);
}

.wysiwyg-editor {
  min-height: 160px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  background: #fff;
  font-weight: 400;
  line-height: 1.5;
}

.wysiwyg-editor:focus {
  outline: 2px solid color-mix(in srgb, var(--primary) 30%, transparent);
  outline-offset: 2px;
}

.rich-text {
  line-height: 1.55;
}

.party-description {
  margin: 0 0 18px;
}

.response-summary {
  display: grid;
  gap: 14px;
}

.response-summary > h3 {
  margin-bottom: 0;
}

.response-summary ul {
  margin: 0;
}

.response-section {
  display: grid;
  gap: 8px;
}

.response-section + .response-section {
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

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

.response-section-heading h4 {
  margin: 0;
  font-size: 17px;
}

.edit-text-link {
  margin-left: 4px;
  font-size: 14px;
  font-weight: 500;
}

.button.compact {
  min-height: 34px;
  padding: 5px 10px;
  font-size: 14px;
}

.empty-response {
  margin: 0;
  color: var(--muted);
  font-style: italic;
}

.redirect-countdown {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
}

.redirect-progress {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #dbeafe;
}

.redirect-progress span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: #2563eb;
  transition: width 100ms linear;
}

.rich-text p,
.rich-text ul,
.rich-text ol {
  margin: 0 0 10px;
}

.rich-text :last-child {
  margin-bottom: 0;
}

button,
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--primary);
  background: var(--primary);
  color: #fff;
  padding: 8px 14px;
  text-decoration: none;
  cursor: pointer;
  font-weight: 700;
}

.button.secondary,
button.secondary {
  background: #fff;
  color: var(--primary-dark);
}

.button.danger,
button.danger {
  border-color: var(--danger);
  background: var(--danger);
}

button:disabled,
.button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

form.inline {
  display: inline;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}

.party-general-form {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.full {
  grid-column: 1 / -1;
}

table {
  width: 100%;
  min-width: 680px;
  border-collapse: collapse;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.table-scroll {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.table-scroll table {
  margin-bottom: 2px;
}

th,
td {
  padding: 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  white-space: nowrap;
}

td {
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
}

tr:last-child td {
  border-bottom: 0;
}

.guest-table td {
  vertical-align: middle;
}

.guest-table input {
  min-width: 140px;
}

.gender-child-fields {
  align-items: end;
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(0, 1fr) auto;
}

.child-checkbox {
  align-items: center;
  display: flex;
  flex-direction: row;
  gap: 8px;
  min-height: 42px;
}

.child-checkbox input {
  height: 18px;
  margin: 0;
  width: 18px;
}

.table-heading {
  align-items: flex-end;
  display: flex;
  justify-content: space-between;
  gap: 16px;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.actions,
.action-normal,
.action-edit {
  align-items: center;
  display: flex;
  gap: 8px;
}

.icon-button,
.token-button {
  min-height: 34px;
  border-radius: 6px;
  padding: 6px 10px;
}

.icon-button {
  width: 36px;
  border-color: var(--line);
  background: #fff;
  color: var(--text);
  font-size: 18px;
  line-height: 1;
}

.icon-button.danger {
  border-color: #e1b5b5;
  background: #fff;
  color: var(--danger);
}

.token-button {
  width: 38px;
  border: 1px solid var(--line);
  background: #f8fafb;
  color: var(--primary-dark);
  font-size: 17px;
  font-weight: 700;
}

.token-button.copied {
  border-color: var(--primary);
  background: #eaf5f3;
}

.status-icon {
  align-items: center;
  display: inline-flex;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font-weight: 800;
}

.status-open {
  background: #e8f1ff;
  color: #1d5fbf;
}

.status-yes {
  background: #e4f6ea;
  color: #1b7d3a;
}

.status-no {
  background: #fae7e7;
  color: #b33030;
}

.status-maybe {
  background: #fff4d6;
  color: #9a6700;
}

.confirm-dialog {
  width: min(360px, calc(100% - 32px));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px;
}

.confirm-dialog::backdrop {
  background: rgb(32 36 42 / 45%);
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.modal-backdrop {
  align-items: center;
  background: rgb(32 36 42 / 45%);
  display: flex;
  inset: 0;
  justify-content: center;
  padding: 24px;
  position: fixed;
  z-index: 20;
}

.modal-panel {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  max-height: calc(100vh - 48px);
  overflow: auto;
  padding: 20px;
  width: min(560px, 100%);
}

.modal-panel.large {
  width: min(880px, 100%);
}

.modal-table-scroll {
  max-height: min(720px, calc(100vh - 190px));
  overflow: auto;
}

.category-list {
  display: grid;
  max-height: 336px;
  overflow: auto;
  gap: 6px;
  margin-bottom: 16px;
}

.category-list button {
  justify-content: space-between;
  border-color: var(--line);
  background: #fff;
  color: var(--text);
}

.category-list button.active {
  border-color: var(--primary);
  background: #dcefeb;
  color: var(--primary-dark);
  box-shadow: inset 4px 0 0 var(--primary);
}

.traffic-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
}

.dot-green {
  background: #1b9b4b;
}

.dot-yellow {
  background: #d6a800;
}

.dot-red {
  background: #c93232;
}

.accordion-list {
  display: grid;
  gap: 10px;
}

.accordion-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}

.accordion-heading {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  border: 0;
  border-radius: 0;
  background: #f8fafb;
  color: var(--text);
  text-align: left;
}

.accordion-heading:hover {
  background: #eef5f3;
}

.accordion-arrow {
  width: 18px;
  color: var(--primary-dark);
}

.evaluation-list {
  margin: 0;
  padding: 10px 18px 14px 42px;
}

.evaluation-list li + li {
  margin-top: 6px;
}

.message-status,
.delivery-status {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 13px;
  font-weight: 750;
}

.message-new {
  background: #e8f1ff;
  color: #1d5fbf;
}

.message-sent,
.delivery-sent {
  background: #e4f6ea;
  color: #1b7d3a;
}

.delivery-error {
  background: #fae7e7;
  color: #b33030;
  cursor: help;
}

.delivery-sending {
  background: #fff4d6;
  color: #9a6700;
}

.delivery-family {
  background: #fff4d6;
  color: #9a6700;
}

.delivery-copied {
  background: #e8f1ff;
  color: #1d5fbf;
}

.placeholder-buttons {
  justify-content: flex-start;
}

.message-recipient-table-scroll {
  max-height: min(52vh, 560px);
  margin: 14px 0;
}

.message-recipient-table .select-all-row {
  background: #f8fafb;
}

.message-recipient-table th:first-child,
.message-recipient-table td:first-child {
  width: 72px;
  text-align: center;
}

.message-recipient-table .recipient-checkbox {
  display: inline-block;
  width: 18px !important;
  height: 18px;
  min-height: 18px;
  margin: 0;
  padding: 0;
  vertical-align: middle;
}

.recipient-name {
  display: grid;
  font-weight: 700;
}

.recipient-name small {
  color: var(--muted);
  font-weight: 400;
}

.send-dialog-actions {
  margin-top: 12px;
}

.tool-layout {
  display: grid;
  grid-template-columns: minmax(180px, 240px) 1fr;
  gap: 18px;
}

.side-menu {
  align-self: start;
  display: grid;
  gap: 8px;
}

.side-menu button {
  justify-content: flex-start;
  border-color: var(--line);
  background: #fff;
  color: var(--text);
}

.side-menu button.active {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}

.notice {
  border-left: 4px solid var(--primary);
  background: #eaf5f3;
  padding: 12px 14px;
  margin-bottom: 16px;
}

.status-overlay {
  position: fixed;
  z-index: 1100;
  top: 16px;
  right: 16px;
  display: grid;
  gap: 10px;
  width: min(420px, calc(100vw - 32px));
  pointer-events: none;
}

.status-toast {
  display: grid;
  grid-template-columns: 1fr 32px;
  gap: 12px;
  align-items: center;
  min-height: 48px;
  border: 1px solid;
  border-radius: 8px;
  padding: 10px 8px 10px 14px;
  box-shadow: 0 12px 30px rgb(15 23 42 / 18%);
  font-weight: 700;
  pointer-events: auto;
}

.status-toast-success {
  border-color: #9fd8b0;
  background: #effbf2;
  color: #176b33;
}

.status-toast-error {
  border-color: #e4aaaa;
  background: #fff1f1;
  color: #a12626;
}

.status-toast-close {
  width: 32px;
  min-height: 32px;
  border: 0;
  border-radius: 6px;
  padding: 0;
  background: transparent;
  color: currentColor;
  font-size: 24px;
  font-weight: 400;
  line-height: 1;
}

.status-toast-close:hover {
  background: rgb(15 23 42 / 8%);
}

.status-toast-enter-active,
.status-toast-leave-active,
.status-toast-move {
  transition: transform 180ms ease, opacity 180ms ease;
}

.status-toast-enter-from,
.status-toast-leave-to {
  transform: translateX(24px);
  opacity: 0;
}

.error {
  border-left-color: var(--danger);
  background: #faeeee;
}

.choice-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.choice-row label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-weight: 600;
}

.choice-row input {
  width: auto;
}

@media (max-width: 720px) {
  body {
    font-size: 15px;
  }

  .top {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
    padding: 12px 14px;
  }

  nav {
    width: 100%;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 2px;
  }

  nav a {
    flex: 0 0 auto;
  }

  .page {
    width: min(100% - 20px, 1120px);
    margin: 16px auto 32px;
  }

  .panel,
  .party,
  .guest-card {
    padding: 14px;
  }

  .grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .stack {
    gap: 12px;
  }

  .toolbar {
    align-items: stretch;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 12px;
  }

  .toolbar > .button,
  .toolbar > button,
  .toolbar a.button {
    width: 100%;
  }

  h1 {
    font-size: 24px;
  }

  h2 {
    font-size: 20px;
  }

  h3 {
    font-size: 17px;
  }

  input,
  select,
  textarea,
  button,
  .button {
    min-height: 44px;
  }

  button,
  .button {
    padding: 9px 12px;
  }

  .form-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .party-general-form {
    grid-template-columns: 1fr;
  }

  .tool-layout {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .side-menu {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 4px;
    scroll-snap-type: x proximity;
  }

  .side-menu button {
    flex: 0 0 auto;
    min-width: max-content;
    scroll-snap-align: start;
  }

  .table-heading {
    align-items: stretch;
    flex-direction: column;
    gap: 8px;
  }

  .button-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    justify-content: stretch;
  }

  .button-row > * {
    width: 100%;
  }

  table {
    min-width: 620px;
    font-size: 14px;
  }

  th,
  td {
    padding: 8px;
  }

  td {
    max-width: 220px;
  }

  .guest-table {
    min-width: 760px;
  }

  .actions,
  .action-normal,
  .action-edit {
    gap: 6px;
  }

  .icon-button {
    width: 42px;
    min-width: 42px;
  }

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

  .choice-row label {
    min-height: 44px;
  }

  .modal-backdrop {
    align-items: flex-end;
    padding: 10px;
  }

  .modal-panel,
  .modal-panel.large {
    width: 100%;
    max-height: calc(100vh - 20px);
    padding: 14px;
  }

  .modal-table-scroll {
    max-height: min(520px, calc(100vh - 170px));
  }

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

  .dialog-actions > * {
    width: 100%;
  }

  .category-list {
    max-height: 308px;
  }
}

@media (max-width: 420px) {
  .button-row {
    grid-template-columns: 1fr;
  }

  .page {
    width: min(100% - 16px, 1120px);
  }

  .panel,
  .party,
  .guest-card {
    padding: 12px;
  }
}
