:root {
  --bg: #fbf6f2;
  --card: #ffffff;
  --ink: #3b2f2f;
  --sub: #8a7a76;
  --line: #eee2dc;
  --rose: #c9677f;
  --rose-soft: #f7e4e8;
  --leaf: #6f9a7c;
  --leaf-soft: #e6f0e8;
  --sun: #f4d58d;
  --sun-soft: #fdf3dc;
  --shadow: 0 2px 10px rgba(80, 50, 40, .06);
  --radius: 16px;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP", "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.7;
  -webkit-text-size-adjust: 100%;
}
#app { max-width: 680px; margin: 0 auto; padding: 16px 16px 110px; }
a { color: var(--rose); }
h1, h2, h3 { line-height: 1.4; margin: 0; }
h1 { font-size: 22px; }
h2 { font-size: 18px; }
h3 { font-size: 15px; }
.muted { color: var(--sub); font-size: 14px; }
.en { font-family: "Georgia", "Times New Roman", serif; }

.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin: 14px 0; }
.row { display: flex; gap: 10px; align-items: center; }
.between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.stack > * + * { margin-top: 10px; }

button, .btn {
  font: inherit; border: 0; cursor: pointer; border-radius: 999px; padding: 11px 20px;
  background: var(--rose); color: #fff; font-weight: 600; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px;
}
button:disabled { opacity: .5; cursor: default; }
.btn-sub { background: var(--rose-soft); color: var(--rose); }
.btn-ghost { background: transparent; color: var(--sub); padding: 8px 12px; min-height: 36px; font-weight: 500; }
.btn-small { padding: 6px 14px; min-height: 34px; font-size: 14px; }
.btn-block { width: 100%; }

input[type=email], input[type=text], textarea {
  font: inherit; width: 100%; border: 1.5px solid var(--line); border-radius: 12px; padding: 12px 14px; background: #fff; color: var(--ink);
}
input:focus, textarea:focus { outline: none; border-color: var(--rose); }
textarea.journal { min-height: 260px; resize: vertical; font-family: "Georgia", "Times New Roman", serif; font-size: 17px; line-height: 1.8; }

/* 上部の数字 */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 12px 0; }
.stat { background: var(--card); border-radius: 14px; padding: 10px 8px; text-align: center; box-shadow: var(--shadow); }
.stat b { display: block; font-size: 22px; color: var(--rose); line-height: 1.3; }
.stat span { font-size: 12px; color: var(--sub); }

.hello { margin-top: 6px; }
.hello .date { color: var(--sub); font-size: 14px; }

