:root {
  --bg: #fff5f7;
  --bg2: #fff0e8;
  --surface: #ffffff;
  --ink: #4a3540;
  --muted: #9a7f8a;
  --accent: #fb8a9a;
  --accent-soft: #ffe4ea;
  --accent-deep: #e05a6f;
  --peach: #ffb38a;
  --peach-soft: #fff0e6;
  --lavender: #c4b5fd;
  --lavender-soft: #f3eefe;
  --sky: #7dd3fc;
  --sky-soft: #e0f5ff;
  --ok: #34d399;
  --ok-soft: #d1fae5;
  --ok-deep: #059669;
  --undo: #a78bfa;
  --undo-soft: #ede9fe;
  --undo-deep: #7c3aed;
  --border: #f8dfe6;
  --shadow: 0 10px 28px rgba(180, 100, 120, 0.1);
  --shadow-soft: 0 4px 14px rgba(180, 100, 120, 0.07);
  --radius: 22px;
  --radius-sm: 16px;
  --font: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP",
    "Yu Gothic", Meiryo, sans-serif;
  /* Soft polka-dot pattern */
  --pattern-dots: radial-gradient(circle, rgba(251, 138, 154, 0.18) 1.4px, transparent 1.6px);
  --pattern-dots-size: 14px 14px;
  /* Soft diagonal stripes */
  --pattern-stripes: repeating-linear-gradient(
    -45deg,
    rgba(255, 179, 138, 0.12) 0 6px,
    transparent 6px 14px
  );
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background-color: var(--bg);
  background-image:
    var(--pattern-dots),
    radial-gradient(ellipse 80% 50% at 10% -10%, #ffe4ec 0%, transparent 55%),
    radial-gradient(ellipse 70% 45% at 100% 0%, #fff3e0 0%, transparent 50%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg2) 100%);
  background-size:
    var(--pattern-dots-size),
    auto,
    auto,
    auto;
  background-attachment: fixed;
  color: var(--ink);
  font-family: var(--font);
  -webkit-tap-highlight-color: transparent;
}

body {
  padding: 12px 12px 36px;
}

.app {
  max-width: 420px;
  margin: 0 auto;
  min-height: calc(100vh - 24px);
}

.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
  padding: 10px 12px 10px;
  border-radius: var(--radius);
  position: relative;
  overflow: hidden;
}

.topbar.patterned {
  background:
    var(--pattern-stripes),
    linear-gradient(135deg, #fff 0%, var(--accent-soft) 100%);
  border: 1.5px solid var(--border);
  box-shadow: var(--shadow-soft);
}

.topbar h1 {
  font-size: 1.3rem;
  margin: 0;
  letter-spacing: 0.03em;
  font-weight: 800;
  position: relative;
  z-index: 1;
}

.topbar .sub {
  margin: 3px 0 0;
  font-size: 0.78rem;
  color: var(--muted);
  position: relative;
  z-index: 1;
}

.back-btn {
  border: none;
  background: var(--surface);
  width: 42px;
  height: 42px;
  border-radius: 14px;
  box-shadow: var(--shadow-soft);
  border: 1.5px solid var(--border);
  font-size: 1.1rem;
  cursor: pointer;
  color: var(--ink);
  flex-shrink: 0;
  transition: transform 0.12s ease;
  position: relative;
  z-index: 1;
}

.back-btn:active {
  transform: scale(0.95);
}

.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1.5px solid var(--border);
  padding: 16px;
  margin-bottom: 12px;
  position: relative;
  overflow: hidden;
}

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

.child-card {
  text-align: left;
  border: 1.5px solid var(--border);
  background:
    var(--pattern-dots),
    var(--surface);
  background-size: var(--pattern-dots-size), auto;
  border-radius: var(--radius);
  padding: 18px 14px 16px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
  font: inherit;
  color: inherit;
  position: relative;
  overflow: hidden;
}

.child-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 10px;
  background: var(--pattern-stripes);
  opacity: 0.9;
  pointer-events: none;
}

