/* =====================================================================
 * Habitlog — style.css（白基調 / 緑を主役に、青をサポート。端末がダークモードでも常にライト配色）
 * CSP のため、インライン style 属性は使わない（色は SVG の属性で指定）
 * =================================================================== */
:root {
  --green-50: #ecfdf5; --green-100: #d1fae5; --green-400: #34d399;
  --green-500: #10b981; --green-600: #059669; --green-700: #047857;
  --blue-50: #eff6ff; --blue-500: #3b82f6; --blue-600: #2563eb;
  --red-50: #fef2f2; --red-600: #dc2626;

  --bg: #ffffff; --bg-alt: #f6f9fc; --surface: #ffffff; --surface-2: #f2f6fb;
  --border: #e4ebf3; --border-soft: #eef3f9;
  --text: #0d1526; --text-2: #43506b; --muted: #7a879f;
  --accent: var(--green-600); --accent-soft: var(--green-50);

  --shadow-sm: 0 1px 2px rgba(13,21,38,.05);
  --shadow: 0 8px 22px -10px rgba(13,21,38,.16), 0 2px 6px -2px rgba(13,21,38,.06);
  --shadow-lg: 0 28px 60px -26px rgba(13,21,38,.32);
  --ring: 0 0 0 3px rgba(5,150,105,.28);
  --gradient: linear-gradient(115deg, var(--blue-600) 0%, var(--green-600) 38%, var(--green-400) 100%);
  --radius: 16px; --radius-lg: 22px; --pill: 999px;
  --ease: cubic-bezier(.22,.8,.28,1);
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: 'Noto Sans JP', 'Hiragino Kaku Gothic ProN', 'Yu Gothic', Meiryo, system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 16px; line-height: 1.75; -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
h1, h2, h3, h4 { margin: 0; line-height: 1.3; letter-spacing: -.01em; }
p { margin: 0 0 1em; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: none; box-shadow: var(--ring); border-radius: 8px; }

.container { width: 100%; max-width: 980px; margin-inline: auto; padding-inline: 20px; }

/* ---------- ボタン ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 22px; border: 1px solid transparent; border-radius: var(--pill);
  font-size: .92rem; font-weight: 700; line-height: 1.2; text-decoration: none;
  cursor: pointer; white-space: nowrap;
  transition: transform .2s var(--ease), box-shadow .2s var(--ease), background-color .2s, border-color .2s, color .2s;
}
.btn:active { transform: translateY(1px); }
.btn--primary { background: var(--gradient); color: #fff; box-shadow: 0 10px 22px -12px rgba(5,150,105,.9); }
.btn--primary:hover { transform: translateY(-1px); }
.btn--ghost { background: var(--surface); border-color: var(--border); color: var(--text); }
.btn--ghost:hover { border-color: var(--green-400); color: var(--accent); }
.btn--danger { background: var(--red-50); border-color: transparent; color: var(--red-600); }
.btn--danger:hover { border-color: var(--red-600); }
.btn--sm { padding: 7px 14px; font-size: .8rem; }
.btn--lg { padding: 14px 30px; font-size: 1rem; }
.btn[disabled] { opacity: .45; cursor: not-allowed; transform: none; }

/* ---------- ヘッダー ---------- */
.site-header { border-bottom: 1px solid var(--border-soft); background: var(--bg); position: sticky; top: 0; z-index: 20; }
.site-header__inner { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 12px; min-height: 62px; padding-block: 8px; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 800; letter-spacing: -.02em; text-decoration: none; }
.brand svg { width: 28px; height: 28px; }
.userbox { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; }
.navlink { padding: 5px 11px; border-radius: var(--pill); font-size: .82rem; font-weight: 700; color: var(--text-2); text-decoration: none; }
.navlink:hover, .navlink[aria-current=page] { background: var(--accent-soft); color: var(--accent); }
.userbox__name { font-size: .85rem; font-weight: 600; max-width: 9em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 520px) { .userbox__name { display: none; } }

/* ---------- ランディング ---------- */
.hero { padding-block: clamp(56px, 10vw, 110px) clamp(40px, 6vw, 70px); text-align: center; position: relative; overflow: hidden; }
.hero::before {
  content: ''; position: absolute; inset: -30% -10% auto auto; width: 60vw; max-width: 620px; aspect-ratio: 1; border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, var(--green-400), transparent 68%); opacity: .3; filter: blur(60px); pointer-events: none;
}
.hero > * { position: relative; }
.eyebrow { font-size: .74rem; font-weight: 800; letter-spacing: .18em; color: var(--accent); margin-bottom: 12px; }
.hero h1 { font-size: clamp(2rem, 6vw, 3.2rem); font-weight: 800; letter-spacing: -.035em; margin-bottom: 20px; }
.grad { background: var(--gradient); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero__lead { max-width: 34em; margin: 0 auto 30px; color: var(--text-2); }
.hero__note { margin: 14px 0 0; font-size: .78rem; color: var(--muted); }

.features { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 16px; padding-bottom: 70px; }
.feature { padding: 22px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-sm); }
.feature h3 { font-size: 1rem; margin-bottom: 6px; }
.feature p { margin: 0; font-size: .86rem; color: var(--text-2); }
.feature__icon { width: 38px; height: 38px; margin-bottom: 12px; border-radius: 12px; background: var(--accent-soft); display: grid; place-items: center; }
.feature__icon svg { width: 20px; height: 20px; fill: none; stroke: var(--accent); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- アプリ ---------- */
.app { padding-block: 28px 60px; }
.app__head { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.app__head h2 { font-size: 1.45rem; }
.app__date { margin: 0; font-size: .82rem; color: var(--muted); }

.summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 26px; }
.stat { padding: 14px 16px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-sm); }
.stat dt { font-size: .66rem; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.stat dd { margin: 2px 0 0; font-size: 1.35rem; font-weight: 800; letter-spacing: -.02em; line-height: 1.3; }
@media (max-width: 460px) { .stat dd { font-size: 1.05rem; } .stat { padding: 12px; } }

.section-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 30px 0 14px; font-size: 1.05rem; }

