:root {
  --bg: #f7f5f0;
  --card: #ffffff;
  --text: #22303c;
  --muted: #75808c;
  --primary: #22303c;
  --accent: #6b7f6e;
  --accent-dark: #4e6253;
  --accent-soft: #e8ece6;
  --border: #ded9cf;
  --both: #48685a;
  --me: #5f7e9e;
  --partner: #a97c5f;
  --radius: 10px;
  --tabbar-h: 62px;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-tap-highlight-color: transparent;
}

.app-header {
  text-align: center;
  padding: 22px 16px 8px;
}
.app-header h1 {
  font-size: 1.25rem;
  margin: 0;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--text);
}
.anniv-chip {
  display: inline-block;
  margin: 10px 0 0;
  padding: 4px 12px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 600;
}

main {
  max-width: 640px;
  margin: 0 auto;
  padding: 12px 14px calc(var(--tabbar-h) + 24px);
}

.section-title { font-size: 1.1rem; margin: 8px 0; font-weight: 700; letter-spacing: 0.02em; }
.sub-title { font-size: 1rem; margin: 22px 0 4px; font-weight: 700; }
.count-text { color: var(--muted); font-size: 0.9rem; margin: 6px 0; }
.hint-text { color: var(--muted); font-size: 0.85rem; line-height: 1.6; margin: 6px 0; }
.error-text { color: #b3261e; font-size: 0.85rem; }
.empty-text { text-align: center; color: var(--muted); line-height: 1.8; padding: 28px 0; }

/* buttons */
.btn {
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 16px;
  font-size: 0.9rem;
  cursor: pointer;
  font-family: inherit;
}
.btn:active { transform: scale(0.98); }
.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #f7f5f0;
  font-weight: 600;
}
.btn-sub { background: var(--accent-soft); border-color: transparent; color: var(--accent-dark); font-weight: 600; }
.btn-block { display: block; width: 100%; padding: 12px; margin: 10px 0 14px; font-size: 1rem; }
.btn-icon { border-radius: 50%; width: 38px; height: 38px; padding: 0; font-size: 1.3rem; line-height: 1; }
.btn-danger { color: #b3261e; }
.btn-small { padding: 5px 12px; font-size: 0.8rem; }

/* chips */
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 2px; }
.chip {
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 0.82rem;
  cursor: pointer;
  font-family: inherit;
}
.chip.active { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }
.cat-chip {
  display: inline-block;
  background: var(--accent-soft);
  color: var(--accent-dark);
  border-radius: 6px;
  padding: 2px 10px;
  font-size: 0.75rem;
  font-weight: 600;
}

/* list */
.list-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.card-list { display: flex; flex-direction: column; gap: 10px; }
.item-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: 0 1px 2px rgba(34, 48, 60, 0.05);
}
.item-card.highlight { outline: 2px solid var(--accent); outline-offset: 2px; }
.item-card h3 { margin: 6px 0 4px; font-size: 1.05rem; }
.item-meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.plan-date { font-size: 0.8rem; color: var(--accent-dark); font-weight: 600; }
.item-memo { margin: 4px 0; font-size: 0.9rem; line-height: 1.6; white-space: pre-wrap; word-break: break-word; }
.memory-memo { background: #f1eee6; border-radius: 8px; padding: 8px 10px; }
.item-link { font-size: 0.85rem; color: var(--me); word-break: break-all; }
.item-sub { color: var(--muted); font-size: 0.75rem; margin-top: 4px; }
.item-actions { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }

/* tab bar */
.tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: rgba(255, 255, 255, 0.97);
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 40;
}
.tab-btn {
  flex: 1;
  background: none;
  border: none;
  font-family: inherit;
  font-size: 0.72rem;
  color: var(--muted);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
}
.tab-btn .tab-icon { display: flex; align-items: center; justify-content: center; }
.tab-btn .tab-icon svg { width: 22px; height: 22px; display: block; }
.tab-btn.active { color: var(--primary); font-weight: 700; }
.btn .icon-svg { width: 15px; height: 15px; vertical-align: -2px; margin-right: 6px; }

