:root {
  --bg: #f4f2ec; --bg-2: #ffffff; --bg-3: #e9ece5; --ink: #1e2b26; --ink-soft: #46554f; --muted: #71807a;
  --red: #b3213a; --red-bright: #d23c55; --red-deep: #8f1a2d; --forest: #1f3a2e; --moss: #5f8a6b;
  --line: rgba(31,58,46,0.16); --line-red: rgba(179,33,58,0.45);
  --ok: #4f8a5f; --serif: 'Cormorant Garamond', Georgia, serif; --sans: 'Inter', system-ui, sans-serif; --radius: 12px;
}
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--sans); font-weight: 300; line-height: 1.55; font-size: 15px; }
h1, h2, h3 { font-family: var(--serif); font-weight: 500; margin: 0; line-height: 1.15; color: var(--forest); }
h2 { font-size: 2rem; margin-bottom: 6px; }
h3 { font-size: 1.35rem; margin: 26px 0 10px; }
p { margin: 0 0 10px; }
a { color: var(--red-bright); }
code { background: var(--bg-3); padding: 2px 6px; border-radius: 4px; font-size: 0.85em; color: var(--forest); }
button { font: inherit; color: inherit; cursor: pointer; }
[hidden] { display: none !important; }
img, video { max-width: 100%; display: block; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--line); background: var(--bg-3);
  padding: 9px 16px; border-radius: 8px; font-size: 0.82rem; letter-spacing: 0.06em; text-transform: uppercase; font-weight: 500; transition: 0.2s; text-decoration: none; color: var(--ink);
}
.btn:hover { border-color: var(--forest); color: var(--forest); background: #fff; }
.btn--primary { background: var(--red); border-color: var(--red); color: #fff; }
.btn--primary:hover { background: var(--red-bright); border-color: var(--red-bright); }
.btn--ghost { background: transparent; }
.btn--danger { color: var(--red-bright); }
.btn--danger:hover { background: var(--red); border-color: var(--red); color: #fff; }
.btn--sm { padding: 6px 10px; font-size: 0.72rem; }
.btn--icon { padding: 6px 9px; min-width: 32px; }
.btn--block { width: 100%; margin-top: 8px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.field { display: grid; gap: 5px; margin-bottom: 14px; }
.field > span { font-size: 0.7rem; letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted); }
.field input, .field textarea, .field select {
  font: inherit; color: var(--ink); background: var(--bg-2); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; width: 100%; resize: vertical;
}
.field input:focus, .field textarea:focus, .field select:focus { outline: none; border-color: var(--red); box-shadow: 0 0 0 3px rgba(193,18,31,0.2); }
.field select option { background: var(--bg-2); }
.field input[type="date"], .field input[type="time"] { color-scheme: light; }
.field > small { font-size: 0.8rem; color: var(--muted); }
.field select[multiple] { padding: 6px; }
.field select[multiple] option { padding: 4px 6px; }
.field--check { display: flex; align-items: center; gap: 10px; }
.field--check input { width: auto; accent-color: var(--red); }
.field--check > span { text-transform: none; letter-spacing: 0; font-size: 0.95rem; color: var(--ink-soft); }
.help-text { font-size: 0.8rem; color: var(--muted); margin-top: -8px; margin-bottom: 14px; }
.row { display: grid; gap: 0 16px; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.form-note { color: var(--red-bright); min-height: 1.4em; margin-top: 10px; font-size: 0.9rem; }

/* login */
.login-body { display: grid; place-items: center; min-height: 100vh; padding: 20px; background: linear-gradient(180deg, #b7c6c9, var(--bg) 60%); }
.login { width: min(100%, 400px); }
.login__back { display: inline-block; color: var(--muted); text-decoration: none; margin-bottom: 14px; font-size: 0.85rem; }
.login__card { background: var(--bg-2); border: 1px solid var(--line); border-radius: 16px; padding: 32px; box-shadow: 0 40px 80px -40px rgba(31,58,46,0.5); }
.login__heart { color: var(--red); font-size: 1.6rem; }
.login h1 { font-size: 2rem; }
.login__hint { color: var(--muted); margin-bottom: 22px; }

/* layout */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px clamp(14px, 3vw, 28px); border-bottom: 1px solid var(--line); background: var(--bg-2); flex-wrap: wrap; position: sticky; top: 0; z-index: 10; }
.topbar__brand { font-family: var(--serif); font-size: 1.3rem; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.topbar__heart { color: var(--red); }
.topbar__tag { font-family: var(--sans); font-size: 0.65rem; letter-spacing: 0.2em; text-transform: uppercase; color: var(--muted); border: 1px solid var(--line); padding: 2px 8px; border-radius: 999px; }
.topbar__links { display: flex; align-items: center; gap: 14px; }
.topbar__links a { text-decoration: none; color: var(--ink-soft); font-size: 0.85rem; }
.topbar__user { color: var(--muted); font-size: 0.8rem; }
.tabs { display: flex; gap: 4px; padding: 10px clamp(14px, 3vw, 28px) 0; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.tab { background: none; border: 0; border-bottom: 2px solid transparent; padding: 10px 14px; color: var(--muted); white-space: nowrap; font-size: 0.85rem; letter-spacing: 0.04em; margin-bottom: -1px; }
.tab:hover { color: var(--forest); }
.tab.is-active { color: var(--forest); border-bottom-color: var(--red); }
.panel-wrap { padding: clamp(18px, 4vw, 36px) clamp(14px, 3vw, 28px) 120px; max-width: 1100px; margin: 0 auto; }
.panel-intro { color: var(--muted); margin-bottom: 20px; }
.card { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius); padding: clamp(16px, 3vw, 24px); margin-bottom: 18px; }
.card h3:first-child { margin-top: 0; }
.savebar { position: fixed; left: 0; right: 0; bottom: 0; padding: 12px clamp(14px, 3vw, 28px); background: rgba(244,242,236,0.94); backdrop-filter: blur(10px); border-top: 1px solid var(--line); display: flex; justify-content: flex-end; align-items: center; gap: 14px; z-index: 10; }
.savebar__status { color: var(--muted); font-size: 0.85rem; }
.toast { position: fixed; left: 50%; bottom: 80px; transform: translateX(-50%); background: var(--forest); border: 1px solid var(--forest); color: #fff; padding: 10px 18px; border-radius: 999px; z-index: 20; box-shadow: 0 20px 40px -20px rgba(0,0,0,0.8); font-size: 0.9rem; }
.toast.is-error { border-color: var(--red); background: var(--red); }

/* list editors */
.list-item { display: grid; gap: 0 12px; grid-template-columns: 1fr auto; align-items: start; border: 1px solid var(--line); border-radius: 10px; padding: 14px; margin-bottom: 10px; background: var(--bg); }
.list-item .fields { display: grid; gap: 0 12px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.list-item .fields .field--wide { grid-column: 1 / -1; }
.list-item .field { margin-bottom: 8px; }
.list-item .actions { display: flex; flex-direction: column; gap: 6px; }
@media (max-width: 600px) { .list-item { grid-template-columns: 1fr; } .list-item .actions { flex-direction: row; flex-wrap: wrap; } }

/* gallery */
.uploader { border: 1px dashed var(--moss); border-radius: var(--radius); padding: 18px; background: rgba(95,138,107,0.06); }
.uploader input[type="file"] { color: var(--ink-soft); font-size: 0.9rem; }
.progress { height: 6px; background: var(--bg-3); border-radius: 3px; overflow: hidden; margin-top: 10px; }
.progress span { display: block; height: 100%; width: 0; background: var(--red); transition: width 0.2s; }
.media-tools { display: flex; gap: 8px; flex-wrap: wrap; margin: 20px 0 12px; align-items: center; }
.media-tools .count { color: var(--muted); font-size: 0.85rem; margin-left: auto; }
.media-list { display: grid; gap: 14px; }
.media-item { display: grid; grid-template-columns: 180px 1fr; gap: 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg-2); padding: 14px; }
.media-item.is-portrait { border-color: var(--red); }
.media-item__thumb { position: relative; aspect-ratio: 1; border-radius: 8px; overflow: hidden; background: var(--bg-3); }
.media-item__thumb img, .media-item__thumb video { width: 100%; height: 100%; object-fit: cover; }
.media-item__thumb .badge { position: absolute; top: 8px; left: 8px; background: rgba(0,0,0,0.7); color: #fff; font-size: 0.65rem; letter-spacing: 0.14em; text-transform: uppercase; padding: 3px 8px; border-radius: 999px; }
.media-item__thumb .badge.is-portrait { background: var(--red); }
.media-item__thumb .badge--share { top: auto; bottom: 8px; background: rgba(179,33,58,0.85); }
.media-item__thumb .badge--bg { top: auto; bottom: 8px; right: 8px; left: auto; background: var(--forest); }
.media-item__thumb .badge--hidden { right: 8px; left: auto; background: #71807a; }
.media-item__body .fields { display: grid; gap: 0 12px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.media-item__body .field--wide { grid-column: 1 / -1; }
.media-item__body .field { margin-bottom: 8px; }
.media-item__actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; align-items: center; }
.media-item__actions .spacer { flex: 1; }
.media-item__when { font-size: 0.72rem; color: var(--red-bright); letter-spacing: 0.12em; text-transform: uppercase; margin-bottom: 8px; }
@media (max-width: 640px) { .media-item { grid-template-columns: 1fr; } .media-item__thumb { aspect-ratio: 16 / 9; } }

/* family */
.people { display: grid; gap: 10px; }
.person-row { display: grid; grid-template-columns: 1fr auto; gap: 12px; border: 1px solid var(--line); border-radius: 10px; padding: 14px; background: var(--bg-2); }
.person-row.is-him { border-color: var(--red); }
.person-row .fields { display: grid; gap: 0 12px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.person-row .field { margin-bottom: 8px; }
.person-row .actions { display: flex; flex-direction: column; gap: 6px; }
@media (max-width: 600px) { .person-row { grid-template-columns: 1fr; } .person-row .actions { flex-direction: row; flex-wrap: wrap; } }

/* memories */
.memory-admin { border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; background: var(--bg-2); margin-bottom: 10px; display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: start; }
.memory-admin p { margin: 0; white-space: pre-line; color: var(--ink-soft); }
.memory-admin .by { color: var(--forest); font-family: var(--serif); font-size: 1.1rem; margin-top: 6px; }
.memory-admin .date { color: var(--muted); font-size: 0.75rem; letter-spacing: 0.1em; text-transform: uppercase; }
.empty { color: var(--muted); font-style: italic; }
.help h3 { margin-top: 22px; }

/* timeline media picker */
.event-media { border-top: 1px solid var(--line); padding-top: 8px; margin-top: 4px; }
.event-media summary { cursor: pointer; font-size: 0.8rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); font-weight: 600; padding: 4px 0; }
.event-media__count { color: var(--red); }
.picker { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; margin-top: 10px; }
.picker__item { position: relative; display: block; aspect-ratio: 1; border-radius: 8px; overflow: hidden; border: 2px solid transparent; background: var(--bg-3); cursor: pointer; }
.picker__item img, .picker__item video, .picker__poster { width: 100%; height: 100%; object-fit: cover; display: block; }
.picker__poster { background: radial-gradient(circle at 50% 40%, #6f8c85, #2e4a40); }
.picker__item input { position: absolute; top: 6px; left: 6px; accent-color: var(--red); width: 18px; height: 18px; margin: 0; z-index: 1; }
.picker__item.is-on { border-color: var(--red); box-shadow: 0 0 0 2px rgba(179,33,58,0.25); }
.picker__cap { position: absolute; left: 0; right: 0; bottom: 0; padding: 3px 6px; font-size: 0.65rem; color: #fff; background: linear-gradient(transparent, rgba(0,0,0,0.75)); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* gallery toolbar, bulk bar, pager */
.media-toolbar .row .field { margin-bottom: 8px; }
.bulkbar { position: sticky; top: 56px; z-index: 5; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 12px; margin-bottom: 14px; background: var(--bg-2); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 10px 30px -20px rgba(31,58,46,0.4); }
.bulkbar .field { margin: 0; }
.bulkbar select, .bulkbar input { font: inherit; font-size: 0.85rem; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; }
.bulkbar__n { color: var(--muted); font-size: 0.85rem; margin-right: 4px; }
.pager { display: flex; justify-content: center; align-items: center; gap: 14px; margin-top: 18px; color: var(--muted); font-size: 0.9rem; }
.media-item { position: relative; }
.media-item.is-selected { border-color: var(--red); box-shadow: 0 0 0 2px rgba(179,33,58,0.2); }
.media-item__check { position: absolute; top: 8px; right: 8px; z-index: 2; width: 20px; height: 20px; accent-color: var(--red); margin: 0; }
.media-item__taken { color: var(--muted); text-transform: none; letter-spacing: 0; }
/* portrait / background slots */
.picture-slot { border: 1px dashed var(--line); border-radius: 10px; padding: 12px; margin-bottom: 14px; display: grid; gap: 8px; justify-items: start; }
.picture-slot__label { font-size: 0.7rem; letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted); }
.picture-slot__preview { width: 110px; height: 110px; border-radius: 50%; overflow: hidden; background: var(--bg-3); display: grid; place-items: center; text-align: center; font-size: 0.75rem; color: var(--muted); padding: 6px; }
.picture-slot__preview--wide { width: 100%; max-width: 320px; height: 120px; border-radius: 8px; }
.picture-slot__preview img { width: 100%; height: 100%; object-fit: cover; }
.picture-slot .help-text { margin: 0; }

/* timeline tab */
.moment { border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg-2); margin-bottom: 14px; overflow: hidden; }
.moment__head { display: flex; align-items: center; gap: 14px; padding: 12px 14px; cursor: pointer; user-select: none; }
.moment__head:hover { background: var(--bg-3); }
.moment__cover { width: 56px; height: 56px; border-radius: 8px; background: var(--bg-3); overflow: hidden; flex: none; display: grid; place-items: center; color: var(--muted); font-size: 0.7rem; }
.moment__cover img { width: 100%; height: 100%; object-fit: cover; }
.moment__meta { flex: 1; min-width: 0; }
.moment__date { font-size: 0.7rem; letter-spacing: 0.16em; text-transform: uppercase; color: var(--red); font-weight: 600; }
.moment__title { font-family: var(--serif); font-size: 1.3rem; color: var(--forest); line-height: 1.15; }
.moment__count { color: var(--muted); font-size: 0.8rem; }
.moment__arrows { display: flex; gap: 4px; }
.moment__body { padding: 0 14px 14px; border-top: 1px solid var(--line); }
.moment__body h4 { font-family: var(--serif); font-weight: 500; font-size: 1.1rem; margin: 18px 0 8px; color: var(--forest); }
.moment__actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 8px; }
.moment__actions .spacer { flex: 1; }
.dropzone { border: 2px dashed var(--moss); border-radius: 10px; padding: 16px; text-align: center; background: rgba(95,138,107,0.06); cursor: pointer; transition: 0.2s; }
.dropzone.is-over { background: rgba(95,138,107,0.18); border-color: var(--forest); }
.dropzone strong { color: var(--forest); }
.dropzone input { display: none; }
.mgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; margin-top: 10px; }
.mtile { position: relative; aspect-ratio: 1; border-radius: 8px; overflow: hidden; background: var(--bg-3); border: 2px solid transparent; }
.mtile img, .mtile video { width: 100%; height: 100%; object-fit: cover; display: block; }
.mtile input { position: absolute; top: 6px; left: 6px; width: 18px; height: 18px; accent-color: var(--red); margin: 0; z-index: 1; }
.mtile.is-on { border-color: var(--red); }
.mtile.is-cover::after { content: 'Cover'; position: absolute; right: 6px; top: 6px; background: var(--red); color: #fff; font-size: 0.6rem; letter-spacing: 0.12em; text-transform: uppercase; padding: 2px 6px; border-radius: 999px; }
.mtile__cap { position: absolute; left: 0; right: 0; bottom: 0; padding: 3px 6px; font-size: 0.62rem; color: #fff; background: linear-gradient(transparent, rgba(0,0,0,0.75)); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mtile__play { position: absolute; inset: 0; display: grid; place-items: center; color: #fff; font-size: 1.4rem; text-shadow: 0 2px 6px rgba(0,0,0,0.6); pointer-events: none; }
.attach { margin-top: 10px; border: 1px solid var(--line); border-radius: 10px; padding: 12px; background: var(--bg); }
.attach .row { align-items: end; }
.attach .field { margin-bottom: 8px; }

/* inbox */
.tab__badge { display: inline-block; min-width: 18px; padding: 0 6px; border-radius: 999px; background: var(--red); color: #fff; font-size: 0.7rem; line-height: 18px; text-align: center; margin-left: 4px; vertical-align: 1px; }
.sub { border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg-2); margin-bottom: 14px; padding: 16px; }
.sub--pending { border-left: 4px solid var(--red); }
.sub__head { display: flex; gap: 12px; flex-wrap: wrap; align-items: baseline; margin-bottom: 6px; }
.sub__name { font-family: var(--serif); font-size: 1.3rem; color: var(--forest); }
.sub__meta { color: var(--muted); font-size: 0.8rem; }
.sub__status { font-size: 0.7rem; letter-spacing: 0.14em; text-transform: uppercase; padding: 2px 8px; border-radius: 999px; background: var(--bg-3); color: var(--muted); }
.sub__status--approved { background: rgba(95,138,107,0.2); color: var(--forest); }
.sub__status--declined { background: rgba(179,33,58,0.12); color: var(--red); }
.sub__msg { white-space: pre-line; color: var(--ink); margin: 8px 0 10px; }
.sub__when { font-size: 0.78rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--red); font-weight: 600; margin-bottom: 8px; }
.sub__files { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; margin: 8px 0 12px; }
.sub__file { position: relative; aspect-ratio: 1; border-radius: 8px; overflow: hidden; background: var(--bg-3); border: 2px solid transparent; }
.sub__file img, .sub__file video { width: 100%; height: 100%; object-fit: cover; display: block; }
.sub__file input { position: absolute; top: 6px; left: 6px; width: 18px; height: 18px; accent-color: var(--red); margin: 0; z-index: 1; }
.sub__file.is-off { opacity: 0.4; }
.sub__file a { position: absolute; right: 6px; bottom: 6px; background: rgba(0,0,0,0.6); color: #fff; font-size: 0.65rem; padding: 2px 6px; border-radius: 999px; text-decoration: none; }
.sub__approve { display: grid; gap: 8px 12px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); align-items: end; padding: 12px; border: 1px dashed var(--line); border-radius: 10px; background: var(--bg); }
.sub__approve .field { margin: 0; }
.sub__approve .field--check { align-self: center; }
.sub__actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 10px; }
.sub__actions .spacer { flex: 1; }
.inbox-filters { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.inbox-filters .btn.is-active { background: var(--forest); border-color: var(--forest); color: #fff; }
