:root {
  color-scheme: light;
  --bg: var(--tg-theme-bg-color, #f3f5f4);
  --text: var(--tg-theme-text-color, #18201f);
  --muted: var(--tg-theme-hint-color, #66706d);
  --panel: var(--tg-theme-secondary-bg-color, #ffffff);
  --button: var(--tg-theme-button-color, #b85d3f);
  --button-text: var(--tg-theme-button-text-color, #ffffff);
  --line: rgba(24, 32, 31, .11);
  --line-strong: rgba(24, 32, 31, .18);
  --field: #f9faf9;
  --soft: rgba(184, 93, 63, .12);
  --soft-strong: rgba(184, 93, 63, .25);
  --accent-coral: #b85d3f;
  --accent-honey: #b87924;
  --accent-rose: #ad4e68;
  --accent-sage: #6d8b62;
  --accent-plum: #835b80;
  --tint-coral: rgba(184, 93, 63, .13);
  --tint-honey: rgba(184, 121, 36, .14);
  --tint-rose: rgba(173, 78, 104, .12);
  --tint-sage: rgba(109, 139, 98, .13);
  --tint-plum: rgba(131, 91, 128, .12);
  --danger: #b42318;
  --warn: #8a5a10;
  --success: #157f3b;
  --nav-active: #94452f;
  --radius: 12px;
  --shadow: 0 8px 22px rgba(18, 26, 31, .055);
  --shadow-quiet: 0 1px 2px rgba(18, 26, 31, .045);
}

:root[data-theme="dark"] {
    color-scheme: dark;
    --bg: var(--tg-theme-bg-color, #111816);
    --text: var(--tg-theme-text-color, #edf2ef);
    --muted: var(--tg-theme-hint-color, #a8b2ae);
    --panel: var(--tg-theme-secondary-bg-color, #18211f);
    --line: rgba(237, 242, 239, .12);
    --line-strong: rgba(237, 242, 239, .2);
    --field: #151c1a;
    --tint-coral: rgba(231, 127, 91, .17);
    --tint-honey: rgba(226, 158, 83, .17);
    --tint-rose: rgba(222, 118, 148, .16);
    --tint-sage: rgba(139, 174, 126, .16);
    --tint-plum: rgba(181, 135, 176, .16);
    --shadow: 0 10px 24px rgba(0, 0, 0, .18);
    --shadow-quiet: 0 1px 2px rgba(0, 0, 0, .22);
    --nav-active: #f0a287;
}

* { box-sizing: border-box; }
.icon-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
html { min-height: 100%; background: var(--bg); }
body {
  min-height: var(--tg-viewport-stable-height, 100vh);
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.45;
  background: var(--bg);
  color: var(--text);
  text-rendering: optimizeLegibility;
}
.app-loading {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 24px;
  color: var(--muted);
}
.app-shell[aria-busy="true"] { display: none; }
.loading-spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--line-strong);
  border-top-color: var(--button);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
button, input, textarea, select { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
h1, h2, h3, p { margin: 0; }
h1 {
  font-size: 28px;
  line-height: 1.12;
  font-weight: 750;
}
h2 {
  font-size: 20px;
  line-height: 1.2;
  font-weight: 740;
}
h3 {
  font-size: 14px;
  margin: 18px 0 9px;
  color: var(--muted);
  font-weight: 720;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }

.app-shell {
  width: min(1040px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: calc(18px + env(safe-area-inset-top)) 14px calc(104px + env(safe-area-inset-bottom));
}
.app-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 4px 1px 16px;
}
.app-header #admin-entry { margin-left: -8px; }
.app-header > div { min-width: 0; }
.app-header .muted {
  margin-top: 5px;
  max-width: 42rem;
}
.kicker {
  margin: 0 0 5px;
  color: var(--button);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0;
}
.icon-button {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  min-height: 44px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--text);
  box-shadow: var(--shadow-quiet);
  line-height: 1;
}
.icon-button svg { width: 20px; height: 20px; }

.notice {
  margin: 0 0 13px;
  padding: 12px 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--text);
  box-shadow: var(--shadow-quiet);
  overflow-wrap: anywhere;
}
.notice.error { border-color: rgba(180, 35, 24, .32); color: var(--danger); }
.notice.success { border-color: rgba(21, 127, 59, .3); color: var(--success); }
.view { display: block; }

/* Keep reading and form line lengths comfortable on the wider desktop shell. */
#profile-form,
#feedback-form,
#help-form,
.help-guide,
.help-section { max-width: 760px; }

.hero-panel,
.details,
.item,
.info-block,
.empty-state,
.stat,
.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}
.week-action {
  display: grid;
  gap: 12px;
  padding: 18px;
  margin-bottom: 12px;
  border: 1px solid var(--line);
  border-left: 5px solid var(--accent-coral);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}
.week-action[data-tone="success"] { border-left-color: var(--success); }
.week-action[data-tone="waiting"] { border-left-color: var(--accent-honey); }
.week-action[data-tone="meeting"] { border-left-color: var(--accent-sage); }
.week-action h2 { font-size: 22px; }
.week-action .primary-action { width: 100%; }
.week-action .action-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

.week-progress,
.coordination ol {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0;
  margin: 0;
  padding: 0;
  list-style: none;
}
.week-progress {
  padding: 12px 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}
.week-progress li,
.coordination-step {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 5px;
  min-width: 0;
  color: var(--muted);
  text-align: center;
  font-size: 11px;
}
.week-progress li:not(:last-child)::after,
.coordination-step:not(:last-child)::after {
  position: absolute;
  top: 11px;
  left: calc(50% + 15px);
  width: calc(100% - 30px);
  height: 2px;
  background: var(--line);
  content: "";
}
.week-progress li > span,
.coordination-step > span {
  position: relative;
  z-index: 1;
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  border: 2px solid var(--line);
  border-radius: 50%;
  background: var(--panel);
  font-weight: 700;
}
.week-progress .complete > span,
.week-progress .current > span,
.coordination-step.complete > span,
.coordination-step.current > span {
  border-color: var(--button);
  background: var(--button);
  color: var(--button-text);
}
.week-progress .complete:not(:last-child)::after,
.coordination-step.complete:not(:last-child)::after { background: var(--button); }
.week-progress .current,
.coordination-step.current { color: var(--text); }

.coordination {
  display: grid;
  gap: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) - 4px);
  background: var(--panel);
}
.coordination-action { width: 100%; min-height: 44px; }
.coordination-complete { margin: 0; color: var(--success); text-align: center; font-weight: 700; }

.scheduler-panel { margin-top: 14px; }
.scheduler-list { display: grid; gap: 10px; }
.scheduler-row { display: grid; gap: 8px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; }
.scheduler-row > div:first-child { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.scheduler-row dl { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin: 0; }
.scheduler-row dl div { display: grid; gap: 3px; }
.scheduler-row dt { color: var(--muted); font-size: 12px; }
.scheduler-row dd { margin: 0; font-weight: 700; }
.scheduler-error { margin: 0; color: var(--danger); }
.eyebrow { color: var(--muted); font-size: 12px; font-weight: 750; text-transform: uppercase; }
.profile-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 1px 15px;
}
.profile-strip > div { min-width: 0; }
.profile-strip h2 { margin-top: 5px; font-size: 17px; }
.profile-strip p { font-size: 13px; }
.draft-note,
.feedback-hint {
  color: var(--muted);
  font-size: 13px;
}
.draft-note::before { content: "✓ "; color: var(--success); }
.hero-panel {
  padding: 18px;
  margin-bottom: 13px;
  display: grid;
  gap: 11px;
  border-color: rgba(22, 134, 111, .18);
  background:
    linear-gradient(0deg, var(--tint-coral), transparent 42%),
    var(--panel);
}
.hero-panel.compact { margin-top: 11px; }
.hero-panel h2 { margin-top: 1px; }
.week-card { box-shadow: none; }
.hero-panel .week-card {
  border: 0;
  border-top: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  padding: 11px 0 0;
}

.badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}
.badge {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  min-height: 25px;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--soft);
  color: var(--button);
  font-size: 12.5px;
  font-weight: 750;
  line-height: 1.25;
  overflow-wrap: anywhere;
}
.badge-row .badge:nth-child(2n) { background: var(--tint-honey); color: var(--accent-honey); }
.badge.warn { background: rgba(138, 90, 16, .12); color: var(--warn); }
.badge.danger { background: rgba(180, 35, 24, .12); color: var(--danger); }

.menu-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.profile-actions { display: grid; gap: 8px; margin-top: 12px; }
.menu-item {
  width: 100%;
  min-height: 88px;
  display: grid;
  align-content: start;
  gap: 6px;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--text);
  text-align: left;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}
.menu-item::before {
  content: "";
  width: 5px;
  position: absolute;
  inset: 0 auto 0 0;
  background: var(--accent-coral);
}
.menu-item:nth-child(2)::before { background: var(--accent-honey); }
.menu-item:nth-child(3)::before { background: var(--accent-rose); }
.menu-item:nth-child(4)::before { background: var(--accent-sage); }
.menu-item:nth-child(5)::before { background: var(--accent-plum); }
.menu-item:nth-child(1) { background: linear-gradient(0deg, var(--tint-coral), transparent 62%), var(--panel); }
.menu-item:nth-child(2) { background: linear-gradient(0deg, var(--tint-honey), transparent 62%), var(--panel); }
.menu-item:nth-child(3) { background: linear-gradient(0deg, var(--tint-rose), transparent 62%), var(--panel); }
.menu-item:nth-child(4) { background: linear-gradient(0deg, var(--tint-sage), transparent 62%), var(--panel); }
.menu-item:nth-child(5) { background: linear-gradient(0deg, var(--tint-plum), transparent 62%), var(--panel); }
.menu-item strong {
  font-size: 16px;
  line-height: 1.2;
  overflow-wrap: anywhere;
}
.menu-item span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.32;
  overflow-wrap: anywhere;
}

.section-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 13px;
}
.section-row h2 { min-width: 0; overflow-wrap: anywhere; }
.details { overflow: hidden; }
.profile-status {
  display: grid;
  gap: 8px;
  padding: 16px;
  background: var(--soft);
  border-bottom: 1px solid var(--line);
}
.profile-section h3 { margin: 0; padding: 16px 14px 6px; color: var(--text); }
.profile-section + .profile-section { border-top: 8px solid var(--bg); }
.detail-row {
  display: grid;
  grid-template-columns: minmax(112px, 190px) minmax(0, 1fr);
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}
.detail-row:last-child { border-bottom: 0; }
.detail-row span {
  color: var(--muted);
  font-size: 14px;
}
.detail-row strong {
  font-weight: 680;
  overflow-wrap: anywhere;
}

