:root {
  --bg: #F6F3EC;
  --card: #FFFFFF;
  --ink: #3B3733;
  --sub: #8D857B;
  --teal: #3F7F7A;
  --teal-dark: #30615D;
  --coral: #F2845C;
  --line: #E7E2D8;
  --danger: #D9534F;
  --radius: 14px;
  --bounce: cubic-bezier(.34, 1.56, .64, 1);
  --header-bg: rgba(246, 243, 236, .92);
  --toast-bg: #3B3733;
  --toast-ink: #fff;
  --control-off: #D8D3C9;
  --control-border: #C9C3B8;
  --control-bg: #FFFFFF;
  --accent-ink: #fff;
  --accent-line: #3B7872;
  color-scheme: light;
}

:root[data-theme="dark"] {
    --bg: #23211D;
    --card: #2E2B26;
    --ink: #EFEAE0;
    --sub: #A59D91;
    --teal: #4A968F;
    --teal-dark: #5EAFA9;
    --coral: #F2936F;
    --line: #443F38;
    --danger: #E06B67;
    --header-bg: rgba(35, 33, 29, .92);
    --toast-bg: #EFEAE0;
    --toast-ink: #23211D;
    --control-off: #55504A;
    --control-border: #6B655D;
    --control-bg: #3A3630;
    --accent-ink: #23211D;
    --accent-line: #4FA19A;
    color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Hiragino Maru Gothic ProN", "Hiragino Sans", "Yu Gothic", sans-serif;
  line-height: 1.5;
}

.hidden { display: none !important; }

button { font-family: inherit; color: inherit; cursor: pointer; }

/* ---- ヘッダー ---- */
.app-header {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 8px;
  padding: calc(env(safe-area-inset-top) + 10px) 14px 10px;
  background: var(--header-bg);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.app-header h1 {
  flex: 1; margin: 0; font-size: 17px; text-align: center;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  /* 左右のテーマボタンぶんの余白（タイトルがボタンに重ならないように） */
  padding: 0 40px;
}
.theme-btn {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  width: 38px; height: 38px; border: none; border-radius: 50%;
  background: transparent; font-size: 18px; line-height: 1;
  display: flex; align-items: center; justify-content: center;
}
.theme-btn:active { background: var(--line); }

main { max-width: 560px; margin: 0 auto; padding: 16px 16px calc(env(safe-area-inset-bottom) + 32px); }

.tagline { color: var(--sub); font-size: 13px; text-align: center; margin: 4px 0 16px; white-space: pre-line; }

/* ---- そんなバナナくん ---- */
.mascot-hero { display: flex; align-items: center; justify-content: center; gap: 12px; margin: 10px 0 4px; }
.mascot-hero img { width: 92px; height: auto; animation: float 3s ease-in-out infinite; }
.list-hero { margin-bottom: 12px; }
.hero-bubble {
  position: relative; max-width: 230px; margin: 0;
  background: var(--card); border: 1.5px solid var(--line); border-radius: 14px;
  padding: 10px 14px; font-size: 13px;
  /* 文言の改行位置は\nで明示する（自動折り返しの不自然な改行を防ぐ） */
  white-space: pre-line;
}
.hero-bubble::before {
  content: ""; position: absolute; left: -14px; top: 50%; transform: translateY(-50%);
  border: 7px solid transparent; border-right-color: var(--card);
}
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}
.hero-bubble.talk-pop { animation: bubble-pop .4s var(--bounce); }
@keyframes bubble-pop {
  from { transform: scale(.85); }
  to { transform: scale(1); }
}
.celebrate-img { width: 150px; height: auto; }
.celebrate-sub-img { width: 90px; margin-left: -14px; }
.celebrate-sub { font-size: 14px; color: var(--sub); font-weight: normal; }

/* ---- ボタン ---- */
.primary-btn {
  display: block; width: 100%; padding: 14px; margin-top: 16px;
  border: none; border-radius: var(--radius);
  background: var(--teal); color: var(--accent-ink); font-size: 16px; font-weight: bold;
  transition: transform .15s var(--bounce);
}
.primary-btn:active { transform: scale(.97); background: var(--teal-dark); }
.dl-btn { text-align: center; text-decoration: none; }
.ghost-btn {
  display: block; width: 100%; padding: 12px; margin-top: 12px;
  border: 1.5px solid var(--line); border-radius: var(--radius);
  background: var(--card); font-size: 14px;
}
.ghost-btn:active { background: var(--bg); }

