/* ============================================================
   Family Media Hub — "Ivory & Ink"
   A warm library aesthetic: cream surfaces, deep ink text,
   a single restrained line of aged gold.
   ============================================================ */

:root {
  --bg: #faf7f0;
  --surface: #ffffff;
  --surface-alt: #f3ecdb;
  --hairline: #e6ddc7;
  --border: #e6ddc7;
  --text: #23201a;
  --text-muted: #7c7261;
  --accent: #b08d57;
  --accent-strong: #8c6d3f;
  --accent-contrast: #fffaf0;
  --chip-bg: #f3ecdb;
  --danger: #a8492f;
  --danger-bg: #fbeae5;
  --success-bg: #e7f1e2;
  --success-text: #3f6b3f;

  --nav-bg: #23201a;
  --nav-text: #f6f0e2;
  --nav-border: #3a3527;
  --icon-btn-bg: rgba(255, 255, 255, 0.07);

  --font-heading: 'Fraunces', ui-serif, Georgia, serif;
  --font-body: 'Work Sans', -apple-system, BlinkMacSystemFont, sans-serif;

  --radius: 14px;
  --radius-sm: 9px;

  --card-shadow: 0 1px 2px rgba(35, 32, 26, 0.05), 0 10px 24px -18px rgba(35, 32, 26, 0.5);
  --card-shadow-hover: 0 14px 30px -14px rgba(35, 32, 26, 0.35);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  line-height: 1.55;
}

a { color: inherit; text-decoration: none; }
h1, h2, h3 { font-family: var(--font-heading); font-weight: 600; margin: 0; }
.icon { width: 1.1em; height: 1.1em; stroke: currentColor; fill: none; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; vertical-align: -0.18em; flex-shrink: 0; }

button { font: inherit; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }

/* ============================================================
   Header / nav
   ============================================================ */
.site-header { background: var(--nav-bg); color: var(--nav-text); border-bottom: 1px solid var(--nav-border); }
.site-nav {
  max-width: 1180px; margin: 0 auto;
  display: flex; align-items: center; gap: 1.75rem; flex-wrap: wrap;
  padding: 1.05rem 1.75rem;
}
.brand { display: flex; align-items: center; gap: 0.6rem; font-family: var(--font-heading); font-size: 1.15rem; font-weight: 600; }
.brand .mark { width: 1.35rem; height: 1.35rem; color: var(--accent); }
.nav-link { display: flex; align-items: center; gap: 0.4rem; font-size: 0.87rem; font-weight: 500; opacity: 0.85; }
.nav-link:hover { opacity: 1; color: var(--accent); }
.site-nav .search-form {
  flex: 1 1 220px; max-width: 26rem; margin: 0;
  background: rgba(255, 255, 255, 0.08); border: 1px solid rgba(255, 255, 255, 0.14);
}
.site-nav .search-form .icon { color: var(--accent); }
.site-nav .search-form input { color: var(--nav-text); }
.site-nav .search-form input::placeholder { color: #9c9482; }
.nav-right { display: flex; align-items: center; gap: 0.85rem; margin-left: auto; }
.nav-email { font-size: 0.8rem; color: #c9c0ab; }
.nav-icon-link { display: flex; align-items: center; color: var(--nav-text); opacity: 0.75; }
.nav-icon-link:hover { opacity: 1; color: var(--accent); }
.avatar-link { display: inline-flex; }
.avatar {
  width: 2.15rem; height: 2.15rem; border-radius: 50%;
  background: var(--accent); color: var(--accent-contrast);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-heading); font-weight: 600; font-size: 0.9rem;
}
.avatar-link:hover .avatar { background: var(--accent-strong); }
.av { width: 2rem; height: 2rem; border-radius: 50%; background: var(--chip-bg); color: var(--accent-strong); display: flex; align-items: center; justify-content: center; font-family: var(--font-heading); font-weight: 600; font-size: 0.82rem; flex-shrink: 0; }
.av-sm { width: 1.6rem; height: 1.6rem; font-size: 0.7rem; }
.av-ghost { background: transparent; border: 1px dashed var(--border); color: var(--text-muted); }
.avatar-img { object-fit: cover; display: block; }

.settings-form-wrap { display: flex; gap: 2rem; align-items: flex-start; max-width: 32rem; }
.settings-form-wrap form { flex: 1; min-width: 0; }
.settings-avatar {
  width: 5.5rem; height: 5.5rem; border-radius: 50%; flex-shrink: 0;
  background: var(--accent); color: var(--accent-contrast);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-heading); font-weight: 600; font-size: 2rem;
}

