:root {
    --bg-color: #ffffff;
    --card-bg: #ffffff;
    --text-primary: #000000;
    --text-secondary: #707070;
    --accent-color: #000000;
    --accent-contrast: #ffffff;
    --border-color: #eeeeee;
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { margin: 0; padding: 0; box-sizing: border-box; font-family: -apple-system, BlinkMacSystemFont, "Inter", "Outfit", sans-serif; -webkit-tap-highlight-color: transparent; }

body { background-color: var(--bg-color); color: var(--text-primary); }

.app-container { max-width: 500px; margin: 0 auto; padding: calc(40px + var(--safe-top)) 20px calc(140px + var(--safe-bottom)); position: relative; min-height: 100vh; }

/* Animations */
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
main:not(.hidden) { animation: fadeIn 0.4s ease-out; }
.modal-content { animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1); }
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }


/* Themes */
body.dark-mode { --bg-color: #000000; --card-bg: #111111; --text-primary: #ffffff; --text-secondary: #888888; --border-color: #222222; --accent-color: #ffffff; --accent-contrast: #111111; }
body.dark-mode .event-card, body.dark-mode .modal-content, body.dark-mode .bottom-nav { background: #111111; border-color: #222222; }
body.dark-mode .albus-input { border-bottom-color: #222222; color: #ffffff; }
body.dark-mode .save-btn[style*="background:#f9f9f9"] { background: #1a1a1a !important; color: #ffffff !important; }


/* Theme Picker */
.theme-picker { display: flex; gap: 15px; margin-top: 10px; }
.theme-dot { width: 30px; height: 30px; border-radius: 50%; cursor: pointer; transition: 0.2s; position: relative; }
.theme-dot.active::after { content: '✓'; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); color: #888; font-size: 14px; }
.theme-dot[data-theme="dark"].active::after { color: #fff; }


/* typography */
.logo {
    font-family: 'Outfit';
    font-size: 56px;
    font-weight: 900;
    letter-spacing: -1.5px;
    color: #000;
    margin-bottom: 15px;
    text-align: center;
}

.onboarding-card {
    text-align: center;
    padding: 60px 40px;
    display: flex;
    flex-direction: column;
    align-items: center;
    max-width: 450px;
    width: 90%;
}

.save-btn, .social-btn {
    cursor: pointer !important;
    transition: all 0.2s ease;
    border: none;
    outline: none;
}

.save-btn:hover, .social-btn:hover {
    filter: brightness(0.95);
    transform: translateY(-1px);
}

.save-btn:active, .social-btn:active {
    transform: translateY(1px);
    opacity: 0.8;
}

/* ALBUS Input */
.albus-input {
    width: 100%; padding: 12px 0; border: none; border-bottom: 1px solid #ddd;
    background: transparent; font-size: 15px; margin-bottom: 25px; outline: none; transition: 0.3s;
}
.albus-input:focus { border-bottom-color: #000; }
.albus-input.large { font-size: 24px; font-weight: 600; }
.albus-input.tall { height: 120px; resize: none; margin-bottom: 15px; }

/* Contacts Grid */
.contacts-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 20px; }
.friend-card { text-align: center; cursor: pointer; }
.avatar-container { width: 100%; aspect-ratio: 1/1; background: #fff; border: 1px solid #f0f0f0; overflow: hidden; margin-bottom: 5px; border-radius: 4px; position: relative; }
.avatar { width: 100%; height: 100%; object-fit: cover; }
.friend-card h4 { font-size: 10px; font-weight: 400; color: #555; }

.tier-badge {
    position: absolute; bottom: 5px; right: 5px; font-size: 8px; font-weight: 700;
    padding: 2px 4px; border-radius: 4px; background: rgba(0,0,0,0.6); color: #fff;
    backdrop-filter: blur(4px);
}
.tier-badge.lvl-1 { background: rgba(0,0,0,0.1); color: #888; }
.tier-badge.lvl-2 { background: rgba(66, 133, 244, 0.8); }
.tier-badge.lvl-3 { background: rgba(225, 29, 72, 0.8); }


/* Events Grid */
#events-list {
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding-bottom: 80px;
}
.event-card { background: #fff; padding: 15px; border-radius: 20px; border: 1px solid #f0f0f0; box-shadow: 0 4px 15px rgba(0,0,0,0.02); cursor: pointer; }
.event-photo { width: 100%; aspect-ratio: 16/9; border-radius: 12px; object-fit: cover; margin-bottom: 12px; }
.event-card h4 { font-size: 16px; font-weight: 600; color: #1a1a1a; margin: 0; }
.event-card-info { display: flex; justify-content: space-between; align-items: center; margin-top: 5px; }
.event-card-meta { font-size: 12px; color: #999; }

/* Modal */
.modal-overlay, .modal { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.4); z-index: 1000; display: flex; align-items: flex-end; backdrop-filter: blur(8px); }
.modal-content, .onboarding-card { background: #fff; width: 100%; max-width: 500px; margin: 0 auto; border-radius: 30px 30px 0 0; padding: 50px 30px; position: relative; }
.onboarding-card { border-radius: 0; height: 100vh; display: flex; flex-direction: column; justify-content: center; text-align: center; }

.close-btn {
    position: absolute; top: 15px; right: 15px; width: 40px; height: 40px;
    border: none; background: rgba(0,0,0,0.05); color: #333;
    border-radius: 50%; display: flex; align-items: center; justify-content: center;
    font-size: 24px; cursor: pointer; z-index: 10;
}

/* Wizard */
.wizard-actions { position: absolute; bottom: 40px; left: 30px; right: 30px; display: flex; align-items: center; }
.wizard-back-icon {
    width: 50px; height: 50px; border-radius: 50%; border: 1px solid #eee; background: none; font-size: 20px; color: #999; cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.wizard-next-btn {
    background: #000; color: #fff; border: none; padding: 15px 40px; border-radius: 12px; font-weight: 600; font-size: 15px; cursor: pointer;
}

/* Tier Selection */
.tier-select-grid { display: grid; gap: 10px; }
.tier-option { cursor: pointer; position: relative; }
.tier-option input { position: absolute; opacity: 0; }
.tier-opt-inner { border: 1px solid #eee; padding: 18px; border-radius: 15px; transition: 0.2s; }
.tier-option input:checked + .tier-opt-inner { border-color: #000; background: #fafafa; }

/* Toggle Card */
.toggle-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 0;
    border-bottom: 1px solid #eee;
    margin-bottom: 20px;
}
.toggle-card span { font-size: 14px; font-weight: 600; }
input[type="checkbox"] { width: 20px; height: 20px; accent-color: #000; }

/* Wizard Step Spacing */
.wizard-step h3 { font-family: 'Outfit'; font-size: 20px; margin-bottom: 20px; }

/* Modal Tabs */
.modal-tabs { display: flex; justify-content: center; gap: 20px; margin-bottom: 20px; }
.modal-tab {
    background: none; border: none; font-size: 14px; font-weight: 600; color: #ccc; cursor: pointer; padding: 10px 0; border-bottom: 2px solid transparent;
}
.modal-tab.active { color: #000; border-bottom-color: #000; }
.tab-content.hidden { display: none; }



/* Filter Tabs */
.filter-tabs { display: flex; gap: 10px; margin: 15px 0; overflow-x: auto; padding-bottom: 10px; scrollbar-width: none; }
.filter-tabs::-webkit-scrollbar { display: none; }
.filter-tab { background: none; border: 1px solid #eee; padding: 8px 18px; border-radius: 20px; font-size: 11px; color: #999; cursor: pointer; white-space: nowrap; }
.filter-tab.active { background: var(--accent-color); color: var(--accent-contrast); border-color: var(--accent-color); }

/* Bottom Nav */
.bottom-nav { position: fixed; bottom: 0; left: 50%; transform: translateX(-50%); width: 100%; max-width: 500px; background: rgba(255,255,255,0.9); backdrop-filter: blur(10px); display: flex; justify-content: space-around; padding: 25px 0 calc(45px + var(--safe-bottom)); border-top: 1px solid #f0f0f0; z-index: 100; }
.nav-item { background: none; border: none; font-size: 26px; color: #ddd; cursor: pointer; }
.nav-item.active { color: #000; }

.save-btn { width: 100%; padding: 18px; border-radius: 12px; border: none; background: var(--accent-color); color: var(--accent-contrast); font-weight: 600; cursor: pointer; font-size: 15px; }
.hidden { display: none !important; }

/* RSVP */
.attendee-item { display: flex; align-items: center; gap: 15px; padding: 12px 0; border-bottom: 1px solid #f9f9f9; }
.attendee-avatar { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; }
.attendee-name { font-size: 13px; font-weight: 600; }
.attendee-item-bringing { font-size: 12px; color: #777; margin-top: 2px; }

/* Buttons */
.social-login-grid { display: grid; gap: 10px; width: 100%; margin-top: 20px; }
.social-btn { padding: 18px; border: none; border-radius: 12px; color: #fff; font-weight: 700; cursor: pointer; }
.line-btn { background: #06c755; }
.google-btn { background: #4285f4; }
.icon-btn { background: none; border: none; font-size: 32px; cursor: pointer; padding: 5px; }
.header-actions { position: absolute; top: 40px; right: 20px; }

/* ===================== */
/* Toast System          */
/* ===================== */
#toast-container {
  position: fixed;
  bottom: calc(110px + env(safe-area-inset-bottom, 0px));
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  pointer-events: none;
  width: calc(100% - 40px);
  max-width: 440px;
}
.toast {
  padding: 14px 18px;
  border-radius: 16px;
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.18);
  animation: toastIn 0.35s cubic-bezier(0.4,0,0.2,1);
  width: 100%;
}
.toast-success { background: #1a1a1a; color: #fff; }
.toast-error { background: #e11d48; color: #fff; }
.toast-info { background: #4285f4; color: #fff; }
.toast-warning { background: #f59e0b; color: #fff; }
@keyframes toastIn {
  from { opacity:0; transform: translateY(20px) scale(0.95); }
  to { opacity:1; transform: translateY(0) scale(1); }
}
@keyframes toastOut {
  from { opacity:1; transform: scale(1); }
  to { opacity:0; transform: scale(0.9); }
}

/* ===================== */
/* Custom Dialog         */
/* ===================== */
#custom-dialog-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(10px);
  z-index: 9998;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
#custom-dialog-box {
  background: #fff;
  width: 100%;
  max-width: 500px;
  border-radius: 28px 28px 0 0;
  padding: 30px 24px calc(30px + env(safe-area-inset-bottom, 0px));
  animation: slideUp 0.35s cubic-bezier(0.4,0,0.2,1);
}
#custom-dialog-box h4 {
  font-family: 'Outfit';
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 10px;
}
#custom-dialog-box p {
  font-size: 14px;
  color: #666;
  margin-bottom: 24px;
  line-height: 1.6;
}
.dialog-actions {
  display: grid;
  gap: 10px;
}
.dialog-btn {
  width: 100%;
  padding: 16px;
  border-radius: 14px;
  border: none;
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
}
.dialog-btn-primary { background: #000; color: #fff; }
.dialog-btn-danger { background: #fdeaea; color: #e11d48; }
.dialog-btn-cancel { background: #f3f4f6; color: #666; }
#custom-dialog-input {
  width: 100%;
  padding: 14px 16px;
  border: 1.5px solid #eee;
  border-radius: 12px;
  font-size: 15px;
  margin-bottom: 16px;
  outline: none;
  transition: border-color 0.2s;
}
#custom-dialog-input:focus { border-color: #000; }

/* ===================== */
/* Settings Sections     */
/* ===================== */
.settings-section {
  margin-bottom: 28px;
  padding-bottom: 20px;
  border-bottom: 1px solid #f0f0f0;
}
.settings-section-title {
  font-family: 'Outfit';
  font-size: 13px;
  font-weight: 700;
  color: #999;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 16px;
}
.settings-label {
  font-size: 12px;
  color: #666;
  display: block;
  margin-bottom: 4px;
}
.privacy-field {
  margin-bottom: 20px;
}
.privacy-field-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}
.privacy-select {
  font-size: 11px;
  border: 1px solid #eee;
  border-radius: 8px;
  padding: 4px 8px;
  background: #fafafa;
  color: #666;
  cursor: pointer;
  outline: none;
}

/* ===================== */
/* Wizard Progress       */
/* ===================== */
.wizard-progress-bar {
  margin-bottom: 24px;
}
.wizard-progress-steps {
  display: flex;
  align-items: center;
  margin-bottom: 10px;
}
.wps {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #eee;
  color: #bbb;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  transition: all 0.3s;
}
.wps.active { background: #000; color: #fff; }
.wps.done { background: #22c55e; color: #fff; }
.wps-line { flex: 1; height: 2px; background: #eee; transition: background 0.3s; }
.wps-line.done { background: #22c55e; }
.wizard-step-label {
  font-size: 13px;
  color: #999;
  font-weight: 600;
}

/* Quick Templates */
.quick-templates { margin-top: 30px; }
.template-chip {
  padding: 8px 14px;
  border: 1px solid #eee;
  border-radius: 20px;
  background: #fff;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
}
.template-chip:hover { border-color: #000; background: #000; color: #fff; }

/* Event Input Group */
.event-input-group { margin-bottom: 8px; }
.event-input-label { font-size: 13px; font-weight: 600; color: #333; display: block; margin-bottom: 8px; }

/* Capacity Buttons */
.capacity-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1.5px solid #eee;
  background: #fff;
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}
.capacity-btn:hover { border-color: #000; }

/* Toggle Switch */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 50px;
  height: 28px;
  flex-shrink: 0;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute;
  inset: 0;
  background: #ddd;
  border-radius: 28px;
  cursor: pointer;
  transition: 0.3s;
}
.toggle-slider::before {
  content: '';
  position: absolute;
  height: 22px;
  width: 22px;
  left: 3px;
  bottom: 3px;
  background: white;
  border-radius: 50%;
  transition: 0.3s;
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}
.toggle-switch input:checked + .toggle-slider { background: #000; }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(22px); }

/* ===================== */
/* Tutorial              */
/* ===================== */
#tutorial-overlay {
  position: fixed;
  inset: 0;
  background: #fff;
  z-index: 10000;
  overflow: hidden;
}
.tutorial-slides-wrapper {
  display: flex;
  height: 100%;
  transition: transform 0.4s cubic-bezier(0.4,0,0.2,1);
}
.tutorial-slide {
  min-width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 40px;
  text-align: center;
}
.tutorial-emoji {
  font-size: 80px;
  margin-bottom: 32px;
  animation: bounce 2s infinite;
}
@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}
.tutorial-slide h2 {
  font-family: 'Outfit';
  font-size: 28px;
  font-weight: 900;
  margin-bottom: 20px;
  line-height: 1.3;
}
.tutorial-slide p {
  font-size: 15px;
  color: #666;
  line-height: 1.7;
  max-width: 320px;
}
.tutorial-dots {
  position: fixed;
  bottom: calc(120px + env(safe-area-inset-bottom,0px));
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
}
.tdot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #ddd;
  transition: all 0.3s;
}
.tdot.active { background: #000; width: 24px; border-radius: 4px; }

/* ===================== */
/* Profile Page          */
/* ===================== */
.profile-edit-btn {
  background: #f3f4f6;
  border: none;
  padding: 10px 20px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  color: #333;
  transition: all 0.2s;
}
.profile-edit-btn:hover { background: #e5e7eb; }

/* ===================== */
/* v3 additions          */
/* ===================== */
.sync-badge {
  position: absolute;
  top: -4px;
  left: -4px;
  font-size: 11px;
  background: #eff6ff;
  border-radius: 50%;
  padding: 2px;
  line-height: 1;
}
.avatar-container { position: relative; }
#qr-canvas svg { width: 100%; height: 100%; display: block; }
#qr-actions { display: grid; gap: 8px; }
#qr-actions.hidden { display: none; }
.social-btn:disabled, .save-btn:disabled { opacity: 0.6; }

/* ═══════ v3.3: ナビゲーション（SVGアイコン） ═══════ */
.nav-item { display: flex; flex-direction: column; align-items: center; gap: 4px; color: #c4c4c4; transition: color 0.15s; }
.nav-item svg { width: 23px; height: 23px; }
.nav-item .nav-label { font-size: 9px; font-weight: 600; letter-spacing: 0.05em; }
.nav-item.active { color: var(--accent-color); }
body.dark-mode .nav-item { color: #555; }

/* ═══════ v3.3: 並び替えコントロール ═══════ */
.sort-control { display: flex; align-items: center; gap: 6px; margin-top: 2px; }
.sort-control .sort-label { font-size: 10px; color: #bbb; margin-right: 2px; }
.sort-chip { background: none; border: none; font-size: 11px; color: #aaa; padding: 6px 10px; border-radius: 8px; cursor: pointer; }
.sort-chip.active { background: var(--accent-color); color: var(--accent-contrast); font-weight: 700; }

/* ═══════ v3.3: 季節カード（エディトリアル調） ═══════ */
.seasonal-card { background: #fff; border: 1px solid #f0f0f0; border-radius: 16px; padding: 16px 18px 14px; margin-bottom: 14px; position: relative; box-shadow: 0 2px 12px rgba(0,0,0,0.03); overflow: hidden; }
.seasonal-card::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--sc-accent, #888); }
.seasonal-card .sc-emoji { position: absolute; right: -6px; bottom: -14px; font-size: 64px; opacity: 0.07; pointer-events: none; }
.seasonal-card .sc-kicker { font-size: 9px; font-weight: 700; letter-spacing: 0.14em; color: var(--sc-accent, #888); margin-bottom: 6px; }
.seasonal-card .sc-title { font-family: 'Outfit', 'Inter', sans-serif; font-size: 15px; font-weight: 700; margin-bottom: 4px; }
.seasonal-card .sc-msg { font-size: 12px; color: #666; line-height: 1.6; margin-bottom: 12px; }
.seasonal-card .sc-cta { font-size: 12px; font-weight: 700; padding: 9px 16px; border-radius: 10px; border: none; background: var(--sc-accent, #333); color: #fff; cursor: pointer; }
.seasonal-card .sc-item { font-size: 11px; color: #777; text-decoration: none; border: 1px solid #eee; border-radius: 14px; padding: 6px 12px; background: #fafafa; }
.seasonal-card .sc-dismiss { position: absolute; top: 10px; right: 12px; background: none; border: none; color: #ccc; font-size: 16px; cursor: pointer; padding: 2px 6px; }
body.dark-mode .seasonal-card { background: #161616; border-color: #242424; }
body.dark-mode .seasonal-card .sc-item { background: #1d1d1d; border-color: #2a2a2a; color: #999; }

/* ═══════ v3.3: 誕生日セクション ═══════ */
.bday-card { background: #fff; border: 1px solid #f0f0f0; border-left: 3px solid #d97706; border-radius: 14px; padding: 12px 16px; margin-bottom: 18px; box-shadow: 0 2px 12px rgba(0,0,0,0.03); }
.bday-card .bd-kicker { font-size: 9px; font-weight: 700; letter-spacing: 0.14em; color: #d97706; margin-bottom: 10px; }
body.dark-mode .bday-card { background: #161616; border-color: #242424; border-left-color: #d97706; }

/* ═══════ v3.3: ⚡フラッシュイベント ═══════ */
.event-card.flash { border: 1px solid #fde68a; box-shadow: 0 4px 16px rgba(217,119,6,0.12); }
.flash-badge { display: inline-flex; align-items: center; gap: 4px; background: #b45309; color: #fff; font-size: 9px; font-weight: 700; letter-spacing: 0.08em; padding: 3px 9px; border-radius: 10px; }
.event-card.public { border: 1px solid #cce0ff; background: #f6f9ff; }
body.dark-mode .event-card.public { background: #0f1830; border-color: #1e3a6b; }
.public-badge { display: inline-flex; align-items: center; gap: 4px; background: #1976d2; color: #fff; font-size: 9px; font-weight: 700; letter-spacing: 0.06em; padding: 3px 9px; border-radius: 10px; }

/* ═══════ v3.5: 言語切替 ═══════ */
.lang-picker { display: flex; gap: 8px; flex-wrap: wrap; }
.lang-chip { background: none; border: 1px solid #eee; padding: 8px 16px; border-radius: 20px; font-size: 12px; color: #999; cursor: pointer; }
.lang-chip.active { background: var(--accent-color); color: var(--accent-contrast); border-color: var(--accent-color); }
body.dark-mode .lang-chip { border-color: #2a2a2a; }

/* ═══════ v3.6: アクセントカラー・パレット / 外観トグル ═══════ */
.accent-picker { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.accent-dot { width: 30px; height: 30px; border-radius: 50%; cursor: pointer; border: 2px solid transparent; box-shadow: 0 0 0 1px #e5e5e5 inset; transition: transform 0.12s; }
.accent-dot:hover { transform: scale(1.1); }
.accent-dot.active { border-color: var(--text-primary); box-shadow: 0 0 0 2px var(--bg-color) inset, 0 2px 8px rgba(0,0,0,0.18); }
.accent-dot.accent-auto { background: linear-gradient(135deg, #111 50%, #fff 50%); }
.appearance-toggle { display: inline-flex; gap: 6px; background: #f3f4f6; border-radius: 12px; padding: 4px; }
body.dark-mode .appearance-toggle { background: #1a1a1a; }
.appearance-btn { border: none; background: none; padding: 8px 16px; border-radius: 9px; font-size: 12px; color: var(--text-secondary); cursor: pointer; }
.appearance-btn.active { background: var(--card-bg); color: var(--text-primary); font-weight: 700; box-shadow: 0 1px 4px rgba(0,0,0,0.08); }
body.dark-mode .appearance-btn.active { background: #2a2a2a; }
