/* ===== CSS Variables ===== */
:root {
  --bg: #0f0f14;
  --bg2: #17171f;
  --bg3: #1e1e2a;
  --surface: #1a1a24;
  --surface2: #222230;
  --border: rgba(255,255,255,0.07);
  --pink: #ff4d6d;
  --pink-light: #ff7096;
  --pink-dark: #cc3355;
  --pink-glow: rgba(255, 77, 109, 0.25);
  --text: #f0eef8;
  --text-muted: #8a8aa8;
  --text-dim: #4a4a68;
  --radius: 16px;
  --radius-sm: 10px;
  --radius-xs: 6px;
  --shadow: 0 8px 32px rgba(0,0,0,0.5);
  --shadow-pink: 0 4px 24px rgba(255,77,109,0.3);
  --font-jp: 'Noto Sans JP', sans-serif;
  --font-display: 'Playfair Display', serif;
  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-jp);
  font-size: 14px;
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ===== Background Overlay ===== */
#bg-overlay {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-size: cover;
  background-position: center;
  transition: opacity 0.4s;
}

#bg-overlay.has-bg {
  opacity: 1;
}

#bg-overlay.has-bg::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(15, 15, 20, 0.82);
  backdrop-filter: blur(6px);
}

/* ===== Header ===== */
#app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(15, 15, 20, 0.9);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 20px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: relative;
  z-index: 1;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  text-decoration: none;
}

.logo-img {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  object-fit: cover;
}

.logo-text {
  font-family: var(--font-display);
  font-size: 18px;
  color: var(--pink-light);
  letter-spacing: 0.02em;
}

.header-nav {
  display: flex;
  gap: 4px;
}

.nav-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: none;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-family: var(--font-jp);
  font-size: 13px;
  cursor: pointer;
  transition: var(--transition);
}

.nav-btn svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

.nav-btn:hover {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}

.nav-btn.active {
  color: var(--pink);
  border-color: var(--pink-glow);
  background: rgba(255, 77, 109, 0.08);
}

/* ===== Screens ===== */
.screen {
  display: none;
  position: relative;
  z-index: 1;
  animation: fadeIn 0.25s ease;
  min-height: calc(100vh - 60px);
}

.screen.active { display: block; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.screen-inner {
  max-width: 900px;
  margin: 0 auto;
  padding: 32px 20px 60px;
}

/* ===== Home Screen ===== */
.home-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
}

.page-title {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 400;
  color: var(--text);
}

.page-title em {
  color: var(--pink);
  font-style: italic;
}

/* ===== Person Grid ===== */
.person-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}

.person-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.person-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, var(--pink-glow) 0%, transparent 60%);
  opacity: 0;
  transition: var(--transition);
}

.person-card:hover {
  transform: translateY(-3px);
  border-color: rgba(255, 77, 109, 0.3);
  box-shadow: var(--shadow-pink);
}

.person-card:hover::before { opacity: 1; }

.card-avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, #ff4d6d, #ff8fa3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  font-weight: 700;
  color: white;
  margin-bottom: 12px;
  position: relative;
  z-index: 1;
  text-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.card-name {
  font-size: 16px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 2px;
  position: relative;
  z-index: 1;
}

.card-nick {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 12px;
  position: relative;
  z-index: 1;
}

.card-affection {
  display: flex;
  align-items: center;
  gap: 8px;
  position: relative;
  z-index: 1;
}

.card-affection-bar {
  flex: 1;
  height: 4px;
  background: var(--bg3);
  border-radius: 2px;
  overflow: hidden;
}

.card-affection-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--pink-dark), var(--pink));
  border-radius: 2px;
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.card-affection-num {
  font-size: 11px;
  color: var(--pink);
  min-width: 28px;
  text-align: right;
}

.card-heart {
  position: absolute;
  top: 16px;
  right: 16px;
  font-size: 18px;
  color: var(--pink);
  opacity: 0.5;
  z-index: 1;
}

/* ===== Empty State ===== */
.empty-state {
  text-align: center;
  padding: 80px 20px;
  color: var(--text-muted);
}

.empty-heart {
  font-size: 64px;
  color: var(--text-dim);
  margin-bottom: 16px;
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}

.empty-sub {
  font-size: 12px;
  margin-top: 6px;
  color: var(--text-dim);
}