.child-card::after {
  content: "";
  position: absolute;
  top: -18px;
  right: -18px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--accent-soft);
  opacity: 0.7;
  pointer-events: none;
}

.child-card:nth-child(2)::after {
  background: var(--sky-soft);
}

.child-card:nth-child(3)::after {
  background: var(--lavender-soft);
}

.child-card:nth-child(4)::after {
  background: var(--peach-soft);
}

.child-card:active {
  transform: scale(0.97);
}

.child-card.inactive {
  opacity: 0.42;
  filter: grayscale(0.3);
  cursor: default;
  box-shadow: none;
}

.child-card.inactive::after,
.child-card.inactive::before {
  display: none;
}

.child-card .emoji {
  font-size: 1.75rem;
  display: block;
  margin-bottom: 8px;
  position: relative;
  z-index: 1;
}

.child-card .name {
  font-size: 1.15rem;
  font-weight: 800;
  margin: 0 0 4px;
  position: relative;
  z-index: 1;
}

.child-card .points {
  font-size: 0.92rem;
  color: var(--accent-deep);
  font-weight: 700;
  position: relative;
  z-index: 1;
}

.child-card .bonus-mini {
  margin: 2px 0 0;
  font-size: 0.7rem;
  font-weight: 700;
  color: #b45309;
  position: relative;
  z-index: 1;
}

.child-card .open-count {
  margin-top: 10px;
  font-size: 0.75rem;
  color: var(--muted);
  position: relative;
  z-index: 1;
}

.badge {
  display: inline-block;
  font-size: 0.7rem;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-deep);
  font-weight: 700;
}