.avatar-source-choice { display: flex; flex-direction: column; gap: 0.4rem; margin: 0.35rem 0 1rem; }
.radio-option { display: flex; align-items: center; gap: 0.5rem; font-weight: 400; font-size: 0.92rem; cursor: pointer; }
.radio-option input { width: auto; }

/* ============================================================
   Flash messages
   ============================================================ */
.flash {
  max-width: 1180px; margin: 1rem auto 0; padding: 0.65rem 1.1rem;
  border-radius: var(--radius-sm); font-size: 0.9rem;
  display: flex; align-items: center; gap: 0.5rem;
}
.flash-success { background: var(--success-bg); color: var(--success-text); }
.flash-error { background: var(--danger-bg); color: var(--danger); }

/* ============================================================
   Page layout
   ============================================================ */
.page { max-width: 1180px; margin: 0 auto; padding: 2.5rem 1.75rem 5rem; position: relative; }
.eyebrow { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.14em; color: var(--accent-strong); font-weight: 600; margin: 0 0 0.5rem; }
h1 { font-size: 2.05rem; margin: 0 0 0.5rem; letter-spacing: -0.01em; position: relative; }
.page > h1::after { content: ""; display: block; width: 42px; height: 3px; background: var(--accent); margin-top: 0.65rem; border-radius: 2px; }
.subtitle { margin: 0 0 2rem; color: var(--text-muted); font-size: 0.95rem; max-width: 40rem; }

.crumb { display: flex; align-items: center; gap: 1.25rem; margin: 0 0 1rem; font-size: 0.85rem; }
.crumb a { display: flex; align-items: center; gap: 0.3rem; color: var(--text-muted); font-weight: 500; }
.crumb a:hover { color: var(--accent-strong); }
.crumb-action { margin-left: auto; color: var(--accent-strong) !important; }

.section-head { display: flex; align-items: baseline; justify-content: space-between; margin: 2.25rem 0 1.1rem; }
.section-head h2, h2 { font-size: 1.2rem; display: flex; align-items: center; gap: 0.5rem; }
.section-head h2 .icon, h2 .icon { color: var(--accent-strong); }

.empty { color: var(--text-muted); font-size: 0.88rem; font-style: italic; }
.text-muted { color: var(--text-muted); }

/* ============================================================
   Buttons
   ============================================================ */
.btn {
  display: inline-flex; align-items: center; gap: 0.45rem;
  border-radius: 999px; padding: 0.62rem 1.15rem;
  font-size: 0.85rem; font-weight: 600; border: 1px solid transparent;
  transition: all 0.15s ease; white-space: nowrap;
}
.btn-primary { background: var(--accent); color: var(--accent-contrast); }
.btn-primary:hover { background: var(--accent-strong); }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--text); }
.btn-ghost:hover { border-color: var(--accent); color: var(--accent-strong); }
.btn-danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-sm { padding: 0.42rem 0.85rem; font-size: 0.8rem; }
.btn-row { display: flex; gap: 0.65rem; margin: 1.25rem 0; flex-wrap: wrap; }

.link-btn { background: none; border: none; padding: 0; font-size: 0.78rem; font-weight: 600; color: var(--accent-strong); }
.link-btn:hover { text-decoration: underline; }
.link-btn.danger { color: var(--danger); }