.habits { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.habit { display: flex; flex-direction: column; gap: 10px; padding: 18px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow-sm); }
.habit.is-running { border-color: var(--green-400); box-shadow: 0 0 0 3px rgba(16,185,129,.16); }
.habit__head { display: flex; align-items: center; gap: 10px; }
.habit__head h3 { flex: 1; font-size: 1rem; overflow-wrap: anywhere; }
.dot { width: 14px; height: 14px; flex: none; }
.habit__today { display: flex; align-items: baseline; gap: 8px; }
.habit__today strong { font-size: 1.5rem; font-weight: 800; letter-spacing: -.02em; }
.habit__today span { font-size: .8rem; color: var(--muted); }
.bar { display: block; width: 100%; height: 8px; }
.bar__track { fill: var(--surface-2); }
.habit__streak { margin: 0; font-size: .8rem; font-weight: 700; color: var(--text-2); }
.habit__streak b { color: var(--accent); }
.habit__actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 4px; }
.timer { font-variant-numeric: tabular-nums; font-weight: 800; font-size: 1.05rem; color: var(--accent); min-width: 5.2em; }

.icon-btn { display: inline-grid; place-items: center; width: 32px; height: 32px; padding: 0; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); cursor: pointer; color: var(--text-2); }
.icon-btn:hover { border-color: var(--green-400); color: var(--accent); }
.icon-btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.empty { padding: 34px 20px; text-align: center; border: 1px dashed var(--border); border-radius: var(--radius-lg); color: var(--muted); }
.empty .btn { margin-top: 10px; }

