/* Sakura pastel theme — cream canvas + soft pink/sage/mist */
:root {
  --cream: #faf6f1;
  --cream-deep: #f3ece3;
  --surface: #ffffff;
  --sakura: #f4c2c2;
  --sakura-deep: #e89fa1;
  --sage: #a8c4a2;
  --sage-deep: #7fa97a;
  --mist: #c8b6d8;
  --mist-deep: #a48cbb;
  --gold: #e8c89a;
  --ink: rgba(60, 40, 50, 0.87);
  --ink-soft: rgba(60, 40, 50, 0.55);
  --ink-faint: rgba(60, 40, 50, 0.32);
  --line: rgba(60, 40, 50, 0.08);
  --shadow-card: 0 2px 8px rgba(232, 159, 161, 0.10), 0 8px 22px rgba(60, 40, 50, 0.05);
  --shadow-pop:  0 4px 14px rgba(232, 159, 161, 0.20), 0 14px 30px rgba(60, 40, 50, 0.08);
  --radius-card: 12px;
  --radius-pill: 50px;
  --space-1: 0.4rem;
  --space-2: 0.8rem;
  --space-3: 1.6rem;
  --space-4: 2.4rem;
  --space-5: 3.2rem;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--cream);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", "PingFang SC", "Hiragino Sans GB",
               "Microsoft YaHei", sans-serif;
  font-size: 16px;
  letter-spacing: -0.16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
img, video { display: block; max-width: 100%; }

/* ------------- top bar ------------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-4);
  background: var(--cream);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
  backdrop-filter: saturate(1.2) blur(8px);
  -webkit-backdrop-filter: saturate(1.2) blur(8px);
}
.brand { display: flex; align-items: center; gap: var(--space-2); font-weight: 600; }
.brand-mark { color: var(--sakura-deep); font-size: 1.3em; }
.brand-name { font-size: 1.05rem; }
.logout-form { display: flex; align-items: center; gap: var(--space-2); margin: 0; }
.who { color: var(--ink-soft); font-size: 0.85rem; }

/* ------------- page container ------------- */
.page { max-width: 1280px; margin: 0 auto; padding: var(--space-4); }
.hero { margin: var(--space-2) 0 var(--space-4); }
.hero-title { font-size: 1.8rem; font-weight: 600; margin: 0 0 var(--space-1); }
.hero-sub { color: var(--ink-soft); margin: 0; font-size: 0.95rem; }