/* ============================================================
   Forms
   ============================================================ */
form { margin: 0; }
label { display: block; font-size: 0.78rem; color: var(--text-muted); margin: 0.85rem 0 0.3rem; font-weight: 500; }
label:first-child { margin-top: 0; }
input[type="text"], input[type="email"], input[type="search"], input[type="date"], input[type="file"], select {
  width: 100%; padding: 0.55rem 0.8rem;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); font-size: 0.9rem;
}
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.checkbox-label { display: flex; align-items: center; gap: 0.5rem; font-size: 0.85rem; color: var(--text); }
.checkbox-label input { width: auto; }

.inline-form { display: flex; gap: 0.6rem; align-items: center; margin: 0 0 2rem; max-width: 30rem; }
.inline-form input, .inline-form select { flex: 1; }

.search-form {
  display: flex; align-items: center; gap: 0.65rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: 999px;
  padding: 0.35rem 0.4rem 0.35rem 1.1rem; max-width: 34rem; margin: 0 0 2.5rem;
}
.search-form .icon { color: var(--accent); }
.search-form input { border: none; background: none; flex: 1; padding: 0.3rem 0; }
.search-form input:focus { outline: none; }

.share-form, .cover-form { max-width: 26rem; margin-bottom: 1.5rem; }
.share-form select, .share-form input { margin-bottom: 0.3rem; }
.cover-form { display: inline-block; margin: -1rem 0 1.75rem; }

/* ============================================================
   Tables
   ============================================================ */
table { width: 100%; border-collapse: collapse; margin: 0 0 2rem; font-size: 0.88rem; }
th, td { text-align: left; padding: 0.65rem 0.7rem; border-bottom: 1px solid var(--hairline); }
th { color: var(--text-muted); font-weight: 600; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.05em; }
.status { font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; padding: 0.2rem 0.55rem; border-radius: 999px; }
.status-pending { background: var(--surface-alt); color: var(--accent-strong); }
.status-accepted { background: var(--success-bg); color: var(--success-text); }
.status-revoked { background: var(--danger-bg); color: var(--danger); }

.member-list { list-style: none; margin: 0 0 1.5rem; padding: 0; display: flex; flex-direction: column; gap: 0.5rem; }
.member-list li { display: flex; align-items: center; gap: 0.65rem; font-size: 0.88rem; }
.member-list form { margin-left: auto; }

/* ============================================================
   Folder grid
   ============================================================ */
