:root {
  color-scheme: light;
  --bg: #f7fbf8;
  --surface: #ffffff;
  --surface-soft: #eef7f0;
  --ink: #17352d;
  --muted: #65756f;
  --line: #dce9e2;
  --green: #2f7d5f;
  --green-soft: #dff1e7;
  --blue: #327aa6;
  --blue-soft: #e2f1f7;
  --coral: #e96b5d;
  --coral-soft: #ffe8e4;
  --shadow: 0 16px 44px rgba(28, 80, 60, 0.12);
  --ui-font: "Microsoft YaHei UI", Meiryo, "Yu Gothic", "Noto Sans JP", "Noto Sans SC", system-ui, sans-serif;
  --latin-font: Inter, Arial, Helvetica, system-ui, sans-serif;
  font-family: var(--ui-font);
  font-size: 16px;
}

:root[lang="ja"],
:root[lang="zh-CN"] {
  font-family: var(--ui-font);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(226, 241, 247, 0.8), rgba(247, 251, 248, 0) 280px),
    var(--bg);
  color: var(--ink);
}

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

button {
  cursor: pointer;
  white-space: nowrap;
}

button:disabled {
  cursor: wait;
  opacity: 0.68;
}

.app-shell {
  width: min(100%, 920px);
  margin: 0 auto;
  min-height: 100svh;
  padding: 12px 14px 24px;
}

.app-shell.has-app-nav {
  padding-bottom: 96px;
  font-family: var(--ui-font);
}

.auth-screen {
  min-height: calc(100svh - 24px);
  display: grid;
  align-content: center;
  gap: 10px;
}

.brand-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 4px 2px;
}

