/* 10年日記：生成りの紙・墨の文字・えんじの差し色 */
:root {
  --paper: #f6f1e7;
  --card: #fffdf8;
  --ink: #2d2620;
  --sub: #7a6f63;
  --line: #e2d8c6;
  --accent: #8c2f39;      /* えんじ */
  --accent-soft: #f3e3e1;
  --green: #4d6b4f;
  --danger: #b3261e;
  --serif: "Hiragino Mincho ProN", "Yu Mincho", "Noto Serif JP", serif;
  --sans: -apple-system, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font-family: var(--sans); font-size: 16px; line-height: 1.7;
  padding-bottom: calc(72px + var(--safe-b));
}
button, input, textarea { font: inherit; color: inherit; }
.hidden { display: none !important; }

.top {
  position: sticky; top: 0; z-index: 5;
  background: rgba(246, 241, 231, .94); backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--line);
  padding: calc(env(safe-area-inset-top, 0px) + 10px) 16px 10px;
}
.top h1 { margin: 0; font-family: var(--serif); font-size: 18px; font-weight: 600; letter-spacing: .08em; text-align: center; }

main { max-width: 640px; margin: 0 auto; padding: 16px; }

.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--card); border-top: 1px solid var(--line);
  padding-bottom: var(--safe-b);
}
.tabs a {
  display: flex; align-items: center; justify-content: center; height: 56px;
  color: var(--sub); text-decoration: none; font-size: 14px;
}
.tabs a.on { color: var(--accent); font-weight: 700; }

/* 日付の見出し */
.dayhead { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 4px 0 12px; }
.dayhead .date { font-family: var(--serif); text-align: center; flex: 1; }
.dayhead .date .y { display: block; font-size: 13px; color: var(--sub); letter-spacing: .1em; }
.dayhead .date .d { font-size: 24px; font-weight: 600; }
.nav-btn {
  width: 44px; height: 44px; border-radius: 22px; border: 1px solid var(--line);
  background: var(--card); font-size: 20px; color: var(--sub); cursor: pointer;
}
.today-link { display: block; text-align: center; font-size: 13px; color: var(--accent); margin: -6px 0 10px; }

/* 今日の入力 */
.page {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 14px; box-shadow: 0 1px 2px rgba(60, 40, 20, .05);
}
.page textarea {
  width: 100%; min-height: 180px; border: 0; outline: none; resize: vertical; background:
    repeating-linear-gradient(to bottom, transparent 0, transparent 31px, var(--line) 31px, var(--line) 32px);
  line-height: 32px; font-family: var(--serif); font-size: 17px; padding: 0 2px;
}
.interim { min-height: 1.6em; color: var(--sub); font-family: var(--serif); font-size: 15px; }
.count { font-size: 12px; color: var(--sub); text-align: right; }

.mic-row { display: flex; flex-direction: column; align-items: center; gap: 6px; margin: 16px 0 8px; }
.mic {
  width: 88px; height: 88px; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--accent); color: #fff; box-shadow: 0 4px 12px rgba(140, 47, 57, .3);
  display: flex; align-items: center; justify-content: center;
}
.mic svg { width: 38px; height: 38px; }
.mic.rec { background: var(--danger); animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(179, 38, 30, .45); } 50% { box-shadow: 0 0 0 14px rgba(179, 38, 30, 0); } }
.mic-label { font-size: 13px; color: var(--sub); text-align: center; }

.actions { display: flex; gap: 10px; margin-top: 12px; }
.btn {
  flex: 1; height: 52px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--card); font-size: 16px; cursor: pointer;
}
.btn.primary { background: var(--ink); color: #fff; border-color: var(--ink); font-weight: 700; }
.btn.primary:disabled { opacity: .45; }
.btn.small { flex: 0 0 auto; height: 40px; padding: 0 14px; font-size: 14px; }
.saved-at { font-size: 12px; color: var(--sub); text-align: center; margin-top: 6px; }

.notice {
  background: var(--accent-soft); color: var(--ink); border-radius: 10px;
  padding: 10px 12px; font-size: 14px; margin-top: 10px;
}

/* 過去の同じ日（10年日記の段） */
.section-title {
  font-family: var(--serif); font-size: 15px; letter-spacing: .1em; color: var(--sub);
  margin: 28px 0 8px; display: flex; align-items: center; gap: 10px;
}
.section-title::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.years { display: flex; flex-direction: column; gap: 10px; }
.year {
  background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--green);
  border-radius: 10px; padding: 10px 14px; text-decoration: none; color: inherit; display: block;
}
.year .lbl { font-size: 13px; color: var(--green); font-weight: 700; }
.year .lbl small { color: var(--sub); font-weight: 400; margin-left: 6px; }
.year .txt { font-family: var(--serif); white-space: pre-wrap; word-break: break-word; margin-top: 2px; }
.year.empty { border-left-color: var(--line); color: var(--sub); font-size: 14px; }

/* カレンダー */
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.cal-head .m { font-family: var(--serif); font-size: 22px; font-weight: 600; }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal .w { text-align: center; font-size: 12px; color: var(--sub); padding: 4px 0; }
.cal .w.sun, .cal .c.sun .n { color: #b3423a; }
.cal .w.sat, .cal .c.sat .n { color: #3a62a8; }
.cal .c {
  aspect-ratio: 1 / 1.1; border-radius: 8px; background: var(--card); border: 1px solid var(--line);
  display: flex; flex-direction: column; align-items: center; justify-content: flex-start; padding-top: 6px;
  text-decoration: none; color: var(--ink); position: relative;
}
.cal .c.blank { background: transparent; border-color: transparent; }
.cal .c .n { font-size: 15px; }
.cal .c.today { border: 2px solid var(--accent); }
.cal .c.has { background: var(--accent-soft); }
.cal .c .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); margin-top: 4px; }
.cal .c .ring { width: 7px; height: 7px; border-radius: 50%; border: 1.5px solid var(--green); margin-top: 3px; }
.legend { display: flex; gap: 16px; justify-content: center; font-size: 12px; color: var(--sub); margin-top: 10px; }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.legend i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.month-list { margin-top: 18px; display: flex; flex-direction: column; gap: 8px; }
.month-list a { display: flex; gap: 10px; text-decoration: none; color: inherit; background: var(--card);
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.month-list .d { flex: 0 0 auto; font-weight: 700; color: var(--accent); font-size: 14px; min-width: 76px; }
.month-list .h { font-family: var(--serif); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 検索・その他 */
.search { display: flex; gap: 8px; }
.search input, .field input {
  flex: 1; height: 48px; border-radius: 10px; border: 1px solid var(--line); background: var(--card);
  padding: 0 12px; font-size: 16px; width: 100%;
}
mark { background: #f6dd8f; color: inherit; padding: 0 1px; }
.help { font-size: 13px; color: var(--sub); }
.box { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px; margin-bottom: 14px; }
.box h2 { font-family: var(--serif); font-size: 17px; margin: 0 0 8px; }
.box .actions { margin-top: 8px; flex-wrap: wrap; }
.login { margin-top: 40px; }
.login h2 { font-family: var(--serif); text-align: center; }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(80px + var(--safe-b)); z-index: 10;
  background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 20px; font-size: 14px;
  max-width: calc(100% - 32px);
}
