/* Instagram-like profile blog for the Freie Comenius Schule Darmstadt */

:root {
  --bg: #ffffff;
  --bg-elevated: #ffffff;
  --text: #000000;
  --text-secondary: #737373;
  --separator: #dbdbdb;
  --separator-strong: #c7c7c7;
  --btn-primary: #0095f6;
  --btn-primary-hover: #1877f2;
  --btn-secondary: #efefef;
  --btn-secondary-hover: #dbdbdb;
  --link: #00376b;
  --error: #ed4956;
  --highlight-bg: #fafafa;
  --overlay: rgba(0, 0, 0, 0.65);
  --hover-overlay: rgba(0, 0, 0, 0.3);
  --media-bg: #000000;
  --shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #000000;
    --bg-elevated: #262626;
    --text: #f5f5f5;
    --text-secondary: #a8a8a8;
    --separator: #262626;
    --separator-strong: #363636;
    --btn-secondary: #363636;
    --btn-secondary-hover: #262626;
    --link: #e0f1ff;
    --highlight-bg: #121212;
    --media-bg: #000000;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #000000;
  --bg-elevated: #262626;
  --text: #f5f5f5;
  --text-secondary: #a8a8a8;
  --separator: #262626;
  --separator-strong: #363636;
  --btn-secondary: #363636;
  --btn-secondary-hover: #262626;
  --link: #e0f1ff;
  --highlight-bg: #121212;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 18px;
  -webkit-font-smoothing: antialiased;
  overflow-wrap: anywhere;
}

body.embed { background: transparent; }
body.embed.embed-solid { background: var(--bg); }

body.no-scroll { overflow: hidden; }

a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
input, textarea, select { font: inherit; color: inherit; }
img { display: block; max-width: 100%; }
svg { display: block; flex-shrink: 0; }
[hidden] { display: none !important; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* ---------- buttons ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 32px; padding: 0 16px; border-radius: 8px;
  font-size: 14px; font-weight: 600; line-height: 18px; white-space: nowrap;
  background: var(--btn-secondary); color: var(--text);
  transition: background-color .15s ease;
}
.btn:hover { background: var(--btn-secondary-hover); }
.btn-primary { background: var(--btn-primary); color: #fff; }
.btn-primary:hover { background: var(--btn-primary-hover); }
.btn-icon { width: 34px; padding: 0; }
.btn:disabled { opacity: .5; cursor: default; }
.btn-text { color: var(--btn-primary); font-weight: 600; font-size: 14px; }
.btn-text:hover { color: var(--link); }
.btn-text:disabled { opacity: .3; cursor: default; }
.btn-danger { color: var(--error); }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 8px; border-radius: 50%;
}
.icon-btn:hover { opacity: .5; }

/* ---------- top bar (mobile) ---------- */

.topbar {
  display: none;
  position: sticky; top: 0; z-index: 20;
  height: 44px;
  background: var(--bg);
  border-bottom: 1px solid var(--separator);
  padding-top: env(safe-area-inset-top);
}
.topbar-inner {
  height: 44px; display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px;
}
.topbar-title {
  display: flex; align-items: center; gap: 4px;
  font-size: 16px; font-weight: 600; line-height: 20px;
  min-width: 0;
}
.topbar-title > span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-actions { display: flex; gap: 4px; margin-right: -8px; }

/* ---------- page / profile ---------- */

.page {
  max-width: 975px;
  margin: 0 auto;
  padding: 30px 20px 0;
}

.profile {
  display: flex;
  align-items: stretch;
  margin-bottom: 44px;
  min-height: 150px;
}

.profile-avatar-col {
  flex: 0 0 30%;
  display: flex; justify-content: center; align-items: flex-start;
  margin-right: 30px;
}

.avatar {
  border-radius: 50%;
  object-fit: cover;
  background: var(--highlight-bg);
  border: 1px solid rgba(0, 0, 0, .0975);
}
.avatar-xl { width: 150px; height: 150px; }
.avatar-sm { width: 32px; height: 32px; }

.profile-info { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; }

.profile-row {
  display: flex; align-items: center; flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
}
.profile-username {
  display: flex; align-items: center; gap: 6px;
  font-size: 20px; font-weight: 400; line-height: 25px;
  margin: 0 12px 0 0;
  overflow: hidden;
}
.profile-username span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-buttons { display: flex; gap: 8px; flex-wrap: wrap; }

