/* ==========================================================================
   chocoZAP 利用履歴管理アプリ（モック）
   デザインは3テーマ: pop / neon / paper
   ========================================================================== */

/* --- reset ------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }
ul, ol { margin: 0; padding: 0; list-style: none; }
h1, h2, h3, h4 { margin: 0; font-family: var(--font-head); font-weight: var(--head-weight); }
a { color: inherit; }

/* --- テーマ1: pop（chocoZAP純正イメージ / イエロー×ブラック） ------------- */
:root, [data-theme="pop"] {
  --font-body: "Hiragino Maru Gothic ProN", "Yu Gothic UI", "Segoe UI", system-ui, sans-serif;
  --font-head: "Hiragino Maru Gothic ProN", "Yu Gothic UI", system-ui, sans-serif;
  --font-num: "Hiragino Maru Gothic ProN", system-ui, sans-serif;
  --head-weight: 800;

  --bg: #FFFCF0;
  --surface: #FFFFFF;
  --surface-2: #FFF7DA;
  --text: #241F14;
  --text-sub: #8A8272;
  --accent: #FFD400;
  --accent-2: #FF7A45;
  --accent-ink: #241F14;
  --border: #F0E4B4;
  --radius: 20px;
  --radius-sm: 14px;
  --shadow: 0 6px 0 rgba(36, 31, 20, .08);
  --shadow-lg: 0 10px 24px rgba(190, 155, 0, .18);
  --header-bg: linear-gradient(120deg, #FFD400, #FFE566);
  --header-ink: #241F14;
  --nav-bg: #FFFFFF;
  --chip-bg: #FFF3C4;
  --danger: #E23D28;
  --ok: #16A34A;
}

/* --- テーマ2: neon（ナイトジム / ダーク×ネオン） ------------------------- */
[data-theme="neon"] {
  --font-body: "Yu Gothic UI", "Segoe UI", system-ui, sans-serif;
  --font-head: "Yu Gothic UI", "Segoe UI", system-ui, sans-serif;
  --font-num: "Consolas", "SF Mono", "Roboto Mono", monospace;
  --head-weight: 700;

  --bg: #0A0D12;
  --surface: #141A23;
  --surface-2: #1B2430;
  --text: #E8F2EC;
  --text-sub: #78889A;
  --accent: #00E5A0;
  --accent-2: #23C2FF;
  --accent-ink: #04140D;
  --border: #24303E;
  --radius: 10px;
  --radius-sm: 8px;
  --shadow: none;
  --shadow-lg: 0 0 24px rgba(0, 229, 160, .20);
  --header-bg: #0F141B;
  --header-ink: #E8F2EC;
  --nav-bg: #0F141B;
  --chip-bg: #1B2430;
  --danger: #FF5C5C;
  --ok: #00E5A0;
}

/* --- テーマ3: paper（ミニマル / 和紙×インディゴ） ----------------------- */
[data-theme="paper"] {
  --font-body: "Yu Gothic UI", "Hiragino Sans", system-ui, sans-serif;
  --font-head: "Yu Mincho", "Hiragino Mincho ProN", "Noto Serif JP", serif;
  --font-num: "Yu Mincho", "Hiragino Mincho ProN", serif;
  --head-weight: 600;

  --bg: #F6F4EF;
  --surface: #FFFFFF;
  --surface-2: #F0EDE5;
  --text: #232733;
  --text-sub: #857F73;
  --accent: #3D4A82;
  --accent-2: #A4713F;
  --accent-ink: #FFFFFF;
  --border: #E2DED3;
  --radius: 3px;
  --radius-sm: 2px;
  --shadow: none;
  --shadow-lg: none;
  --header-bg: #FFFFFF;
  --header-ink: #232733;
  --nav-bg: #FFFFFF;
  --chip-bg: #F0EDE5;
  --danger: #A83232;
  --ok: #3F7A4E;
}

/* --- テーマ4: pink（ガーリー・ピンク / パステルピンク×白） --------------- */
[data-theme="pink"] {
  --font-body: "Hiragino Maru Gothic ProN", "Yu Gothic UI", "Segoe UI", system-ui, sans-serif;
  --font-head: "Hiragino Maru Gothic ProN", "Yu Gothic UI", system-ui, sans-serif;
  --font-num: "Hiragino Maru Gothic ProN", system-ui, sans-serif;
  --head-weight: 700;

  --bg: #FFF4F8;
  --surface: #FFFFFF;
  --surface-2: #FFE4EF;
  --text: #3E2531;
  --text-sub: #B084A0;
  --accent: #FF6FA0;
  --accent-2: #FFACC9;
  --accent-ink: #FFFFFF;
  --border: #FBD2E3;
  --radius: 22px;
  --radius-sm: 16px;
  --shadow: 0 8px 18px rgba(255, 111, 160, .16);
  --shadow-lg: 0 12px 28px rgba(255, 111, 160, .26);
  --header-bg: linear-gradient(120deg, #FFC2DA, #FF6FA0);
  --header-ink: #FFFFFF;
  --nav-bg: #FFFFFF;
  --chip-bg: #FFE4EF;
  --danger: #E0447A;
  --ok: #3FA372;
}

/* --- テーマ5: green（ナチュラル・グリーン / 白×深緑） -------------------- */
[data-theme="green"] {
  --font-body: "Yu Gothic UI", "Hiragino Sans", "Segoe UI", system-ui, sans-serif;
  --font-head: "Yu Gothic UI", "Hiragino Sans", system-ui, sans-serif;
  --font-num: "Yu Gothic UI", system-ui, sans-serif;
  --head-weight: 700;

  --bg: #F3F7F1;
  --surface: #FFFFFF;
  --surface-2: #E6F0E1;
  --text: #223326;
  --text-sub: #7E9182;
  --accent: #3F8F5F;
  --accent-2: #8CB369;
  --accent-ink: #FFFFFF;
  --border: #D6E6D1;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 4px 12px rgba(63, 143, 95, .12);
  --shadow-lg: 0 8px 24px rgba(63, 143, 95, .2);
  --header-bg: linear-gradient(120deg, #DCEAD6, #B7D6AC);
  --header-ink: #223326;
  --nav-bg: #FFFFFF;
  --chip-bg: #E6F0E1;
  --danger: #C1442A;
  --ok: #3F8F5F;
}

/* --- layout ------------------------------------------------------------ */
#app { display: none; min-height: 100vh; padding-bottom: 78px; }
#app.is-active { display: block; }

.app-header {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px;
  background: var(--header-bg); color: var(--header-ink);
  border-bottom: 1px solid transparent;
}
[data-theme="neon"] .app-header,
[data-theme="paper"] .app-header { border-bottom-color: var(--border); }

.app-header .brand { font-family: var(--font-head); font-weight: var(--head-weight); font-size: 17px; letter-spacing: .02em; }
.app-header .brand small { display: block; font-size: 10px; opacity: .7; font-weight: 400; letter-spacing: .12em; }
.app-header .spacer { flex: 1; }

.icon-btn {
  display: grid; place-items: center;
  width: 38px; height: 38px; border-radius: 999px;
  color: inherit;
}
.icon-btn:active { transform: scale(.94); }
[data-theme="pop"] .icon-btn { background: rgba(255, 255, 255, .55); }
[data-theme="neon"] .icon-btn { border: 1px solid var(--border); border-radius: var(--radius-sm); }
[data-theme="paper"] .icon-btn { border: 1px solid var(--border); }

.user-chip {
  display: flex; align-items: center; gap: 7px;
  padding: 5px 12px 5px 5px; border-radius: 999px;
  background: var(--surface); font-size: 13px; font-weight: 600;
  border: 1px solid var(--border);
}
.avatar {
  width: 26px; height: 26px; border-radius: 999px;
  display: grid; place-items: center;
  color: #fff; font-size: 12px; font-weight: 700;
}
[data-theme="paper"] .user-chip { border-radius: 2px; }

main { padding: 16px; max-width: 720px; margin: 0 auto; }
.screen { display: none; animation: fade .18s ease; }
.screen.is-active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.section-title {
  display: flex; align-items: center; gap: 8px;
  margin: 22px 0 10px; font-size: 14px; letter-spacing: .04em;
}
.section-title .line { flex: 1; height: 1px; background: var(--border); }
[data-theme="neon"] .section-title { text-transform: none; color: var(--text-sub); }
[data-theme="paper"] .section-title { letter-spacing: .16em; }

/* --- card -------------------------------------------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}
.card + .card { margin-top: 12px; }
[data-theme="neon"] .card { background: linear-gradient(180deg, var(--surface), var(--surface-2)); }

/* --- home stats -------------------------------------------------------- */
.hero {
  border-radius: var(--radius); padding: 18px;
  background: var(--surface); border: 1px solid var(--border);
  box-shadow: var(--shadow);
}
[data-theme="pop"] .hero { background: linear-gradient(135deg, #FFE97A, #FFD400); border-color: #F5C400; }
[data-theme="neon"] .hero { background: radial-gradient(120% 140% at 0% 0%, #16302A, #101720); box-shadow: var(--shadow-lg); }
[data-theme="paper"] .hero { background: var(--surface); }

.hero .label { font-size: 12px; color: var(--text-sub); letter-spacing: .1em; }
[data-theme="pop"] .hero .label { color: #7A6200; }
.hero .big { font-family: var(--font-num); font-size: 46px; font-weight: 800; line-height: 1.05; }
[data-theme="neon"] .hero .big { color: var(--accent); text-shadow: 0 0 18px rgba(0, 229, 160, .45); }
[data-theme="paper"] .hero .big { font-weight: 500; }
.hero .big span { font-size: 16px; font-weight: 600; margin-left: 4px; }

.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 12px; }
.stat {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px;
}
.stat .k { font-size: 11px; color: var(--text-sub); letter-spacing: .08em; }
.stat .v { font-family: var(--font-num); font-size: 26px; font-weight: 700; margin-top: 2px; }
.stat .v small { font-size: 12px; font-weight: 500; color: var(--text-sub); margin-left: 3px; }
[data-theme="neon"] .stat .v { color: var(--accent-2); }

.user-stat-row { display: flex; align-items: center; gap: 10px; padding: 10px 0; }
.user-stat-row + .user-stat-row { border-top: 1px solid var(--border); }
.user-stat-row .name { flex: 1; font-weight: 600; font-size: 14px; }
.user-stat-row .num { font-family: var(--font-num); font-size: 20px; font-weight: 700; }
.user-stat-row .num small { font-size: 11px; color: var(--text-sub); margin-left: 2px; }
.bar { height: 6px; border-radius: 999px; background: var(--surface-2); overflow: hidden; margin-top: 6px; }
.bar > i { display: block; height: 100%; border-radius: 999px; }

/* --- list -------------------------------------------------------------- */
.list-item {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 14px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius);
  width: 100%; text-align: left;
}
.list-item + .list-item { margin-top: 8px; }
[data-theme="paper"] .list-item { border-left: 3px solid var(--border); }
[data-theme="paper"] .list-item:active { border-left-color: var(--accent); }
[data-theme="neon"] .list-item:active { border-color: var(--accent); }
.list-item .main { flex: 1; min-width: 0; }
.list-item .t1 { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-item .t2 { font-size: 12px; color: var(--text-sub); margin-top: 3px; }
.list-item .right { text-align: right; flex-shrink: 0; }
.list-item .dur { font-family: var(--font-num); font-weight: 700; font-size: 16px; }
.list-item .dur small { font-size: 10px; color: var(--text-sub); }

.date-badge {
  width: 46px; flex-shrink: 0; text-align: center;
  border-radius: var(--radius-sm); padding: 5px 0;
  background: var(--surface-2);
}
.date-badge .m { font-size: 10px; color: var(--text-sub); }
.date-badge .d { font-family: var(--font-num); font-size: 19px; font-weight: 700; line-height: 1.1; }

.rank-badge {
  width: 30px; height: 30px; flex-shrink: 0; border-radius: 999px;
  display: grid; place-items: center;
  font-family: var(--font-num); font-weight: 700; font-size: 14px;
  background: var(--chip-bg);
}
.rank-badge.top { background: var(--accent); color: var(--accent-ink); }

/* --- chips / tags ------------------------------------------------------ */
.chips { display: flex; flex-wrap: wrap; gap: 7px; }
.chip {
  padding: 6px 12px; border-radius: 999px; font-size: 12px;
  background: var(--chip-bg); border: 1px solid transparent; color: var(--text-sub);
  white-space: nowrap;
}
[data-theme="paper"] .chip { border-radius: 2px; border-color: var(--border); background: transparent; }
.chip.is-on { background: var(--accent); color: var(--accent-ink); font-weight: 700; border-color: var(--accent); }
[data-theme="neon"] .chip.is-on { box-shadow: 0 0 12px rgba(0, 229, 160, .35); }

.tag {
  display: inline-block; padding: 3px 8px; border-radius: var(--radius-sm);
  font-size: 11px; background: var(--surface-2); color: var(--text-sub);
}
.tag.accent { background: var(--accent); color: var(--accent-ink); font-weight: 700; }
.tag.line { background: transparent; border: 1px solid var(--border); }

/* --- forms ------------------------------------------------------------- */
.field { margin-bottom: 14px; }
.field > label { display: block; font-size: 12px; color: var(--text-sub); margin-bottom: 6px; letter-spacing: .04em; }
.input, select.input, textarea.input {
  width: 100%; padding: 12px 14px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  outline: none;
}
.input:focus { border-color: var(--accent); }
[data-theme="neon"] .input:focus { box-shadow: 0 0 0 3px rgba(0, 229, 160, .15); }
[data-theme="paper"] .input { border-width: 0 0 1px 0; border-radius: 0; background: transparent; padding-left: 2px; }
textarea.input { min-height: 76px; resize: vertical; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.row-2.with-mid { grid-template-columns: 1fr auto 1fr; align-items: end; }
.mid-mark { padding-bottom: 12px; color: var(--text-sub); }

.picker-btn {
  width: 100%; display: flex; align-items: center; gap: 10px;
  padding: 12px 14px; text-align: left;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
}
[data-theme="paper"] .picker-btn { border-width: 0 0 1px 0; border-radius: 0; background: transparent; padding-left: 2px; }
.picker-btn .ph { color: var(--text-sub); }
.picker-btn .val { flex: 1; font-weight: 600; }

.duration-preview {
  display: flex; align-items: baseline; justify-content: center; gap: 6px;
  padding: 12px; border-radius: var(--radius-sm); background: var(--surface-2);
  margin-bottom: 14px;
}
.duration-preview b { font-family: var(--font-num); font-size: 30px; }
[data-theme="neon"] .duration-preview b { color: var(--accent); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 14px 20px; border-radius: var(--radius-sm);
  font-weight: 700; font-size: 15px;
  background: var(--accent); color: var(--accent-ink);
  width: 100%;
}
.btn:active { transform: translateY(1px); }
[data-theme="pop"] .btn { border-radius: 999px; box-shadow: 0 4px 0 rgba(36, 31, 20, .18); }
[data-theme="neon"] .btn { box-shadow: 0 0 18px rgba(0, 229, 160, .3); letter-spacing: .04em; }
[data-theme="paper"] .btn { border-radius: 2px; font-weight: 600; letter-spacing: .1em; }
.btn.ghost { background: transparent; border: 1px solid var(--border); color: var(--text); box-shadow: none; }
.btn.danger { background: transparent; border: 1px solid var(--danger); color: var(--danger); box-shadow: none; }
.btn-row { display: flex; gap: 10px; margin-top: 8px; }

/* --- bottom nav -------------------------------------------------------- */
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--nav-bg); border-top: 1px solid var(--border);
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
}
.nav button {
  display: grid; justify-items: center; gap: 3px;
  padding: 7px 0; font-size: 10px; color: var(--text-sub);
  border-radius: var(--radius-sm);
}
.nav button svg { width: 21px; height: 21px; }
.nav button.is-on { color: var(--text); font-weight: 700; }
[data-theme="pop"] .nav button.is-on { background: var(--chip-bg); }
[data-theme="neon"] .nav button.is-on { color: var(--accent); }
[data-theme="paper"] .nav button.is-on { color: var(--accent); box-shadow: inset 0 2px 0 var(--accent); border-radius: 0; }

/* --- modal / sheet ----------------------------------------------------- */
.overlay {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(10, 12, 16, .5);
  display: none; align-items: flex-end; justify-content: center;
}
.overlay.is-open { display: flex; }
.sheet {
  width: 100%; max-width: 720px; max-height: 88vh; overflow-y: auto;
  background: var(--bg); border-radius: var(--radius) var(--radius) 0 0;
  padding: 18px 16px calc(20px + env(safe-area-inset-bottom));
  animation: slideup .22s ease;
}
@keyframes slideup { from { transform: translateY(24px); opacity: .6; } to { transform: none; opacity: 1; } }
.sheet-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.sheet-head h3 { flex: 1; font-size: 16px; }

/* --- login ------------------------------------------------------------- */
.is-hidden { display: none !important; }
#login { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-box { width: 100%; max-width: 380px; text-align: center; }
.login-logo {
  width: 78px; height: 78px; margin: 0 auto 18px; border-radius: 26px;
  display: grid; place-items: center;
  background: var(--accent); color: var(--accent-ink);
  font-family: var(--font-head); font-weight: 800; font-size: 30px;
  box-shadow: var(--shadow-lg);
}
.login-box h1 { font-size: 22px; margin-bottom: 6px; }
.login-box p.lead { color: var(--text-sub); font-size: 13px; margin: 0 0 26px; }
.gbtn {
  width: 100%; display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 13px; border-radius: var(--radius-sm);
  background: var(--surface); border: 1px solid var(--border);
  font-weight: 600; font-size: 14px;
}
.gbtn + .gbtn { margin-top: 10px; }
.gbtn img, .gbtn svg { width: 19px; height: 19px; }
.login-status { margin: 10px 0 0; font-size: 12px; text-align: center; line-height: 1.6; }
.login-status.is-error { color: var(--danger); }
.login-status.is-info { color: var(--text-sub); }

.mock-note {
  margin-top: 22px; padding: 10px 12px; border-radius: var(--radius-sm);
  background: var(--surface-2); color: var(--text-sub); font-size: 11px; line-height: 1.6;
}

/* --- theme picker ------------------------------------------------------ */
.theme-grid { display: grid; gap: 10px; }
.theme-card {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 12px; border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--surface); text-align: left;
}
.theme-card.is-on { border-color: var(--accent); border-width: 2px; }
.swatch { width: 52px; height: 52px; border-radius: 12px; flex-shrink: 0; overflow: hidden; display: grid; grid-template-rows: 1fr 1fr; }
.swatch i { display: block; }
.theme-card .tt { font-weight: 700; font-size: 14px; }
.theme-card .td { font-size: 11px; color: var(--text-sub); margin-top: 2px; line-height: 1.5; }

/* --- misc -------------------------------------------------------------- */
.empty { text-align: center; padding: 34px 16px; color: var(--text-sub); font-size: 13px; }
.search-wrap { position: relative; margin-bottom: 10px; }
.search-wrap svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 17px; height: 17px; color: var(--text-sub); }
.search-wrap .input { padding-left: 36px; }
[data-theme="paper"] .search-wrap .input { padding-left: 34px; }
.result-count { font-size: 11px; color: var(--text-sub); margin: 8px 2px; }
.kv { display: flex; gap: 10px; padding: 7px 0; font-size: 13px; border-bottom: 1px solid var(--border); }
.kv .k { width: 88px; flex-shrink: 0; color: var(--text-sub); font-size: 12px; }
.kv .v { flex: 1; }
.count-badge {
  display: inline-flex; align-items: baseline; gap: 2px;
  padding: 3px 9px; border-radius: 999px; background: var(--accent); color: var(--accent-ink);
  font-family: var(--font-num); font-weight: 700; font-size: 13px;
}
.count-badge small { font-size: 9px; font-weight: 600; }
.count-badge.zero { background: var(--surface-2); color: var(--text-sub); }
[data-theme="paper"] .count-badge { border-radius: 2px; }

.toast {
  position: fixed; left: 50%; bottom: 92px; transform: translateX(-50%) translateY(10px);
  z-index: 60; padding: 11px 18px; border-radius: 999px;
  background: var(--text); color: var(--bg); font-size: 13px; font-weight: 600;
  opacity: 0; pointer-events: none; transition: .2s;
}
.toast.is-show { opacity: 1; transform: translateX(-50%); }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.mini-num { display: flex; align-items: center; gap: 8px; }
.mini-num label { flex: 1; font-size: 12px; }
.mini-num input { width: 58px; text-align: center; padding: 8px; }
.check-line { display: flex; align-items: center; gap: 8px; padding: 8px 0; font-size: 13px; }
.check-line input { width: 18px; height: 18px; accent-color: var(--accent); }