.folder-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 1.15rem; margin-bottom: 1rem; }
.folder-card {
  position: relative; display: block; border-radius: var(--radius); overflow: hidden;
  aspect-ratio: 4 / 3.1; border: 1px solid var(--border); box-shadow: var(--card-shadow);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.folder-card:hover { transform: translateY(-3px); box-shadow: var(--card-shadow-hover); }
.folder-cover { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.folder-scrim { position: absolute; inset: 0; background: linear-gradient(180deg, rgba(35, 32, 26, 0) 40%, rgba(20, 18, 13, 0.78) 100%); }
.folder-badge {
  position: absolute; top: 0.65rem; left: 0.65rem; width: 2rem; height: 2rem; border-radius: 8px;
  background: rgba(255, 255, 255, 0.22); backdrop-filter: blur(6px); color: #fff;
  display: flex; align-items: center; justify-content: center;
}
.folder-meta { position: absolute; left: 0; right: 0; bottom: 0; padding: 0.85rem 0.9rem 0.8rem; color: #fff; }
.folder-meta .name { font-family: var(--font-heading); font-weight: 600; font-size: 1rem; margin: 0; }
.folder-card.add {
  display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 0.55rem;
  background: var(--chip-bg); border: 1.5px dashed var(--border); box-shadow: none; color: var(--text-muted); padding: 1rem;
}
.folder-card.add:hover { border-color: var(--accent); color: var(--accent-strong); transform: none; }
.folder-card.add .add-name { border: none; background: transparent; text-align: center; font-size: 0.85rem; padding: 0.2rem; }
.folder-card.add .btn { margin-top: 0.3rem; }

.cov-0 { background: linear-gradient(135deg, #d9b877, #8c6d3f); }
.cov-1 { background: linear-gradient(135deg, #7c9a82, #2f4d38); }
.cov-2 { background: linear-gradient(135deg, #b3717a, #5c2b38); }
.cov-3 { background: linear-gradient(135deg, #7f96b3, #2c3e5c); }
.cov-4 { background: linear-gradient(135deg, #c9a15a, #7a5a2a); }
.cov-5 { background: linear-gradient(135deg, #9a8bb0, #4a3d63); }

/* ============================================================
   Content grid
   ============================================================ */
.content-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 1.1rem; margin-bottom: 1.5rem; }
.content-card { display: block; border-radius: var(--radius-sm); overflow: hidden; border: 1px solid var(--border); background: var(--surface); box-shadow: var(--card-shadow); transition: transform 0.2s ease, box-shadow 0.2s ease; }
.content-card:hover { transform: translateY(-2px); box-shadow: var(--card-shadow-hover); }
.content-thumb { aspect-ratio: 1/1; position: relative; background: var(--chip-bg); }
.content-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.content-placeholder { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; color: var(--text-muted); }
.content-placeholder .icon { width: 1.8rem; height: 1.8rem; }
.content-info { padding: 0.6rem 0.7rem 0.75rem; }
.content-info .t { font-size: 0.83rem; font-weight: 600; margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.upload-form { display: flex; align-items: center; gap: 0.75rem; margin-top: 1rem; }

/* ============================================================
   Detail page + comments
   ============================================================ */
.detail-wrap { display: block; }
.detail-main { margin-bottom: 3rem; }
.detail-media { display: inline-block; max-width: 100%; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); box-shadow: var(--card-shadow); position: relative; background: var(--chip-bg); min-height: 220px; margin-bottom: 1.25rem; }
.detail-media img, .detail-media video { display: block; max-width: 100%; max-height: 75vh; width: auto; height: auto; }
.media-notice { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.75rem; text-align: center; padding: 3rem 2.5rem; min-height: 220px; min-width: 320px; color: var(--text-muted); }
.media-notice .icon { width: 2.2rem; height: 2.2rem; color: var(--accent-strong); }
.media-notice p { margin: 0; max-width: 22rem; font-size: 0.88rem; }

.toolbar { display: flex; align-items: baseline; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.toolbar h1 { font-size: 1.4rem; margin: 0; }
.toolbar .btn-row { margin: 0 0 0 auto; }

.meta-strip { display: flex; align-items: center; gap: 1.5rem; flex-wrap: wrap; padding-bottom: 1.25rem; border-bottom: 1px solid var(--hairline); margin-bottom: 1.25rem; }
.meta-date { font-size: 0.84rem; color: var(--text-muted); white-space: nowrap; }
.edit-toggle { margin-left: auto; }

.edit-panel { display: none; margin-bottom: 1.75rem; }
.edit-panel.open { display: block; }
.edit-form { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; align-items: start; }
.edit-form .field label { margin: 0 0 0.3rem; }
.edit-form .field:has(> input) { align-self: end; }
.edit-form .save-row, .edit-form .persons-field { grid-column: 1 / -1; }

.persons-rows { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 0.5rem; }
.persons-row { display: flex; align-items: center; gap: 0.35rem; background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 0.2rem 0.3rem 0.2rem 0.9rem; }
.persons-row input { border: none; background: none; padding: 0.25rem 0; width: 9rem; font-size: 0.87rem; }
.persons-row input:focus { outline: none; }
.remove-person { width: 1.4rem; height: 1.4rem; border-radius: 50%; border: none; background: var(--chip-bg); color: var(--text-muted); font-size: 1rem; line-height: 1; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.remove-person:hover { background: var(--danger-bg); color: var(--danger); }
.add-person { font-size: 0.8rem; }

.pill-row { display: flex; gap: 0.5rem; flex-wrap: wrap; margin: 0; }
.pill { display: inline-flex; align-items: center; gap: 0.35rem; background: var(--chip-bg); color: var(--text); border: 1px solid var(--border); padding: 0.32rem 0.7rem; border-radius: 999px; font-size: 0.76rem; }
.pill .icon { color: var(--accent-strong); width: 0.95em; height: 0.95em; }

.comment-thread { list-style: none; margin: 0; padding: 0; }
.comment-thread .comment-thread { margin-left: 2.7rem; padding-left: 0; margin-top: 0.9rem; }
.comment { margin-bottom: 1.1rem; scroll-margin-top: 1.5rem; }
.detail-comments { scroll-margin-top: 1.5rem; }
.comment-row { display: flex; gap: 0.7rem; }
.bubble-wrap { flex: 1; min-width: 0; }
.bubble { background: var(--chip-bg); border-radius: var(--radius-sm); padding: 0.6rem 0.85rem; }
.bubble .who { font-weight: 700; font-size: 0.8rem; margin: 0 0 0.2rem; display: flex; gap: 0.5rem; align-items: baseline; }
.bubble .who time { font-weight: 400; color: var(--text-muted); font-size: 0.72rem; }
.bubble .body { font-size: 0.87rem; margin: 0; line-height: 1.5; }
.deleted-note { font-style: italic; color: var(--text-muted); font-size: 0.85rem; margin: 0; }
.comment-actions { display: flex; gap: 0.9rem; margin: 0.35rem 0.2rem; }

.comment-input { display: flex; gap: 0.6rem; margin-top: 1.3rem; align-items: center; }
.comment-input input { flex: 1; border: 1px solid var(--border); background: var(--surface); border-radius: 999px; padding: 0.6rem 1rem; font-size: 0.85rem; }
.comment-input .btn { border-radius: 50%; width: 2.3rem; height: 2.3rem; padding: 0; justify-content: center; flex-shrink: 0; }

/* Must come after .comment-input so its `display: none` isn't lost to source
   order (both are single-class selectors, so later wins on the tie). */
.reply-input { display: none; margin: 0.5rem 0.2rem 0; }
.reply-input.open { display: flex; }

/* ============================================================
   Activity list
   ============================================================ */
.activity-list { list-style: none; margin: 0 0 1rem; padding: 0; border-top: 1px solid var(--hairline); }
.activity-row { display: flex; align-items: center; gap: 0.9rem; padding: 0.85rem 0.15rem; border-bottom: 1px solid var(--hairline); }
.activity-ico { width: 2.1rem; height: 2.1rem; border-radius: var(--radius-sm); background: var(--chip-bg); color: var(--accent-strong); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.activity-row p { margin: 0; font-size: 0.89rem; line-height: 1.4; }
.activity-row .who { font-weight: 600; }
.activity-row time { margin-left: auto; font-size: 0.76rem; color: var(--text-muted); white-space: nowrap; padding-left: 1rem; }

/* ============================================================
   Auth page
   ============================================================ */
.auth-page { max-width: 26rem; margin: 0 auto; text-align: center; padding: 5rem 1.5rem; }
.auth-mark { width: 2.5rem; height: 2.5rem; color: var(--accent); margin-bottom: 1rem; }
.auth-page h1 { margin-bottom: 0.6rem; }
.auth-page p { color: var(--text-muted); margin: 0 0 1.75rem; }

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 720px) {
  .site-nav { padding: 0.9rem 1.1rem; gap: 1rem; }
  .nav-email { display: none; }
  .page { padding: 1.75rem 1.1rem 3.5rem; }
  .folder-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
  .inline-form { flex-direction: column; align-items: stretch; }
  .toolbar .btn-row { margin-left: 0; }
  .meta-strip { align-items: flex-start; }
  .edit-toggle { margin-left: 0; }
  .edit-form { grid-template-columns: repeat(2, 1fr); }
}