.stats {
  display: flex; gap: 40px;
  margin: 0 0 20px; padding: 0; list-style: none;
  font-size: 16px; line-height: 20px;
}
.stats li { white-space: nowrap; }
.stats strong { font-weight: 600; }

.profile-name { font-weight: 600; margin: 0; font-size: 14px; }
.profile-category { color: var(--text-secondary); }
.profile-bio { white-space: pre-line; margin: 0; }
.profile-link {
  display: inline-flex; align-items: center; gap: 4px;
  color: var(--link); font-weight: 600;
  margin-top: 2px;
}
.profile-link:hover { text-decoration: underline; }

.verified { width: 18px; height: 18px; }
.verified-sm { width: 12px; height: 12px; }

/* ---------- highlights ---------- */

.highlights {
  display: flex; gap: 0;
  margin: 0 0 44px;
  overflow-x: auto; scrollbar-width: none;
  padding-left: 44px;
}
.highlights::-webkit-scrollbar { display: none; }
.highlight {
  flex: 0 0 auto;
  width: 115px;
  display: flex; flex-direction: column; align-items: center;
  padding: 0 15px;
  text-align: center;
}
.highlight-ring {
  width: 87px; height: 87px; border-radius: 50%;
  border: 1px solid var(--separator);
  padding: 4px;
  background: var(--bg);
}
.highlight-ring img {
  width: 100%; height: 100%; border-radius: 50%; object-fit: cover;
  background: var(--highlight-bg);
}
.highlight-title {
  margin-top: 15px;
  font-size: 12px; font-weight: 600; line-height: 16px;
  max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ---------- tabs ---------- */

.tabs {
  display: flex; justify-content: center; gap: 60px;
  border-top: 1px solid var(--separator);
}
.tab {
  display: flex; align-items: center; gap: 6px;
  height: 52px;
  margin-top: -1px;
  border-top: 1px solid transparent;
  color: var(--text-secondary);
  font-size: 12px; font-weight: 600; letter-spacing: 1px; text-transform: uppercase;
}
.tab.active { color: var(--text); border-top-color: var(--text); }

/* ---------- filter / reorder bars ---------- */

.filter, .reorder-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 16px; margin: 0 0 12px;
  border-radius: 8px;
  background: var(--highlight-bg);
  border: 1px solid var(--separator);
}
.filter strong { font-weight: 600; }
.reorder-bar { position: sticky; top: 8px; z-index: 5; box-shadow: var(--shadow); }

/* ---------- grid ---------- */

.grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
}

.tile {
  position: relative;
  aspect-ratio: 3 / 4;
  overflow: hidden;
  background: var(--highlight-bg);
  display: block;
  cursor: pointer;
}
.tile img {
  width: 100%; height: 100%; object-fit: cover;
  transition: opacity .2s ease;
}
.tile img.loading { opacity: 0; }
.tile-badge {
  position: absolute; top: 8px; right: 8px;
  color: #fff; filter: drop-shadow(0 0 1px rgba(0, 0, 0, .4));
}
.tile-hover {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center; gap: 30px;
  background: var(--hover-overlay);
  color: #fff; font-size: 16px; font-weight: 700;
  opacity: 0;
  transition: opacity .1s ease;
}
.tile-hover span { display: flex; align-items: center; gap: 7px; }
@media (hover: hover) {
  .tile:hover .tile-hover { opacity: 1; }
}
.tile:focus-visible { outline: 3px solid var(--btn-primary); outline-offset: -3px; }

.grid.reordering .tile { cursor: grab; }
.grid.reordering .tile-hover { display: none; }
.grid.reordering .tile::after {
  content: ""; position: absolute; inset: 0;
  border: 2px dashed rgba(255, 255, 255, .9);
  pointer-events: none;
}
.tile.sortable-ghost { opacity: .35; }
.tile.sortable-chosen { transform: scale(.97); }
.tile-pos {
  position: absolute; left: 8px; top: 8px;
  min-width: 26px; height: 26px; padding: 0 8px; border-radius: 13px;
  display: none; align-items: center; justify-content: center;
  background: rgba(0, 0, 0, .65); color: #fff; font-weight: 700; font-size: 12px;
}
.grid.reordering .tile-pos { display: flex; }