/* ---------- グラフ・履歴 ---------- */
.card { padding: 18px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow-sm); }
.chart { display: block; width: 100%; height: auto; }
.chart text { fill: var(--muted); font-size: 12px; font-family: inherit; }
.chart .chart__total { fill: var(--text-2); font-weight: 700; }
.chart .chart__grid { stroke: var(--border-soft); stroke-width: 1; }
.chart .chart__today { fill: var(--accent); font-weight: 800; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 12px 0 0; padding: 0; list-style: none; font-size: .78rem; color: var(--text-2); }
.legend li { display: inline-flex; align-items: center; gap: 6px; }

.history { display: grid; gap: 18px; }
.history__day h4 { font-size: .78rem; font-weight: 800; letter-spacing: .06em; color: var(--muted); margin-bottom: 6px; }
.history__list { margin: 0; padding: 0; list-style: none; display: grid; gap: 6px; }
.history__item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--border-soft); border-radius: 12px; background: var(--surface); }
.history__name { flex: 1; min-width: 0; font-size: .9rem; font-weight: 600; overflow-wrap: anywhere; }
.history__note { display: block; font-weight: 400; font-size: .78rem; color: var(--muted); }
.history__time { font-variant-numeric: tabular-nums; font-weight: 700; font-size: .9rem; }

.archived { margin-top: 26px; font-size: .86rem; color: var(--text-2); }
.archived summary { cursor: pointer; font-weight: 700; }
.archived ul { margin: 10px 0 0; padding: 0; list-style: none; display: grid; gap: 6px; }
.archived li { display: flex; align-items: center; gap: 10px; }
.archived li span:first-of-type { flex: 1; }

.app__foot { margin-top: 44px; padding-top: 20px; border-top: 1px solid var(--border-soft); display: flex; flex-wrap: wrap; gap: 8px 18px; font-size: .8rem; color: var(--muted); }
.linkbtn { padding: 0; border: 0; background: none; color: var(--muted); text-decoration: underline; cursor: pointer; font-size: inherit; }
.linkbtn:hover { color: var(--red-600); }

/* ---------- わかめ・レベル ---------- */
.wakame { display: block; width: 100%; height: auto; overflow: visible; }
.wakame--sway { transform-origin: 50% 95%; animation: sway 4.6s ease-in-out infinite; }
@keyframes sway { 0%, 100% { transform: rotate(-2.2deg); } 50% { transform: rotate(2.2deg); } }
.wk-twinkle { transform-box: fill-box; transform-origin: center; animation: twinkle 2.4s ease-in-out infinite; }
.wk-float { animation: floaty 3.4s ease-in-out infinite; }
.wk-d2 { animation-delay: -1.1s; }
.wk-d3 { animation-delay: -2.2s; }
@keyframes twinkle { 0%, 100% { transform: scale(.7); opacity: .55; } 50% { transform: scale(1.1); opacity: 1; } }
@keyframes floaty { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-7px); } }