.today-card { border: 2px dashed var(--rose-soft); text-align: center; }
.entry-link { display: block; color: inherit; text-decoration: none; padding: 12px 0; border-bottom: 1px solid var(--line); }
.entry-link:last-child { border-bottom: 0; }
.entry-link .d { font-size: 13px; color: var(--sub); }
.entry-link .t { font-weight: 600; }
.entry-link .p { font-size: 14px; color: var(--sub); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ヒント */
.hints { margin-top: 10px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.chip { background: var(--sun-soft); color: var(--ink); border: 0; border-radius: 999px; padding: 5px 12px; font-size: 14px; min-height: 32px; font-weight: 500; }
.chip.used { background: var(--leaf-soft); color: var(--leaf); }
.chip.used::before { content: "✓ "; }

/* 写真 */
.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; margin-top: 10px; }
.photo { position: relative; border-radius: 12px; overflow: hidden; background: var(--line); aspect-ratio: 1; }
.photo img { width: 100%; height: 100%; object-fit: cover; display: block; cursor: zoom-in; }
.photo .del { position: absolute; top: 6px; right: 6px; background: rgba(0,0,0,.55); color: #fff; border-radius: 999px; min-height: 30px; padding: 2px 10px; font-size: 13px; }
.lightbox { position: fixed; inset: 0; background: rgba(20,10,10,.85); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 16px; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 8px; }

/* 日記を読む */
.body-text { white-space: pre-wrap; font-family: "Georgia", "Times New Roman", serif; font-size: 17px; line-height: 1.85; }
.title-big { font-size: 22px; }
.title-sub { color: var(--sub); font-size: 14px; }

/* 添削 */
.fb-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.toggle { display: inline-flex; background: var(--rose-soft); border-radius: 999px; padding: 3px; }
.toggle button { background: transparent; color: var(--rose); padding: 4px 14px; min-height: 32px; font-size: 14px; }
.toggle button.on { background: var(--rose); color: #fff; }
.good { background: var(--leaf-soft); border-radius: 12px; padding: 12px 14px; }
.encourage { background: var(--sun-soft); border-radius: 12px; padding: 12px 14px; }
.point { border-left: 3px solid var(--rose); padding: 4px 0 4px 12px; margin: 14px 0; }
.point .before { color: var(--sub); text-decoration: line-through; text-decoration-color: rgba(201,103,127,.6); }
.point .after { font-weight: 600; color: var(--ink); }
.point .why { font-size: 14px; margin-top: 4px; }
details { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 10px; }
summary { cursor: pointer; font-weight: 600; color: var(--rose); }
.phrase { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; padding: 10px 0; border-bottom: 1px solid var(--line); }
.phrase:last-child { border-bottom: 0; }
.thinking { text-align: center; padding: 30px 10px; }
.dots span { display: inline-block; width: 8px; height: 8px; margin: 0 3px; background: var(--rose); border-radius: 50%; animation: bob 1s infinite ease-in-out; }
.dots span:nth-child(2) { animation-delay: .15s; } .dots span:nth-child(3) { animation-delay: .3s; }
@keyframes bob { 0%, 80%, 100% { transform: scale(.5); opacity: .4; } 40% { transform: scale(1); opacity: 1; } }

/* カレンダー */
.cal-nav { display: flex; justify-content: space-between; align-items: center; }
.cal-nav h1 { font-size: 20px; }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; margin-top: 10px; }
.cal .wd { text-align: center; font-size: 12px; color: var(--sub); padding: 4px 0; }
.cal .day { background: var(--card); border-radius: 8px; min-height: 64px; padding: 4px; font-size: 12px; color: inherit; text-decoration: none; display: flex; flex-direction: column; overflow: hidden; }
.cal .day.empty { background: transparent; }
.cal .day .n { font-size: 12px; color: var(--sub); }
.cal .day.has { background: var(--rose-soft); }
.cal .day.has .n { color: var(--rose); font-weight: 700; }
.cal .day.today { outline: 2px solid var(--rose); }
.cal .day .ct { font-size: 10.5px; line-height: 1.3; margin-top: 2px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; word-break: break-word; }
.cal .day .cam { font-size: 10px; }
@media (min-width: 560px) { .cal .day { min-height: 84px; } .cal .day .ct { font-size: 12px; } }

/* 設定 */
.opt-group { margin: 18px 0; }
.opt-group > h3 { margin-bottom: 8px; }
.opts { display: grid; gap: 8px; }
.opt { display: flex; gap: 10px; align-items: flex-start; border: 1.5px solid var(--line); border-radius: 12px; padding: 12px; cursor: pointer; background: #fff; }
.opt input { margin-top: 5px; accent-color: var(--rose); }
.opt.on { border-color: var(--rose); background: #fffafb; }
.opt b { display: block; }
.opt small { color: var(--sub); font-size: 13px; display: block; line-height: 1.5; }
.opts.three { grid-template-columns: repeat(3, 1fr); }
.opts.three .opt { flex-direction: column; align-items: center; text-align: center; gap: 2px; padding: 10px 6px; }
.opts.three .opt input { display: none; }

/* 単語帳 */
.vocab-item { padding: 12px 0; border-bottom: 1px solid var(--line); }
.vocab-item:last-child { border-bottom: 0; }
.vocab-item .ph { font-weight: 700; font-size: 17px; }
.vocab-item a.from { font-size: 13px; }

/* 管理 */
.admin-row { display: flex; justify-content: space-between; gap: 8px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 14px; word-break: break-all; }

/* 下のタブ */
#tabs { position: fixed; left: 0; right: 0; bottom: 0; background: rgba(255,255,255,.96); border-top: 1px solid var(--line); display: flex; justify-content: space-around; padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); z-index: 20; backdrop-filter: blur(8px); }
#tabs[hidden] { display: none; }
#tabs a { flex: 1; text-align: center; color: var(--sub); text-decoration: none; font-size: 11px; line-height: 1.3; padding: 4px 0; }
#tabs a .ti { display: block; font-size: 20px; }
#tabs a.on { color: var(--rose); font-weight: 700; }

#toast { position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%) translateY(20px); background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 999px; font-size: 14px; opacity: 0; pointer-events: none; transition: .25s; z-index: 60; max-width: calc(100% - 32px); text-align: center; }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.login-wrap { min-height: 80vh; display: flex; flex-direction: column; justify-content: center; }
.logo { text-align: center; margin-bottom: 10px; }
.logo img { width: 64px; height: 64px; }
.error { color: #b2384f; font-size: 14px; }
.modal-bg { position: fixed; inset: 0; background: rgba(40,20,20,.4); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 40; }
.modal { background: #fff; border-radius: var(--radius); padding: 20px; max-width: 360px; width: 100%; }

/* 復習・練習 */
.review-cta { display: flex; justify-content: space-between; align-items: center; gap: 10px; text-decoration: none; color: inherit; border: 2px solid var(--sun); background: var(--sun-soft); }
.review-cta.done { border-color: var(--leaf-soft); background: var(--leaf-soft); }
.review-cta .go { color: var(--rose); font-weight: 700; white-space: nowrap; }
.phrase-btns { display: flex; flex-direction: column; gap: 6px; flex-shrink: 0; }
.speak { background: transparent; color: inherit; padding: 0 4px; min-height: 28px; font-size: 16px; vertical-align: middle; }
.level { color: var(--rose); font-size: 11px; letter-spacing: 1px; white-space: nowrap; }
.flash { text-align: center; padding: 28px 18px; min-height: 220px; }
.flash hr { border: 0; border-top: 1px dashed var(--line); margin: 18px 0; }
.q-label { color: var(--sub); font-size: 13px; }
.q-main { font-size: 22px; font-weight: 700; margin-top: 8px; line-height: 1.5; }
.flash .from { font-size: 13px; }
.grade { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.grade button { flex-direction: column; gap: 0; border-radius: 14px; padding: 10px 4px; line-height: 1.3; }
.grade small { font-size: 11px; font-weight: 400; opacity: .85; }
.g-again { background: #f1e3e0; color: #9a4b4b; }
.g-hard { background: var(--sun-soft); color: #8a6a1f; }
.g-good { background: var(--leaf); color: #fff; }
.ex { padding: 8px 0; border-bottom: 1px solid var(--line); }
.ex:last-child { border-bottom: 0; }
.check { margin-top: 12px; border-radius: 12px; padding: 12px 14px; }
.check.ok { background: var(--leaf-soft); }
.check.ng { background: var(--sun-soft); }
.check .after, .hist .after { font-weight: 600; }
.hist { padding: 10px 0; border-bottom: 1px solid var(--line); }
.hist:last-child { border-bottom: 0; }
.hist.ok::before { content: "🌸"; float: right; }
