:root {
  color-scheme: dark;
  --bg: #0b0c10;
  --surface: #111217;
  --surface-raised: #17181e;
  --text: #f4f2ee;
  --muted: #a4a29d;
  --quiet: #777671;
  --line: rgba(244, 242, 238, .13);
  --line-strong: rgba(244, 242, 238, .25);
  --button: #f4f2ee;
  --button-text: #111217;
  --danger: #f08f82;
  --focus: #f4f2ee;
  --grain-opacity: .10;
  --grain-blend: screen;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background: var(--bg);
  color: var(--text);
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f1f0eb;
  --surface: #fafaf8;
  --surface-raised: #fff;
  --text: #181816;
  --muted: #66655f;
  --quiet: #888780;
  --line: rgba(24, 24, 22, .12);
  --line-strong: rgba(24, 24, 22, .24);
  --button: #181816;
  --button-text: #fafaf8;
  --danger: #ad4338;
  --focus: #181816;
  --grain-opacity: .18;
  --grain-blend: multiply;
}

* { box-sizing: border-box; }

html {
  min-width: 320px;
  min-height: 100%;
  background: var(--bg);
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  min-width: 320px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  overflow-x: hidden;
}

button, input, textarea { font: inherit; }
button { color: inherit; }
button, a, summary { -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible, summary:focus-visible, input:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
}
button:disabled { cursor: wait; opacity: .52; }

.app-frame {
  position: relative;
  z-index: 1;
  width: min(100%, 520px);
  min-height: 100vh;
  min-height: 100dvh;
  margin-inline: auto;
  padding-bottom: max(20px, env(safe-area-inset-bottom));
  background: var(--bg);
}

.screen { position: relative; isolation: isolate; min-height: 100vh; min-height: 100dvh; }
.screen::before {
  position: absolute;
  z-index: 0;
  inset: 0;
  pointer-events: none;
  content: "";
  opacity: var(--grain-opacity);
  mix-blend-mode: var(--grain-blend);
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.82' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.62'/%3E%3C/svg%3E");
}
.screen > * { position: relative; z-index: 1; }
.screen-content { padding: 0 22px 40px; }

.topbar {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: calc(60px + env(safe-area-inset-top));
  padding: calc(8px + env(safe-area-inset-top)) 18px 8px;
  border-bottom: 1px solid var(--line);
  background: transparent;
}

.topbar-start, .topbar-actions { display: flex; align-items: center; gap: 7px; min-width: 44px; }
.topbar-actions { justify-content: flex-end; }
.topbar-brand { font-size: 22px; line-height: 1; font-weight: 750; letter-spacing: -.09em; }
.topbar-spacer { flex: 1; }
.quiet-wordmark { font-size: 20px; font-weight: 750; letter-spacing: -.09em; }

.icon-button, .text-button, .pill-button, .primary-button, .secondary-button, .provider-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-width: 44px;
  min-height: 44px;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  text-decoration: none;
}

.icon-button { padding: 0 11px; background: transparent; color: var(--text); }
.icon-button svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.icon-button:hover, .text-button:hover, .pill-button:hover { background: var(--surface-raised); }
.text-button { padding: 0 12px; background: transparent; color: var(--muted); font-size: 14px; }
.pill-button { border: 1px solid var(--line); padding: 0 14px; background: transparent; color: var(--text); font-size: 14px; }
.primary-button { width: 100%; padding: 0 18px; background: var(--button); color: var(--button-text); font-weight: 650; }
.secondary-button { width: 100%; padding: 0 18px; border: 1px solid var(--line-strong); background: transparent; color: var(--text); font-weight: 600; }
.primary-button:hover { opacity: .86; }
.secondary-button:hover { background: var(--surface-raised); }
.danger-text { color: var(--danger); }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