.brand-identity {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 48px;
  height: 48px;
  flex: 0 0 48px;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.brand-mark svg {
  width: 100%;
  height: 100%;
  display: block;
}

.brand-mark rect {
  fill: var(--green);
}

.brand-mark path {
  fill: var(--bg);
  opacity: 0.95;
}

.brand-mark text {
  fill: white;
  font-family: "Noto Sans JP", "Hiragino Kaku Gothic ProN", "Yu Gothic", Meiryo, sans-serif;
  font-size: 48px;
  font-weight: 800;
}

.brand-mark circle {
  fill: var(--coral);
}

.brand-panel h1,
.mini-label {
  font-family: var(--latin-font);
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 1.5rem;
  line-height: 1.2;
  letter-spacing: 0;
}

h2 {
  font-size: 1.28rem;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

h3 {
  font-size: 1rem;
  line-height: 1.35;
}

p {
  color: var(--muted);
  line-height: 1.65;
}

.auth-card,
.selected-adventure,
.evidence-panel,
.review-card,
.bank-panel,
.history-list,
.memory-list,
.world-panel,
.empty-state {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.auth-card {
  position: relative;
  display: grid;
  gap: 9px;
  padding: 14px;
  min-width: 0;
  height: min(505px, calc(100svh - 76px));
  grid-template-rows: auto auto minmax(0, 1fr);
}

.auth-content {
  min-height: 0;
  overflow-y: hidden;
  display: grid;
  align-content: start;
  gap: 8px;
}

.auth-content > h2 {
  min-height: 1.35em;
  font-size: 1.16rem;
  line-height: 1.25;
}

.auth-steps {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.auth-mode {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.auth-mode button {
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  font-weight: 900;
}

.auth-mode button.active {
  color: white;
  border-color: var(--green);
  background: var(--green);
}

.auth-steps span {
  height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  line-height: 1;
  padding: 4px 6px;
  text-align: center;
  overflow: hidden;
  white-space: nowrap;
}

.auth-steps span.active {
  color: white;
  border-color: var(--green);
  background: var(--green);
}

.auth-steps-placeholder {
  visibility: hidden;
  pointer-events: none;
}

.auth-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.auth-actions .primary-action:only-child {
  grid-column: 1 / -1;
}

.auth-explain {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  padding: 12px;
  display: grid;
  gap: 4px;
}

.auth-note {
  font-size: 0.82rem;
  line-height: 1.45;
}

.locale-row {
  display: grid;
  grid-template-columns: repeat(2, 56px);
  gap: 6px;
  justify-content: flex-end;
  align-items: center;
}

.locale-row button {
  width: 56px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  padding: 0;
  display: grid;
  place-items: center;
  line-height: 1;
  white-space: nowrap;
  font-weight: 800;
}

.locale-row button.active {
  background: var(--green);
  color: white;
  border-color: var(--green);
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 700;
}

label > span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.auth-card label {
  gap: 4px;
  font-size: 0.84rem;
  line-height: 1.2;
}

.auth-card input,
.auth-card select {
  min-height: 38px;
  padding: 7px 11px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfefd;
  color: var(--ink);
  min-height: 42px;
  padding: 9px 12px;
}

textarea {
  resize: vertical;
}

fieldset {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  display: grid;
  gap: 8px;
}

legend {
  color: var(--muted);
  font-weight: 800;
  padding: 0 6px;
}

.radio-line {
  display: flex;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 8px;
  font-weight: 600;
}

.check-line {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
}

.check-line input {
  width: auto;
  min-height: auto;
}

.radio-line input,
.media-toggle input {
  width: auto;
  min-height: auto;
}

.primary-action,
.secondary-action,
.adventure-row button {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  padding: 10px 14px;
  font-weight: 800;
}

.auth-card .primary-action,
.auth-card .secondary-action {
  min-height: 40px;
  padding: 8px 12px;
}

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

.secondary-action {
  background: var(--surface-soft);
  color: var(--green);
}

.form-error,
.toast {
  background: var(--coral-soft);
  color: #8b3029;
  border-radius: 8px;
  padding: 10px 12px;
  font-weight: 700;
}

.top-bar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 6px 2px 14px;
}

.top-bar > div:first-child {
  min-width: 0;
}

.top-bar h1 {
  font-size: 1.2rem;
  line-height: 1.2;
  min-height: 1.25em;
  white-space: nowrap;
  overflow: hidden;
}

.top-actions {
  display: grid;
  justify-items: end;
  gap: 8px;
  flex: 0 0 auto;
}

.app-locale-row {
  justify-content: end;
}

.mini-label {
  color: var(--green);
  font-weight: 800;
  font-size: 0.8rem;
  line-height: 1.2;
}

.status-pill {
  white-space: nowrap;
  border-radius: 8px;
  padding: 8px 10px;
  background: var(--green-soft);
  color: var(--green);
  font-size: 0.78rem;
  font-weight: 900;
}

.main-grid {
  display: grid;
  gap: 14px;
}

.main-grid > section,
.review-card,
.bank-panel,
.family-panel,
.family-task-panel,
.mutual-aid-panel,
.history-list,
.memory-list,
.world-panel,
.empty-state {
  min-width: 0;
}

.profile-strip {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
}

.profile-strip > div:first-child {
  min-width: 0;
}

.profile-strip span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.profile-strip strong {
  display: block;
  margin-top: 3px;
  overflow-wrap: anywhere;
}

.profile-strip select {
  max-width: 42%;
}

.profile-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex: 0 0 auto;
}

.profile-logout {
  min-height: 34px;
  border: 0;
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--green);
  padding: 7px 10px;
  font-size: 0.78rem;
  font-weight: 900;
  white-space: nowrap;
}

.section-head {
  display: grid;
  gap: 7px;
  padding: 4px 2px;
}

.section-head h2,
.review-card h2,
.bank-panel h2,
.family-panel h3,
.history-list h3,
.section-title-row h3,
.world-panel h2,
.empty-state h2 {
  min-height: 1.35em;
}

.section-head p,
.review-card > p,
.section-title-row p,
.family-task-row p,
.mutual-aid-row p,
.memory-row p,
.world-panel p,
.empty-state p,
.ai-note p {
  min-height: 1.65em;
}

.selected-adventure {
  display: grid;
  grid-template-columns: 1fr 112px;
  gap: 12px;
  padding: 14px;
  overflow: hidden;
  min-height: 168px;
}

.selected-adventure > div,
.adventure-row > div {
  min-width: 0;
}

.selected-adventure span,
.adventure-row span,
.review-card span {
  color: var(--green);
  font-size: 0.78rem;
  font-weight: 900;
}

.selected-adventure h3 {
  margin-top: 6px;
  font-size: 1.12rem;
  line-height: 1.34;
  min-height: 2.68em;
}

.selected-adventure p {
  margin-top: 8px;
  line-height: 1.55;
  min-height: 4.65em;
}

.selected-adventure img {
  width: 112px;
  height: 112px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--line);
}

.adventure-list,
.memory-list {
  display: grid;
  gap: 10px;
}

.adventure-row,
.memory-row,
.history-row {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.adventure-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 84px;
  align-items: center;
  gap: 12px;
  padding: 13px;
  min-height: 124px;
}

.adventure-row.selected {
  border-color: var(--green);
  background: linear-gradient(180deg, #ffffff, #f2fbf5);
}

.adventure-row p {
  margin-top: 4px;
  line-height: 1.5;
  min-height: 3em;
}

.adventure-row button {
  width: 100%;
  min-height: 44px;
  background: var(--green-soft);
  color: var(--green);
}

.adventure-row h3 {
  font-size: 0.98rem;
  line-height: 1.34;
  min-height: 2.7em;
}

.review-log-row > div,
.family-task-row > div,
.mutual-aid-row > div,
.member-row > div,
.history-row span,
.memory-row,
.world-panel {
  min-width: 0;
}

.review-card h3,
.review-log-row strong,
.family-task-row h4,
.mutual-aid-row h4,
.member-row strong,
.history-row span,
.memory-row h3,
.world-panel strong {
  min-height: 1.35em;
}

.evidence-panel,
.review-card,
.bank-panel,
.empty-state {
  display: grid;
  gap: 13px;
  padding: 15px;
}

.media-toggle {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.media-toggle label {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfefd;
  min-height: 42px;
}

.ai-note {
  padding: 12px;
  background: var(--blue-soft);
  border-radius: 8px;
}

.ai-note strong {
  color: var(--blue);
}

.inline-note {
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--green);
  padding: 10px 12px;
  font-weight: 800;
}

.button-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.review-history {
  display: grid;
  gap: 10px;
  padding: 14px;
}

.review-log-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfefd;
  padding: 11px 12px;
}

.review-log-row span {
  display: block;
  margin-bottom: 3px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.big-number {
  font-size: 2.7rem;
  line-height: 1;
  color: var(--green);
  font-weight: 900;
}

.spend-form {
  display: grid;
  gap: 10px;
}

.spend-form input[type="number"] {
  appearance: textfield;
}

.family-task-panel,
.mutual-aid-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 14px;
  display: grid;
  gap: 12px;
}

.section-title-row h3,
.section-title-row p {
  margin: 0;
}

.section-title-row p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 750;
}

