:root {
  color-scheme: light;
  --bg: #fff3e3;
  --surface: #fffaf2;
  --surface-strong: #ffe7c7;
  --line: #edd5b6;
  --text: #3b281b;
  --muted: #735d4a;
  --accent: #a35620;
  --accent-strong: #843f15;
  --danger: #b42318;
  --danger-bg: #ffe6e3;
  --focus: #0b5cab;
  --shadow: 0 12px 30px rgba(77, 45, 23, 0.10);
  --bottom-nav-height: 76px;
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic", "YuGothic", "Noto Sans JP", sans-serif;
  font-size: 16px;
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  background: var(--bg);
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-width: 0;
  overflow-x: hidden;
}

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

button {
  cursor: pointer;
  -webkit-tap-highlight-color: rgba(163, 86, 32, 0.18);
  touch-action: manipulation;
}

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

a {
  color: var(--accent-strong);
}

a.primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

:focus {
  outline: none;
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

.skip-link {
  position: fixed;
  left: 12px;
  top: 12px;
  z-index: 100;
  transform: translateY(-140%);
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--focus);
  color: white;
  font-weight: 700;
}

.skip-link:focus {
  transform: translateY(0);
}

.app-shell {
  min-height: 100vh;
  min-height: 100svh;
  display: grid;
  grid-template-rows: auto 1fr auto;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px clamp(16px, 4vw, 36px);
  background: rgba(255, 243, 227, 0.94);
  border-bottom: 1px solid var(--line);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  padding-top: calc(14px + env(safe-area-inset-top));
}

.logo {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  object-fit: cover;
}

.brand {
  min-width: 0;
  flex: 1;
}

.topbar-settings {
  display: inline-grid;
  place-items: center;
  min-width: 48px;
  min-height: 48px;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--accent-strong);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.15;
}

.topbar-settings span:first-child {
  font-size: 19px;
}

.brand-title {
  margin: 0;
  font-size: 18px;
  line-height: 1.2;
}

.brand-subtitle {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.main {
  width: min(1080px, 100%);
  margin: 0 auto;
  padding: 18px max(16px, env(safe-area-inset-left)) calc(var(--bottom-nav-height) + 24px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-right));
  scroll-padding-bottom: calc(var(--bottom-nav-height) + 16px);
  overflow-wrap: anywhere;
}

.tabs {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 4px;
  padding: 8px max(8px, env(safe-area-inset-left)) calc(8px + env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-right));
  background: rgba(255, 250, 242, 0.96);
  border-top: 1px solid var(--line);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  box-shadow: 0 -10px 28px rgba(77, 45, 23, 0.08);
}

.tab {
  min-height: 52px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  display: grid;
  place-items: center;
  gap: 2px;
  font-size: 12px;
  line-height: 1.2;
}

.tab span:first-child {
  font-size: 20px;
  line-height: 1;
}

.tab.active {
  background: var(--surface-strong);
  color: var(--accent-strong);
  font-weight: 700;
}

.tab[aria-current="page"] {
  box-shadow: inset 0 0 0 2px rgba(163, 86, 32, 0.28);
}