.form-grid { display: grid; gap: 11px; }
.form-grid.panel { padding: 14px; }
.admin-picker {
  display: grid;
  grid-template-columns: minmax(120px, .72fr) minmax(170px, 1.28fr);
  gap: 10px;
  align-items: end;
}
.admin-picker.single { grid-template-columns: 1fr; }
label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 640;
}
input,
textarea,
select {
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--field);
  color: var(--text);
  outline: none;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .04);
}
textarea {
  min-height: 92px;
  resize: vertical;
  line-height: 1.4;
}
select { cursor: pointer; }
.hint {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
button:focus-visible,
summary:focus-visible {
  border-color: var(--button);
  outline: 2px solid var(--button);
  outline-offset: 2px;
  box-shadow: 0 0 0 3px var(--soft);
}
input:disabled {
  color: var(--muted);
  opacity: .82;
}

button {
  min-height: 48px;
  max-width: 100%;
  border: 0;
  border-radius: var(--radius);
  padding: 10px 14px;
  background: var(--button);
  color: var(--button-text);
  cursor: pointer;
  font-weight: 750;
  line-height: 1.2;
  text-align: center;
  overflow-wrap: anywhere;
  box-shadow: var(--shadow-quiet);
}

.button-link {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  padding: 11px 16px;
  border-radius: var(--radius);
  background: var(--button);
  color: var(--button-text);
  font-weight: 700;
  text-decoration: none;
}
button.secondary {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
}
button.ghost {
  min-height: 44px;
  background: transparent;
  color: var(--button);
  padding-inline: 6px;
  box-shadow: none;
}
button.danger { color: var(--danger); }
button:disabled {
  opacity: .55;
  cursor: not-allowed;
}
button[aria-busy="true"] { position: relative; cursor: wait; }
@media (hover: hover) {
  button:not(:disabled):hover { filter: brightness(.98); }
  .menu-item:hover,
  .item.with-actions:hover {
    border-color: var(--line-strong);
  }
}

.action-list,
.stack {
  display: grid;
  gap: 10px;
}
.action-list { margin-top: 13px; }
.item {
  display: grid;
  gap: 7px;
  padding: 14px;
}
.meeting-card { gap: 12px; }
.meeting-card-heading { display: flex; justify-content: space-between; gap: 10px; }
.meeting-card-heading strong { display: block; margin-top: 3px; }
.meeting-person { display: flex; align-items: center; gap: 11px; }
.partner-heading { display: grid; gap: 3px; min-width: 0; }
.partner-heading strong,
.partner-heading span { display: block; overflow-wrap: anywhere; }
.partner-heading span { color: var(--muted); font-size: 13px; }
.person-avatar {
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--tint-sage);
  color: var(--accent-sage);
  font-weight: 800;
}
.meeting-meta { display: flex; flex-wrap: wrap; gap: 6px; }
.meeting-meta span { padding: 3px 7px; border-radius: 999px; background: var(--field); font-size: 12px; }
.meeting-topic { padding-top: 10px; border-top: 1px solid var(--line); }
.meeting-actions { display: grid; gap: 8px; padding-top: 2px; }
.meeting-history {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow-quiet);
  overflow: hidden;
}
.meeting-history > summary {
  min-height: 52px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 13px;
  cursor: pointer;
  font-weight: 800;
  list-style: none;
}
.meeting-history > summary::-webkit-details-marker { display: none; }
.meeting-history > summary::after {
  content: "›";
  margin-left: auto;
  color: var(--muted);
  font-size: 22px;
  line-height: 1;
  transition: transform .18s ease;
}
.meeting-history[open] > summary::after { transform: rotate(90deg); }
.meeting-history .summary-count { margin-left: 2px; }
.meeting-history-list {
  display: grid;
  gap: 10px;
  padding: 10px;
  border-top: 1px solid var(--line);
}
.partner-card {
  display: grid;
  gap: 11px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--field);
}
.partner-card.readonly { background: var(--panel); }
.meeting-locked {
  color: var(--muted);
  font-size: 13px;
}
.partner-actions { display: grid; gap: 8px; }
.partner-actions button:first-child { width: 100%; }
.danger-link {
  min-height: 44px;
  padding: 6px;
  background: transparent;
  color: var(--danger);
  box-shadow: none;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.partner-details { border-top: 1px solid var(--line); padding-top: 10px; }
.partner-details summary,
.feedback-extra summary {
  display: flex;
  align-items: center;
  min-height: 44px;
  cursor: pointer;
  color: var(--button);
  font-weight: 700;
  overflow-wrap: anywhere;
}
.partner-details[open] summary { margin-bottom: 9px; }
.partner-detail { display: grid; gap: 2px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.partner-detail:last-child { border-bottom: 0; }
.partner-detail span { color: var(--muted); font-size: 12px; }
.partner-detail strong { font-size: 14px; font-weight: 650; }

.step-progress { display: grid; gap: 7px; margin-bottom: 4px; }
.step-progress-track { height: 5px; overflow: hidden; border-radius: 5px; background: var(--line); }
.step-progress-track span { display: block; height: 100%; background: var(--button); transition: width .2s ease; }
.step-fields { display: grid; gap: 11px; }
.step-actions { display: grid; grid-template-columns: auto 1fr; gap: 8px; margin-top: 4px; }
.profile-choice-fieldset { min-width: 0; margin: 0; padding: 0; border: 0; }
.profile-choice-fieldset legend { margin-bottom: 8px; color: var(--text); font-size: 15px; font-weight: 720; }
.profile-choice-grid { display: grid; gap: 8px; }
.profile-choice {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--text);
  font-weight: 680;
}
.profile-choice input[type="radio"] {
  appearance: none;
  width: 19px;
  height: 19px;
  min-height: 19px;
  margin: 0 0 0 auto;
  flex: 0 0 auto;
  border: 2px solid var(--line-strong);
  border-radius: 50%;
  background: var(--panel);
}
.profile-choice input[type="radio"]:checked { border: 5px solid var(--button); }
.profile-choice:focus-within { outline: 2px solid var(--button); outline-offset: 2px; }
.profile-choice-fieldset > .hint { display: block; margin-top: 7px; }
.feedback-fieldset { min-width: 0; margin: 0; padding: 0; border: 0; }
.feedback-fieldset legend { margin-bottom: 10px; font-size: 20px; font-weight: 750; }
.feedback-choice-grid { display: grid; gap: 8px; }
.feedback-choice {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--text);
  font-weight: 700;
  text-align: left;
}
.feedback-choice input[type="radio"] {
  appearance: none;
  width: 18px;
  height: 18px;
  margin-left: auto;
  margin-right: 0;
  flex: 0 0 auto;
  border: 2px solid var(--line-strong);
  border-radius: 50%;
  background: var(--panel);
}
.feedback-choice:has(input:checked) { border-color: var(--button); background: var(--soft); color: var(--button); }
.feedback-choice input[type="radio"]:checked { border: 5px solid var(--button); }
.feedback-choice:focus-within { outline: 2px solid var(--button); outline-offset: 2px; }
.feedback-extra { padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius); }
.feedback-extra[open] summary { margin-bottom: 12px; }
.problem-extra summary { color: var(--danger); }
.info-message {
  padding: 11px 12px;
  border-radius: var(--radius);
  background: var(--soft);
  color: var(--text);
}
.item strong {
  font-size: 15px;
  line-height: 1.28;
  overflow-wrap: anywhere;
}
.item span,
.item p {
  color: var(--muted);
  overflow-wrap: anywhere;
}
.item.with-actions {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
}
.inline-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}
.inline-actions button { min-width: 96px; }
.info-block {
  display: grid;
  gap: 6px;
  padding: 14px;
  border-left: 5px solid var(--accent-honey);
  background: linear-gradient(0deg, var(--tint-honey), transparent 68%), var(--panel);
}
.info-block span {
  color: var(--muted);
  overflow-wrap: anywhere;
}
.help-guide {
  display: grid;
  gap: 10px;
  padding: 18px;
  border-left: 5px solid var(--accent-honey);
  background: linear-gradient(0deg, var(--tint-honey), transparent 45%), var(--panel);
}
.help-guide h3,
.help-stage h4,
.help-section h3 { margin: 0; }
.help-lead,
.help-note,
.help-stage p,
.help-faq-answer p { margin: 0; }
.help-lead { line-height: 1.55; }
.help-timeline {
  display: grid;
  margin-top: 2px;
  border-top: 1px solid var(--line);
}
.help-stage {
  display: grid;
  grid-template-columns: minmax(120px, 165px) minmax(0, 1fr);
  gap: 14px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}