.family-task-form,
.family-task-list,
.mutual-aid-form,
.mutual-aid-list {
  display: grid;
  gap: 10px;
}

.family-task-row,
.mutual-aid-row {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfefd;
  padding: 12px;
  display: grid;
  gap: 10px;
}

.family-task-row span,
.mutual-aid-row span {
  color: var(--green);
  font-size: 0.78rem;
  font-weight: 900;
}

.family-task-row h4,
.family-task-row p,
.mutual-aid-row h4,
.mutual-aid-row p {
  margin: 0;
}

.family-task-row p,
.mutual-aid-row p {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 800;
}

.progress-track {
  width: 100%;
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-soft);
}

.progress-fill {
  height: 100%;
  border-radius: inherit;
  background: var(--green);
}

.family-task-contribute {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(132px, auto);
  gap: 8px;
}

.mutual-aid-submit {
  display: grid;
  gap: 8px;
}

.history-list {
  padding: 14px;
  display: grid;
  gap: 10px;
}

.family-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 14px;
  display: grid;
  gap: 12px;
}

.member-list,
.add-member-form {
  display: grid;
  gap: 10px;
}

.member-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfefd;
  padding: 11px 12px;
}

.member-row span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.add-member-form {
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.compact-head {
  padding-top: 8px;
}

.history-row,
.memory-row {
  padding: 12px;
}

.history-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.memory-row {
  display: grid;
  gap: 6px;
}

.memory-row time {
  color: var(--blue);
  font-size: 0.78rem;
  font-weight: 900;
}

.world-panel {
  display: grid;
  gap: 12px;
  padding: 15px;
}

.world-panel img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--line);
}

