:root {
  --bg: #f4f1ea;
  --surface: #ffffff;
  --ink: #2c3038;
  --ink-soft: #6b7280;
  --line: #e6e1d6;
  --navy: #2f3b52;
  --navy-d: #233047;
  --accent: #c0703f;
  --danger: #c0392b;
  --ok: #2e7d4f;
  --shadow: 0 2px 10px rgba(40,40,50,.08);
  --radius: 14px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Zen Maru Gothic", system-ui, -apple-system, "Hiragino Kaku Gothic ProN", sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-text-size-adjust: 100%;
}

/* ===== Header ===== */
.app-header {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; padding: 10px 14px;
  background: var(--navy); color: #fff;
  box-shadow: var(--shadow);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.brand-icon { font-size: 1.3rem; }
.brand-name { font-size: 1.1rem; }
.header-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.count-badge { font-size: .8rem; color: #cdd6e6; }

/* ===== Buttons ===== */
.btn {
  font-family: inherit; font-size: .92rem; font-weight: 500;
  border: 0; border-radius: 999px; padding: 8px 14px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 4px; line-height: 1;
  transition: filter .15s, background .15s;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { filter: brightness(1.05); }
.btn-primary:disabled { opacity: .6; cursor: default; }
.btn-ghost { background: #e7e2d7; color: var(--ink); }
.btn-ghost:hover { filter: brightness(.97); }
.app-header .btn-ghost { background: rgba(255,255,255,.14); color: #fff; }
.app-header .btn-ghost:hover { background: rgba(255,255,255,.24); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-block { width: 100%; justify-content: center; padding: 12px; font-size: 1rem; }

/* ===== Layout ===== */
.main { max-width: 880px; margin: 0 auto; padding: 16px 14px 64px; }
.view { display: none; }
.view.active { display: block; }

/* ===== Login ===== */
.login-card {
  max-width: 360px; margin: 8vh auto 0; background: var(--surface);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 28px 24px; text-align: center;
}
.login-icon { font-size: 2.6rem; }
.login-title { margin: 6px 0 2px; font-size: 1.5rem; }
.login-sub { margin: 0 0 18px; color: var(--ink-soft); font-size: .9rem; }
.login-form { display: flex; flex-direction: column; gap: 12px; text-align: left; }
.login-form label { display: flex; flex-direction: column; gap: 4px; font-size: .85rem; color: var(--ink-soft); }
.login-form input {
  width: 100%; padding: 11px; border: 1px solid var(--line); border-radius: 10px;
  font-size: 1rem; font-family: inherit;
}

/* ===== Search & chips ===== */
.search-row { margin-bottom: 12px; }
.search-input {
  width: 100%; padding: 12px 14px; border: 1px solid var(--line);
  border-radius: 999px; font-size: 1rem; font-family: inherit; background: var(--surface);
}
.upcoming {
  background: #fff4e9; border: 1px solid #f0d7bf; border-radius: 12px;
  padding: 10px 12px; margin-bottom: 12px; font-size: .9rem; line-height: 1.9;
}
.tag-filter { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.chip {
  font-family: inherit; font-size: .82rem; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); border-radius: 999px;
  padding: 5px 11px; cursor: pointer;
}
.chip-on { background: var(--navy); color: #fff; border-color: var(--navy); }
.chip-bday { background: #fff; border-color: #f0d7bf; }

/* ===== People grid ===== */
.people-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px;
}
.person-card {
  display: flex; gap: 12px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px; cursor: pointer;
  box-shadow: var(--shadow); transition: transform .12s, box-shadow .12s;
}
.person-card:hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(40,40,50,.12); }
.avatar {
  flex: 0 0 auto; width: 44px; height: 44px; border-radius: 50%;
  background: var(--navy); color: #fff; display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem; font-weight: 700;
}
.card-body { min-width: 0; flex: 1; }
.card-name { font-weight: 700; font-size: 1.05rem; display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; }
.card-reading { font-size: .72rem; color: var(--ink-soft); font-weight: 400; }
.card-meta { font-size: .85rem; color: var(--ink-soft); margin-top: 2px; }
.card-likes { font-size: .85rem; color: var(--accent); margin-top: 4px; }
.card-bday { display: inline-block; font-size: .8rem; color: var(--ink-soft); margin-top: 4px; }
.card-tags { margin-top: 6px; display: flex; flex-wrap: wrap; gap: 4px; }
.tag { font-size: .72rem; background: #eef0f4; color: #50607a; border-radius: 6px; padding: 2px 7px; }
.card-lastlog { margin-top: 8px; font-size: .8rem; color: var(--ink-soft); border-top: 1px dashed var(--line); padding-top: 6px; }

/* 一覧カードの「＋ ひとこと」クイック追記 */
.quick-zone { margin-top: 8px; }
.quick-toggle {
  font-family: inherit; font-size: .78rem; color: var(--accent);
  background: none; border: 1px dashed #e0c4ab; border-radius: 8px;
  padding: 4px 10px; cursor: pointer;
}
.quick-toggle:hover { background: #fff4e9; }
.quick-box { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.quick-input {
  width: 100%; padding: 8px; border: 1px solid var(--line); border-radius: 8px;
  font-family: inherit; font-size: .9rem; resize: vertical; box-sizing: border-box;
}
.quick-save {
  align-self: flex-end; font-family: inherit; font-size: .82rem;
  background: var(--accent); color: #fff; border: 0; border-radius: 999px;
  padding: 6px 16px; cursor: pointer;
}
.quick-save:hover { filter: brightness(1.05); }

.empty { text-align: center; color: var(--ink-soft); padding: 48px 16px; }
.empty-icon { font-size: 2.4rem; }

/* ===== Form ===== */
.person-form { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 18px; box-shadow: var(--shadow); }
.person-form-title { margin: 0 0 16px; font-size: 1.25rem; }
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; font-size: .85rem; color: var(--ink-soft); }
.field .req { color: var(--danger); font-size: .72rem; }
.field input, .field textarea {
  width: 100%; padding: 11px; border: 1px solid var(--line); border-radius: 10px;
  font-size: 1rem; font-family: inherit; color: var(--ink); background: #fff;
}
.field textarea { resize: vertical; }

.log-section { margin: 18px 0; border-top: 1px solid var(--line); padding-top: 14px; }
.log-head { font-weight: 700; font-size: .95rem; margin-bottom: 10px; }
.log-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.log-empty { color: var(--ink-soft); font-size: .85rem; margin: 0; }
.log-item {
  display: flex; gap: 8px; align-items: flex-start; background: #faf8f3;
  border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; font-size: .9rem;
}
.log-date { flex: 0 0 auto; color: var(--accent); font-size: .78rem; padding-top: 2px; }
.log-text { flex: 1; min-width: 0; word-break: break-word; }
.log-del { flex: 0 0 auto; background: none; border: 0; color: var(--ink-soft); cursor: pointer; font-size: .9rem; }
.log-add { display: flex; gap: 8px; align-items: flex-end; }
.log-add textarea { flex: 1; min-width: 0; padding: 10px; border: 1px solid var(--line); border-radius: 10px; font-family: inherit; font-size: .95rem; resize: vertical; }

.form-actions { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.form-actions .spacer { flex: 1; }

/* ===== Banner ===== */
.banner {
  position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%) translateY(20px);
  background: var(--navy-d); color: #fff; padding: 11px 18px; border-radius: 999px;
  font-size: .9rem; box-shadow: 0 4px 16px rgba(0,0,0,.2); opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s; z-index: 50; max-width: 90vw; text-align: center;
}
.banner.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.banner-error { background: var(--danger); }
.banner-success { background: var(--ok); }

@media (max-width: 480px) {
  .brand-name { font-size: 1rem; }
  .btn { padding: 7px 11px; font-size: .85rem; }
  .people-grid { grid-template-columns: 1fr; }
}