.gamecard { display: grid; grid-template-columns: minmax(110px, 170px) 1fr; align-items: center; gap: 20px; margin-bottom: 20px; background: linear-gradient(180deg, var(--surface) 0%, var(--accent-soft) 100%); }
.gamecard.is-levelup { animation: levelup .9s var(--ease) 2; }
@keyframes levelup { 50% { transform: scale(1.02); box-shadow: 0 0 0 4px rgba(16,185,129,.25); } }
.gamecard__name { margin: 0 0 4px; font-size: .74rem; font-weight: 800; letter-spacing: .14em; color: var(--muted); }
.gamecard__info { min-width: 0; }
.gamecard__medals { margin: 10px 0 12px; font-size: .9rem; font-weight: 700; color: var(--text-2); }
.gamecard__medals b { font-size: 1.15rem; color: #d97706; }
.gamecard__links { display: flex; flex-wrap: wrap; gap: 8px; }
.level { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; margin-bottom: 8px; }
.level__badge { padding: 2px 14px; border-radius: var(--pill); background: var(--gradient); color: #fff; font-weight: 800; font-size: .95rem; }
.level__badge b { font-size: 1.3rem; margin-left: 2px; }
.level__text { font-size: .82rem; font-weight: 700; color: var(--text-2); }
@media (max-width: 460px) { .gamecard { grid-template-columns: 96px 1fr; gap: 14px; } }

.section-title__note { margin-left: auto; font-size: .78rem; font-weight: 700; color: var(--accent); }
.missions { margin: 0; padding: 0; list-style: none; display: grid; gap: 8px; }
.mission { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-sm); }
.mission.is-done { border-color: var(--green-400); box-shadow: 0 0 0 3px rgba(16,185,129,.14); }
.mission.is-claimed { background: var(--surface-2); }
.mission__check { flex: none; width: 26px; height: 26px; fill: none; stroke: var(--border); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.mission.is-done .mission__check, .mission.is-claimed .mission__check { stroke: var(--green-500); }
.mission.is-claimed .mission__check circle { fill: var(--green-100); }
.mission__body { flex: 1; min-width: 0; display: grid; gap: 1px; }
.mission__body strong { font-size: .92rem; }
.mission__body span { font-size: .78rem; color: var(--muted); }
.mission__body .mission__reward { color: #b45309; font-weight: 700; }
.mission__side { flex: none; text-align: right; }
.mission__progress, .mission__state { font-size: .8rem; font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; }
.mission__state { color: var(--accent); }

/* ---------- カレンダー ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.chip { display: inline-flex; align-items: center; gap: 8px; padding: 7px 14px; border: 1px solid var(--border); border-radius: var(--pill); background: var(--surface); font-size: .84rem; font-weight: 700; color: var(--text-2); cursor: pointer; }
.chip:hover { border-color: var(--green-400); }
.chip.is-active { border-color: var(--green-500); background: var(--accent-soft); color: var(--accent); box-shadow: 0 0 0 3px rgba(16,185,129,.14); }
.monthnav { display: flex; align-items: center; justify-content: center; gap: 18px; margin-bottom: 16px; }
.monthnav h3 { min-width: 8em; text-align: center; font-size: 1.15rem; }
.icon-btn[disabled] { opacity: .35; cursor: not-allowed; }
.cal { display: block; width: 100%; height: auto; user-select: none; }
.cal text { font-family: inherit; }
.cal .cal__wd { fill: var(--muted); font-size: 12px; font-weight: 700; }
.cal .cal__wd--sun { fill: var(--red-600); }
.cal .cal__wd--sat { fill: var(--blue-600); }
.cal .cal__cell { fill: var(--surface-2); }
.cal .cal__today { fill: none; stroke: var(--accent); stroke-width: 2; }
.cal .cal__picked { fill: none; stroke: var(--text); stroke-width: 1.5; stroke-dasharray: 3 3; }
.cal .cal__num { fill: var(--muted); font-size: 11px; font-weight: 700; }
.cal .cal__min { fill: var(--text); font-size: 13px; font-weight: 800; }
.cal .cal__on { fill: #fff; }
.cal .cal__goal { fill: none; stroke: #fff; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.cal .cal__day { cursor: pointer; }
.cal .cal__day:focus-visible { outline: none; }
.cal .cal__day:focus-visible .cal__cell { stroke: var(--accent); stroke-width: 2; }
.cal__legend { margin: 10px 2px 0; font-size: .76rem; color: var(--muted); }

/* ---------- ショップ ---------- */
.shopview { display: grid; grid-template-columns: minmax(120px, 190px) 1fr; align-items: center; gap: 22px; margin-bottom: 8px; background: linear-gradient(180deg, var(--surface) 0%, var(--accent-soft) 100%); }
.shopview__hint { margin: 0; font-size: .82rem; color: var(--text-2); }
@media (max-width: 460px) { .shopview { grid-template-columns: 110px 1fr; gap: 14px; } }
.items { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; }
.item { position: relative; display: flex; flex-direction: column; gap: 6px; padding: 14px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow-sm); }
.item.is-equipped { border-color: var(--green-400); box-shadow: 0 0 0 3px rgba(16,185,129,.16); }
.item__art { width: 96px; margin: 0 auto 4px; }
.item h4 { font-size: .95rem; }
.item p { margin: 0; font-size: .78rem; color: var(--muted); flex: 1; }
.item__action { margin-top: 6px; }
.item__action .btn { width: 100%; }
.item__tag { position: absolute; top: 10px; right: 10px; padding: 1px 9px; border-radius: var(--pill); background: var(--accent); color: #fff; font-size: .68rem; font-weight: 800; }
.item__tag--own { background: var(--surface-2); color: var(--text-2); }

/* ---------- ダイアログ ---------- */
.modal { width: min(460px, calc(100vw - 28px)); max-height: calc(100dvh - 28px); padding: 0; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg); overflow: auto; }
.modal::backdrop { background: rgba(4,22,16,.55); backdrop-filter: blur(4px); }
.modal[open] { animation: pop .25s var(--ease); }
@keyframes pop { from { opacity: 0; transform: translateY(12px) scale(.98); } }
.modal form { padding: 24px; display: grid; gap: 16px; }
.modal h3 { font-size: 1.1rem; }
.modal p { margin: 0; font-size: .86rem; color: var(--text-2); }
.field { display: grid; gap: 6px; }
.field label, .field .label { font-size: .78rem; font-weight: 700; color: var(--text-2); }
.field input[type=text], .field input[type=password], .field input[type=number], .field input[type=date] {
  width: 100%; padding: 11px 14px; border: 1px solid var(--border); border-radius: 12px; background: var(--bg); font-size: 16px;
}
.field input:focus { outline: none; border-color: var(--green-400); box-shadow: var(--ring); }
.hint { font-size: .74rem; color: var(--muted); }
.authcard { max-width: 380px; margin: 0 auto; display: grid; gap: 14px; text-align: left; }
.authcard .btn { width: 100%; }
.authtabs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; border-radius: 12px; background: var(--surface-2); }
.authtab { padding: 8px; border: 0; border-radius: 9px; background: none; color: var(--text-2); font-weight: 700; font-size: .86rem; cursor: pointer; }
.authtab.is-active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatch { position: relative; cursor: pointer; }
.swatch input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.swatch svg { display: block; width: 30px; height: 30px; }
.swatch circle.ring { fill: none; stroke: transparent; stroke-width: 2.5; }
.swatch input:checked + svg circle.ring { stroke: var(--text); }
.swatch input:focus-visible + svg { box-shadow: var(--ring); border-radius: 50%; }
.modal__actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; margin-top: 4px; }
.modal__actions .spacer { flex: 1; }
.error-msg { color: var(--red-600); font-size: .82rem; min-height: 1.2em; }

/* ---------- トースト ---------- */
.toast { position: fixed; left: 50%; bottom: calc(22px + env(safe-area-inset-bottom, 0px)); transform: translate(-50%, 20px); z-index: 60; max-width: calc(100vw - 32px); padding: 11px 20px; border-radius: var(--pill); background: var(--text); color: var(--bg); font-size: .86rem; font-weight: 600; box-shadow: var(--shadow-lg); opacity: 0; pointer-events: none; transition: opacity .25s, transform .25s var(--ease); }
.toast.is-show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- 法務ページ ---------- */
.doc { padding-block: 40px 70px; max-width: 720px; }
.doc h1 { font-size: 1.6rem; margin-bottom: 8px; }
.doc h2 { font-size: 1.1rem; margin: 30px 0 8px; }
.doc p, .doc li { font-size: .92rem; color: var(--text-2); }
.doc ul { padding-left: 1.3em; }
.doc .draft { padding: 12px 16px; border-radius: 12px; background: var(--blue-50); color: var(--text-2); font-size: .82rem; }

.loading { min-height: 50vh; display: grid; place-items: center; color: var(--muted); font-size: .9rem; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