.signin-screen {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  padding: max(12px, env(safe-area-inset-top)) 22px max(28px, env(safe-area-inset-bottom));
  background: var(--surface);
}
.signin-top { display: flex; justify-content: flex-end; min-height: 50px; }
.signin-brand { margin: auto 0; padding: 5vh 0 8vh; text-align: center; }
.signin-logo { margin: 0; font-size: clamp(62px, 18vw, 76px); line-height: .9; font-weight: 780; letter-spacing: -.105em; }
.signin-actions { display: grid; gap: 11px; margin: 0 auto; width: min(100%, 340px); }
.provider-button { width: 100%; padding: 0 18px; border: 1px solid var(--line-strong); background: transparent; font-size: 15px; font-weight: 590; }
.provider-button:hover { background: rgba(127,127,127,.08); }
.provider-icon { display: inline-flex; align-items: center; justify-content: center; width: 20px; font-size: 17px; font-weight: 700; }
.provider-icon svg { display: block; width: 20px; height: 20px; }
.signin-error { min-height: 22px; margin: 16px auto 0; max-width: 360px; color: var(--danger); font-size: 14px; text-align: center; }

.page-heading { display: flex; align-items: end; justify-content: space-between; gap: 14px; padding: 31px 0 22px; }
.page-title { margin: 0; font-size: 34px; line-height: 1.05; letter-spacing: -.055em; font-weight: 735; }
.page-subtitle { margin: 8px 0 0; color: var(--muted); font-size: 14px; }
.spaces-list { display: grid; gap: 0; }
.space-row {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr) 24px;
  align-items: center;
  gap: 15px;
  width: 100%;
  padding: 13px 0;
  border: 0;
  border-top: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}