/* ===== Detail Screen ===== */
.detail-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.detail-actions {
  display: flex;
  gap: 8px;
}

.detail-hero {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  margin-bottom: 24px;
  display: flex;
  align-items: flex-start;
  gap: 20px;
  flex-wrap: wrap;
}

.detail-avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: linear-gradient(135deg, #ff4d6d, #ff8fa3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
  text-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.detail-name-block {
  flex: 1;
  min-width: 150px;
}

.detail-name-block h2 {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}

.detail-nick {
  color: var(--text-muted);
  font-size: 13px;
  margin-top: 4px;
}

.affection-block {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 160px;
}

.affection-label {
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.affection-bar-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.affection-bar-track {
  flex: 1;
  height: 6px;
  background: var(--bg3);
  border-radius: 3px;
  overflow: hidden;
}

.affection-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--pink-dark), var(--pink-light));
  border-radius: 3px;
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.affection-value {
  font-size: 16px;
  font-weight: 700;
  color: var(--pink);
  min-width: 32px;
}

/* ===== Tabs ===== */
.tabs {
  display: flex;
  gap: 4px;
  background: var(--surface);
  padding: 4px;
  border-radius: var(--radius-sm);
  margin-bottom: 20px;
}

.tab {
  flex: 1;
  padding: 9px 12px;
  background: none;
  border: none;
  border-radius: var(--radius-xs);
  color: var(--text-muted);
  font-family: var(--font-jp);
  font-size: 13px;
  cursor: pointer;
  transition: var(--transition);
}

.tab.active {
  background: var(--pink);
  color: white;
  font-weight: 500;
}

.tab:not(.active):hover {
  background: var(--bg3);
  color: var(--text);
}

.tab-panel { display: none; }
.tab-panel.active { display: block; animation: fadeIn 0.2s ease; }

/* ===== Info Grid ===== */
.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
}

.info-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
}

.info-label {
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 6px;
}

.info-value {
  font-size: 15px;
  color: var(--text);
  font-weight: 500;
}

/* ===== Likes Section ===== */
.likes-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 12px;
}

.section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 500;
  color: var(--pink);
  margin-bottom: 14px;
}

.section-title.dislike {
  color: #a78bfa;
}

.section-title svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag {
  padding: 5px 12px;
  background: rgba(255, 77, 109, 0.12);
  border: 1px solid rgba(255, 77, 109, 0.25);
  border-radius: 20px;
  font-size: 12px;
  color: var(--pink-light);
}

.tag-dislike {
  background: rgba(167, 139, 250, 0.12);
  border-color: rgba(167, 139, 250, 0.25);
  color: #c4b5fd;
}

.tag-trait {
  background: rgba(96, 165, 250, 0.12);
  border-color: rgba(96, 165, 250, 0.25);
  color: #93c5fd;
}

.tag-empty {
  color: var(--text-dim);
  font-size: 12px;
  font-style: italic;
}

/* ===== Logs ===== */
.log-add-form {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}

.log-add-form textarea {
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font-jp);
  font-size: 14px;
  padding: 12px;
  resize: none;
  outline: none;
  transition: border-color 0.2s;
  line-height: 1.6;
}

.log-add-form textarea:focus {
  border-color: rgba(255, 77, 109, 0.4);
}

.log-form-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
  gap: 10px;
}

.log-date-input {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  color: var(--text);
  font-family: var(--font-jp);
  font-size: 13px;
  padding: 7px 10px;
  outline: none;
}

.log-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.log-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  position: relative;
  animation: fadeIn 0.2s ease;
}

.log-date {
  font-size: 11px;
  color: var(--pink);
  margin-bottom: 6px;
  font-weight: 500;
}

.log-content {
  font-size: 13px;
  color: var(--text);
  line-height: 1.6;
  white-space: pre-wrap;
}

.log-delete {
  position: absolute;
  top: 12px;
  right: 12px;
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: color 0.2s;
  font-size: 16px;
  line-height: 1;
}

.log-delete:hover { color: var(--pink); }

/* ===== Notes ===== */
.notes-wrap {
  position: relative;
}

.notes-textarea {
  width: 100%;
  min-height: 300px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font-jp);
  font-size: 14px;
  padding: 20px;
  resize: vertical;
  outline: none;
  transition: border-color 0.2s;
  line-height: 1.8;
}

.notes-textarea:focus {
  border-color: rgba(255, 77, 109, 0.4);
}