.hero,
.card,
.notice,
.section {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.hero {
  padding: 18px;
  margin-bottom: 16px;
}

.compact-hero {
  padding: 14px;
}

.compact-hero .logo {
  width: 36px;
  height: 36px;
}

.hero h1,
.hero h2,
.section h2 {
  margin: 0 0 8px;
  font-size: clamp(20px, 5vw, 28px);
  letter-spacing: 0;
}

.hero p,
.section-lead {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
}

.eyebrow {
  display: inline-block;
  margin-bottom: 5px;
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 800;
}

.home-hero {
  border-color: #d9b98d;
  background: linear-gradient(145deg, #fffaf2 0%, #fff0d9 100%);
}

.home-primary-actions {
  display: grid;
  gap: 8px;
  margin-top: 16px;
}

.home-primary {
  width: 100%;
  min-height: 54px;
  font-size: 17px;
}

.home-reassurance {
  margin-top: 8px !important;
  font-size: 14px;
  text-align: center;
}

.urgent-home {
  margin: 0 0 10px;
}

.flow-help {
  display: grid;
  gap: 10px;
  margin: 0 0 12px;
  padding: 12px;
  border: 1px solid #d9b98d;
  border-radius: 8px;
  background: #fff8e8;
}

.flow-help-title {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 8px;
}

.flow-help-title strong,
.flow-help-title small {
  display: block;
}

.flow-help-title small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.flow-steps {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 4px;
}

.flow-step {
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 42px;
  padding: 4px 2px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.15;
  text-align: center;
}

.flow-step b {
  font-size: 12px;
}

.flow-step.current {
  border-color: var(--accent);
  background: var(--surface-strong);
  color: var(--accent-strong);
  font-weight: 800;
}

.mind-map-section {
  border-color: #d9b98d;
  background: #fffdf8;
}

.mind-diagram {
  position: relative;
  width: min(680px, 100%);
  height: 560px;
  margin: 18px auto 4px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: radial-gradient(circle at center, #fff0d9 0 18%, #fffdf8 40%, #f8f3eb 100%);
}

.mind-diagram-lines {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.mind-diagram-lines line {
  stroke: #b99269;
  stroke-width: 2;
  stroke-linecap: round;
}

.mind-diagram-lines circle {
  fill: #a35620;
}

.mind-diagram-center,
.mind-diagram-node {
  position: absolute;
  z-index: 1;
  display: grid;
  place-items: center;
  text-align: center;
}

.mind-diagram-center {
  left: 50%;
  top: 50%;
  width: 154px;
  min-height: 112px;
  padding: 12px;
  transform: translate(-50%, -50%);
  border: 3px solid var(--accent);
  border-radius: 50%;
  background: #fff7e9;
  box-shadow: 0 8px 20px rgba(77, 45, 23, 0.14);
}

.mind-diagram-center > span {
  font-size: 28px;
}

.mind-diagram-center small,
.mind-diagram-node small {
  color: var(--muted);
  line-height: 1.25;
}

.mind-diagram-node {
  width: 180px;
  min-height: 104px;
  padding: 10px;
  border: 2px solid #d8b990;
  border-radius: 50%;
  background: white;
  color: var(--text);
  box-shadow: 0 5px 14px rgba(77, 45, 23, 0.10);
}

.mind-diagram-node > span {
  font-size: 24px;
  line-height: 1;
}

.mind-diagram-node strong {
  font-size: 14px;
  line-height: 1.25;
}

.mind-diagram-node small {
  max-width: 145px;
  font-size: 11px;
}

.mind-diagram-node:hover,
.mind-diagram-node:focus-visible {
  border-color: var(--accent);
  background: #fff8ed;
}

.mind-node-1 { left: 3%; top: 2%; }
.mind-node-2 { right: 3%; top: 2%; }
.mind-node-3 { left: 1%; top: 38%; }
.mind-node-4 { right: 1%; top: 38%; }
.mind-node-5 { left: 7%; bottom: 2%; }
.mind-node-6 { right: 7%; bottom: 2%; }

.mind-diagram-help {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.mind-detail-list {
  margin-top: 14px;
}

.mind-map-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.mind-card {
  display: grid;
  gap: 8px;
  align-content: start;
  min-width: 0;
  padding: 12px;
  border: 2px solid var(--line);
  border-radius: 10px;
  background: white;
}

.mind-card h3,
.mind-card p {
  margin: 0;
}

.mind-card p {
  color: var(--text);
  line-height: 1.65;
  white-space: pre-wrap;
}

.mind-card.close {
  border-color: #6ca08a;
  background: #f2fbf7;
}

.mind-card.different {
  border-color: #c58a67;
  background: #fff5ef;
}

.mind-card.important {
  border-color: #d3a319;
  background: #fff9df;
}

.mind-review,
.review-key {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.mind-review {
  margin-top: auto;
  padding-top: 4px;
}

.review-button {
  min-height: 44px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: white;
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
}

.review-button.selected {
  border-color: var(--accent-strong);
  background: var(--accent-strong);
  color: white;
}

.review-key {
  margin-top: 10px;
  color: var(--muted);
  font-size: 14px;
}

.consultation-use > summary {
  color: var(--accent-strong);
}

.notice {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 12px;
  margin-bottom: 14px;
  color: var(--muted);
  box-shadow: none;
}

.compact-notice {
  padding: 10px;
  margin-bottom: 8px;
}

.notice strong {
  color: var(--text);
}

.notice.danger {
  background: var(--danger-bg);
  border-color: #f4b4ae;
  color: #7a271a;
}

.notice.danger strong {
  color: var(--danger);
}

.status-notice {
  background: #fff7dc;
  border-color: #e5c76d;
  color: #5d4710;
}

.grid {
  display: grid;
  gap: 12px;
}

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

.card,
.section {
  padding: 14px;
}

.section {
  margin: 14px 0;
}

.compact-details {
  padding: 0;
  overflow: hidden;
}

.compact-details > summary {
  display: grid;
  gap: 3px;
  min-height: 50px;
  padding: 13px 14px;
  cursor: pointer;
  color: var(--accent-strong);
  font-weight: 800;
  list-style-position: inside;
}

.compact-details > summary span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.45;
}

.compact-details[open] > summary {
  border-bottom: 1px solid var(--line);
}

.compact-details-body {
  display: grid;
  gap: 12px;
  padding: 12px 14px 14px;
}

.card h3,
.section h3 {
  margin: 0 0 8px;
  font-size: 17px;
}

.card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.action-row {
  width: 100%;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  min-height: 52px;
  padding: 13px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  text-align: left;
}

.action-row + .action-row {
  margin-top: 10px;
}

.action-row:hover,
.action-row:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.critical-action {
  background: #fff1ee;
  border-color: #f4b4ae;
}

.critical-action .row-title,
.critical-action .icon {
  color: var(--danger);
}

.icon {
  width: 32px;
  flex: 0 0 32px;
  color: var(--accent);
  font-size: 22px;
  text-align: center;
}

.row-title {
  display: block;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.row-subtitle {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.form-grid {
  display: grid;
  gap: 12px;
}

.personhood-fields {
  display: grid;
  gap: 12px;
  min-width: 0;
  margin: 2px 0;
  padding: 14px;
  border: 2px solid #d8b96f;
  border-radius: 10px;
  background: #fffbed;
}

.personhood-fields legend {
  padding: 0 7px;
  color: var(--accent-strong);
  font-weight: 800;
}

.personhood-fields > .hint {
  margin: -3px 0 2px;
}

.personhood-fields textarea {
  min-height: 125px;
}

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

.hint {
  color: var(--muted);
  font-size: 13px;
  font-weight: 400;
  line-height: 1.55;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: white;
  color: var(--text);
  font-size: 16px;
  line-height: 1.5;
  -webkit-appearance: none;
  appearance: none;
}

select {
  background-image:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position:
    calc(100% - 18px) 50%,
    calc(100% - 12px) 50%;
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  padding-right: 34px;
}

textarea {
  min-height: 170px;
  resize: vertical;
  line-height: 1.65;
}

textarea.free-output {
  min-height: 250px;
  background: #fffefb;
  border-color: #d9b98d;
  box-shadow: inset 0 0 0 1px rgba(163, 86, 32, 0.10);
}

.speech-input-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-top: -4px;
}

.speech-input-button.is-listening {
  background: var(--danger-bg);
  border-color: #f4b4ae;
  color: var(--danger);
}

.prompt-panel {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff7ea;
}

.input-supporter {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  margin: 4px 0;
  scroll-margin-top: 88px;
}

.supporter-avatar {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  border: 2px solid #d9b98d;
  border-radius: 50%;
  background: #fff1dc;
  font-size: 36px;
  box-shadow: 0 5px 12px rgba(77, 45, 23, 0.10);
}

.supporter-bubble {
  position: relative;
  display: grid;
  gap: 6px;
  min-width: 0;
  padding: 12px 14px;
  border: 2px solid #d9b98d;
  border-radius: 12px;
  background: #fffaf2;
}

.supporter-bubble::before {
  content: "";
  position: absolute;
  left: -10px;
  top: 20px;
  width: 16px;
  height: 16px;
  transform: rotate(45deg);
  border-left: 2px solid #d9b98d;
  border-bottom: 2px solid #d9b98d;
  background: #fffaf2;
}

.supporter-name {
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 800;
}

.supporter-bubble strong {
  line-height: 1.45;
}

.supporter-bubble p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

.supporter-examples {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 2px;
}

.supporter-example,
.supporter-skip {
  min-height: 42px;
  padding: 8px 10px;
  border: 1px solid #d9b98d;
  border-radius: 10px;
  background: white;
  color: var(--accent-strong);
  font-weight: 700;
  text-align: left;
}

.supporter-skip {
  justify-self: start;
  border-color: transparent;
  background: transparent;
  color: var(--muted);
  text-decoration: underline;
}

.result-supporter {
  margin-top: 14px;
}

.prompt-panel p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.output-promise,
.result-preview {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff7ea;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.output-promise span:first-child,
.result-preview span {
  color: var(--text);
}

.result-preview strong {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 3px 8px;
  border-radius: 999px;
  background: white;
  color: var(--accent-strong);
  font-size: 12px;
}

.prompt-group-grid {
  display: grid;
  gap: 10px;
}

.prompt-group {
  display: grid;
  gap: 6px;
}

.prompt-group-title {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.prompt-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.prompt-chip {
  min-height: 44px;
  padding: 9px 11px;
  border: 1px solid #d9b98d;
  border-radius: 999px;
  background: white;
  color: var(--accent-strong);
  font-weight: 700;
  text-align: left;
}

.mini-details {
  margin-top: 8px;
  border-top: 1px solid #f0ddc4;
}

.mini-details summary {
  min-height: 44px;
  padding: 10px 0;
  cursor: pointer;
  color: var(--accent-strong);
  font-weight: 800;
}

.mini-details .list {
  margin-top: 0;
}

.reference-links {
  display: grid;
  gap: 8px;
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
}

.reference-links li {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}

.reference-links a {
  color: var(--accent-strong);
  font-weight: 800;
  overflow-wrap: anywhere;
}

.reference-links span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.draft-notice {
  margin-top: 10px;
  background: #fff7dc;
  border-color: #e5c76d;
}

.extra-prompts {
  padding-top: 2px;
}

.optional-details {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffaf2;
}

.optional-details summary {
  min-height: 50px;
  padding: 13px 12px;
  cursor: pointer;
  font-weight: 700;
  color: var(--accent-strong);
}

.journal-step-indicator {
  display: grid;
  gap: 7px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff8ed;
}

.journal-step-indicator > div:first-child {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.journal-step-indicator span {
  color: var(--muted);
  font-size: 12px;
}

.journal-step-track {
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: #eadbc8;
}

.journal-step-track span {
  display: block;
  width: 25%;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 180ms ease;
}

.journal-step {
  display: grid;
  gap: 14px;
  scroll-margin-top: 90px;
}

.journal-step[hidden] {
  display: none;
}

.journal-step-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.optional-step-heading {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border-radius: 10px;
  background: #fff1dc;
}

.optional-step-heading > span {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: white;
  color: var(--accent-strong);
  font-size: 22px;
  font-weight: 800;
}

.optional-step-heading div {
  display: grid;
}

.optional-step-heading small {
  color: var(--muted);
}

.optional-fields {
  display: grid;
  gap: 12px;
  padding: 0 12px 12px;
}

.template-list {
  display: grid;
  gap: 8px;
}

.primary,
.secondary,
.danger-button {
  min-height: 48px;
  border-radius: 8px;
  padding: 10px 14px;
  border: 1px solid transparent;
  font-weight: 700;
}

.primary {
  background: var(--accent);
  color: white;
}

.secondary {
  background: var(--surface-strong);
  border-color: var(--line);
  color: var(--accent-strong);
}

.danger-button {
  background: var(--danger-bg);
  color: var(--danger);
  border-color: #f4b4ae;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

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

.note-card {
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}

.compact-details-body > .note-card {
  margin: 0;
}

.note-card h3 {
  margin: 0 0 6px;
  font-size: 16px;
}

.note-card p {
  margin: 6px 0 0;
  color: var(--muted);
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--surface-strong);
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 700;
}

.reply-line {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 8px;
  padding: 8px 0;
  border-top: 1px solid #f0ddc4;
}

.reply-line:first-child {
  border-top: 0;
}

.reply-title {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.reply-text {
  display: block;
  margin-top: 2px;
  line-height: 1.6;
}

.brief-card,
.original-note,
.carry-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}

.brief-card {
  margin-top: 12px;
  padding: 14px;
  border-color: #e6b16d;
  background: #fff8ec;
}

.brief-card p {
  margin: 5px 0 0;
  color: var(--text);
  font-size: 17px;
  font-weight: 800;
  line-height: 1.65;
}

.original-note {
  margin-top: 12px;
  padding: 12px;
}

.original-note p {
  margin: 5px 0 0;
  color: var(--text);
}

.carry-list {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.carry-item {
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: 10px;
  padding: 12px;
}

.carry-number {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 999px;
  background: var(--surface-strong);
  color: var(--accent-strong);
  font-size: 14px;
  font-weight: 800;
}

.list {
  margin: 8px 0 0;
  padding-left: 1.2em;
  line-height: 1.7;
}

.empty {
  padding: 24px 12px;
  color: var(--muted);
  text-align: center;
}

.resource-group {
  margin-top: 18px;
}

.resource-group h3 {
  margin: 0 0 4px;
}

.resource-group > p {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 13px;
}

.dialog-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: max(18px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right)) max(18px, env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left));
  background: rgba(34, 24, 17, 0.38);
}

.dialog {
  width: min(520px, 100%);
  max-height: min(720px, calc(100vh - 36px));
  max-height: min(720px, calc(100dvh - 36px));
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--surface);
  border-radius: 8px;
  padding: 18px;
  box-shadow: 0 20px 70px rgba(0, 0, 0, 0.28);
}

.dialog h2 {
  margin: 0 0 10px;
}

.dialog-header {
  position: sticky;
  top: -18px;
  z-index: 2;
  display: grid;
  grid-template-columns: 1fr 44px;
  gap: 10px;
  align-items: start;
  margin: -18px -18px 10px;
  padding: 16px 12px 8px 18px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.dialog-header h2 {
  margin: 0;
}

.dialog-close {
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: white;
  color: var(--text);
  font-size: 26px;
  line-height: 1;
}

.daily-check-card,
.journal-hero {
  border-color: #c9b8d8;
  background: linear-gradient(145deg, #fffaf2 0%, #f9f2ff 100%);
}

.today-glance,
.entry-glance {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 14px 0;
}

.today-glance span,
.entry-glance span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 42px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: white;
}

.scale-fieldset,
.sleep-fieldset {
  min-width: 0;
  margin: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf9;
}

.scale-fieldset legend,
.sleep-fieldset legend {
  padding: 0 6px;
  font-weight: 800;
}

.face-scale {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 6px;
  margin-top: 10px;
}

.face-choice {
  min-width: 0;
  cursor: pointer;
}

.face-choice input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
  pointer-events: none;
}

.face-choice-body {
  display: grid;
  place-items: center;
  min-height: 92px;
  padding: 7px 3px;
  border: 2px solid var(--line);
  border-radius: 10px;
  background: white;
  color: var(--muted);
  line-height: 1.15;
  text-align: center;
}

.face-choice-body .face {
  font-size: clamp(24px, 7vw, 36px);
  filter: grayscale(0.15);
}

.face-choice-body small {
  min-height: 24px;
  font-size: 10px;
}

.face-choice input:checked + .face-choice-body {
  border-color: var(--accent);
  background: var(--surface-strong);
  color: var(--accent-strong);
  box-shadow: 0 0 0 2px rgba(163, 86, 32, 0.16);
}

.face-choice input:focus-visible + .face-choice-body {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

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

.section-heading-row h2 {
  margin-bottom: 4px;
}

.compact-button {
  min-height: 40px;
  width: auto;
  padding: 7px 11px;
  white-space: nowrap;
}

.trend-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 14px 0;
}

.trend-summary > div {
  display: grid;
  gap: 2px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}

.trend-summary span,
.trend-summary small {
  color: var(--muted);
  font-size: 12px;
}

.mini-trend {
  display: grid;
  grid-template-columns: 100px 1fr;
  gap: 10px;
  align-items: end;
  margin-top: 12px;
}

.mini-trend > span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.mini-trend > div {
  display: flex;
  gap: 3px;
  align-items: end;
  min-height: 76px;
  padding: 6px 4px 0;
  border-bottom: 2px solid var(--line);
}

.trend-bar {
  display: grid;
  grid-template-rows: 56px auto;
  align-items: end;
  flex: 1;
  min-width: 20px;
  text-align: center;
}

.trend-bar i {
  display: block;
  height: var(--level);
  max-height: 56px;
  border-radius: 5px 5px 0 0;
  background: #b695c8;
}

.numeric-bar {
  position: relative;
  grid-template-rows: auto 56px auto;
}

.numeric-bar b {
  align-self: end;
  margin-bottom: 2px;
  color: var(--text);
  font-size: 9px;
  font-weight: 800;
}

.numeric-bar i {
  background: #6f9c83;
}

.trend-bar small {
  color: var(--muted);
  font-size: 9px;
}

.timeline-list {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.timeline-card {
  position: relative;
  padding: 14px;
  border: 1px solid var(--line);
  border-left: 5px solid #b695c8;
  border-radius: 8px;
  background: white;
}

.timeline-date {
  font-weight: 800;
}

.timeline-card > p {
  margin: 9px 0;
}

.personhood-line {
  display: flex;
  gap: 8px;
  color: var(--muted);
}

.journal-detail {
  margin: 10px 0 0;
  padding: 12px;
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  line-height: 1.6;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.timeline-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-top: 12px;
}

.lab-fieldset {
  min-width: 0;
  margin: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfaf7;
}

.lab-fieldset legend {
  padding: 0 6px;
  font-weight: 800;
}

.lab-rows,
.lab-trend-list {
  display: grid;
  gap: 10px;
}

.lab-row {
  display: grid;
  grid-template-columns: minmax(180px, 2fr) minmax(90px, 1fr) minmax(110px, 1fr) minmax(130px, 1.2fr) auto;
  gap: 8px;
  align-items: end;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}

.lab-row label {
  gap: 4px;
  font-size: 12px;
}

.lab-row input {
  min-width: 0;
}

.lab-trend {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}

.lab-trend summary {
  cursor: pointer;
  font-weight: 800;
}

.lab-glance {
  display: flex;
  gap: 8px;
  color: var(--muted);
}

.text-danger {
  min-height: 40px;
  padding: 6px 10px;
  border: 0;
  background: transparent;
  color: var(--danger);
  font-weight: 700;
}

.personhood-change p {
  padding: 10px 12px;
  border-left: 4px solid #8bb89a;
  border-radius: 6px;
  background: #f3fbf5;
}

.month-organize-card {
  border-color: #b9d4c2;
  background: linear-gradient(145deg, #f3fbf5, #fffdf8);
}

.month-organize-card .primary {
  margin-top: 8px;
}

.empty-journal {
  text-align: center;
}

.empty-icon {
  display: block;
  margin-bottom: 4px;
  font-size: 42px;
}

.form-error {
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--danger-bg);
  color: var(--danger);
  font-weight: 700;
}

.hidden {
  display: none !important;
}

@media (min-width: 860px) {
  .app-shell {
    grid-template-columns: 248px 1fr;
    grid-template-rows: auto 1fr;
  }

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

  .main {
    padding-bottom: 32px;
  }

  .tabs {
    position: sticky;
    top: 71px;
    align-self: start;
    height: calc(100vh - 71px);
    height: calc(100dvh - 71px);
    grid-template-columns: 1fr;
    grid-template-rows: repeat(5, min-content);
    padding: 18px;
    border-top: 0;
    border-right: 1px solid var(--line);
  }

  .tab {
    grid-template-columns: 28px 1fr;
    justify-items: start;
    min-height: 48px;
    padding: 0 12px;
    font-size: 14px;
  }
}

@media (max-width: 360px) {
  .brand-title {
    font-size: 16px;
  }

  .brand-subtitle {
    font-size: 11px;
  }

  .tab {
    font-size: 11px;
  }

  .tab span:first-child {
    font-size: 18px;
  }
}

@media (max-width: 520px) {
  .topbar {
    gap: 10px;
    padding-left: max(12px, env(safe-area-inset-left));
    padding-right: max(12px, env(safe-area-inset-right));
  }

  .logo {
    width: 38px;
    height: 38px;
    border-radius: 8px;
  }

  .main {
    padding-top: 12px;
    padding-left: max(12px, env(safe-area-inset-left));
    padding-right: max(12px, env(safe-area-inset-right));
  }

  .brand-subtitle,
  .row-subtitle {
    display: none;
  }

  .start-action .row-subtitle,
  .critical-action .row-subtitle {
    display: block;
  }

  .hero,
  .section {
    padding: 13px;
  }

  .hero,
  .section,
  .notice {
    margin-bottom: 10px;
  }

.hero h1,
.hero h2,
.section h2 {
    font-size: 20px;
  }

  .action-row {
    align-items: center;
    min-height: 48px;
    padding: 11px 12px;
  }

  .icon {
    width: 28px;
    flex-basis: 28px;
    font-size: 20px;
  }

  textarea {
    min-height: 130px;
  }

  textarea.free-output {
    min-height: 190px;
  }

  .prompt-grid {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 4px;
    scroll-snap-type: x proximity;
  }

  .prompt-group-grid {
    gap: 12px;
  }

  .prompt-chip {
    flex: 0 0 auto;
    max-width: 270px;
    scroll-snap-align: start;
  }

  .input-supporter {
    grid-template-columns: 46px minmax(0, 1fr);
    gap: 9px;
  }

  .supporter-avatar {
    width: 46px;
    height: 46px;
    font-size: 26px;
  }

  .supporter-bubble {
    padding: 10px;
  }

  .supporter-bubble::before {
    top: 14px;
  }

  .supporter-examples {
    display: grid;
  }

  .supporter-example {
    width: 100%;
  }

  .grid.two {
    grid-template-columns: minmax(0, 1fr);
  }

  .mind-map-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .mind-diagram {
    height: 580px;
    border-radius: 12px;
  }

  .mind-diagram-center {
    width: 126px;
    min-height: 100px;
    padding: 8px;
  }

  .mind-diagram-center small {
    font-size: 10px;
  }

  .mind-diagram-node {
    width: 42%;
    min-height: 100px;
    padding: 7px;
  }

  .mind-diagram-node > span {
    font-size: 21px;
  }

  .mind-diagram-node strong {
    font-size: 12px;
  }

  .mind-diagram-node small {
    max-width: 120px;
    font-size: 9px;
  }

  .mind-node-1 { left: 1%; }
  .mind-node-2 { right: 1%; }
  .mind-node-3 { left: 0; }
  .mind-node-4 { right: 0; }
  .mind-node-5 { left: 3%; }
  .mind-node-6 { right: 3%; }

  .flow-step {
    font-size: 10px;
  }

  .button-row {
    display: grid;
  }

  .journal-step-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .journal-step-actions > *:last-child:nth-child(3) {
    grid-column: 1 / -1;
  }

  .final-step-actions .primary {
    grid-column: auto;
  }

  .face-scale {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .face-choice-body {
    min-height: 84px;
  }

  .trend-summary {
    grid-template-columns: minmax(0, 1fr);
  }

  .mini-trend {
    grid-template-columns: 1fr;
  }

  .lab-row {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }

  .lab-row label:first-child,
  .lab-row .text-danger {
    grid-column: 1 / -1;
  }

  .section-heading-row {
    flex-wrap: wrap;
  }

  .section-heading-row .compact-button {
    width: auto;
  }

  .timeline-actions .secondary {
    width: auto;
  }

  .primary,
  .secondary,
  .danger-button,
  a.primary {
    width: 100%;
  }
}

@media (max-height: 600px) {
  .topbar {
    padding-top: calc(8px + env(safe-area-inset-top));
    padding-bottom: 8px;
  }

  .topbar .logo {
    width: 32px;
    height: 32px;
  }

  .brand-subtitle {
    display: none;
  }

  .main {
    padding-top: 8px;
  }
}

@media (orientation: landscape) and (max-height: 500px) and (max-width: 859px) {
  :root {
    --bottom-nav-height: 58px;
  }

  .tabs {
    padding-top: 4px;
    padding-bottom: calc(4px + env(safe-area-inset-bottom));
  }

  .tab {
    min-height: 48px;
    grid-template-columns: 24px auto;
    justify-content: center;
  }

  .tab span:first-child {
    font-size: 18px;
  }
}

@media (display-mode: standalone) {
  .brand-subtitle {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

@media (prefers-contrast: more) {
  :root {
    --bg: #fff8ed;
    --surface: #ffffff;
    --surface-strong: #ffdfad;
    --line: #8a5a2b;
    --text: #1f130c;
    --muted: #4d3828;
    --accent: #873d0d;
    --accent-strong: #642a06;
    --focus: #004f9f;
  }

  .hero,
  .card,
  .notice,
  .section,
  .action-row,
  .note-card,
  input,
  select,
  textarea {
    border-width: 2px;
  }
}

@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .topbar,
  .tabs {
    background: var(--surface);
  }
}