.empty {
  display: flex; flex-direction: column; align-items: center; gap: 16px;
  padding: 60px 20px; text-align: center;
}
.empty h2 { font-size: 30px; font-weight: 800; line-height: 36px; margin: 0; }
.empty-icon {
  width: 62px; height: 62px; border-radius: 50%;
  border: 2px solid var(--text);
  display: flex; align-items: center; justify-content: center;
}

.skeleton { background: var(--highlight-bg); animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .5; } }

.footer {
  padding: 40px 0 52px;
  text-align: center;
  color: var(--text-secondary);
  font-size: 12px; line-height: 16px;
}
.footer a:hover { text-decoration: underline; }
.footer nav { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 16px; margin-bottom: 16px; }

/* ---------- modal base ---------- */

.modal {
  position: fixed; inset: 0; z-index: 100;
  background: var(--overlay);
  display: flex; align-items: center; justify-content: center;
  animation: fade-in .15s ease;
}
@keyframes fade-in { from { opacity: 0; } }

.modal-close {
  position: fixed; top: 10px; right: 10px; z-index: 2;
  color: #fff; padding: 8px;
}
.modal-nav {
  position: fixed; top: 50%; z-index: 2;
  width: 32px; height: 32px; margin-top: -16px; border-radius: 50%;
  background: #fff; color: #000;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 0 6px rgba(0,0,0,.2);
}
.modal-nav.prev { left: 24px; }
.modal-nav.next { right: 24px; }
.modal-nav:hover { opacity: .85; }

/* ---------- post view ---------- */

.post {
  display: grid;
  grid-template-columns: auto minmax(405px, 500px);
  grid-template-rows: auto 1fr auto auto;
  grid-template-areas:
    "media header"
    "media caption"
    "media actions"
    "media date";
  background: var(--bg);
  max-width: calc(100vw - 128px);
  height: min(calc(100vh - 48px), 900px);
  height: min(calc(100dvh - 48px), 900px);
  border-radius: 4px;
  overflow: hidden;
  animation: pop-in .2s ease;
}
@keyframes pop-in { from { transform: scale(1.03); opacity: 0; } }

.post-mobile-bar { display: none; }

.post-media {
  grid-area: media;
  position: relative;
  background: var(--media-bg);
  height: 100%;
  aspect-ratio: var(--ar, 0.8);
  max-width: calc(100vw - 128px - 405px);
  min-width: 0;
  overflow: hidden;
}