.notes-save-btn {
  margin-top: 12px;
  float: right;
}

/* ===== Settings ===== */
.settings-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 16px;
}

.settings-heading {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.setting-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.merge-ask {
  margin-top: 16px;
  padding: 16px;
  background: var(--bg3);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.merge-ask p {
  margin-bottom: 12px;
  color: var(--text-muted);
  font-size: 13px;
}

.merge-btns {
  display: flex;
  gap: 10px;
}

/* ===== Buttons ===== */
.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  background: var(--pink);
  border: none;
  border-radius: 24px;
  color: white;
  font-family: var(--font-jp);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  box-shadow: 0 2px 12px var(--pink-glow);
  white-space: nowrap;
}

.btn-primary svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

.btn-primary:hover {
  background: var(--pink-light);
  transform: translateY(-1px);
  box-shadow: var(--shadow-pink);
}

.btn-primary.btn-sm {
  padding: 8px 16px;
  font-size: 13px;
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 18px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 24px;
  color: var(--text-muted);
  font-family: var(--font-jp);
  font-size: 13px;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}

.btn-secondary svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

.btn-secondary:hover {
  background: var(--surface2);
  color: var(--text);
  border-color: rgba(255,255,255,0.12);
}

.btn-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-family: var(--font-jp);
  font-size: 13px;
  cursor: pointer;
  transition: var(--transition);
}

.btn-back svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

.btn-back:hover {
  background: var(--surface);
  color: var(--text);
}

.btn-icon {
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
}

.btn-icon svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

.btn-icon:hover {
  background: var(--surface2);
  color: var(--text);
}

.btn-icon.btn-danger:hover {
  background: rgba(255, 77, 109, 0.15);
  border-color: rgba(255, 77, 109, 0.3);
  color: var(--pink);
}

.btn-danger {
  background: var(--pink);
  border: none;
  border-radius: 24px;
  color: white;
  font-family: var(--font-jp);
  font-size: 14px;
  padding: 10px 20px;
  cursor: pointer;
  transition: var(--transition);
}

.btn-danger:hover {
  background: var(--pink-dark);
}

/* ===== Modal ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 200;
  display: flex !important;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(4px);
  animation: fadeIn 0.2s ease;
}

.modal-overlay[style*="display:none"] {
  display: none !important;
  animation: none;
}

.modal {
  background: var(--bg2);
  border: 1px solid rgba(255, 77, 109, 0.15);
  border-radius: var(--radius);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 64px rgba(0,0,0,0.6);
}

.modal-sm { max-width: 360px; }

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
}

.modal-header h2 {
  font-size: 16px;
  font-weight: 500;
  color: var(--text);
}

.modal-close {
  width: 32px;
  height: 32px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: var(--transition);
  line-height: 1;
}

.modal-close:hover {
  background: var(--surface);
  color: var(--text);
}

.modal-body {
  padding: 20px 24px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.modal-footer {
  padding: 16px 24px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* ===== Form ===== */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.form-group label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
}

.required {
  color: var(--pink);
  margin-left: 2px;
}

.hint {
  color: var(--text-dim);
  font-weight: 400;
}

.form-group input[type="text"],
.form-group input[type="number"],
.form-group input[type="date"] {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font-jp);
  font-size: 14px;
  padding: 10px 12px;
  outline: none;
  transition: border-color 0.2s;
}

.form-group input:focus {
  border-color: rgba(255, 77, 109, 0.5);
}

input[type="range"] {
  width: 100%;
  height: 4px;
  background: var(--bg3);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
  accent-color: var(--pink);
}

/* ===== Toast ===== */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 12px 24px;
  color: var(--text);
  font-size: 13px;
  z-index: 300;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
  white-space: nowrap;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--surface2); border-radius: 3px; }

/* ===== Color scheme for date inputs ===== */
input[type="date"]::-webkit-calendar-picker-indicator {
  filter: invert(0.5);
  cursor: pointer;
}

/* ===== Responsive ===== */
@media (max-width: 600px) {
  .detail-hero { flex-direction: column; gap: 16px; }
  .affection-block { min-width: unset; width: 100%; }
  .form-row { grid-template-columns: 1fr; }
  .home-top { gap: 12px; }
  .page-title { font-size: 22px; }
  .setting-row { flex-direction: column; }
}