/* ------------- pills ------------- */
.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.55em 1.4em;
  border-radius: var(--radius-pill);
  font-size: 0.9rem;
  font-weight: 500;
  letter-spacing: -0.01em;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.18s ease, border-color 0.18s ease;
  background: transparent;
  color: var(--ink);
}
.pill:active { transform: scale(0.96); }
.pill-primary { background: var(--sakura); color: var(--ink); border-color: var(--sakura-deep); }
.pill-primary:hover { background: var(--sakura-deep); color: #fff; }
.pill-ghost { background: var(--surface); border-color: var(--line); }
.pill-ghost:hover { border-color: var(--sakura-deep); }

/* ------------- cards & grids ------------- */
.card {
  background: var(--surface);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

.grid { display: grid; gap: var(--space-3); }
.grid-accounts { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.grid-media   { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: var(--space-2); }

.account-card { transition: transform 0.18s ease, box-shadow 0.18s ease; }
.account-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-pop); }

.cover-wrap {
  position: relative;
  aspect-ratio: 1 / 1;
  background: var(--cream-deep);
  overflow: hidden;
}
.cover { width: 100%; height: 100%; object-fit: cover; }
.cover-empty {
  display: flex; align-items: center; justify-content: center;
  height: 100%; color: var(--ink-faint); font-size: 0.95rem;
}

.card-body { padding: var(--space-3); }
.account-name { font-size: 1.1rem; margin: 0 0 var(--space-2); font-weight: 600; }
.account-meta { margin: 0 0 var(--space-1); display: flex; gap: var(--space-1); flex-wrap: wrap; }
.account-when { margin: var(--space-1) 0 0; color: var(--ink-soft); font-size: 0.8rem; }

.chip {
  display: inline-block;
  padding: 0.18em 0.7em;
  border-radius: var(--radius-pill);
  font-size: 0.78rem;
  font-weight: 500;
  background: var(--cream-deep);
}
.chip-sage { background: rgba(168, 196, 162, 0.30); color: #4d6b48; }
.chip-mist { background: rgba(200, 182, 216, 0.30); color: #5a4974; }

/* ------------- account page ------------- */
.breadcrumb {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: var(--space-3); color: var(--ink-soft); font-size: 0.9rem;
}
.breadcrumb a:hover { color: var(--sakura-deep); }
.ig-link { color: var(--mist-deep); }
.account-header {
  margin-bottom: var(--space-4); padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--line);
}
.account-header h1 { margin: 0 0 var(--space-3); font-size: 1.6rem; font-weight: 600; }
.filter-row { display: flex; gap: var(--space-2); flex-wrap: wrap; }

.day-section {
  margin-bottom: var(--space-3);
  background: var(--surface);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}
.day-section[open] { margin-bottom: var(--space-4); }
.day-summary {
  list-style: none;
  cursor: pointer;
  padding: var(--space-2) var(--space-3);
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: 0.95rem;
  user-select: none;
  transition: background 0.15s ease;
}
.day-summary::-webkit-details-marker { display: none; }
.day-summary:hover { background: var(--cream); }
.day-chevron {
  display: inline-block;
  color: var(--sakura-deep);
  font-size: 0.85em;
  transition: transform 0.18s ease;
  width: 1em; text-align: center;
}
.day-section[open] .day-chevron { transform: rotate(90deg); }
.day-title {
  font-weight: 500;
  color: var(--ink);
  font-feature-settings: "tnum";
}
.day-counts {
  margin-left: auto;
  display: flex;
  gap: var(--space-1);
  flex-wrap: wrap;
}
.day-body { padding: 0 var(--space-3) var(--space-3); }
.day-loading {
  padding: var(--space-3);
  text-align: center;
  color: var(--ink-faint);
  font-size: 0.9rem;
}
.hint {
  margin-left: var(--space-2);
  font-size: 0.8rem;
  color: var(--ink-faint);
  align-self: center;
}

.media-cell {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: var(--radius-card);
  overflow: hidden;
  background: var(--cream-deep);
  box-shadow: var(--shadow-card);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.media-cell:hover { transform: scale(1.02); box-shadow: var(--shadow-pop); }
.media-cell img, .media-cell video { width: 100%; height: 100%; object-fit: cover; }

.kind-badge {
  position: absolute; top: 8px; left: 8px;
  padding: 0.15em 0.55em;
  border-radius: var(--radius-pill);
  font-size: 0.72rem;
  background: rgba(255, 255, 255, 0.85);
  color: var(--ink);
}
.kind-video { background: rgba(200, 182, 216, 0.92); color: #fff; }
.kind-image { background: rgba(168, 196, 162, 0.92); color: #fff; }

.play-pill {
  position: absolute; bottom: 8px; right: 8px;
  width: 28px; height: 28px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.9);
  color: var(--mist-deep);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.85rem;
  box-shadow: 0 2px 6px rgba(0,0,0,0.10);
}

/* ------------- viewer ------------- */
.viewer {
  display: flex; justify-content: center; align-items: center;
  background: var(--surface); border-radius: var(--radius-card);
  box-shadow: var(--shadow-card); padding: var(--space-3);
  min-height: 60vh;
}
.viewer-media { max-height: 80vh; max-width: 100%; border-radius: 8px; }
.viewer-meta {
  display: flex; align-items: center; gap: var(--space-3); justify-content: center;
  margin-top: var(--space-3); color: var(--ink-soft);
}
.filename { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.8rem; }
.meta-tag {
  background: var(--cream-deep); color: var(--ink-soft);
  padding: 0.15em 0.7em; border-radius: var(--radius-pill); font-size: 0.78rem;
}

/* ------------- login ------------- */
.login-wrap {
  min-height: calc(100vh - 8rem);
  display: flex; align-items: center; justify-content: center;
}
.login-card { width: min(380px, 92vw); padding: var(--space-4); }
.login-title { margin: 0 0 var(--space-1); font-size: 1.4rem; font-weight: 600; }
.login-sub { margin: 0 0 var(--space-4); color: var(--ink-soft); font-size: 0.9rem; }
.login-form { display: flex; flex-direction: column; gap: var(--space-3); }
.field { display: flex; flex-direction: column; gap: var(--space-1); font-size: 0.85rem; color: var(--ink-soft); }
.field input {
  padding: 0.7em 1em;
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  background: var(--cream);
  font-size: 0.95rem;
  color: var(--ink);
  outline: none;
  letter-spacing: -0.01em;
  transition: border-color 0.18s ease, background 0.18s ease;
}
.field input:focus { border-color: var(--sakura-deep); background: #fff; }
.login-btn { margin-top: var(--space-1); }
.alert { padding: 0.7em 1em; border-radius: var(--radius-card); font-size: 0.88rem; margin-bottom: var(--space-2); }
.alert-error { background: rgba(232, 159, 161, 0.18); color: #8c2d33; border: 1px solid rgba(232, 159, 161, 0.45); }

.empty {
  text-align: center; padding: var(--space-5);
  color: var(--ink-soft); background: var(--surface);
  border-radius: var(--radius-card); box-shadow: var(--shadow-card);
}

@media (max-width: 600px) {
  .topbar { padding: var(--space-2) var(--space-3); }
  .page { padding: var(--space-3); }
  .grid-media { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
}