.help-stage > strong { color: var(--button); }
.help-stage div { display: grid; gap: 4px; }
.help-stage h4 { font-size: 15px; }
.help-stage p,
.help-note {
  color: var(--muted);
  line-height: 1.5;
  overflow-wrap: anywhere;
}
.help-note { font-size: 13px; }
.help-section { display: grid; gap: 10px; }
.help-faq { display: grid; gap: 8px; }
.help-faq-item {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow-quiet);
}
.help-faq-item summary {
  display: flex;
  min-height: 48px;
  align-items: center;
  padding: 12px 14px;
  cursor: pointer;
  font-weight: 700;
  line-height: 1.35;
  overflow-wrap: anywhere;
}
.help-faq-item summary::marker { color: var(--muted); }
.help-faq-item[open] summary { border-bottom: 1px solid var(--line); }
.help-faq-answer {
  display: grid;
  gap: 10px;
  padding: 13px 14px 15px;
  color: var(--muted);
  line-height: 1.55;
}
.help-faq-answer ol {
  margin: 0;
  padding-left: 20px;
}
.help-faq-answer li + li { margin-top: 6px; }
.empty-state {
  padding: 24px 16px;
  text-align: center;
}
.empty-state h2 { font-size: 19px; }
.empty-state p {
  margin: 6px auto 0;
  max-width: 28rem;
  color: var(--muted);
}
.empty-state button { margin-top: 14px; }
.details > .empty-state,
.hero-panel > .empty-state {
  border: 0;
  box-shadow: none;
  background: transparent;
}
.danger-zone { margin-top: 14px; }

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}
.stat {
  display: grid;
  gap: 4px;
  padding: 13px;
}
.stat strong {
  font-size: 24px;
  line-height: 1.1;
}
.stat span {
  color: var(--muted);
  font-size: 13px;
}
.attention-panel { padding: 14px; }
.attention-panel h3 { margin-top: 0; }
.attention-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 9px;
}
.attention-item {
  min-height: 68px;
  display: grid;
  gap: 2px;
  align-content: center;
  border: 1px solid var(--line);
  background: var(--soft);
  color: var(--button);
  text-align: left;
}
.attention-item strong { font-size: 22px; }
.attention-item span {
  color: var(--text);
  font-size: 13px;
}
.attention-item.quiet {
  background: var(--panel);
  color: var(--muted);
}
.inline-details {
  display: grid;
  border-top: 1px solid var(--line);
}
.inline-details .detail-row { padding-inline: 0; }

