:root {
  --paper: #f6f2ec;
  --card: #fffdf9;
  --ink: #2a2826;
  --muted: #6f6a64;
  --line: #e4ddd3;
  --accent: #2f5d66;
  --accent-soft: #e3ecec;
  --warm: #b0704a;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(40, 30, 20, .05), 0 6px 24px rgba(40, 30, 20, .06);
  --serif: 'Frank Ruhl Libre', 'Times New Roman', serif;
  --sans: 'Assistant', system-ui, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font-family: var(--sans); font-size: 17px; line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { font-family: var(--serif); font-weight: 500; line-height: 1.25; margin: 0 0 .4em; }
h2 { font-size: 1.6rem; }
button, input, textarea, select { font: inherit; color: inherit; }
img, video { max-width: 100%; display: block; }

/* ---------- hero ---------- */
.hero { position: relative; height: min(78vh, 680px); min-height: 420px; overflow: hidden; background: #1d2a2e; }
.hero-img { width: 100%; height: 100%; object-fit: cover; object-position: 70% 15%; }
.hero-shade { position: absolute; inset: 0; background: linear-gradient(to left, transparent 35%, rgba(18, 26, 30, .78) 100%), linear-gradient(to top, rgba(18, 26, 30, .55), transparent 45%); }
.hero-text { position: absolute; left: 6vw; bottom: 12%; color: #fff; text-align: right; max-width: 460px; }
.hero h1 { font-size: clamp(3rem, 7vw, 5.2rem); font-weight: 400; margin: 0; letter-spacing: .01em; }
.hero .dates { font-size: 1.25rem; opacity: .9; margin: .2em 0 1.4em; letter-spacing: .04em; direction: ltr; text-align: right; }
@media (max-width: 720px) {
  .hero { height: 74vh; }
  .hero-img { object-position: 78% 30%; }
  .hero-shade { background: linear-gradient(to top, rgba(18, 26, 30, .88) 0%, rgba(18, 26, 30, .35) 45%, transparent 70%); }
  .hero-text { left: 16px; right: 16px; bottom: 28px; max-width: none; }
}

/* ---------- tabs ---------- */
.tabs {
  position: sticky; top: 0; z-index: 20; display: flex; gap: 4px; justify-content: safe center;
  background: rgba(246, 242, 236, .94); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line); padding: 0 12px; overflow-x: auto; scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
@media (max-width: 720px) { .tabs { justify-content: flex-start; padding: 0 4px; } .tabs a { padding: 14px 11px 12px; } }
.tabs a {
  padding: 14px 16px 12px; color: var(--muted); text-decoration: none; white-space: nowrap;
  border-bottom: 2px solid transparent; font-weight: 600;
}
.tabs a:hover { color: var(--ink); }
.tabs a.active { color: var(--accent); border-color: var(--accent); }

main { max-width: 1180px; margin: 0 auto; padding: 32px 16px 64px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 18px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--card); cursor: pointer; font-weight: 600; font-size: .95rem; white-space: nowrap;
  transition: background .15s, border-color .15s;
}
.btn:hover { border-color: var(--accent); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: #24494f; }
.btn-light { background: rgba(255, 255, 255, .95); color: var(--ink); border: 0; padding: 13px 24px; font-size: 1.05rem; }
.btn:disabled { opacity: .5; cursor: default; }
.link-btn { background: none; border: 0; color: var(--accent); cursor: pointer; font-weight: 600; padding: 6px 0; }
.btn-small { padding: 6px 12px; font-size: .85rem; }

/* ---------- gallery ---------- */
.findme { padding: 24px; display: grid; grid-template-columns: 1fr auto; gap: 16px 24px; align-items: center; margin-bottom: 40px; }
.findme p { margin: 0; color: var(--muted); }
.findme-actions { display: flex; gap: 10px; flex-wrap: wrap; }
#findme-result { grid-column: 1 / -1; }
#findme-result:empty { display: none; }
@media (max-width: 720px) { .findme { grid-template-columns: 1fr; } }

.section-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px; margin: 8px 0 16px; }
.section-head h2 { margin: 0; }
.count { font-family: var(--sans); font-size: 1rem; color: var(--muted); }
.upload-actions { display: flex; gap: 8px; flex-wrap: wrap; }
#people-filter { padding: 8px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--card); min-width: 200px; }

.people { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 16px 12px; margin-bottom: 8px; }
.person { background: none; border: 0; padding: 0; cursor: pointer; text-align: center; }
.person .face, .face {
  width: 84px; height: 84px; border-radius: 50%; margin: 0 auto 6px; overflow: hidden;
  background: var(--line) center/cover no-repeat; border: 2px solid var(--card); box-shadow: 0 0 0 1px var(--line);
}
.person:hover .face { box-shadow: 0 0 0 2px var(--accent); }
.person .pname { font-size: .88rem; line-height: 1.3; display: block; }
.person .pname.unnamed { color: var(--muted); }
.person .pcount { font-size: .78rem; color: var(--muted); }

.dropzone {
  border: 1.5px dashed var(--line); border-radius: var(--radius); padding: 14px; text-align: center;
  color: var(--muted); font-size: .92rem; margin-bottom: 16px;
}
.dropzone.over { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
@media (hover: none) { .dropzone, .desktop-only { display: none !important; } }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 6px; }
@media (max-width: 520px) { .grid { grid-template-columns: repeat(3, 1fr); gap: 3px; } }
.tile { position: relative; aspect-ratio: 1; overflow: hidden; border-radius: 6px; background: var(--line); cursor: pointer; border: 0; padding: 0; }
.tile img { width: 100%; height: 100%; object-fit: cover; transition: transform .3s; }
.tile:hover img { transform: scale(1.04); }
.tile .play {
  position: absolute; inset: auto 8px 8px auto; background: rgba(0, 0, 0, .6); color: #fff;
  border-radius: 999px; padding: 2px 9px; font-size: .78rem; direction: ltr;
}
.empty { color: var(--muted); text-align: center; padding: 40px 0; }

/* ---------- modal ---------- */
.modal { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(20, 20, 20, .82); }
.modal-box {
  position: relative; background: var(--card); border-radius: var(--radius); width: min(920px, calc(100vw - 32px));
  max-height: calc(100vh - 32px); overflow: auto; padding: 28px;
}
.modal:has(.lightbox) .modal-backdrop { background: rgba(10, 10, 10, .96); }
.modal-box.lightbox { background: transparent; width: 100vw; height: 100vh; max-height: none; border-radius: 0; padding: 0; overflow: hidden; }
.close-x {
  position: absolute; top: 10px; left: 10px; width: 40px; height: 40px; border-radius: 50%; border: 0;
  background: rgba(0, 0, 0, .06); cursor: pointer; font-size: 1.4rem; line-height: 1; z-index: 5;
}
.lightbox .close-x { background: rgba(255, 255, 255, .15); color: #fff; top: 14px; left: 14px; }

.lb-stage { position: absolute; inset: 0 0 72px 0; display: flex; align-items: center; justify-content: center; }
.lb-frame { position: relative; max-width: 100%; max-height: 100%; }
.lb-frame img, .lb-frame video { max-width: 100vw; max-height: calc(100vh - 72px); object-fit: contain; }
.lb-nav {
  position: absolute; top: 50%; transform: translateY(-50%); width: 48px; height: 48px; border-radius: 50%;
  border: 0; background: rgba(255, 255, 255, .15); color: #fff; font-size: 1.6rem; cursor: pointer; z-index: 4;
}
.lb-prev { right: 14px; } .lb-next { left: 14px; }
@media (max-width: 720px) { .lb-nav { display: none; } }
.lb-bar {
  position: absolute; bottom: 0; left: 0; right: 0; height: 72px; display: flex; align-items: center; gap: 10px;
  padding: 0 16px; color: #ddd; font-size: .9rem; overflow-x: auto;
}
.lb-bar .meta { margin-inline-end: auto; white-space: nowrap; }
.lb-chip {
  display: inline-flex; align-items: center; gap: 6px; background: rgba(255, 255, 255, .12); color: #fff;
  border: 0; border-radius: 999px; padding: 4px 12px 4px 4px; cursor: pointer; white-space: nowrap; font-size: .85rem;
}
.lb-chip .face { width: 28px; height: 28px; margin: 0; border: 0; box-shadow: none; }
.facebox { position: absolute; border: 2px solid rgba(255, 255, 255, .85); border-radius: 6px; cursor: pointer; background: none; padding: 0; }
.facebox:hover { border-color: #ffd28a; }
.facebox span {
  position: absolute; top: 100%; right: -2px; margin-top: 3px; background: rgba(0, 0, 0, .7); color: #fff;
  font-size: .75rem; padding: 1px 7px; border-radius: 4px; white-space: nowrap;
}
.hide-boxes .facebox { display: none; }

/* person / face panel */
.person-head { display: flex; gap: 18px; align-items: center; margin-bottom: 20px; flex-wrap: wrap; }
.person-head .face { width: 96px; height: 96px; margin: 0; }
.person-head h2 { margin: 0; }
.inline-form { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.inline-form input, .inline-form select { padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px; background: #fff; min-width: 180px; }
.small-muted { color: var(--muted); font-size: .88rem; }

/* ---------- posts ---------- */
.posts-intro { text-align: center; max-width: 640px; margin: 0 auto 28px; }
.posts-intro p { color: var(--muted); margin: 0; }
.compose { padding: 24px; margin-bottom: 40px; }
.compose-toggle { display: flex; justify-content: center; margin-bottom: 28px; }
.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-weight: 600; font-size: .92rem; margin-bottom: 4px; }
.field input[type=text] { width: 100%; padding: 10px 14px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.row { display: flex; gap: 16px; flex-wrap: wrap; align-items: flex-end; }
.row > .field { flex: 1 1 240px; }
.check { display: inline-flex; gap: 8px; align-items: center; margin-bottom: 14px; cursor: pointer; }
.editor-wrap { background: #fff; border-radius: 10px; margin-bottom: 14px; }
.editor-wrap .ql-toolbar { border-radius: 10px 10px 0 0; border-color: var(--line); direction: ltr; }
.editor-wrap .ql-container { border-radius: 0 0 10px 10px; border-color: var(--line); min-height: 220px; font-family: var(--sans); font-size: 17px; }
.ql-editor { direction: rtl; text-align: right; min-height: 220px; }
.ql-editor.ql-blank::before { right: 15px; left: auto; font-style: normal; color: #aaa; }
.files-list { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 14px; }
.file-pill { background: var(--accent-soft); color: var(--accent); border-radius: 999px; padding: 4px 6px 4px 12px; font-size: .85rem; display: inline-flex; gap: 6px; align-items: center; }
.file-pill button { border: 0; background: none; cursor: pointer; color: inherit; font-size: 1rem; }
.compose-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }

.post-list { columns: 3 300px; column-gap: 18px; }
.post-card {
  break-inside: avoid; margin-bottom: 18px; padding: 20px 22px; cursor: pointer; display: block; width: 100%;
  text-align: right; transition: transform .15s;
}
.post-card:hover { transform: translateY(-2px); }
.post-card h3 { font-size: 1.2rem; margin-bottom: .3em; }
.post-card .excerpt { white-space: pre-line; color: #4a4642; font-size: .96rem; display: -webkit-box; -webkit-line-clamp: 6; -webkit-box-orient: vertical; overflow: hidden; }
.post-card .thumbs { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.post-card .thumbs img { width: 64px; height: 64px; object-fit: cover; border-radius: 6px; }
.post-card .att-count { font-size: .82rem; color: var(--accent); margin-top: 8px; }
.byline { font-size: .86rem; color: var(--muted); margin-top: 12px; }
.post-full .byline { margin: 0 0 18px; }
.post-body { font-size: 1.08rem; line-height: 1.8; }
.post-body.ql-editor { min-height: 0; overflow: visible; height: auto; }
.post-body img { border-radius: 8px; margin: 12px 0; }
.post-body .ql-align-center { text-align: center; } .post-body .ql-align-left { text-align: left; } .post-body .ql-align-justify { text-align: justify; }
.attachment { margin: 18px 0; }
.attachment img, .attachment video { border-radius: 8px; max-height: 80vh; margin: 0 auto; }
.attachment iframe { width: 100%; height: 75vh; border: 1px solid var(--line); border-radius: 8px; }
.docx { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 24px; }
.dl { display: inline-flex; gap: 8px; align-items: center; padding: 10px 14px; border: 1px solid var(--line); border-radius: 10px; text-decoration: none; color: var(--accent); font-weight: 600; }

/* about */
.about { max-width: 760px; margin: 0 auto; padding: 0 0 32px; overflow: hidden; text-align: center; }
.about-img { width: 100%; max-height: 420px; object-fit: cover; object-position: 70% 30%; margin-bottom: 24px; }
.about .dates { color: var(--muted); direction: ltr; }
.about-body { text-align: right; padding: 0 32px; font-size: 1.1rem; line-height: 1.85; }
.placeholder { color: var(--muted); text-align: center; font-style: italic; }

/* ---------- progress / toast ---------- */
.progress {
  position: fixed; bottom: 16px; left: 16px; z-index: 60; width: min(360px, calc(100vw - 32px));
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px;
}
.progress-text { font-size: .92rem; margin-bottom: 8px; }
.progress-note { font-size: .78rem; color: var(--muted); margin-top: 6px; }
.bar { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; }
.bar > div { height: 100%; width: 0; background: var(--accent); transition: width .3s; }
.toast {
  position: fixed; bottom: 20px; right: 50%; transform: translateX(50%); z-index: 70;
  background: var(--ink); color: #fff; padding: 10px 20px; border-radius: 999px; font-size: .94rem; max-width: calc(100vw - 32px);
}
.spinner { width: 22px; height: 22px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; display: inline-block; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }
.foot { text-align: center; color: var(--muted); font-size: .88rem; padding: 24px 16px 40px; font-family: var(--serif); }