/* ---- ようこそ画面 ---- */
.welcome-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  margin-top: 14px; padding: 4px 16px 14px;
  box-shadow: 0 1px 3px rgba(59, 55, 51, .05);
}
.welcome-card h2 { font-size: 15px; color: var(--coral); margin: 12px 0 6px; }
.help-text { font-size: 14px; color: var(--ink); line-height: 1.8; margin: 0 0 4px; white-space: pre-line; }
.help-list { margin: 0; padding-left: 20px; font-size: 14px; line-height: 1.8; }
.help-list li { margin-bottom: 8px; white-space: pre-line; }
.help-list code {
  font-family: ui-monospace, Menlo, monospace; font-size: 12px;
  background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 1px 5px;
}

/* ---- カウントダウン・進捗 ---- */
.countdown {
  margin: 0 0 12px; padding: 10px 14px; border-radius: var(--radius);
  background: var(--card); border: 1.5px solid var(--coral);
  font-size: 14px; font-weight: bold; color: var(--coral); text-align: center;
}
.progress-wrap { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.progress-bar { flex: 1; height: 10px; border-radius: 5px; background: var(--line); overflow: hidden; }
#progress-fill { height: 100%; width: 0; border-radius: 5px; background: var(--accent-line); transition: width .3s; }
#progress-text { font-size: 13px; color: var(--sub); min-width: 44px; text-align: right; }

/* ---- カテゴリ ---- */
.category {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  margin-bottom: 14px; padding: 4px 14px 10px;
  box-shadow: 0 1px 3px rgba(59, 55, 51, .05);
}
.category > header { display: flex; align-items: center; gap: 4px; padding: 8px 0 4px; }
.category h2 {
  flex: 1; min-width: 0; margin: 0; font-size: 15px; color: var(--coral);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.category.cat-new { animation: pop-in .4s var(--bounce); }
.items { list-style: none; margin: 0; padding: 0; }
.item { display: flex; align-items: center; border-top: 1px solid var(--line); }
.item.item-new { animation: item-in .5s var(--bounce); }
@keyframes item-in {
  from { opacity: 0; transform: translateX(14px); }
  to { opacity: 1; transform: translateX(0); }
}
/* 追加直後のハイライト（数秒でふわっと消える） */
.item.item-new .iname { animation: item-glow 2.4s ease-out; border-radius: 6px; }
@keyframes item-glow {
  0%, 55% { background: color-mix(in srgb, var(--teal) 22%, transparent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--teal) 22%, transparent); }
  100% { background: transparent; box-shadow: none; }
}

/* ---- チェックUI ---- */
.check { flex: 1; display: flex; align-items: center; gap: 12px; padding: 11px 0; cursor: pointer; position: relative; }
.check input { position: absolute; opacity: 0; width: 0; height: 0; }
.iname { font-size: 15px; transition: opacity .2s; padding: 0 4px; }
.item.checked .iname { opacity: .4; text-decoration: line-through; }

.style-toggle .control {
  flex: none; width: 48px; height: 28px; border-radius: 14px;
  background: var(--control-off); position: relative; transition: background .25s;
}
.style-toggle .control::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 24px; height: 24px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .25), 0 0 0 1.5px rgba(0, 0, 0, .35);
  transition: transform .25s var(--bounce);
}
.style-toggle .check input:checked + .control { background: var(--teal); }
.style-toggle .check input:checked + .control::after { transform: translateX(20px); }
.style-toggle .check:active .control::after { transform: scale(1.1); }
.style-toggle .check input:checked + .control:active::after { transform: translateX(20px) scale(1.1); }

/* ---- その他 ---- */
.note { font-size: 12px; color: var(--sub); margin-top: 18px; white-space: pre-line; }
.sync-note { margin-top: 4px; text-align: center; }
#updated-at { text-align: center; }

.about-banana { text-align: center; margin-top: 26px; }
.about-banana img { width: 100px; height: auto; }
.about-banana p { font-size: 13px; color: var(--sub); white-space: pre-line; }
.about-link { text-decoration: none; display: block; color: inherit; }

/* ---- お祝い ---- */
#celebrate {
  position: fixed; inset: 0; z-index: 30;
  display: flex; align-items: center; justify-content: center;
  background: rgba(59, 55, 51, .25); pointer-events: none;
}
.celebrate-card {
  background: var(--card); border-radius: 20px; padding: 28px 44px;
  font-size: 22px; font-weight: bold; text-align: center; line-height: 1.6;
  box-shadow: 0 8px 30px rgba(0, 0, 0, .18);
  animation: pop-in .45s var(--bounce);
}
@keyframes pop-in {
  from { transform: scale(.5); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

/* ---- トースト ---- */
#toast {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 24px);
  transform: translateX(-50%); z-index: 40;
  background: var(--toast-bg); color: var(--toast-ink); font-size: 13px;
  padding: 10px 18px; border-radius: 20px; max-width: 86%;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .2);
  white-space: pre-line;
}