.preview-box {
  display: grid;
  gap: 6px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--soft);
}
.preview-box.error {
  background: rgba(180, 35, 24, .08);
  border-color: rgba(180, 35, 24, .3);
}
.preview-box.ok {
  background: rgba(21, 127, 59, .08);
  border-color: rgba(21, 127, 59, .3);
}
.preview-box span,
.preview-box li {
  color: var(--muted);
  overflow-wrap: anywhere;
}
.preview-box ul {
  margin: 0;
  padding-left: 18px;
}
.segmented {
  display: flex;
  gap: 7px;
  overflow-x: auto;
  padding: 2px 0 10px;
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
  scroll-snap-type: x proximity;
  overscroll-behavior-inline: contain;
  -webkit-overflow-scrolling: touch;
}
.segmented::-webkit-scrollbar { height: 5px; }
.segmented::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 999px; }
.segmented button {
  white-space: nowrap;
  min-height: 44px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--muted);
  scroll-snap-align: start;
}
.segmented button.has-alert {
  border-color: rgba(180, 35, 24, .42);
}
.tab-alert {
  min-width: 20px;
  height: 20px;
  display: inline-grid;
  place-items: center;
  margin-left: 6px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-size: 11px;
  font-weight: 850;
  line-height: 1;
}
.segmented button.active {
  background: var(--soft);
  color: var(--button);
  border-color: var(--soft-strong);
  font-weight: 800;
  box-shadow: inset 0 -3px 0 var(--button);
}
.admin-modes {
  margin-top: -4px;
  padding-bottom: 13px;
  mask-image: none;
}
.admin-modes button {
  min-height: 40px;
  border-radius: 999px;
  font-size: 13px;
}
.admin-modes button.active { box-shadow: none; }
.admin-content { display: grid; gap: 13px; }
.feedback-section-heading h3 { margin-bottom: 4px; }
.feedback-section-heading p { margin: 0; }
.inbox-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.inbox-heading h3 { margin: 0 0 4px; }
.inbox-heading p { margin: 0; }
.inbox-heading > button { flex: 0 0 auto; }
.inbox-toolbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 10px;
}
.inbox-status-filters {
  min-width: 0;
  flex: 1 1 auto;
}
.inbox-status-filters button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}
.inbox-type-filter {
  min-width: 185px;
  flex: 0 0 210px;
}
.inbox-type-filter > span {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}
.inbox-search { margin-top: -2px; }
.feedback-filters { padding-bottom: 2px; }
.feedback-filters button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}
.filter-count,
.summary-count {
  min-width: 24px;
  height: 24px;
  display: inline-grid;
  place-items: center;
  padding: 0 7px;
  border-radius: 999px;
  background: var(--soft);
  color: var(--button);
  font-size: 12px;
  font-weight: 800;
}
.feedback-filters button.active .filter-count {
  background: var(--button);
  color: #fff;
}
.admin-feedback-list,
.admin-message-groups,
.admin-inbox-list { display: grid; gap: 8px; }
.admin-feedback-card,
.admin-message-group,
.admin-inbox-card,
.missing-feedback {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow-quiet);
  overflow: hidden;
}
.admin-feedback-card.problem { border-color: rgba(180, 35, 24, .32); }
.admin-inbox-card.attention { border-color: rgba(180, 35, 24, .32); }
.admin-feedback-card summary,
.admin-message-group summary,
.admin-inbox-card summary,
.missing-feedback summary {
  min-height: 52px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 13px;
  cursor: pointer;
  overflow-wrap: anywhere;
}
.admin-feedback-card summary::marker,
.admin-message-group summary::marker,
.admin-inbox-card summary::marker,
.missing-feedback summary::marker { color: var(--muted); }
.admin-feedback-card summary::after,
.admin-message-group summary::after,
.admin-inbox-card summary::after,
.missing-feedback summary::after {
  content: "›";
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 22px;
  line-height: 1;
  transition: transform .18s ease;
}
.admin-feedback-card[open] > summary::after,
.admin-message-group[open] > summary::after,
.admin-inbox-card[open] > summary::after,
.missing-feedback[open] > summary::after { transform: rotate(90deg); }
.feedback-unread-dot {
  width: 9px;
  height: 9px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--line-strong);
}
.feedback-unread-dot.active { background: var(--danger); }
.admin-feedback-heading {
  min-width: 0;
  flex: 1 1 auto;
  display: grid;
  gap: 3px;
}
.admin-feedback-heading span {
  color: var(--muted);
  font-size: 12.5px;
}
.admin-inbox-heading {
  min-width: 0;
  flex: 1 1 auto;
  display: grid;
  gap: 3px;
}
.admin-inbox-heading span {
  color: var(--muted);
  font-size: 12.5px;
}
.admin-inbox-status {
  flex: 0 1 auto;
  color: var(--muted);
  font-size: 12.5px;
  text-align: right;
}
.admin-inbox-body {
  display: grid;
  gap: 10px;
  padding: 12px 13px 13px 32px;
  border-top: 1px solid var(--line);
}
.admin-inbox-body .inline-details:empty { display: none; }
.admin-inbox-body .detail-row { padding-block: 9px; }
.admin-inbox-contact {
  margin: 0;
  color: var(--muted);
  font-size: 12.5px;
}
.admin-inbox-text {
  margin: 0;
  white-space: pre-wrap;
}
.admin-feedback-rating {
  flex: 0 1 auto;
  color: var(--muted);
  font-size: 12.5px;
  text-align: right;
}
.admin-feedback-body {
  display: grid;
  gap: 9px;
  padding: 0 13px 13px 32px;
  border-top: 1px solid var(--line);
}
.admin-feedback-body .badge-row { padding-top: 12px; }
.admin-feedback-body .detail-row { padding-block: 9px; }
.admin-message-counts {
  display: flex;
  flex: 0 0 auto;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 5px;
}
.admin-message-group-body {
  display: grid;
  border-top: 1px solid var(--line);
}
.admin-message-entry {
  display: grid;
  gap: 9px;
  padding: 13px;
}
.admin-message-entry + .admin-message-entry { border-top: 1px solid var(--line); }
.admin-message-entry p { margin: 0; white-space: pre-wrap; }
.admin-message-meta { display: grid; gap: 3px; }
.admin-message-meta span { color: var(--muted); font-size: 12.5px; }
.feedback-pagination:has(button:disabled + button:disabled) { display: none; }
.inbox-pagination:has(button:disabled + button:disabled) { display: none; }
.missing-feedback { margin-top: 4px; }
.missing-feedback summary {
  justify-content: flex-start;
  font-weight: 800;
}
.missing-feedback summary .summary-count { margin-left: auto; }
.missing-feedback[open] summary { border-bottom: 1px solid var(--line); }
.missing-feedback > .stack { padding: 10px; }
.admin-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  align-items: end;
}
.toolbar > * { flex: 1 1 150px; }
.table-list {
  display: grid;
  gap: 9px;
}
.code {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 13px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.bottom-nav {
  position: fixed;
  left: 50%;
  bottom: 0;
  z-index: 10;
  width: min(1040px, 100%);
  transform: translateX(-50%);
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 5px;
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: var(--panel);
  box-shadow: 0 -8px 22px rgba(18, 26, 31, .055);
}
.bottom-nav button {
  min-width: 0;
  min-height: 50px;
  padding: 7px 4px;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.15;
  box-shadow: none;
  white-space: normal;
  display: flex;
  flex-direction: column;
  gap: 3px;
  align-items: center;
  justify-content: center;
}
.nav-icon {
  width: 21px;
  height: 21px;
  flex: 0 0 auto;
  display: block;
  fill: none;
  stroke: currentColor;
  opacity: 1;
  visibility: visible;
}
.bottom-nav button.active {
  background: var(--tint-coral);
  color: var(--text);
}
.bottom-nav button.active .nav-icon {
  color: var(--nav-active);
  stroke: var(--nav-active);
  opacity: 1;
}

@media (max-width: 720px) {
  .app-shell { padding: calc(14px + env(safe-area-inset-top)) 12px calc(100px + env(safe-area-inset-bottom)); }
  .app-header { padding-bottom: 14px; }
  h1 { font-size: 24px; }
  .menu-grid,
  .admin-grid,
  .stats,
  .attention-grid {
    grid-template-columns: 1fr;
  }
  .admin-picker { grid-template-columns: 1fr; }
  .hero-panel { padding: 16px; }
  .week-action .action-pair { grid-template-columns: 1fr; }
  .help-stage {
    grid-template-columns: 1fr;
    gap: 5px;
  }
  .detail-row {
    grid-template-columns: 1fr;
    gap: 4px;
  }
  .item.with-actions { grid-template-columns: 1fr; }
  .inbox-heading,
  .inbox-toolbar {
    align-items: stretch;
    flex-direction: column;
  }
  .inbox-heading > button,
  .inbox-type-filter { width: 100%; flex-basis: auto; }
  .admin-feedback-card summary,
  .admin-inbox-card summary {
    align-items: flex-start;
    flex-wrap: wrap;
  }
  .admin-feedback-rating,
  .admin-inbox-status {
    flex-basis: 100%;
    padding-left: 19px;
    text-align: left;
  }
  .admin-feedback-body,
  .admin-inbox-body { padding-left: 13px; }
  .inline-actions { justify-content: stretch; }
  .inline-actions button {
    flex: 1 1 128px;
    min-width: 0;
  }
  .scheduler-row dl { grid-template-columns: 1fr; }
}

@media (max-width: 380px) {
  body { font-size: 15px; }
  .app-shell { padding-inline: 10px; }
  .app-header {
    grid-template-columns: minmax(0, 1fr) 44px 44px;
    gap: 8px;
  }
  .app-header #admin-entry { margin-left: 0; }
  .app-header h1 { font-size: clamp(20px, 6.5vw, 24px); overflow-wrap: anywhere; }
  .app-header .muted { font-size: 13px; }
  .section-row {
    align-items: flex-start;
    flex-direction: column;
  }
  .section-row button { width: 100%; }
  .bottom-nav {
    gap: 3px;
    padding-inline: 5px;
  }
  .bottom-nav button {
    min-height: 52px;
    font-size: 11px;
    padding-inline: 2px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}
