:root {
  color-scheme: light;
  --accent: #f44336;
  --accent-dark: #d32f2f;
  --nav: #b71c1c;
  --ink: #1c1c1c;
  --muted: #6b6b6b;
  --line: #e4e4e4;
  --page: #f3f3f3;
  --card: #ffffff;
  --input: #ffffff;
  --input-line: #cfcfcf;
  --soft: #eeeeee;
  --mine: #fde8ea;
  --mine-line: #f3c1c7;
  --green: #a5d6a7;
  --warn: #ffe0b2;
  --shadow: 0 10px 28px rgba(0, 0, 0, 0.12);
  font-family: "Segoe UI", Tahoma, sans-serif;
}
html.is-dark {
  color-scheme: dark;
  --ink: #ececec;
  --muted: #b5b5b5;
  --line: #4a4a4a;
  --page: #2a2a2a;
  --card: #3a3a3a;
  --input: #2f2f2f;
  --input-line: #5a5a5a;
  --soft: #333333;
  --mine: #4a3436;
  --mine-line: #6a4548;
  --warn: #5d4037;
  --shadow: 0 10px 28px rgba(0, 0, 0, 0.4);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; width: 100%; background: var(--page); color: var(--ink); }
button, input, textarea { font: inherit; }
button { cursor: pointer; }
button {
  transition: transform 0.12s ease, filter 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
}
button:hover:not(:disabled) {
  transform: translateY(-2px);
  filter: brightness(1.08);
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.16);
}
button:active:not(:disabled) {
  transform: translateY(2px) scale(0.98);
  filter: brightness(0.95);
  box-shadow: none;
}
button:disabled { cursor: not-allowed; }
h1, h2, p { margin: 0; }