.carousel {
  display: flex; height: 100%; width: 100%;
  overflow-x: auto; overflow-y: hidden;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  overscroll-behavior-x: contain;
}
.carousel::-webkit-scrollbar { display: none; }
.slide {
  flex: 0 0 100%; height: 100%;
  scroll-snap-align: center;
  display: flex; align-items: center; justify-content: center;
  position: relative;
}
.slide img { width: 100%; height: 100%; object-fit: contain; user-select: none; -webkit-user-drag: none; }
.carousel-btn {
  position: absolute; top: 50%; margin-top: -15px;
  width: 30px; height: 30px; border-radius: 50%;
  background: rgba(255, 255, 255, .8); color: #262626;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 0 5px rgba(0,0,0,.15);
  transition: opacity .2s;
}
.carousel-btn:hover { background: #fff; }
.carousel-btn.prev { left: 12px; }
.carousel-btn.next { right: 12px; }
.dots {
  position: absolute; bottom: 15px; left: 0; right: 0;
  display: flex; justify-content: center; gap: 4px;
  pointer-events: none;
}
.dot { width: 6px; height: 6px; border-radius: 50%; background: rgba(255, 255, 255, .4); transition: background .2s; }
.dot.active { background: #fff; }

.heart-burst {
  position: absolute; top: 50%; left: 50%;
  width: 96px; height: 96px; margin: -48px 0 0 -48px;
  color: #fff; pointer-events: none;
  filter: drop-shadow(0 0 12px rgba(0,0,0,.3));
  animation: burst .9s ease forwards;
}
@keyframes burst {
  0% { transform: scale(0); opacity: 0; }
  15% { transform: scale(1.2); opacity: 1; }
  30% { transform: scale(.95); }
  45%, 80% { transform: scale(1); opacity: 1; }
  100% { transform: scale(.2) translateY(-60px); opacity: 0; }
}

.post-header {
  grid-area: header;
  display: flex; align-items: center; gap: 12px;
  height: 60px; padding: 14px 4px 14px 16px;
  border-bottom: 1px solid var(--separator);
}
.post-header-text { flex: 1; min-width: 0; line-height: 18px; }
.post-author { display: flex; align-items: center; gap: 4px; font-weight: 600; }
.post-location { font-size: 12px; line-height: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.post-caption {
  grid-area: caption;
  overflow-y: auto;
  padding: 16px;
  min-height: 0;
}
.comment { display: flex; gap: 14px; }
.comment-body { flex: 1; min-width: 0; }
.comment-text { white-space: pre-line; }
.comment-text a { color: var(--link); }
.comment-text a:hover { text-decoration: underline; }
.comment-author { font-weight: 600; margin-right: 4px; }
.comment-meta { margin-top: 8px; color: var(--text-secondary); font-size: 12px; line-height: 16px; }

.post-actions {
  grid-area: actions;
  border-top: 1px solid var(--separator);
  padding: 6px 16px 0;
}
.action-row { display: flex; align-items: center; margin: 0 -8px; }
.action-row .spacer { flex: 1; }
.action-btn { padding: 8px; display: inline-flex; }
.action-btn:hover { opacity: .5; }
.action-btn.liked { color: var(--error); }
.action-btn.liked:hover { opacity: 1; }
.action-btn.pop svg { animation: like-pop .45s ease; }
@keyframes like-pop { 0% { transform: scale(1); } 25% { transform: scale(1.2); } 50% { transform: scale(.95); } 100% { transform: scale(1); } }
.likes { font-weight: 600; margin: 2px 0 4px; }
.post-date {
  grid-area: date;
  padding: 0 16px 16px;
  color: var(--text-secondary);
  font-size: 10px; line-height: 12px; letter-spacing: .2px; text-transform: uppercase;
}

/* ---------- action sheet (… menu) / confirm ---------- */

.sheet {
  width: 400px; max-width: calc(100vw - 40px);
  background: var(--bg-elevated);
  border-radius: 12px;
  overflow: hidden;
  animation: pop-in .15s ease;
  text-align: center;
}
.sheet-head { padding: 32px 32px 16px; }
.sheet-head h3 { margin: 0 0 4px; font-size: 20px; line-height: 25px; font-weight: 400; }
.sheet-head p { margin: 0; color: var(--text-secondary); }
.sheet button, .sheet a {
  display: block; width: 100%;
  min-height: 48px; padding: 4px 8px;
  border-top: 1px solid var(--separator);
  font-size: 14px; line-height: 18px;
}
.sheet > button:first-child, .sheet > a:first-child { border-top: 0; }
.sheet .danger { color: var(--error); font-weight: 700; }
.sheet .strong { font-weight: 700; }
.sheet button:active { background: rgba(0,0,0,.05); }

/* ---------- dialog (composer / profile editor / login) ---------- */

.dialog {
  display: flex; flex-direction: column;
  background: var(--bg-elevated);
  border-radius: 12px;
  overflow: hidden;
  width: min(900px, calc(100vw - 40px));
  max-height: calc(100vh - 40px);
  max-height: calc(100dvh - 40px);
  animation: pop-in .2s ease;
}
.dialog.narrow { width: min(560px, calc(100vw - 40px)); }
.dialog-head {
  flex: 0 0 43px;
  display: grid; grid-template-columns: 80px 1fr 80px; align-items: center;
  border-bottom: 1px solid var(--separator);
  padding: 0 16px;
}
.dialog-head h2 { margin: 0; text-align: center; font-size: 16px; font-weight: 600; line-height: 24px; }
.dialog-head > :first-child { justify-self: start; }
.dialog-head > :last-child { justify-self: end; }
.dialog-body { overflow-y: auto; flex: 1; min-height: 0; }

.dropzone {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 16px; text-align: center;
  min-height: min(560px, 60vh);
  padding: 24px;
}
.dropzone p { font-size: 20px; line-height: 25px; margin: 0; }
.dropzone.drag { background: var(--highlight-bg); }

.compose {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  min-height: min(560px, 70vh);
}
.compose-preview {
  background: var(--media-bg);
  position: relative;
  aspect-ratio: 4 / 5;
  max-height: 70vh;
  justify-self: stretch;
}
.compose-side {
  display: flex; flex-direction: column;
  border-left: 1px solid var(--separator);
  min-width: 0;
}
.compose-user { display: flex; align-items: center; gap: 12px; padding: 16px 16px 8px; font-weight: 600; }
.caption-input {
  display: block; width: 100%;
  min-height: 168px; resize: vertical;
  padding: 4px 16px; border: 0; outline: 0;
  background: transparent;
  font-size: 16px; line-height: 22px;
}
.char-count { padding: 0 16px 8px; text-align: right; color: var(--text-secondary); font-size: 12px; }
.field-row {
  display: flex; align-items: center; gap: 8px;
  padding: 0 16px;
  border-top: 1px solid var(--separator);
  min-height: 44px;
}
.field-row input, .field-row label { flex: 1; }
.field-row input {
  border: 0; outline: 0; background: transparent; min-height: 44px; font-size: 16px;
}
.field-row .label { color: var(--text-secondary); white-space: nowrap; }

.thumbs {
  display: flex; gap: 8px; flex-wrap: wrap;
  padding: 12px 16px;
  border-top: 1px solid var(--separator);
}
.thumb {
  position: relative; width: 64px; height: 80px; border-radius: 4px; overflow: hidden;
  background: var(--highlight-bg); cursor: grab;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb.sortable-ghost { opacity: .35; }
.thumb-remove {
  position: absolute; top: 3px; right: 3px;
  width: 20px; height: 20px; border-radius: 50%;
  background: rgba(26, 26, 26, .8); color: #fff;
  display: flex; align-items: center; justify-content: center;
}
.thumb-add {
  width: 64px; height: 80px; border-radius: 4px;
  border: 1px dashed var(--separator-strong);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-secondary);
}
.thumb-progress {
  position: absolute; inset: 0; background: rgba(0,0,0,.45);
  display: flex; align-items: center; justify-content: center;
}
.spinner {
  width: 22px; height: 22px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,.35); border-top-color: #fff;
  animation: spin .7s linear infinite;
}
.spinner.dark { border-color: var(--separator); border-top-color: var(--text-secondary); }
@keyframes spin { to { transform: rotate(360deg); } }

.form { padding: 24px 32px 32px; display: grid; gap: 16px; }
.form-avatar { display: flex; align-items: center; gap: 16px; padding: 16px; border-radius: 20px; background: var(--highlight-bg); }
.form-avatar .avatar { width: 56px; height: 56px; }
.form-avatar div { flex: 1; min-width: 0; }
.form label { display: grid; gap: 6px; font-weight: 600; font-size: 14px; }
.form .hint { font-weight: 400; color: var(--text-secondary); font-size: 12px; line-height: 16px; }
.input {
  width: 100%;
  border: 1px solid var(--separator);
  border-radius: 12px;
  background: var(--bg);
  padding: 10px 14px;
  font-size: 16px; line-height: 20px; font-weight: 400;
  outline: 0;
}
.input:focus { border-color: var(--text-secondary); }
textarea.input { resize: vertical; min-height: 90px; }
.form .row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.check { display: flex !important; grid-auto-flow: column; align-items: center; gap: 8px !important; font-weight: 400 !important; }
.hl-list { display: grid; gap: 10px; }
.hl-item {
  display: grid; grid-template-columns: 48px 1fr 1fr 32px; gap: 8px; align-items: center;
}
.hl-item .hl-img {
  width: 48px; height: 48px; border-radius: 50%; overflow: hidden;
  border: 1px solid var(--separator);
}
.hl-item .hl-img img { width: 100%; height: 100%; object-fit: cover; }
.hl-item .input { padding: 8px 10px; font-size: 14px; }

/* login */
.login-wrap { display: flex; justify-content: center; padding: 40px 16px 80px; }
.login {
  width: 350px; max-width: 100%;
  border: 1px solid var(--separator);
  padding: 40px 40px 24px;
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  text-align: center;
}
.login img { width: 96px; height: 96px; margin-bottom: 12px; }
.login h1 { margin: 0 0 12px; font-size: 16px; font-weight: 600; color: var(--text-secondary); line-height: 20px; }
.login .input { border-radius: 3px; background: var(--highlight-bg); font-size: 14px; padding: 9px 8px; }
.login .btn { width: 100%; }
.login .err { color: var(--error); min-height: 18px; }

/* ---------- toast ---------- */

.toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 300;
  transform: translate(-50%, 20px);
  background: #262626; color: #fff;
  padding: 12px 18px; border-radius: 8px;
  font-size: 14px;
  opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s;
  max-width: calc(100vw - 32px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- mid-size ---------- */

@media (max-width: 1100px) {
  .post { grid-template-columns: auto 405px; }
}

@media (max-width: 1000px) and (min-width: 736px) {
  .post { grid-template-columns: auto 335px; }
  .post-media { max-width: calc(100vw - 128px - 335px); }
}

/* ---------- mobile ---------- */

@media (max-width: 735px) {
  body:not(.embed) .topbar { display: block; }

  .page { padding: 0; }
  .desktop-only { display: none !important; }

  .profile {
    display: block;
    padding: 16px 16px 0;
    margin: 0;
    min-height: 0;
  }
  .profile-top { display: flex; align-items: center; gap: 24px; margin-bottom: 14px; }
  .profile-avatar-col { flex: 0 0 auto; margin: 0; }
  .avatar-xl { width: 86px; height: 86px; }
  .profile-row { display: none; }
  .profile-top .stats {
    flex: 1; justify-content: space-around; gap: 4px; margin: 0;
    font-size: 14px; line-height: 18px; text-align: center;
  }
  .profile-top .stats li { display: flex; flex-direction: column; }
  .profile-top .stats strong { font-size: 16px; line-height: 20px; }
  .profile-buttons.mobile { display: flex; gap: 6px; margin: 14px 0 0; }
  .profile-buttons.mobile .btn { flex: 1; padding: 0 8px; }
  .profile-buttons.mobile .btn-icon { flex: 0 0 34px; }

  .highlights { padding: 20px 4px 12px; margin: 0; }
  .highlight { width: 82px; padding: 0 8px; }
  .highlight-ring { width: 64px; height: 64px; padding: 3px; }
  .highlight-title { margin-top: 6px; font-weight: 400; }

  .tabs { gap: 0; margin-top: 8px; }
  .tab { flex: 1; justify-content: center; height: 44px; border-top: 0; border-bottom: 1px solid transparent; margin: 0; }
  .tab.active { border-bottom-color: var(--text); }
  .tab span { display: none; }
  .tab svg { width: 24px; height: 24px; }

  .filter, .reorder-bar { margin: 8px; font-size: 13px; }
  .reorder-bar { top: 52px; }
  body.embed .reorder-bar { top: 8px; }

  .grid { gap: 2px; }
  .tile-badge { top: 6px; right: 6px; }
  .tile-badge svg { width: 16px; height: 16px; }

  .footer { padding: 24px 16px 40px; }

  /* post view becomes a full-screen page */
  .modal.post-modal { background: var(--bg); display: block; overflow-y: auto; -webkit-overflow-scrolling: touch; }
  .post-modal .modal-close, .post-modal .modal-nav { display: none; }
  .post {
    display: flex; flex-direction: column;
    max-width: none; width: 100%; height: auto !important; min-height: 100%;
    border-radius: 0;
    animation: slide-in .22s ease;
    padding-bottom: env(safe-area-inset-bottom);
  }
  @keyframes slide-in { from { transform: translateX(30px); opacity: 0; } }
  .post-mobile-bar {
    display: flex; align-items: center;
    position: sticky; top: 0; z-index: 3;
    height: 44px; padding: 0 8px; padding-top: env(safe-area-inset-top);
    background: var(--bg);
    border-bottom: 1px solid var(--separator);
  }
  .post-mobile-bar h1 { flex: 1; text-align: center; margin: 0 44px 0 0; font-size: 16px; font-weight: 600; }
  .post-header { order: 1; border-bottom: 0; height: 56px; padding: 12px 4px 12px 12px; }
  .post-media { order: 2; height: auto !important; width: 100% !important; max-width: none; aspect-ratio: var(--ar-m, 0.8); }
  .post-actions { order: 3; border-top: 0; padding: 4px 12px 0; }
  .post-caption { order: 4; overflow: visible; padding: 0 12px 6px; }
  .post-caption .avatar { display: none; }
  .post-caption .comment-meta { display: none; }
  .post-date { order: 5; padding: 2px 12px 20px; text-transform: none; font-size: 12px; letter-spacing: 0; }
  .post-more { order: 6; }

  .dialog { width: 100vw; max-height: none; height: 100%; border-radius: 0; }
  .modal.dialog-modal { align-items: stretch; }
  .dialog-head { padding-top: env(safe-area-inset-top); flex-basis: auto; min-height: 44px; }
  .compose { display: flex; flex-direction: column; }
  .compose-preview { max-height: none; width: 100%; }
  .compose-side { border-left: 0; }
  .form { padding: 16px; }
  .form .row2 { grid-template-columns: 1fr; }
  .hl-item { grid-template-columns: 40px 1fr 32px; }
  .hl-item .hl-url { grid-column: 2 / 3; }
  .hl-item .hl-img { width: 40px; height: 40px; }
  .login { border: 0; padding: 20px; }
}

@media (min-width: 736px) {
  .mobile-only { display: none !important; }
  .profile-top { display: contents; }
  .profile-top .stats { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ---------- highlights: new / reorder ---------- */

button.highlight { background: none; border: 0; font: inherit; color: inherit; cursor: pointer; }
.highlight-new .highlight-ring {
  display: flex; align-items: center; justify-content: center;
  color: var(--text-secondary);
}
.highlight-new .highlight-ring span {
  width: 100%; height: 100%; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--highlight-bg);
}
.highlights.reordering .highlight[data-story] { cursor: grab; }
.highlights.reordering .highlight[data-story] .highlight-ring { border: 2px dashed var(--btn-primary); }
.highlight.sortable-ghost { opacity: .35; }

/* ---------- story viewer ---------- */

.modal.story-modal { background: #1a1a1a; }
.story-shell { display: flex; align-items: center; gap: 28px; }
.story {
  position: relative;
  height: min(calc(100vh - 40px), 920px);
  height: min(calc(100dvh - 40px), 920px);
  aspect-ratio: 9 / 16;
  border-radius: 8px;
  overflow: hidden;
  background: #000;
  color: #fff;
  user-select: none; -webkit-user-select: none;
  touch-action: pan-x pinch-zoom;
  transition: transform .15s ease;
  animation: pop-in .2s ease;
}
.story-media { position: absolute; inset: 0; overflow: hidden; }
.story-bg {
  position: absolute; inset: -10%; width: 120%; height: 120%;
  object-fit: cover; filter: blur(28px) brightness(.65); transform: scale(1.1);
}
.story-fg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.story-fg.cover { object-fit: cover; }
.story-shade {
  position: absolute; left: 0; right: 0; top: 0; height: 130px;
  background: linear-gradient(rgba(0,0,0,.5), rgba(0,0,0,0));
  pointer-events: none;
}
.story-top { position: absolute; left: 0; right: 0; top: 0; z-index: 3; padding: 8px 8px 0; transition: opacity .2s; }
.story-bars { display: flex; gap: 4px; }
.story-bar { flex: 1; height: 2px; border-radius: 1px; background: rgba(255,255,255,.35); overflow: hidden; }
.story-fill { height: 100%; background: #fff; transform-origin: left center; transform: scaleX(0); }
.story-head { display: flex; align-items: center; gap: 8px; margin-top: 10px; padding-left: 4px; }
.story-head .avatar { border: 0; }
.story-head-text { flex: 1; min-width: 0; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-shadow: 0 0 4px rgba(0,0,0,.3); }
.story-head-text strong { font-weight: 600; }
.story-title { color: rgba(255,255,255,.8); }
.story-btn { color: #fff; padding: 6px; display: inline-flex; filter: drop-shadow(0 0 2px rgba(0,0,0,.3)); }
.story-btn:hover { opacity: .7; }
.story-text {
  position: absolute; left: 7%; right: 7%; bottom: 13%; z-index: 2;
  text-align: center; pointer-events: none;
  transition: opacity .2s;
}
.story-text span {
  display: inline;
  font-size: 19px; line-height: 1.55; font-weight: 600;
  color: #fff;
  background: rgba(0, 0, 0, .62);
  padding: 3px 10px;
  border-radius: 8px;
  -webkit-box-decoration-break: clone; box-decoration-break: clone;
}
.story-tap { display: none; }
.story.is-holding .story-top, .story.is-holding .story-text { opacity: 0; }
.story.is-loading::after {
  content: ""; position: absolute; left: 50%; top: 50%; width: 32px; height: 32px; margin: -16px;
  border-radius: 50%; border: 3px solid rgba(255,255,255,.3); border-top-color: #fff;
  animation: spin .7s linear infinite; z-index: 2;
}
.story-close { position: fixed; top: 16px; right: 16px; color: #fff; padding: 8px; z-index: 2; }
.story-nav {
  width: 32px; height: 32px; border-radius: 50%;
  background: rgba(255,255,255,.9); color: #000;
  display: flex; align-items: center; justify-content: center; flex: none;
}
.story-nav:hover { background: #fff; }

/* ---------- highlight editor ---------- */

.hl-dialog { width: min(860px, calc(100vw - 40px)); }
.hl-editor { display: grid; grid-template-columns: 320px minmax(0, 1fr); min-height: min(570px, 75vh); }
.hl-preview { position: relative; aspect-ratio: 9 / 16; background: #000; overflow: hidden; align-self: start; }
.hl-preview .story-text { bottom: 12%; }
.hl-preview .story-text span { font-size: 14px; }
.hl-preview-empty {
  position: absolute; inset: 0; z-index: 3;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  padding: 24px; text-align: center;
  background: var(--highlight-bg); color: var(--text);
}
.hl-preview-empty p { margin: 0; color: var(--text-secondary); }
.hl-side { display: flex; flex-direction: column; gap: 16px; padding: 16px; border-left: 1px solid var(--separator); min-width: 0; }
.hl-cover-row { display: flex; align-items: center; gap: 14px; }
.hl-cover-row .highlight-ring { width: 72px; height: 72px; flex: none; }
.hl-cover-actions { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 8px; }
.hl-cover-actions .btn-text { font-size: 13px; }
.hl-items { display: grid; grid-template-columns: repeat(auto-fill, minmax(62px, 1fr)); gap: 8px; }
.hl-item-thumb {
  position: relative; aspect-ratio: 9 / 16; border-radius: 6px; overflow: hidden;
  background: var(--highlight-bg); cursor: grab;
}
.hl-item-thumb img { width: 100%; height: 100%; object-fit: cover; }
.hl-item-thumb.selected { outline: 2px solid var(--btn-primary); outline-offset: 1px; }
.hl-item-thumb.sortable-ghost { opacity: .35; }
.hl-video-badge, .hl-text-badge {
  position: absolute; bottom: 4px;
  font-size: 10px; font-weight: 700; line-height: 14px; color: #fff;
  background: rgba(0,0,0,.6); padding: 1px 5px; border-radius: 4px;
}
.hl-video-badge { left: 4px; }
.hl-text-badge { right: 4px; }
.hl-item-add {
  aspect-ratio: 9 / 16; border-radius: 6px;
  border: 1px dashed var(--separator-strong);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  font-size: 10px; color: var(--text-secondary);
}
.hl-textfield { display: grid; gap: 6px; font-weight: 600; }
.btn-danger-outline { margin-top: auto; background: transparent; border: 1px solid var(--separator); color: var(--error); }
.btn-danger-outline:hover { background: var(--highlight-bg); }

@media (max-width: 735px) {
  .modal.story-modal { background: #000; }
  .story-shell { width: 100%; height: 100%; justify-content: center; }
  .story-nav { display: none; }
  /* keep true 9:16 so designed slides are never cropped; letterbox on very tall phones */
  .story {
    width: min(100vw, calc(100dvh * 9 / 16)); height: auto; max-height: 100dvh;
    aspect-ratio: 9 / 16;
    border-radius: 0; animation: none;
  }
  @media (max-aspect-ratio: 9/16) { .story { border-radius: 10px; } }
  .story-top { padding-top: calc(8px + env(safe-area-inset-top)); }
  .story-text { bottom: calc(10% + env(safe-area-inset-bottom)); }
  .hl-editor { grid-template-columns: 1fr; }
  .hl-preview { height: 52vh; justify-self: center; margin-top: 12px; border-radius: 8px; }
  .hl-side { border-left: 0; }
}