.world-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.world-stats span {
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--green);
  padding: 9px 8px;
  text-align: center;
  font-weight: 900;
  font-size: 0.78rem;
}

.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  transform: none;
  width: 100%;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
  padding: 7px max(10px, env(safe-area-inset-left)) calc(7px + env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-right));
  border: 1px solid var(--line);
  border-width: 1px 0 0;
  border-radius: 0;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 -10px 30px rgba(28, 80, 60, 0.08);
  backdrop-filter: blur(12px);
}

.bottom-nav button {
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  height: 50px;
  display: grid;
  grid-template-rows: 18px 18px;
  place-items: center;
  align-content: center;
  gap: 2px;
  font-size: 0.72rem;
  font-weight: 800;
}

.nav-icon {
  width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
}

.nav-icon svg {
  width: 18px;
  height: 18px;
  display: block;
  stroke: currentColor;
  stroke-width: 2.2;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.bottom-nav button > span:last-child {
  line-height: 1;
  white-space: nowrap;
}

.bottom-nav button.active {
  background: var(--green);
  color: white;
}

@media (min-width: 760px) {
  .app-shell {
    padding: 26px 24px 104px;
  }

  .app-shell.has-app-nav {
    width: min(100%, 920px);
    display: grid;
    grid-template-rows: auto auto auto;
    grid-template-areas:
      "header"
      "nav"
      "main";
    align-items: start;
    align-content: start;
    gap: 14px;
    padding-bottom: 42px;
  }

  .has-app-nav .top-bar {
    grid-area: header;
    padding-top: 0;
  }

  .top-bar h1 {
    font-size: 1.5rem;
    line-height: 1.2;
  }

  .has-app-nav .main-grid {
    grid-area: main;
  }

  .has-app-nav .bottom-nav {
    grid-area: nav;
    position: static;
    left: auto;
    bottom: auto;
    transform: none;
    width: 100%;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    align-self: start;
    padding: 8px;
    gap: 6px;
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: none;
    backdrop-filter: none;
  }

  .has-app-nav .bottom-nav button {
    height: 48px;
    grid-template-columns: 22px auto;
    grid-template-rows: 1fr;
    justify-content: center;
    justify-items: center;
    align-content: center;
    gap: 8px;
    padding: 0 12px;
    font-size: 0.86rem;
  }

  .auth-screen {
    grid-template-columns: 0.85fr 1.15fr;
    align-items: center;
    column-gap: 42px;
  }

  .brand-panel {
    justify-content: flex-start;
  }

  .brand-panel > .auth-locale-row {
    position: absolute;
    top: 40px;
    right: 38px;
    z-index: 1;
  }

  .auth-card {
    padding-top: 64px;
  }

  .main-grid {
    grid-template-columns: 1.1fr 0.9fr;
    align-items: start;
  }

  .profile-strip,
  .toast,
  .section-head,
  .selected-adventure,
  .adventure-list,
  .evidence-panel {
    grid-column: 1 / -1;
  }

  .adventure-row {
    grid-template-columns: minmax(0, 1fr) 190px;
    align-items: center;
  }
}