.auth-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--accent);
}
.auth-card, .profile-card, .editor-card, .placeholder-card, .person-card {
  background: var(--card);
  border-radius: 16px;
  box-shadow: var(--shadow);
}
.auth-card {
  width: min(420px, 100%);
  padding: 24px;
  display: grid;
  gap: 16px;
}
.auth-card h1 { text-align: center; font-size: 24px; }
.auth-card .brand { margin: 0 0 4px; text-align: center; font-weight: 800; color: var(--accent-dark); }
.app-icon { width: 88px; height: 88px; display: block; margin: 0 auto 8px; border-radius: 20px; }
label { display: grid; gap: 10px; font-weight: 600; }
input, textarea, select {
  background: var(--input);
  color: var(--ink);
  border-color: var(--input-line);
}
input, textarea {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--input-line);
  border-radius: 8px;
  font-weight: 400;
}
.primary, .text-button, .top-actions button, .dialog-actions button, .tag-toolbar button, .mode-row button {
  border: 0;
  border-radius: 8px;
}
.primary {
  background: var(--accent);
  color: white;
  padding: 14px 16px;
  font-weight: 700;
}
.primary.is-busy { opacity: 0.7; cursor: wait; }
.save-button {
  background: #2e7d32;
  color: white;
  padding: 14px 16px;
  font-weight: 700;
  border: 0;
  border-radius: 8px;
}
.save-button:disabled {
  background: #bdbdbd;
  color: #616161;
  box-shadow: none;
  filter: none;
  transform: none;
}
.password-wrap { position: relative; display: block; }
.password-wrap input { padding-right: 48px; }
.password-wrap button {
  position: absolute;
  right: 4px;
  top: 50%;
  width: 40px;
  height: 40px;
  padding: 6px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #555;
  transform: translateY(-50%);
}
.password-wrap button:hover:not(:disabled) { transform: translateY(calc(-50% - 2px)); }
.password-wrap button:active:not(:disabled) { transform: translateY(calc(-50% + 2px)) scale(0.98); }
.text-button { background: transparent; color: var(--accent); padding: 8px; }
.banner { padding: 12px; border-radius: 10px; }
.banner.error { background: #ffcdd2; color: #4a1014; }
html.is-dark .banner.error { background: #5c3034; color: #ffcdd2; }
.banner.warn { background: var(--warn); }
.hint, small { color: var(--muted); font-weight: 400; line-height: 1.5; }

.app-screen { --top-bar-h: 64px; min-height: 100vh; width: 100%; }
.app-screen.is-compact { --top-bar-h: 46px; }
.side-nav, .bottom-nav { display: none; }
.stage { width: 100%; min-width: 0; }
.top-bar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: var(--top-bar-h);
  padding: 12px 16px;
  background: var(--accent);
  color: white;
  transition: min-height 0.2s ease, padding 0.2s ease;
}
.top-bar h1 { font-size: 20px; flex: 1; text-align: center; transition: font-size 0.2s ease; }
.app-screen.is-compact .top-bar { padding: 2px 12px; }
.app-screen.is-compact .top-bar h1 { font-size: 16px; }
.app-screen.is-compact .layout-label { font-size: 11px; min-width: 0; }
.app-screen.is-compact .top-actions button { padding: 4px 8px; }
.layout-label {
  font-size: 12px;
  opacity: 0.9;
  min-width: 96px;
}
.top-actions { display: flex; gap: 8px; }
.top-actions button {
  background: transparent;
  color: white;
  padding: 8px 10px;
  font-weight: 700;
}
.panel { padding: 20px; }
.stack { display: grid; gap: 24px; }
.profile-card, .person-card, .placeholder-card, .editor-card { padding: 20px; }
.profile-card, .person-card { padding-top: 58px; }
.preview-wrap, .person-card, #profile-editor { position: relative; }
.edit-bar {
  position: sticky;
  top: var(--top-bar-h);
  z-index: 8;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  transition: top 0.2s ease, padding 0.2s ease;
}
.app-screen.is-compact .edit-bar { top: var(--top-bar-h); padding: 4px 10px; }
#done-button {
  flex: 0 0 auto;
  border: 1px solid var(--input-line);
  background: var(--card);
  color: var(--ink);
  white-space: nowrap;
}
.corner-action {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 0;
  border-radius: 999px;
  background: var(--card);
  color: var(--ink);
  padding: 8px 12px;
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}
.corner-action .nav-count { margin-left: 0; }
.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}
.dot.on { background: #2e7d32; }
.dot.off { background: var(--accent); }
.avatar {
  width: 120px;
  height: 120px;
  margin: 0 auto 16px;
  border-radius: 50%;
  background: var(--soft);
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 42px;
  overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.person-name, .profile-card h2 { font-size: 28px; margin-top: 8px; }
.town-block { display: grid; gap: 10px; }
.town-block .group-title { font-weight: 700; margin: 0; }
.town-add { display: flex; gap: 8px; align-items: center; }
.town-add input { flex: 1; }
.town-chip { display: inline-flex; align-items: center; gap: 8px; }
.town-chip button { border: 0; background: transparent; padding: 0 2px; font: inherit; font-weight: 700; cursor: pointer; }
.section-label { margin: 18px 0 10px; font-size: 18px; }
.chips, .tag-results {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: flex-start;
  gap: 14px 12px;
  width: 100%;
}
.chips { align-items: center; }
.chip, .tag-results button {
  width: max-content;
  max-width: 100%;
  flex: 0 0 auto;
}
.tag-results > :nth-child(5n + 2) { margin-top: 12px; }
.tag-results > :nth-child(5n + 3) { margin-top: 4px; }
.tag-results > :nth-child(5n + 4) { margin-top: 16px; }
.tag-results > :nth-child(5n + 5) { margin-top: 7px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 0;
  border-radius: 16px;
  padding: 8px 12px;
  background: var(--green);
}
.tag-count {
  min-width: 1.4em;
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.12);
  color: inherit;
  font-size: 12px;
  font-weight: 800;
  text-align: center;
}
.tag-results button .tag-count { background: #f3e6e8; color: var(--accent); }
.chip.black .tag-count { background: rgba(255, 255, 255, 0.18); }
.chip.white .tag-count { background: #f3e6e8; color: var(--accent); }
.chip.black { background: #111; color: white; }
.chip.white { background: #fff; color: #111; box-shadow: inset 0 0 0 1px #9e9e9e; }
.bio-text { white-space: pre-wrap; line-height: 1.5; }
.edit-tabs { display: flex; gap: 8px; overflow-x: auto; margin: 0; flex: 1; min-width: 0; }
.edit-tabs button, #done-button, .side-nav button, .bottom-nav button {
  border: 0;
  background: var(--card);
  border-radius: 999px;
  padding: 10px 14px;
  font-weight: 700;
}
.edit-tabs button, #done-button { flex: 0 0 auto; white-space: nowrap; background: var(--page); transition: padding 0.2s ease, font-size 0.2s ease; }
#done-button { margin-left: auto; border: 1px solid var(--input-line); background: var(--card); }
.app-screen.is-compact .edit-tabs button,
.app-screen.is-compact #done-button { padding: 4px 10px; font-size: 13px; }
.edit-tabs button.is-active, .side-nav button.is-active, .bottom-nav button.is-active {
  background: var(--accent);
  color: white;
}
.editor-card { display: grid; gap: 22px; }
.editor-card > button { justify-self: start; }
.photo-row { display: flex; gap: 12px; flex-wrap: wrap; }
.photo-slot {
  position: relative;
  width: 100px;
  height: 130px;
  background: var(--soft);
  display: grid;
  place-items: center;
  text-align: center;
  color: var(--muted);
  padding: 0;
  overflow: hidden;
  border-radius: 12px;
}
.photo-slot img { width: 100%; height: 100%; object-fit: cover; }
.photo-add { border: 1px dashed var(--input-line); background: var(--card); color: var(--ink); font-weight: 700; }
.photo-actions {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  gap: 4px;
  padding: 4px;
  background: rgba(0, 0, 0, 0.45);
}
.photo-actions button {
  flex: 1;
  border: 0;
  border-radius: 6px;
  background: var(--card);
  color: var(--ink);
  padding: 4px;
  font-size: 12px;
}
.tag-toolbar, .mode-row, .dialog-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.search-field { position: relative; flex: 1; min-width: 0; }
.search-field input { width: 100%; padding-right: 36px; }
#tag-search-clear {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: #666;
  font-size: 20px;
  line-height: 1;
}
.mode-status { font-weight: 700; }
.mode-status.interest { color: #2e7d32; }
.mode-status.blacklist { color: var(--ink); }
.tag-toolbar input { flex: 1; }
.tag-toolbar button, .mode-row button, .dialog-actions button {
  background: var(--soft);
  color: var(--ink);
  padding: 10px 12px;
}
.dialog-actions button.primary {
  background: var(--accent);
  color: white;
}
button.save-button { background: #2e7d32; color: white; }
button.save-button:disabled {
  background: #bdbdbd;
  color: #616161;
  box-shadow: none;
  filter: none;
  transform: none;
}
.mode-row button.is-active.interest { background: #2e7d32; color: white; }
.mode-row button.is-active.neutral { background: #fff; color: #111; box-shadow: inset 0 0 0 2px #111; }
.mode-row button.is-active.blacklist { background: #111; color: white; }
.mode-row button.list-choice.is-active { background: var(--nav); color: white; }
.mode-status.neutral { color: #424242; }
.label-row { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.help-wrap { position: relative; }
.tag-side { display: grid; gap: 8px; }
.tag-side h3 { margin: 0; font-size: 16px; }
.note-block { position: relative; display: grid; gap: 8px; }
.note-block .help-wrap { position: static; }
.note-block .help-pop { top: 36px; }
.weight-block { position: relative; }
.weight-block .help-wrap { position: static; }
.help {
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 50%;
  background: var(--soft);
  color: var(--ink);
  font-weight: 800;
}
.help-pop {
  display: none;
  position: absolute;
  z-index: 5;
  left: 0;
  right: 0;
  top: 40px;
  width: auto;
  padding: 12px;
  background: var(--card);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 10px;
  font-weight: 400;
  line-height: 1.4;
  box-shadow: var(--shadow);
}
#tag-dialog {
  max-height: calc(100dvh - 24px);
  overflow: auto;
  overscroll-behavior: contain;
}
#tag-dialog form { overflow: visible; }
.scroll-hint {
  position: sticky;
  bottom: 0;
  margin: 0 -20px -20px;
  padding: 22px 12px 10px;
  text-align: center;
  font-weight: 700;
  color: var(--ink);
  background: linear-gradient(transparent, var(--card) 58%);
  pointer-events: none;
}
.help-wrap:hover .help-pop,
.help-wrap:focus-within .help-pop,
.help-wrap.is-open .help-pop { display: block; }
.term {
  position: relative;
  color: var(--accent-dark);
  font-weight: 700;
  text-decoration: underline dotted;
  cursor: help;
}
.term-pop {
  display: none;
  position: fixed;
  z-index: 25;
  left: 12px;
  top: 12px;
  width: min(340px, calc(100vw - 24px));
  max-height: calc(100dvh - 24px);
  overflow: auto;
  padding: 12px;
  background: var(--card);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 10px;
  font-weight: 400;
  line-height: 1.4;
  text-decoration: none;
  box-shadow: var(--shadow);
}
.term.is-open .term-pop { display: block; }
.private-block { display: grid; }
.private-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  font-weight: 700;
}
.private-toggle::after { content: "▾"; }
.private-toggle[aria-expanded="true"]::after { content: "▴"; }
.private-roll {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.35s ease;
}
.private-roll.is-open { grid-template-rows: 1fr; }
.private-roll-inner {
  overflow: hidden;
  display: grid;
  gap: 22px;
  min-height: 0;
}
.private-roll.is-open .private-roll-inner { padding-top: 18px; padding-bottom: 8px; }
.filter-grid { display: grid; gap: 22px; }
.filter-grid select { width: 100%; padding: 12px; border: 1px solid var(--input-line); border-radius: 8px; }
.check-grid {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px 16px;
  display: grid;
  gap: 14px;
}
.check-grid .group-title { font-weight: 700; margin: 8px 0 0; }
label.check-option { display: flex; align-items: center; gap: 8px; font-weight: 500; }
label.check-option input { width: auto; padding: 0; }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
#detail-dialog {
  display: grid;
  gap: 22px;
}
#detail-body {
  white-space: pre-wrap;
  line-height: 1.6;
}
.dialog-actions .save-button { margin-left: auto; }
.tag-results button, .owned-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-align: center;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 14px;
}
.danger { color: var(--accent-dark); }
.switch-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  background: var(--soft);
  color: var(--ink);
  padding: 12px;
  border-radius: 10px;
}
.switch-row small { display: block; }
.switch-row input { width: 22px; height: 22px; flex: 0 0 auto; }
.sample-note {
  margin-top: 10px;
  padding: 12px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
}
.feedback-note {
  margin-top: 10px;
  padding: 12px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
}
.feedback-note p { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.feedback-note-bar { display: flex; align-items: center; gap: 12px; margin-top: 8px; }
.account-wipe { margin-top: 28px; padding-top: 18px; border-top: 1px solid var(--line); }
.danger-button, .dialog-actions .danger-button {
  background: var(--card);
  color: var(--accent-dark);
  border: 1px solid var(--accent-dark);
  border-radius: 8px;
  padding: 12px 16px;
  font-weight: 700;
}
.danger-button:disabled, .dialog-actions .danger-button:disabled { opacity: 0.45; }
.delete-phrase { margin: 0; font-size: 22px; font-weight: 800; letter-spacing: 0.03em; }
dialog:not([open]) { display: none !important; }
dialog {
  width: min(440px, calc(100% - 24px));
  border: 0;
  border-radius: 16px;
  padding: 20px;
  background: var(--card);
  color: var(--ink);
}
dialog::backdrop { background: rgba(0, 0, 0, 0.45); }
dialog form { display: grid; gap: 18px; }
#detail-title.blacklist { color: var(--accent); }
#detail-title.interest { color: #2e7d32; }
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: #2e7d32;
  color: white;
  padding: 12px 18px;
  border-radius: 999px;
  font-weight: 700;
  z-index: 30;
  box-shadow: var(--shadow);
}
.chat-layout { display: grid; gap: 16px; }
.chat-row {
  text-align: left;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px;
}
.chat-row.is-open { border-color: var(--accent); }
.chat-row strong, .chat-row small { display: block; }
.chat-row small {
  color: var(--muted);
  margin-top: 4px;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.chat-thread {
  display: grid;
  gap: 12px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
}
.chat-thread-bar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.chat-thread-bar h2 { font-size: 22px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-thread-actions { display: flex; gap: 8px; margin-left: auto; flex-wrap: wrap; justify-content: flex-end; }
.chat-thread-actions .text-button {
  background: var(--card);
  border: 2px solid var(--accent);
  border-radius: 999px;
  padding: 6px 12px;
  font-weight: 700;
}
#chat-worked { border-color: #2e7d32; color: #1b5e20; }
html.is-dark #chat-worked { border-color: #81c784; color: #a5d6a7; }
#chat-move-on { border-color: var(--accent); color: var(--accent); }
#chat-keep { border-color: #1565c0; color: #0d47a1; }
html.is-dark #chat-keep { border-color: #90caf9; color: #bbdefb; }
#chat-delete { border-color: #c62828; color: #b71c1c; }
html.is-dark #chat-delete { border-color: #ef9a9a; color: #ffcdd2; }
.chat-thread-actions .help { flex: 0 0 auto; }
.help-dialog {
  display: grid;
  gap: 16px;
  max-height: min(80dvh, 720px);
  overflow: auto;
}
.help-dialog h2, .help-dialog h3, .help-dialog p { margin: 0; }
.help-dialog h3 { font-size: 16px; }
.help-dialog section { display: grid; gap: 8px; }
.help-dialog .dialog-actions { position: sticky; bottom: 0; background: var(--card); padding-top: 8px; }
.chat-messages {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 180px;
  max-height: min(52vh, 520px);
  overflow: auto;
}
.bubble {
  max-width: min(80%, 420px);
  padding: 10px 14px;
  border-radius: 16px;
  background: var(--soft);
  border: 1px solid var(--line);
}
.bubble.mine { margin-left: auto; background: var(--mine); border-color: var(--mine-line); }
.bubble.matchmaker {
  max-width: min(100%, 520px);
  margin-left: auto;
  margin-right: auto;
  background: var(--card);
  border-color: var(--accent);
}
.bubble.matchmaker strong { display: block; margin-bottom: 4px; color: var(--accent-dark); font-size: 13px; }
.bubble p { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.bubble small { display: block; color: var(--muted); margin-top: 4px; }
.chat-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: end;
}
.chat-form textarea {
  min-height: 88px;
  max-height: 220px;
  resize: none;
  line-height: 1.45;
  overflow-x: hidden;
  overflow-y: auto;
  overflow-wrap: anywhere;
}
.chat-form .hint { grid-column: 1 / -1; margin: 0; }
.message-row { margin-top: 8px; }
.person-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 8px; }
.person-actions .message-row { margin-top: 0; }
.person-card.is-mini .person-actions { flex-direction: column; align-items: stretch; }
.person-card.is-mini .person-actions .message-row,
.person-card.is-mini .move-on { width: 100%; margin-top: 0; padding: 8px; font-size: 13px; }

.nav-count {
  display: inline-grid;
  place-items: center;
  min-width: 1.4em;
  margin-left: 6px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--accent);
  color: white;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.4;
  vertical-align: middle;
}
.side-nav button:not(.is-active) .nav-count { background: var(--card); color: var(--accent-dark); }
.side-nav button.is-active .nav-count,
.bottom-nav button.is-active .nav-count,
.edit-tabs button.is-active .nav-count { background: var(--card); color: var(--accent-dark); }
.discover-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  position: sticky;
  top: var(--top-bar-h);
  z-index: 7;
  margin: -8px 0 8px;
  padding: 8px 0;
  background: var(--page);
}
.introduce-row { display: flex; align-items: center; gap: 8px; }
.introduce-row .help-wrap { position: static; }
.introduce-row .help-pop {
  left: 0;
  right: auto;
  top: calc(100% + 8px);
  width: min(360px, 100%);
}
#introduce-me { padding: 8px 14px; white-space: nowrap; }
#introduce-note { margin: 0 0 8px; }
#discover-layout {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  padding: 8px 12px;
  font-weight: 700;
}
#discover-layout[aria-pressed="true"] { background: var(--accent); color: white; }
#discover-layout svg { display: block; fill: currentColor; }
.discover-list.is-grid, #discover-list.is-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(112px, 1fr));
  gap: 8px;
  align-items: start;
}
#discover-list.is-grid > .hint { grid-column: 1 / -1; }
.person-card.is-mini { padding: 8px; }
.person-card.is-mini .avatar {
  width: 100%;
  height: 84px;
  margin: 0 0 8px;
  border-radius: 12px;
  font-size: 32px;
}
.person-card.is-mini .person-name { font-size: 15px; margin: 0; }
.mini-stats { margin-top: 4px; font-size: 12px; line-height: 1.3; color: var(--ink); }
.mini-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.mini-tag {
  border-radius: 999px;
  background: var(--green);
  padding: 2px 6px;
  font-size: 11px;
  font-weight: 700;
}
.person-card.is-mini .hint { margin: 6px 0 0; font-size: 11px; }
.message-notice {
  position: fixed;
  top: calc(var(--top-bar-h) + 8px);
  left: 50%;
  z-index: 40;
  width: min(420px, calc(100% - 24px));
  transform: translate(-50%, calc(-100% - var(--top-bar-h) - 24px));
  transition: transform 0.45s ease;
  pointer-events: none;
}
.message-notice.is-in { transform: translate(-50%, 0); pointer-events: auto; }
.message-notice button {
  width: 100%;
  display: grid;
  gap: 4px;
  text-align: left;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
  box-shadow: var(--shadow);
}
#message-notice-text {
  display: block;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-weight: 500;
  color: var(--ink);
}
.chat-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 8px; align-items: center; }
.chat-row small { grid-column: 1; }
.chat-row .nav-count { grid-row: 1 / span 2; grid-column: 2; margin-left: 0; }