/* map */
.segmented { display: flex; background: #eae7df; border-radius: 10px; padding: 3px; gap: 3px; }
.segmented button {
  flex: 1;
  border: none;
  background: transparent;
  border-radius: 7px;
  padding: 8px 4px;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
}
.segmented button.active[data-mode="both"] { background: var(--both); color: #fff; }
.segmented button.active[data-mode="me"] { background: var(--me); color: #fff; }
.segmented button.active[data-mode="partner"] { background: var(--partner); color: #fff; }
.legend { display: flex; gap: 14px; margin: 10px 0 2px; font-size: 0.8rem; color: var(--muted); flex-wrap: wrap; }
.legend-item { display: inline-flex; align-items: center; gap: 5px; }
.swatch { width: 14px; height: 14px; border-radius: 4px; display: inline-block; }
.sw-both { background: var(--both); }
.sw-me { background: var(--me); }
.sw-partner { background: var(--partner); }

.jp-grid {
  display: grid;
  grid-template-columns: repeat(11, 1fr);
  gap: 3px;
  margin: 8px 0 4px;
}
.jp-tile {
  aspect-ratio: 1;
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: 5px;
  font-size: 0.58rem;
  font-family: inherit;
  color: var(--text);
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  line-height: 1.1;
}
.jp-tile.mark-both { background: var(--both); border-color: var(--both); color: #fff; font-weight: 700; }
.jp-tile.mark-me { background: var(--me); border-color: var(--me); color: #fff; font-weight: 700; }
.jp-tile.mark-partner { background: var(--partner); border-color: var(--partner); color: #fff; font-weight: 700; }

.region-title { font-size: 0.95rem; margin: 16px 0 6px; color: var(--text); font-weight: 700; }
.country-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.country-chip {
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.85rem;
  font-family: inherit;
  cursor: pointer;
}
.country-chip.mark-both { background: var(--both); border-color: var(--both); color: #fff; font-weight: 700; }
.country-chip.mark-me { background: var(--me); border-color: var(--me); color: #fff; font-weight: 700; }
.country-chip.mark-partner { background: var(--partner); border-color: var(--partner); color: #fff; font-weight: 700; }

/* calendar */
.cal-header { display: flex; align-items: center; justify-content: space-between; }
.cal-weekdays, .cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; }
.cal-weekdays span { text-align: center; font-size: 0.75rem; color: var(--muted); padding: 4px 0; }
.cal-cell {
  aspect-ratio: 1;
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  padding: 0;
  color: var(--text);
}
.cal-cell.empty { border: none; background: transparent; cursor: default; }
.cal-cell.today { border-color: var(--primary); font-weight: 700; }
.cal-cell.selected { background: var(--accent-soft); border-color: var(--accent); }
.cal-cell .cal-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--accent); }
.cal-cell .cal-anniv { font-size: 0.55rem; line-height: 1; color: var(--accent-dark); font-weight: 700; letter-spacing: 0.02em; }
#calDayDetail { margin-top: 14px; }
#calDayDetail h3 { font-size: 0.95rem; margin: 6px 0; }

/* settings */
.settings-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
}
.settings-card h3 { margin: 0 0 8px; font-size: 0.95rem; }
.room-row { display: flex; align-items: center; gap: 8px; margin: 8px 0; }
.room-code {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  background: var(--bg);
  border: 1px dashed var(--accent);
  border-radius: 8px;
  padding: 8px 12px;
  flex: 1;
  text-align: center;
}
.join-row { display: flex; gap: 8px; margin-top: 8px; }
.join-row input { flex: 1; min-width: 0; }
.field { display: flex; align-items: center; gap: 10px; margin: 8px 0; font-size: 0.9rem; }
.field span { width: 7.5em; color: var(--muted); flex-shrink: 0; }
.field input { flex: 1; min-width: 0; }
input[type="text"], input[type="date"], input[type="url"], textarea, select {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 10px;
  font-size: 0.95rem;
  font-family: inherit;
  background: #fff;
  color: var(--text);
  width: 100%;
}
input[type="text"]:focus, input[type="date"]:focus, input[type="url"]:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--accent);
}
.file-label { display: inline-flex; align-items: center; cursor: pointer; }

/* modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(34, 48, 60, 0.48);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 100;
}
.modal-sheet {
  background: #fff;
  width: 100%;
  max-width: 640px;
  max-height: 88vh;
  overflow-y: auto;
  border-radius: 14px 14px 0 0;
  padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
}
.modal-sheet h2 { font-size: 1.05rem; margin: 0 0 12px; }
.modal-sheet .field { align-items: flex-start; }
.modal-sheet .field span { padding-top: 9px; }
.modal-actions { display: flex; gap: 8px; margin-top: 14px; }
.modal-actions .btn { flex: 1; padding: 11px; }
.random-result { text-align: center; padding: 8px 0; }
.random-result .big { font-size: 1.3rem; font-weight: 700; margin: 10px 0 4px; }
textarea { resize: vertical; min-height: 64px; }
