:root {
  --ink: #292735;
  --muted: #8c8998;
  --line: #e9e6ef;
  --panel: #ffffff;
  --bg: #fbfaff;
  --primary: #7569e8;
  --primary-soft: #efedff;
  --green: #4fc28a;
  --pink: #ee719b;
  --yellow: #efb936;
  --purple: #9974db;
  --shadow: 0 16px 42px rgba(58, 46, 94, 0.1);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic UI", "Noto Sans JP", sans-serif;
  color: var(--ink);
  background: var(--bg);
  font-synthesis: none;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; min-height: 100dvh; background: var(--bg); }
button, input, textarea, select { font: inherit; }
button { color: inherit; }
.app-shell { min-height: 100dvh; max-width: 520px; margin: 0 auto; background: var(--panel); position: relative; box-shadow: var(--shadow); }

.screen { min-height: 100dvh; padding-bottom: calc(92px + env(safe-area-inset-bottom)); background: linear-gradient(180deg, #fdfcff 0, #fff 180px); }
.screen.no-nav { padding-bottom: calc(28px + env(safe-area-inset-bottom)); }
.topbar { height: calc(76px + env(safe-area-inset-top)); padding: env(safe-area-inset-top) 20px 0; display: grid; grid-template-columns: 48px 1fr 48px; align-items: center; position: sticky; top: 0; z-index: 20; background: rgba(253, 252, 255, .92); backdrop-filter: blur(18px); border-bottom: 1px solid rgba(233,230,239,.65); }
.topbar h1 { margin: 0; font-size: 20px; text-align: center; letter-spacing: .02em; }
.topbar-action { border: 0; background: none; color: var(--primary); font-weight: 700; padding: 12px 0; min-width: 48px; }
.icon-button { width: 44px; height: 44px; padding: 0; border: 0; border-radius: 50%; background: transparent; display: grid; place-items: center; font-size: 24px; }
.icon-button:active { background: var(--primary-soft); }

.content { padding: 18px 18px 28px; }
.brand { font-size: 13px; font-weight: 800; color: var(--primary); letter-spacing: .08em; }
.month-switch { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.month-switch h2 { font-size: 25px; margin: 0; letter-spacing: .02em; }
.month-arrows { display: flex; gap: 6px; }
.month-arrows button { border: 1px solid var(--line); background: #fff; width: 38px; height: 38px; border-radius: 12px; font-size: 20px; }

.calendar { border: 1px solid var(--line); border-radius: 18px; overflow: hidden; background: #fff; box-shadow: 0 8px 26px rgba(58,46,94,.06); }
.weekdays, .calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); }
.weekdays { border-bottom: 1px solid var(--line); }
.weekday { padding: 11px 0; text-align: center; color: var(--muted); font-size: 12px; font-weight: 700; }
.weekday:first-child { color: var(--pink); }
.weekday:last-child { color: #5085e8; }
.day { position: relative; border: 0; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); background: #fff; min-height: 67px; padding: 8px 4px 5px; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.day:nth-child(7n) { border-right: 0; }
.day:nth-last-child(-n+7) { border-bottom: 0; }
.day.outside { color: #c2bfc8; background: #fdfcfe; }
.day.today .day-number { background: var(--primary); color: white; }
.day.selected { box-shadow: inset 0 0 0 2px var(--primary); z-index: 1; }
.day-number { width: 25px; height: 25px; border-radius: 50%; display: grid; place-items: center; font-size: 13px; font-weight: 650; }
.mood-mini { font-size: 21px; line-height: 20px; font-weight: 700; }
.record-dot { width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.mood-1 { color: var(--purple); }.mood-2 { color: var(--pink); }.mood-3 { color: var(--yellow); }.mood-4,.mood-5 { color: var(--green); }

.summary-card { margin-top: 16px; padding: 18px; border-radius: 18px; background: linear-gradient(135deg, #f0edff, #fff3f7); }
.summary-card h3 { margin: 0 0 7px; font-size: 15px; }
.summary-card p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.6; }
.legend { margin-top: 18px; display: flex; flex-wrap: wrap; gap: 10px 14px; color: var(--muted); font-size: 11px; }
.legend span { display: flex; align-items: center; gap: 5px; }
.legend .mood-mini { font-size: 17px; }

.fab { position: fixed; z-index: 30; right: max(22px, calc((100vw - 520px)/2 + 22px)); bottom: calc(92px + env(safe-area-inset-bottom)); width: 62px; height: 62px; border: 0; border-radius: 50%; color: white; background: linear-gradient(145deg, #8175ee, #6559dc); box-shadow: 0 12px 24px rgba(101,89,220,.33); font-size: 32px; font-weight: 200; }
.bottom-nav { position: fixed; z-index: 25; bottom: 0; left: max(0px, calc((100vw - 520px)/2)); width: min(100%, 520px); height: calc(76px + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); display: grid; grid-template-columns: repeat(3,1fr); background: rgba(255,255,255,.94); backdrop-filter: blur(18px); border-top: 1px solid var(--line); }
.nav-item { border: 0; background: none; color: #9995a1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; font-size: 11px; font-weight: 700; }
.nav-item.active { color: var(--primary); }
.nav-icon { font-size: 21px; line-height: 1; }

.field { margin-bottom: 26px; }
.field-label { display: flex; justify-content: space-between; align-items: end; margin-bottom: 11px; }
.field-label label, .field-label h2 { margin: 0; font-size: 16px; font-weight: 800; }
.field-help { color: var(--muted); font-size: 12px; }
.date-input, .text-input, .textarea { width: 100%; border: 1px solid var(--line); background: #fff; border-radius: 14px; padding: 14px; color: var(--ink); outline: none; }
.date-input:focus, .text-input:focus, .textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.textarea { min-height: 126px; resize: vertical; line-height: 1.65; }
.char-count { display: block; text-align: right; color: var(--muted); font-size: 11px; margin-top: 5px; }

.mood-picker { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.mood-option { border: 0; border-radius: 14px; background: transparent; padding: 7px 1px; display: flex; flex-direction: column; align-items: center; gap: 7px; }
.mood-face { width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center; font-size: 28px; font-weight: 750; background: color-mix(in srgb, currentColor 18%, white); }
.mood-option small { font-size: 10px; color: var(--muted); white-space: nowrap; }
.mood-option.selected { outline: 2px solid currentColor; outline-offset: 2px; }

.category-block { margin-bottom: 12px; border: 1px solid var(--line); border-radius: 16px; background: white; overflow: hidden; }
.category-title { padding: 13px 14px 8px; display: flex; align-items: center; gap: 10px; font-size: 14px; font-weight: 800; }
.category-icon { width: 31px; height: 31px; border-radius: 10px; background: var(--primary-soft); display: grid; place-items: center; font-size: 17px; }
.product-check { display: flex; align-items: center; gap: 11px; padding: 10px 14px; border-top: 1px solid #f3f1f6; font-size: 13px; }
.product-check input { appearance: none; width: 21px; height: 21px; border: 1.5px solid #cbc7d3; border-radius: 7px; margin: 0; display: grid; place-items: center; flex: 0 0 auto; }
.product-check input:checked { background: var(--primary); border-color: var(--primary); }
.product-check input:checked::after { content: "✓"; color: white; font-weight: 800; font-size: 14px; }
.empty-hint { padding: 12px 14px 15px; color: var(--muted); font-size: 12px; }

.primary-button { width: 100%; border: 0; border-radius: 15px; background: var(--primary); color: white; padding: 15px; font-weight: 800; box-shadow: 0 9px 20px rgba(117,105,232,.22); }
.secondary-button { width: 100%; border: 1px solid var(--line); border-radius: 15px; background: white; color: var(--ink); padding: 14px; font-weight: 750; }
.danger-button { width: 100%; border: 0; background: transparent; color: #dd4f73; padding: 15px; font-weight: 750; margin-top: 8px; }

.detail-hero { text-align: center; padding: 8px 0 24px; }
.detail-date { color: var(--muted); font-size: 13px; margin-bottom: 14px; }
.detail-face { margin: 0 auto 8px; width: 78px; height: 78px; border-radius: 50%; display: grid; place-items: center; font-size: 46px; font-weight: 700; background: color-mix(in srgb, currentColor 18%, white); }
.detail-mood-label { font-weight: 800; }
.detail-section { padding: 18px 0; border-top: 1px solid var(--line); }
.detail-section h2 { margin: 0 0 12px; font-size: 15px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { padding: 9px 12px; border-radius: 999px; background: #f2f0f7; font-size: 12px; font-weight: 650; }
.memo-card { margin: 0; padding: 14px; border-radius: 14px; background: #faf9fc; color: #5e5a67; line-height: 1.7; font-size: 14px; white-space: pre-wrap; }

.list-header { display: flex; align-items: center; justify-content: space-between; margin: 3px 0 14px; }
.list-header p { margin: 0; color: var(--muted); font-size: 12px; }
.add-small { border: 0; border-radius: 11px; background: var(--primary-soft); color: var(--primary); padding: 9px 12px; font-size: 12px; font-weight: 800; }
.product-card { display: flex; align-items: center; gap: 12px; border: 1px solid var(--line); background: #fff; border-radius: 15px; padding: 13px; margin-bottom: 10px; }
.product-avatar { width: 40px; height: 40px; flex: 0 0 auto; border-radius: 12px; background: var(--primary-soft); display: grid; place-items: center; }
.product-info { flex: 1; min-width: 0; }
.product-name { font-weight: 750; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.product-meta { color: var(--muted); font-size: 11px; margin-top: 3px; }
.more-button { border: 0; background: transparent; font-size: 22px; color: var(--muted); padding: 8px; }
.empty-state { padding: 50px 22px; text-align: center; color: var(--muted); }
.empty-state .empty-icon { font-size: 42px; margin-bottom: 12px; }
.empty-state h2 { color: var(--ink); font-size: 17px; margin: 0 0 8px; }
.empty-state p { font-size: 13px; line-height: 1.7; margin: 0 0 22px; }

.modal-backdrop { position: fixed; z-index: 80; inset: 0; background: rgba(36,31,49,.3); display: flex; align-items: end; justify-content: center; }
.sheet { width: min(100%, 520px); padding: 10px 20px calc(24px + env(safe-area-inset-bottom)); border-radius: 24px 24px 0 0; background: white; box-shadow: 0 -16px 38px rgba(31,24,52,.14); animation: sheet-in .2s ease-out; }
@keyframes sheet-in { from { transform: translateY(30px); opacity: 0; } }
.sheet-handle { width: 38px; height: 4px; border-radius: 99px; background: #ddd9e3; margin: 0 auto 18px; }
.sheet h2 { margin: 0 0 18px; font-size: 19px; }
.sheet-actions { display: flex; gap: 10px; margin-top: 18px; }
.sheet-actions button { flex: 1; }
.toast { position: fixed; z-index: 100; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); transform: translate(-50%, 18px); background: #34303c; color: white; padding: 10px 16px; border-radius: 999px; font-size: 12px; opacity: 0; pointer-events: none; transition: .2s; white-space: nowrap; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (min-width: 700px) {
  body { padding: 22px 0; }
  .app-shell, .screen { min-height: calc(100dvh - 44px); border-radius: 28px; overflow: hidden; }
  .bottom-nav { bottom: 22px; }
  .fab { bottom: 112px; }
}