@media (max-width: 860px) {
  .bottom-nav {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--card);
    border-top: 1px solid var(--line);
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  }
  .bottom-nav button { background: transparent; border-radius: 10px; font-size: 13px; padding: 8px 4px; }
  .stage { padding-bottom: 76px; }
  .top-bar { width: 100%; }
  .toast { bottom: 88px; }
}

@media (min-width: 861px) {
  .app-screen {
    display: grid;
    grid-template-columns: 220px minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
    grid-template-areas:
      "header header"
      "nav stage";
    width: 100%;
    height: 100vh;
    min-height: 100vh;
    overflow: hidden;
  }
  .top-bar { grid-area: header; }
  .side-nav {
    grid-area: nav;
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-self: stretch;
    background: var(--nav);
    color: white;
    padding: 20px 12px;
    min-height: 100%;
  }
  .stage { grid-area: stage; width: 100%; max-width: none; min-height: 0; overflow: auto; }
  .discover-bar { top: 0; }
  .edit-bar, .app-screen.is-compact .edit-bar { top: 0; }
  .side-nav .app-icon { width: 64px; height: 64px; margin: 4px 8px 0; }
  .side-nav .brand { font-weight: 800; padding: 8px; }
  .side-nav button { background: transparent; color: white; text-align: left; }
  .side-nav button.is-active { background: var(--card); color: var(--accent-dark); }
}
@media (min-width: 861px) {
  .chat-layout { grid-template-columns: minmax(220px, 280px) minmax(0, 1fr); align-items: start; }
  #chat-back { display: none; }
}
.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatch {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 50%;
  border: 3px solid transparent;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.25);
}
.swatch.is-selected { border-color: var(--ink); }
.color-row { display: flex; align-items: center; gap: 12px; }
.color-row input[type="color"] { width: 56px; height: 40px; padding: 4px; }
.moved-row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px;
}
.moved-row div { min-width: 0; }
.moved-row strong, .moved-row small { display: block; }
.moved-row .text-button { margin-left: auto; }
.tour[hidden] { display: none !important; }
.tour-block { position: fixed; inset: 0; z-index: 60; }
.tour-ring {
  position: fixed;
  z-index: 61;
  border-radius: 12px;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.55);
  outline: 2px solid #fff;
  outline-offset: 3px;
  pointer-events: none;
}
.tour-card {
  position: fixed;
  z-index: 62;
  right: 12px;
  bottom: 12px;
  width: min(360px, calc(100% - 24px));
  max-height: min(42dvh, 420px);
  overflow: hidden;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  gap: 10px;
  padding: 16px;
  background: var(--card);
  color: var(--ink);
  border-radius: 16px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.28);
}
#tour-body { overflow: auto; min-height: 0; }
.person-card.is-practice { outline: 2px dashed var(--accent); outline-offset: 3px; }
.tour-live { position: relative; z-index: 61; }
.tour-sheet {
  margin: 0 0 12px;
  padding: 14px 16px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  display: grid;
  gap: 10px;
}
.tour-sheet h3, .tour-sheet p { margin: 0; }
#tour-tag-lab {
  margin: 12px 0;
  padding: 14px;
  border: 1px dashed var(--accent);
  border-radius: 12px;
  display: grid;
  gap: 10px;
}
.tour-card h2, .tour-card p { margin: 0; }
.tour-card .dialog-actions { justify-content: space-between; }
.tour-nav { display: flex; gap: 8px; margin-left: auto; }
.tour-card .tour-skip {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
  font-weight: 650;
}