.badge.school { background: #dbeafe; color: #1d4ed8; }
.badge.juku { background: #fce7f3; color: #be185d; }
.badge.self { background: #d1fae5; color: #047857; }
.badge.other { background: #f3f4f6; color: #4b5563; }

.points-panel {
  display: flex;
  gap: 10px;
  align-items: stretch;
  margin-bottom: 14px;
}

.points-panel .stat {
  flex: 1;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1.5px solid var(--border);
  padding: 14px;
  box-shadow: var(--shadow-soft);
  position: relative;
  overflow: hidden;
}

.points-panel .stat:first-child {
  background:
    var(--pattern-dots),
    linear-gradient(160deg, #fff 0%, var(--accent-soft) 140%);
  background-size: var(--pattern-dots-size), auto;
}

.points-panel .label {
  font-size: 0.72rem;
  color: var(--muted);
  margin: 0 0 4px;
  font-weight: 600;
}

.points-panel .value {
  font-size: 1.4rem;
  font-weight: 800;
  margin: 0;
  color: var(--accent-deep);
}

.bonus-badge {
  display: inline-block;
  margin-top: 6px;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  background: #fef3c7;
  color: #b45309;
}

.progress-bar {
  height: 12px;
  background: #fce7f0;
  border-radius: 999px;
  overflow: hidden;
  margin-top: 8px;
  border: 1px solid #f9d0de;
}

.progress-bar > span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #fda4af, #fb8a9a 50%, #ffb38a);
  border-radius: 999px;
  transition: width 0.25s ease;
}

.progress-bar.today-bar {
  height: 8px;
  margin-top: 4px;
  background: #fff0e6;
  border-color: #ffd8b8;
}

.progress-bar.today-bar > span {
  background: linear-gradient(90deg, #fbbf24, #fb923c);
}

/* —— 今日の予定 —— */
.today-plan {
  background:
    var(--pattern-stripes),
    linear-gradient(160deg, #fff 0%, #fff7ed 100%);
  margin-bottom: 14px;
}

.today-plan-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.today-plan-header h2 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 800;
}

.today-plan-total {
  font-size: 0.9rem;
  font-weight: 800;
  color: #c2410c;
  background: #ffedd5;
  padding: 3px 10px;
  border-radius: 999px;
}

.today-plan-row {
  margin-bottom: 10px;
}

.today-plan-row:last-of-type {
  margin-bottom: 6px;
}

.today-plan-row-main {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}

.today-plan-name {
  font-size: 0.85rem;
  font-weight: 700;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.today-plan-count {
  font-size: 0.8rem;
  font-weight: 800;
  color: #c2410c;
  flex-shrink: 0;
}

.today-plan-count em {
  font-style: normal;
  color: #059669;
  font-size: 0.75rem;
}

.today-plan-empty {
  margin: 0 0 8px;
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.5;
  text-align: center;
}

.bonus-note {
  margin: 8px 0 0;
  font-size: 0.72rem;
  font-weight: 700;
  color: #b45309;
  text-align: center;
  background: #fef3c7;
  border-radius: 999px;
  padding: 5px 10px;
}

.today-target-edit {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
  padding: 10px 10px;
  background:
    var(--pattern-dots),
    var(--peach-soft);
  background-size: 12px 12px, auto;
  border-radius: var(--radius-sm);
  border: 1px solid #ffd8b8;
}

.today-target-label {
  font-size: 0.75rem;
  font-weight: 800;
  color: #9a3412;
}

.today-done-pill {
  font-size: 0.72rem;
  font-weight: 700;
  color: #9a3412;
  margin-left: auto;
}

.today-done-pill.static {
  display: inline-block;
  margin: 10px 0 0;
  padding: 4px 10px;
  background: var(--peach-soft);
  border-radius: 999px;
}

.stepper.mini {
  gap: 6px;
  margin: 0;
}

.stepper.mini button {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  font-size: 1.1rem;
  background: #fff;
  border: 1.5px solid #ffd8b8;
  color: #c2410c;
}

.stepper.mini .count {
  font-size: 1.1rem;
  min-width: 28px;
}

.card-pattern-strip {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 8px;
  background: var(--pattern-stripes);
  pointer-events: none;
}

.assignment {
  margin-bottom: 12px;
  position: relative;
  padding-top: 20px;
}

.assignment.done-card {
  opacity: 0.88;
  background: linear-gradient(160deg, #fff 0%, var(--ok-soft) 160%);
}

.assignment .row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  flex-wrap: wrap;
}

.assignment .title {
  font-weight: 800;
  font-size: 1.02rem;
  margin: 8px 0 4px;
  line-height: 1.35;
}

.assignment .meta {
  font-size: 0.8rem;
  color: var(--muted);
  margin: 0 0 10px;
  line-height: 1.5;
}

.assignment .progress-text {
  font-size: 0.85rem;
  font-weight: 700;
  margin-bottom: 6px;
  color: var(--ink);
}

.btn-row {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.btn {
  border: none;
  border-radius: var(--radius-sm);
  padding: 13px 12px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  flex: 1;
  transition: transform 0.1s ease, opacity 0.15s ease;
}

.btn:active:not(:disabled) {
  transform: scale(0.97);
}

.btn-primary {
  background: linear-gradient(180deg, #fda4af, #fb7185);
  color: #5c1020;
  box-shadow: 0 5px 14px rgba(251, 113, 133, 0.35);
}

.btn-primary:disabled {
  opacity: 0.4;
  cursor: default;
  box-shadow: none;
}

.btn-undo {
  background: var(--undo-soft);
  color: var(--undo-deep);
  border: 1.5px solid #ddd6fe;
  box-shadow: none;
  flex: 0.85;
}

.btn-undo:disabled {
  opacity: 0.35;
  cursor: default;
}

.btn-secondary {
  background: var(--accent-soft);
  color: var(--accent-deep);
}

.btn-ghost {
  background: #fff;
  border: 1.5px solid var(--border);
  color: var(--ink);
}

.fab-area {
  margin-top: 10px;
}

.empty {
  text-align: center;
  color: var(--muted);
  padding: 32px 12px;
  font-size: 0.95rem;
  line-height: 1.6;
}

.chip-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 14px;
}

.chip-grid.cols-3 {
  grid-template-columns: 1fr 1fr 1fr;
}

.chip {
  border: 2px solid var(--border);
  background: #fff;
  border-radius: var(--radius-sm);
  padding: 14px 8px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  color: var(--ink);
  transition: transform 0.1s ease, border-color 0.15s ease;
}

.chip:active {
  transform: scale(0.97);
}

.chip.selected {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-deep);
  box-shadow: 0 2px 8px rgba(251, 138, 154, 0.2);
}

.chip.inactive-child {
  opacity: 0.4;
}

.section-label {
  font-size: 0.85rem;
  font-weight: 800;
  margin: 0 0 8px;
  color: var(--ink);
}

.stepper {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.stepper button {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  border: none;
  background: var(--accent-soft);
  color: var(--accent-deep);
  font-size: 1.4rem;
  font-weight: 700;
  cursor: pointer;
}

.stepper .count {
  font-size: 1.6rem;
  font-weight: 800;
  min-width: 48px;
  text-align: center;
}

input[type="date"],
textarea {
  width: 100%;
  font: inherit;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  background: #fff;
  color: var(--ink);
  margin-bottom: 14px;
}

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

.summary-card {
  background:
    var(--pattern-dots),
    #fffafb !important;
  background-size: 12px 12px, auto !important;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: #4a3540;
  color: #fff;
  padding: 11px 18px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 50;
  max-width: 90vw;
  box-shadow: 0 8px 24px rgba(74, 53, 64, 0.25);
}

.toast.show {
  opacity: 1;
}

.done-mark {
  background: var(--ok-soft);
  color: #166534;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
}

.hint {
  font-size: 0.75rem;
  color: var(--muted);
  margin: -8px 0 14px;
  line-height: 1.45;
}

.section-heading {
  font-size: 0.8rem;
  font-weight: 800;
  color: var(--muted);
  margin: 16px 2px 8px;
  letter-spacing: 0.04em;
}

/* —— 予実管理 —— */
.yojitsu {
  margin: 10px 0 12px;
  padding: 10px 12px;
  background: linear-gradient(160deg, #fff 0%, #f8fafc 100%);
  border: 1.5px solid #e2e8f0;
  border-radius: var(--radius-sm);
}

.yojitsu-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 4px;
  font-size: 0.82rem;
}

.yojitsu-row:last-of-type {
  margin-bottom: 0;
}

.yojitsu-label {
  flex-shrink: 0;
  font-weight: 800;
  font-size: 0.72rem;
  color: #64748b;
  background: #f1f5f9;
  padding: 2px 8px;
  border-radius: 999px;
  min-width: 2.6em;
  text-align: center;
}

.yojitsu-value {
  font-weight: 700;
  color: var(--ink);
  line-height: 1.4;
}

.yojitsu-orig {
  margin: 6px 0 0;
  font-size: 0.68rem;
  color: var(--muted);
  line-height: 1.4;
}

.track-pill {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 800;
  padding: 3px 10px;
  border-radius: 999px;
}

.track-pill.ahead {
  background: var(--ok-soft);
  color: var(--ok-deep);
}

.track-pill.on-track {
  background: var(--sky-soft);
  color: #0369a1;
}

.track-pill.behind {
  background: #fee2e2;
  color: #b91c1c;
}

.track-pill.done {
  background: var(--ok-soft);
  color: #166534;
}

.assignment.track-behind {
  border-color: #fecaca;
}

.assignment.track-ahead {
  border-color: #a7f3d0;
}

.assignment.track-on-track {
  border-color: #bae6fd;
}

.pace-rule-hint {
  margin: 0 0 10px;
  font-size: 0.68rem;
  color: var(--muted);
  line-height: 1.4;
}

.today-plan-sub {
  margin: 2px 0 0;
  font-size: 0.68rem;
  color: var(--muted);
}

.pace-preview {
  margin: 0 0 14px;
  padding: 12px 14px;
  background:
    var(--pattern-dots),
    linear-gradient(160deg, #fff 0%, var(--lavender-soft) 140%);
  background-size: 12px 12px, auto;
  border: 1.5px solid #ddd6fe;
  border-radius: var(--radius-sm);
}

.pace-preview-main {
  margin: 0 0 4px;
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.45;
}

.pace-preview-main strong {
  color: var(--accent-deep);
  font-size: 1.05em;
}

.pace-preview-sub {
  margin: 0;
  font-size: 0.7rem;
  color: var(--muted);
  line-height: 1.4;
}

.auto-reset-btn {
  border: 1.5px solid #ffd8b8;
  background: #fff;
  color: #9a3412;
  font: inherit;
  font-size: 0.72rem;
  font-weight: 800;
  padding: 6px 10px;
  border-radius: 999px;
  cursor: pointer;
}

.auto-reset-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

/* ---------- PWA install banner ---------- */
#pwa-banner-host {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1000;
  padding: 12px 12px calc(12px + env(safe-area-inset-bottom, 0px));
  pointer-events: none;
}

.pwa-banner {
  pointer-events: auto;
  max-width: 420px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 18px;
  background:
    linear-gradient(135deg, #fff 0%, #ffe4ea 100%);
  border: 1.5px solid var(--border);
  box-shadow: 0 12px 32px rgba(180, 100, 120, 0.18);
  animation: pwa-banner-in 0.35s ease-out;
}

.pwa-banner.ios {
  background: linear-gradient(135deg, #fff 0%, #f3eefe 100%);
  border-color: #ddd6fe;
}

.pwa-banner-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.pwa-banner-text strong {
  font-size: 0.88rem;
  font-weight: 800;
  color: var(--ink);
}

.pwa-banner-text span {
  font-size: 0.72rem;
  color: var(--muted);
  line-height: 1.35;
}

.pwa-banner-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-shrink: 0;
}

.pwa-banner-btn {
  font: inherit;
  font-size: 0.72rem;
  font-weight: 800;
  padding: 7px 12px;
  border-radius: 999px;
  border: 1.5px solid var(--border);
  background: #fff;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
}

.pwa-banner-btn.primary {
  background: linear-gradient(180deg, #fda4af, #fb7185);
  border-color: transparent;
  color: #5c1020;
}

@keyframes pwa-banner-in {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (display-mode: standalone) {
  #pwa-banner-host {
    display: none;
  }
}

/* —— Family passcode lock —— */
.topbar {
  justify-content: space-between;
}

.topbar-main {
  min-width: 0;
  flex: 1;
  position: relative;
  z-index: 1;
}

.lock-chip {
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font: inherit;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 8px 10px;
  border-radius: 999px;
  box-shadow: var(--shadow-soft);
  cursor: pointer;
  flex-shrink: 0;
  position: relative;
  z-index: 1;
  transition: transform 0.12s ease, color 0.12s ease;
}

.lock-chip:active {
  transform: scale(0.96);
  color: var(--ink);
}

.lock-screen {
  min-height: calc(100vh - 48px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 0 24px;
}

.lock-card {
  width: 100%;
  text-align: center;
  padding: 28px 20px 24px;
  background:
    var(--pattern-dots),
    linear-gradient(165deg, #fff 0%, var(--accent-soft) 120%);
  background-size: var(--pattern-dots-size), auto;
}

.lock-emoji {
  font-size: 2.4rem;
  margin-bottom: 8px;
  line-height: 1;
}

.lock-title {
  margin: 0 0 6px;
  font-size: 1.45rem;
  font-weight: 800;
  letter-spacing: 0.03em;
}

.lock-note {
  margin: 0 0 22px;
  color: var(--muted);
  font-size: 0.88rem;
}

.lock-label {
  display: block;
  text-align: left;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--muted);
  margin: 0 0 6px 2px;
}

.lock-input {
  width: 100%;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  font: inherit;
  font-size: 1.25rem;
  letter-spacing: 0.35em;
  text-align: center;
  background: var(--surface);
  color: var(--ink);
  margin-bottom: 10px;
  box-shadow: var(--shadow-soft);
}

.lock-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(251, 138, 154, 0.25);
}

.lock-error {
  margin: 0 0 12px;
  color: var(--accent-deep);
  font-size: 0.82rem;
  font-weight: 700;
  min-height: 1.2em;
}

.lock-enter {
  width: 100%;
  margin-top: 4px;
}