.space-cover { width: 76px; height: 76px; border-radius: 8px; object-fit: cover; background: var(--surface-raised); }
.space-cover-placeholder { display: flex; align-items: center; justify-content: center; color: var(--quiet); font-size: 24px; }
.space-row-copy { min-width: 0; }
.space-row-title { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 18px; letter-spacing: -.035em; font-weight: 650; }
.space-row-description { display: -webkit-box; margin-top: 6px; overflow: hidden; color: var(--muted); font-size: 14px; line-height: 1.35; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.space-row-draft { display: block; margin-top: 5px; color: var(--muted); font-size: 11px; }
.row-chevron { color: var(--quiet); font-size: 25px; font-weight: 300; }
.empty-state { padding: 14vh 12px 9vh; text-align: center; }
.empty-plus { display: grid; place-items: center; width: 86px; height: 86px; margin: 0 auto 23px; border: 1px solid var(--line-strong); border-radius: 50%; background: transparent; color: var(--text); font-size: 46px; font-weight: 250; cursor: pointer; }
.empty-title { margin: 0; font-size: 23px; letter-spacing: -.04em; font-weight: 680; }
.empty-description { max-width: 270px; margin: 10px auto 0; color: var(--muted); font-size: 15px; line-height: 1.45; }
.load-state { min-height: 42px; padding: 18px 0; color: var(--muted); text-align: center; font-size: 14px; }
.retry-button { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; margin-top: 8px; padding: 0 15px; border: 1px solid var(--line-strong); border-radius: 999px; background: transparent; color: var(--text); cursor: pointer; }

.space-intro { padding: 30px 22px 26px; }
.space-title { max-width: 100%; margin: 0; overflow-wrap: anywhere; font-size: clamp(36px, 10vw, 48px); line-height: .98; letter-spacing: -.07em; font-weight: 770; }
.space-description { max-width: 440px; margin: 13px 0 0; color: var(--muted); font-size: 15px; line-height: 1.48; white-space: pre-wrap; overflow-wrap: anywhere; }
.posts-toolbar { display: flex; align-items: center; justify-content: space-between; padding: 0 20px 12px; border-bottom: 1px solid var(--line); }
.posts-toolbar-label { color: var(--quiet); font-size: 12px; text-transform: uppercase; letter-spacing: .14em; }
.post-list { display: grid; gap: 0; }
.post { padding: 0 0 20px; border-bottom: 1px solid var(--line); }
.post-media-button { position: relative; display: block; width: 100%; min-height: 120px; padding: 0; border: 0; background: var(--surface-raised); cursor: pointer; overflow: hidden; }
.post-video-wrap { position: relative; width: 100%; background: var(--surface-raised); }
.post-video-wrap .post-media-button { aspect-ratio: 4 / 3; max-height: 620px; }
.post-media { display: block; width: 100%; max-height: 620px; aspect-ratio: 4 / 3; object-fit: cover; background: var(--surface-raised); }
.post-video-wrap .post-media-button .post-media { position: absolute; inset: 0; width: 100%; height: 100%; max-height: none; aspect-ratio: auto; object-fit: cover; }
.post-video-wrap .video-media { z-index: 2; opacity: 0; pointer-events: none; transition: opacity .12s ease; }
.post-video-wrap .inline-video-preview { z-index: 1; opacity: 1; pointer-events: none; transition: opacity .12s ease; }
.post-video-wrap[data-rendering="true"] .video-media { opacity: 1; }
.post-video-wrap[data-rendering="true"] .inline-video-preview { opacity: 0; }
.inline-video-preview-status { position: absolute; z-index: 3; inset: 0; display: grid; place-items: center; padding: 20px; background: var(--surface-raised); color: var(--muted); text-align: center; pointer-events: none; }
.post-video-wrap[data-preview-ready="true"] .inline-video-preview-status,
.post-video-wrap[data-rendering="true"] .inline-video-preview-status,
.post-video-wrap[data-preview-error="true"] .inline-video-preview-status { display: none; }
.inline-video-error { position: absolute; z-index: 3; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; padding: 20px; background: rgba(8, 9, 12, .38); color: #fff; text-align: center; }
.inline-video-error[hidden] { display: none; }
.inline-video-controls { position: absolute; z-index: 4; top: 12px; right: 12px; display: flex; gap: 8px; }
.inline-video-controls .icon-button { border: 1px solid rgba(255,255,255,.18); background: rgba(0,0,0,.62); color: #fff; backdrop-filter: blur(9px); }
.inline-video-controls .icon-button:hover { background: rgba(0,0,0,.78); }
.inline-video-controls .icon-button svg { width: 20px; height: 20px; }
.media-count { position: absolute; z-index: 4; right: 12px; bottom: 12px; display: grid; place-items: center; min-width: 44px; min-height: 44px; padding: 0 9px; border: 0; border-radius: 999px; background: rgba(0,0,0,.62); color: #fff; font-size: 13px; font-variant-numeric: tabular-nums; backdrop-filter: blur(9px); cursor: pointer; }
.media-load-error { display: grid; place-items: center; min-height: 180px; padding: 24px; color: var(--muted); text-align: center; }
.post-copy { padding: 14px 22px 0; }
.post-meta { display: flex; flex-wrap: wrap; align-items: baseline; gap: 5px 9px; color: var(--muted); font-size: 13px; }
.post-author { color: var(--text); font-weight: 650; font-size: 14px; }
.post-location { color: var(--muted); }
.post-time { color: var(--quiet); }
.post-menu { margin-left: auto; align-self: center; }
.post-menu .menu-popover .danger { color: var(--danger); }
.post-text { margin: 11px 0 0; color: var(--text); font-size: 16px; line-height: 1.47; white-space: pre-wrap; overflow-wrap: anywhere; }
.post-actions { display: flex; align-items: center; gap: 9px; margin-top: 12px; }
.post-action { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 44px; padding: 0 10px; border: 0; border-radius: 999px; background: transparent; color: var(--muted); font-size: 14px; cursor: pointer; }
.post-action svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.post-action:hover { background: var(--surface-raised); color: var(--text); }
.post-action[aria-pressed="true"] { color: var(--text); }
.post-action[aria-pressed="true"] svg { fill: currentColor; }
.post-fallback { min-height: 130px; padding: 22px; color: var(--muted); background: var(--surface-raised); }

.details-menu { position: relative; }
.details-menu summary { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; color: var(--text); list-style: none; cursor: pointer; font-size: 22px; }
.details-menu summary::-webkit-details-marker { display: none; }
.menu-popover { position: absolute; z-index: 5; top: 46px; right: 0; min-width: 155px; padding: 5px; border: 1px solid var(--line); border-radius: 13px; background: var(--surface-raised); box-shadow: 0 12px 28px rgba(0,0,0,.22); }
.menu-popover button { width: 100%; min-height: 42px; padding: 0 11px; border: 0; border-radius: 8px; background: transparent; color: var(--text); text-align: left; cursor: pointer; }
.menu-popover button:hover { background: var(--line); }

.screen-message { padding: 15px 14px; border-radius: 10px; background: var(--surface-raised); color: var(--muted); font-size: 14px; line-height: 1.4; }
.screen-message.error { color: var(--danger); }
.screen-message[hidden] { display: none; }

.overlay-backdrop { position: fixed; z-index: 10; inset: 0; display: block; width: 100%; border: 0; background: rgba(0,0,0,.58); cursor: default; }
.sheet, .gallery-viewer {
  position: fixed;
  z-index: 11;
  inset: auto 0 0;
  display: flex;
  flex-direction: column;
  width: min(100%, 520px);
  max-height: min(92dvh, 860px);
  margin: auto auto 0;
  padding: 0 22px max(20px, env(safe-area-inset-bottom));
  border-radius: 22px 22px 0 0;
  background: var(--surface);
  box-shadow: 0 -12px 48px rgba(0,0,0,.22);
  overflow: hidden;
}
.sheet-header { display: flex; align-items: center; justify-content: space-between; min-height: 62px; border-bottom: 1px solid var(--line); }
.sheet-title { margin: 0; font-size: 18px; letter-spacing: -.025em; font-weight: 690; }
.sheet-scroll { min-height: 0; padding: 18px 0 5px; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.form-stack { display: grid; gap: 17px; }
.field-label { display: grid; gap: 8px; color: var(--text); font-size: 14px; font-weight: 620; }
.text-field { display: block; width: 100%; min-height: 48px; padding: 12px 14px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--bg); color: var(--text); font-size: 16px; font-weight: 400; line-height: 1.35; }
textarea.text-field { min-height: 116px; resize: vertical; }
.field-hint { display: flex; justify-content: space-between; gap: 10px; color: var(--quiet); font-size: 12px; font-weight: 400; }
.form-error { min-height: 18px; color: var(--danger); font-size: 14px; line-height: 1.35; }
.form-actions { display: grid; grid-template-columns: 1fr 1.3fr; gap: 10px; padding-top: 2px; }
.share-actions { grid-template-columns: 1fr auto; align-items: center; }
.share-actions .primary-button { grid-column: 1 / -1; }
.file-picker { display: block; width: 100%; min-height: 52px; padding: 14px; border: 1px dashed var(--line-strong); border-radius: 10px; background: transparent; color: var(--text); font-size: 14px; }
.file-picker::file-selector-button { min-height: 38px; margin: -7px 12px -7px -7px; padding: 0 12px; border: 0; border-radius: 999px; background: var(--button); color: var(--button-text); font: inherit; font-weight: 600; }
.selected-list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 9px; }
.selected-item { position: relative; min-width: 0; overflow: hidden; border-radius: 9px; background: var(--surface-raised); }
.selected-preview-button { position: relative; display: block; width: 100%; padding: 0; border: 0; background: transparent; cursor: pointer; }
.selected-preview-button:disabled { cursor: default; }
.selected-preview { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; }
.selected-placeholder { display: grid; place-items: center; width: 100%; aspect-ratio: 1; background: var(--surface-raised); color: var(--muted); font-size: 28px; }
.selected-status { position: absolute; inset: auto 0 0; padding: 16px 4px 6px; background: linear-gradient(transparent, rgba(0,0,0,.7)); color: #fff; font-size: 11px; }
.selected-kind { position: absolute; top: 6px; left: 6px; padding: 4px 7px; border-radius: 999px; background: rgba(0,0,0,.65); color: #fff; font-size: 10px; }
.selected-remove { position: absolute; top: 3px; right: 3px; display: grid; place-items: center; width: 44px; height: 44px; border: 0; border-radius: 50%; background: rgba(0,0,0,.72); color: white; font-size: 19px; cursor: pointer; }
.selected-label { display: block; overflow: hidden; padding: 6px 7px 2px; color: var(--text); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.selected-retry { min-height: 30px; margin: 2px 5px 5px; padding: 0 9px; border: 1px solid var(--line-strong); border-radius: 999px; background: transparent; color: var(--text); font-size: 11px; cursor: pointer; }
.selected-error { display: block; padding: 3px 7px 8px; color: var(--danger); font-size: 11px; line-height: 1.25; overflow-wrap: anywhere; }
.processing-note { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 24px; color: var(--muted); font-size: 13px; }
.draft-protection { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; color: var(--quiet); font-size: 11px; }
.draft-protection .text-button { min-height: 32px; padding-left: 0; font-size: 12px; }
.share-actions [data-action="cancel-share"] { min-height: 44px; }
[hidden] { display: none !important; }
.reply-list { display: grid; gap: 0; margin: -2px 0 18px; }
.reply { padding: 13px 0; border-bottom: 1px solid var(--line); }
.reply-head { display: flex; align-items: baseline; gap: 8px; }
.reply-author { font-size: 14px; font-weight: 650; }
.reply-time, .private-marker { color: var(--quiet); font-size: 12px; }
.private-marker { padding: 2px 7px; border: 1px solid var(--line); border-radius: 999px; }
.reply-text { margin: 7px 0 0; font-size: 15px; line-height: 1.45; white-space: pre-wrap; overflow-wrap: anywhere; }
.reply-composer { display: grid; gap: 10px; padding-top: 12px; }
.reply-composer textarea { min-height: 82px; }

.gallery-viewer { inset: 0; width: 100%; height: 100vh; height: 100dvh; max-height: none; padding: max(10px, env(safe-area-inset-top)) 0 max(10px, env(safe-area-inset-bottom)); border-radius: 0; background: #050506; box-shadow: none; color: #fff; }
.gallery-top { display: flex; align-items: center; justify-content: space-between; min-height: 54px; padding: 0 14px; }
.gallery-count { font-size: 14px; font-variant-numeric: tabular-nums; }
.gallery-stage { position: relative; display: flex; flex: 1; min-height: 0; align-items: center; justify-content: center; overflow: hidden; touch-action: pan-y; }
.gallery-media { display: block; max-width: 100%; max-height: 100%; object-fit: contain; }
.gallery-media.image { width: 100%; height: 100%; }
.gallery-media.video { width: 100%; height: auto; max-height: 100%; }
.gallery-nav { position: absolute; top: 50%; display: grid; place-items: center; width: 48px; height: 48px; border: 1px solid rgba(255,255,255,.3); border-radius: 50%; background: rgba(0,0,0,.55); color: white; font-size: 25px; cursor: pointer; transform: translateY(-50%); }
.gallery-nav.previous { left: 12px; }
.gallery-nav.next { right: 12px; }
.gallery-caption { min-height: 38px; padding: 7px 18px; color: rgba(255,255,255,.8); text-align: center; font-size: 13px; }
.gallery-error { color: #fff; }

.edit-screen { min-height: 100vh; min-height: 100dvh; }
.edit-content { padding: 23px 22px 50px; }
.edit-heading { display: flex; align-items: center; gap: 10px; margin-bottom: 27px; }
.edit-title { margin: 0; font-size: 25px; letter-spacing: -.045em; font-weight: 710; }
.edit-form { display: grid; gap: 18px; }

@media (min-width: 600px) {
  .screen-content { padding-inline: 30px; }
  .space-intro { padding-inline: 30px; }
  .post-copy { padding-inline: 30px; }
  .topbar { padding-inline: 26px; }
  .sheet { margin-inline: auto; border-radius: 22px 22px 0 0; }
}

@media (max-width: 350px) {
  .screen-content, .space-intro, .post-copy { padding-inline: 16px; }
  .topbar { padding-inline: 12px; }
  .space-row { grid-template-columns: 64px minmax(0, 1fr) 18px; gap: 11px; }
  .space-cover { width: 64px; height: 64px; }
  .page-title { font-size: 30px; }
}

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