:root {
  color-scheme: dark;
  --bg: #071117;
  --bg-2: #0d1b24;
  --bg-3: #101f2d;
  --panel: rgba(15, 24, 31, .9);
  --panel-2: rgba(20, 31, 39, .92);
  --panel-3: rgba(30, 44, 54, .96);
  --panel-soft: rgba(17, 27, 35, .76);
  --line: rgba(138, 167, 182, .18);
  --line-soft: rgba(122, 144, 163, .16);
  --line-strong: rgba(158, 179, 190, .24);
  --text: #edf4f8;
  --muted: #a2b8c3;
  --muted-2: #7f96a4;
  --accent: #8fe7ab;
  --accent-2: #7cd8ff;
  --accent-cool: #8bc8ff;
  --accent-warm: #f8d5a4;
  --accent-glow: rgba(143, 231, 171, .26);
  --danger: #ff9f9f;
  --up: #67e2a5;
  --down: #ff9f9f;
  --radius-sm: 10px;
  --radius: 18px;
  --radius-lg: 24px;
  --shadow-sm: 0 1px 0 rgba(255,255,255,.02), 0 16px 38px rgba(2, 7, 12, .28);
  --shadow: 0 18px 40px -20px rgba(4, 10, 14, .8), 0 4px 12px rgba(0,0,0,.18);
  --shadow-lg: 0 30px 55px -20px rgba(4, 10, 14, .82);
  --ease: cubic-bezier(.2, .7, .3, 1);
}

* { box-sizing: border-box; }
*:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

html { scrollbar-color: #34406b var(--bg); scrollbar-width: thin; }
body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(680px 420px at 100% 0%, rgba(124, 216, 255, .11), transparent 60%),
    radial-gradient(780px 520px at -12% 20%, rgba(143, 231, 171, .09), transparent 58%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-2) 100%);
  color: var(--text);
  font: 15px/1.6 -apple-system, BlinkMacSystemFont, "Avenir Next", "Helvetica Neue", sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection { background: rgba(94, 234, 212, .28); color: var(--text); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #2a3559; border-radius: 999px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: #38477a; background-clip: content-box; }

a { color: inherit; }
button { font: inherit; }
h1, h2, h3, h4 { font-family: "Avenir Next", -apple-system, BlinkMacSystemFont, "Helvetica Neue", sans-serif; letter-spacing: -.01em; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.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; }

/* Topbar */
.topbar { background: rgba(7, 17, 23, .82); backdrop-filter: saturate(140%) blur(18px); -webkit-backdrop-filter: saturate(140%) blur(18px); border-bottom: 1px solid var(--line-soft); box-shadow: 0 10px 30px rgba(0, 0, 0, .12); }
.topbar-inner { max-width: 1240px; margin: 0 auto; padding: 15px 28px; display: flex; align-items: center; gap: 22px; }
.brand {
  font-size: 1.28rem; font-weight: 800; text-decoration: none; letter-spacing: -.03em;
  display: flex; align-items: center; gap: 7px; padding: 4px 2px; border-radius: var(--radius-sm);
  transition: opacity .15s var(--ease);
}
.brand:hover { opacity: .85; }
.brand-mark {
  display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 26px;
  border-radius: 8px; font-size: 1rem;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #11211d; box-shadow: 0 0 22px rgba(143, 231, 171, .18);
}
.search-form { flex: 1; display: flex; gap: 8px; max-width: 500px; position: relative; }
.search-form input {
  flex: 1; padding: 11px 16px; border-radius: 999px; border: 1px solid var(--line); background: rgba(21, 33, 41, .78);
  color: var(--text); transition: border-color .15s var(--ease), background .15s var(--ease), box-shadow .15s var(--ease), transform .15s var(--ease);
}
.search-form input::placeholder { color: var(--muted-2); }
.search-form input:focus { outline: none; border-color: rgba(143, 231, 171, .7); background: rgba(28, 40, 49, .9); box-shadow: 0 0 0 4px rgba(143, 231, 171, .12); }
.search-form button { display: none; }
.auth-nav { display: flex; gap: 8px; align-items: center; }

.btn {
  padding: 9px 16px; border-radius: 12px; border: 1px solid var(--line); background: rgba(19, 31, 39, .8);
  color: var(--text); cursor: pointer; transition: transform .12s var(--ease), border-color .15s var(--ease), background .15s var(--ease), box-shadow .15s var(--ease);
  font-weight: 600;
}
.btn:hover { border-color: rgba(143, 231, 171, .6); background: rgba(27, 41, 50, .94); }
.btn:active { transform: translateY(1px) scale(.99); }
.btn.primary {
  background: linear-gradient(135deg, var(--accent), #baf7cb); color: #102213; border: none; font-weight: 800;
  box-shadow: 0 12px 24px -12px rgba(143, 231, 171, .7);
}
.btn.primary:hover { background: linear-gradient(135deg, #baf7cb, var(--accent)); border: none; box-shadow: 0 18px 28px -16px rgba(143, 231, 171, .8); }
.btn.ghost { background: transparent; border-color: var(--line); }
.btn.ghost:hover { background: rgba(23, 35, 42, .92); }
.btn.full { width: 100%; }
.btn.small { padding: 5px 11px; font-size: .8rem; border-radius: 7px; }
.link-btn { background: none; border: none; color: var(--accent); cursor: pointer; padding: 0; text-decoration: underline; text-underline-offset: 2px; }
.link-btn:hover { color: var(--accent-2); }
.icon-btn { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 1.1rem; border-radius: 6px; padding: 4px; transition: all .15s var(--ease); }
.icon-btn:hover { color: var(--text); background: var(--panel-2); }

/* Layout */
.layout { max-width: 1240px; margin: 0 auto; padding: 44px 28px 100px; display: grid; grid-template-columns: 260px minmax(0, 760px); gap: 42px; align-items: start; animation: fade-in .35s var(--ease); }
.sidebar { position: sticky; top: 86px; display: flex; flex-direction: column; gap: 18px; }
.panel {
  background: linear-gradient(180deg, rgba(17, 27, 35, .84), rgba(13, 22, 28, .9)); border: 1px solid var(--line-soft);
  border-radius: 18px; padding: 14px; box-shadow: var(--shadow-sm);
}
.panel h3 { margin: 0 0 11px; font-size: .74rem; text-transform: uppercase; letter-spacing: .12em; color: var(--muted-2); font-weight: 700; }

.sort-tabs { display: flex; flex-direction: column; gap: 4px; }
.sort-tab { text-align: left; padding: 9px 11px; border-radius: 12px; border: 1px solid transparent; background: transparent; color: var(--muted); cursor: pointer; transition: all .15s var(--ease); font-weight: 600; }
.sort-tab:hover { background: rgba(19, 31, 39, .78); color: var(--text); }
.sort-tab.is-active { background: linear-gradient(135deg, rgba(143, 231, 171, .12), rgba(124, 216, 255, .08)); color: var(--text); border-color: rgba(143, 231, 171, .35); font-weight: 700; box-shadow: inset 0 0 0 1px rgba(143, 231, 171, .1); }

.tag-cloud { display: flex; flex-wrap: wrap; gap: 6px; }
.tag-chip {
  display: inline-flex; align-items: center; gap: 4px; padding: 5px 12px; border-radius: 999px;
  background: rgba(19, 31, 39, .75); border: 1px solid var(--line); color: var(--muted); font-size: .8rem; cursor: pointer;
  transition: all .15s var(--ease);
}
.tag-chip:hover { color: var(--text); border-color: rgba(124, 216, 255, .5); background: rgba(28, 42, 52, .94); }
.tag-chip.is-active { color: #102213; background: linear-gradient(135deg, var(--accent), #baf7cb); border-color: transparent; font-weight: 700; }
.tag-chip.is-active .count { color: rgba(16, 34, 19, .82); opacity: .8; }
.tag-chip .count { color: var(--muted-2); font-size: .72rem; }

#active-filter { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* Feed */
.feed-heading { padding-bottom: 18px; border-bottom: 1px solid var(--line-soft); }
.feed-list { display: flex; flex-direction: column; gap: 12px; }
.post-card {
  display: flex; gap: 16px; background: linear-gradient(180deg, rgba(19, 29, 36, .95), rgba(13, 22, 28, .9)); border: 1px solid var(--line-soft); border-radius: 18px;
  padding: 18px 20px; box-shadow: var(--shadow-sm); transition: border-color .18s var(--ease), transform .18s var(--ease), box-shadow .18s var(--ease), background .18s var(--ease);
  animation: rise-in .3s var(--ease) backwards;
}
.post-card:hover { border-color: rgba(143, 231, 171, .45); box-shadow: var(--shadow); transform: translateY(-2px); background: linear-gradient(180deg, rgba(23, 35, 42, .98), rgba(13, 22, 28, .92)); }
.vote-col { display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 40px; height: max-content; padding: 4px 2px; border-right: 1px solid var(--line-soft); }
.vote-btn {
  background: none; border: none; color: var(--muted-2); font-size: 1.05rem; cursor: pointer; line-height: 1;
  padding: 6px; border-radius: 8px; transition: all .15s var(--ease); width: 30px; height: 26px;
  display: flex; align-items: center; justify-content: center;
}
.vote-btn:hover { color: var(--accent); background: rgba(143, 231, 171, .08); }
.vote-btn.is-active-up { color: var(--up); background: rgba(103, 226, 165, .12); }
.vote-btn.is-active-down { color: var(--down); background: rgba(255, 159, 159, .12); }
.vote-score { color: var(--accent); font-weight: 800; font-size: .92rem; font-variant-numeric: tabular-nums; }

.post-body-col { flex: 1; min-width: 0; }
.post-title { margin: 0 0 6px; font-size: 1.1rem; line-height: 1.35; font-weight: 700; letter-spacing: -.02em; }
.post-title a { text-decoration: none; transition: color .15s var(--ease); }
.post-title a:hover { color: var(--accent); }
.post-meta { color: var(--muted); font-size: .82rem; margin-bottom: 6px; display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.post-meta a { color: var(--accent-cool); text-decoration: none; }
.post-meta a:hover { text-decoration: underline; }
.post-excerpt { color: #d4e0da; font-size: .93rem; margin: 8px 0; line-height: 1.6; }
.post-excerpt :is(p, ul, ol) { margin: 4px 0; }
.post-tags { display: flex; gap: 6px; flex-wrap: wrap; margin: 9px 0 2px; }
.post-tags .tag-chip { font-size: .74rem; padding: 3px 10px; }
.post-actions { display: flex; gap: 16px; color: var(--muted); font-size: .82rem; margin-top: 6px; }
.post-actions button { background: none; border: none; color: inherit; cursor: pointer; display: inline-flex; align-items: center; gap: 5px; transition: color .15s var(--ease); padding: 2px 0; }
.post-actions button:hover { color: var(--accent); }
.post-actions .danger:hover { color: var(--danger); }
.attachment-chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border: 1px solid var(--line); border-radius: 8px;
  font-size: .78rem; color: var(--muted); text-decoration: none; margin: 4px 6px 0 0; transition: all .15s var(--ease); background: var(--panel-2);
}
.attachment-chip:hover { border-color: var(--accent); color: var(--accent); background: var(--panel-3); }
.attachment-media { max-width: 100%; border-radius: var(--radius-sm); margin-top: 8px; display: block; border: 1px solid var(--line-soft); }

.attachment-carousel {
  position: relative;
  display: block;
  margin-top: 10px;
}
.attachment-carousel-track {
  position: relative;
  min-height: 220px;
  overflow: hidden;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  background: var(--panel-2);
  cursor: zoom-in;
}
.attachment-carousel-track:focus-visible { outline-offset: 3px; }
.attachment-slide { display: none; width: 100%; min-height: 220px; align-items: center; justify-content: center; padding: 12px; }
.attachment-slide.is-active { display: flex; }
.attachment-slide .attachment-media { width: 100%; max-height: 360px; object-fit: contain; margin-top: 0; }
.attachment-slide .attachment-chip { margin: 0; }
.attachment-carousel-controls {
  position: absolute;
  inset: 50% 12px auto 12px;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  z-index: 2;
  pointer-events: none;
}
.attachment-carousel-btn {
  border: 1px solid rgba(255, 255, 255, .14);
  border-radius: 999px;
  background: rgba(7, 17, 23, .34);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: var(--text);
  width: 32px;
  height: 32px;
  cursor: pointer;
  pointer-events: auto;
  font-size: .8rem;
  transition: all .15s var(--ease);
}
.attachment-carousel-btn:hover { border-color: rgba(143, 231, 171, .5); color: var(--accent); background: rgba(10, 18, 24, .5); }
.attachment-carousel-dots {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 12px 0;
  border-radius: 0 0 8px 8px;
  background: transparent;
  border: none;
  z-index: 2;
}
.attachment-dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  border: none;
  background: rgba(255,255,255,.25);
  cursor: pointer;
  padding: 0;
}
.attachment-dot.is-active { background: var(--accent); }

/* Inline (not maximized) carousel: controls and dots sit on the attachment's edges */
.attachment-carousel:not(.is-maximized) .attachment-carousel-controls { inset: 50% 18px auto 18px; }
.attachment-carousel:not(.is-maximized) .attachment-carousel-dots {
  position: absolute; left: 0; right: 0; bottom: 18px; padding: 0; pointer-events: none;
}
.attachment-carousel:not(.is-maximized) .attachment-dot { pointer-events: auto; box-shadow: 0 0 0 1px rgba(0, 0, 0, .35); background: rgba(255, 255, 255, .55); }
.attachment-carousel:not(.is-maximized) .attachment-dot.is-active { background: var(--accent); }

.feed-more { text-align: center; margin-top: 18px; }
.profile-results-panel { margin-bottom: 18px; }
.search-result-section + .search-result-section { margin-top: 16px; }
.search-section-heading { display: flex; align-items: baseline; gap: 10px; margin-bottom: 8px; }
.search-section-heading h2 { margin: 0; font-size: 1rem; }
.profile-search-results { display: grid; gap: 8px; }
.search-tag-results { display: flex; flex-wrap: wrap; gap: 8px; }
.profile-search-result { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--line-soft); border-radius: var(--radius-sm); background: var(--panel); text-decoration: none; }
.profile-search-result:hover { border-color: var(--accent); background: var(--panel-2); }
.profile-search-result span { display: grid; min-width: 0; }
.profile-search-result small { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes rise-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

/* Post detail view */
.post-detail-back { margin-bottom: 14px; }
.post-detail { background: var(--panel); border: 1px solid var(--line-soft); border-radius: var(--radius-lg); padding: 24px; margin-bottom: 22px; box-shadow: var(--shadow-sm); animation: rise-in .3s var(--ease); }
.post-detail .post-title { font-size: 1.5rem; font-weight: 750; }
.profile-back { margin-bottom: 14px; }
.profile-panel { max-width: 680px; background: var(--panel); border: 1px solid var(--line-soft); border-radius: var(--radius-lg); padding: 24px; box-shadow: var(--shadow-sm); animation: rise-in .3s var(--ease); }
.profile-heading { display: flex; gap: 16px; align-items: center; margin-bottom: 24px; }
.profile-heading h1 { margin: 0; font-size: 1.5rem; }
.profile-heading p { margin: 2px 0 0; }
.profile-heading .eyebrow { color: var(--accent); font-size: .74rem; font-weight: 750; letter-spacing: .08em; text-transform: uppercase; }
.profile-form { display: grid; gap: 16px; }
.profile-form textarea { resize: vertical; min-height: 82px; }
.profile-form label { display: grid; gap: 6px; }
.profile-avatar-preview { min-height: 68px; display: flex; align-items: center; }
.profile-remove-avatar { justify-self: start; }
.profile-form footer { display: flex; justify-content: flex-end; }
.comment-form { margin: 18px 0 22px; }
.comment-thread { display: flex; flex-direction: column; gap: 14px; }
.comment { border-left: 2px solid var(--line-soft); padding-left: 14px; transition: border-color .15s var(--ease); }
.comment:hover { border-left-color: var(--line); }
.comment-header { display: flex; gap: 10px; align-items: center; font-size: .82rem; color: var(--muted); margin-bottom: 5px; }
.comment-author { color: var(--accent-2); font-weight: 700; }
.comment-body { font-size: .93rem; color: #d7deef; line-height: 1.55; }
.comment-body :is(p, ul, ol) { margin: 4px 0; }
.comment-actions { display: flex; gap: 14px; font-size: .8rem; color: var(--muted); margin: 6px 0 2px; }
.comment-actions button { background: none; border: none; color: inherit; cursor: pointer; transition: color .15s var(--ease); }
.comment-actions button:hover { color: var(--accent); }
.comment-replies { margin-top: 12px; margin-left: 6px; display: flex; flex-direction: column; gap: 12px; }
.comment.is-deleted .comment-body { font-style: italic; color: var(--muted); }
.reply-form { margin-top: 10px; }

/* Rich text editor */
.richtext-toolbar { display: flex; gap: 5px; margin-bottom: 7px; }
.richtext-toolbar button {
  padding: 5px 10px; border-radius: 7px; border: 1px solid var(--line); background: var(--panel-2); color: var(--text);
  cursor: pointer; transition: all .15s var(--ease); font-size: .85rem;
}
.richtext-toolbar button:hover { border-color: var(--accent); background: var(--panel-3); }
.richtext-toolbar button.is-active { border-color: var(--accent); background: rgba(214, 243, 107, .16); color: var(--accent); }
.richtext-editor {
  min-height: 100px; max-height: 320px; overflow-y: auto; border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 11px 13px; background: var(--panel-2); line-height: 1.5; transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
.richtext-editor:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(94, 234, 212, .12); }
.richtext-editor:empty::before { content: attr(data-placeholder); color: var(--muted-2); }
.attachment-preview { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 9px; }
.attachment-preview .attachment-item { position: relative; }
.attachment-preview img { max-width: 80px; max-height: 80px; border-radius: 8px; display: block; border: 1px solid var(--line); }
.attachment-preview .remove-att {
  position: absolute; top: -6px; right: -6px; background: var(--danger); color: #200; border: 2px solid var(--panel);
  border-radius: 50%; width: 20px; height: 20px; cursor: pointer; font-size: .68rem; line-height: 1; transition: transform .12s var(--ease);
}
.attachment-preview .remove-att:hover { transform: scale(1.12); }

/* Forms & modals */
label { display: flex; flex-direction: column; gap: 6px; font-size: .87rem; color: var(--muted); margin-bottom: 13px; font-weight: 500; }
.post-body-field { display: flex; flex-direction: column; gap: 6px; font-size: .87rem; color: var(--muted); margin-bottom: 13px; font-weight: 500; }
label input[type="text"], label input[type="url"], label input[type="password"], label input[type="file"] {
  padding: 10px 13px; border-radius: 12px; border: 1px solid var(--line); background: rgba(20, 31, 39, .8); color: var(--text);
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease), background .15s var(--ease); font: inherit;
}
label input:focus { outline: none; border-color: rgba(143, 231, 171, .7); box-shadow: 0 0 0 4px rgba(143, 231, 171, .12); background: rgba(24, 38, 47, .9); }
label input[type="file"] { padding: 8px 10px; cursor: pointer; }
.form-error { color: var(--danger); font-size: .85rem; background: rgba(255, 159, 159, .08); border: 1px solid rgba(255, 159, 159, .25); border-radius: var(--radius-sm); padding: 9px 11px; }

.modal {
  border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--panel-2); color: var(--text); padding: 0;
  max-width: 480px; width: 92vw; max-height: 88vh; overflow-y: auto; box-shadow: var(--shadow-lg);
  animation: modal-in .22s var(--ease);
}
.modal.wide { max-width: 640px; }
.modal::backdrop { background: rgba(4, 7, 16, .65); backdrop-filter: blur(3px); animation: fade-in .18s var(--ease); }
@keyframes modal-in { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: translateY(0) scale(1); } }
.modal-card { padding: 22px; }
.modal-card header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.modal-card header h2 { margin: 0; font-size: 1.22rem; font-weight: 750; }
.modal-card footer { display: flex; justify-content: flex-end; gap: 10px; margin-top: 10px; }

/* SMS / text share preview */
.sms-preview {
  margin: 14px 0 12px; border: 1px solid var(--line); border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(10, 18, 24, .92), rgba(8, 14, 19, .92)); overflow: hidden;
}
.sms-preview-header { display: flex; align-items: center; gap: 8px; padding: 9px 13px; border-bottom: 1px solid var(--line-soft); background: rgba(255,255,255,.03); }
.sms-preview-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.sms-preview-name { font-size: .78rem; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.sms-preview-thread { padding: 16px 14px; display: flex; flex-direction: column; align-items: flex-end; gap: 5px; }
.sms-bubble {
  position: relative; max-width: 86%; padding: 10px 13px; border-radius: 20px;
  background: linear-gradient(180deg, #2f9cff, #1a76ec); color: #fff; box-shadow: var(--shadow-sm);
}
.sms-bubble-tail { position: absolute; right: -5px; bottom: 2px; width: 0; height: 0; border-left: 10px solid #1a76ec; border-bottom: 8px solid transparent; border-top: 6px solid transparent; }
.sms-bubble-text { margin: 0; font-size: .92rem; line-height: 1.4; white-space: pre-wrap; overflow-wrap: anywhere; }
.sms-bubble-text:empty { display: none; }
.sms-link-card {
  display: block; margin-top: 8px; border-radius: 14px; overflow: hidden; text-decoration: none;
  background: rgba(255, 255, 255, .96); color: #10202c; border: 1px solid rgba(0,0,0,.08);
}
.sms-link-media { background: #0d1a22; width: 100%; aspect-ratio: 1 / 1; overflow: hidden; }
.sms-link-media img { display: block; width: 100%; height: 100%; object-fit: cover; }
.sms-link-body { display: flex; flex-direction: column; gap: 2px; padding: 9px 11px; }
.sms-link-title { font-size: .86rem; font-weight: 700; line-height: 1.3; }
.sms-link-desc { font-size: .78rem; line-height: 1.35; color: #4b5f6d; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden; }
.sms-link-card.is-expanded .sms-link-desc { -webkit-line-clamp: 4; line-clamp: 4; }
.sms-link-desc:empty { display: none; }
.sms-link-domain { font-size: .72rem; text-transform: lowercase; color: #7a8d99; margin-top: 2px; }
.sms-status { font-size: .68rem; color: var(--muted); padding-right: 4px; }
.sms-message-field { display: flex; flex-direction: column; gap: 6px; font-size: .88rem; }
.sms-message-field textarea {
  width: 100%; resize: vertical; padding: 10px 12px; font: inherit; font-size: .9rem; color: var(--text);
  background: rgba(20, 32, 40, .8); border: 1px solid var(--line); border-radius: var(--radius-sm);
}
.sms-message-field textarea:focus { outline: none; border-color: rgba(143, 231, 171, .7); box-shadow: 0 0 0 4px rgba(143, 231, 171, .12); }
.share-preview-footer { flex-wrap: wrap; }
@media (max-width: 560px) {
  .sms-bubble { max-width: 94%; }
}

.carousel-modal {
  border: 0; background: transparent; color: var(--text); padding: 0; width: 96vw; max-width: none; height: 94vh; max-height: none; overflow: hidden;
}
.carousel-modal::backdrop { background: rgba(4, 7, 16, .88); backdrop-filter: blur(5px); animation: fade-in .18s var(--ease); }
.carousel-modal-shell { position: relative; width: 100%; height: 100%; display: grid; place-items: center; }
.carousel-modal-close { position: absolute; z-index: 2; top: 10px; right: 10px; width: 40px; height: 40px; background: rgba(10, 14, 26, .82); border: 1px solid var(--line); }
#carousel-modal-content { width: 100%; height: 100%; min-height: 0; display: grid; place-items: center; }
#carousel-modal-content .attachment-carousel {
  width: min(100%, 1100px);
  height: 100%;
  margin: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}
#carousel-modal-content .attachment-carousel-track {
  width: min(92vw, 1100px);
  min-height: 0;
  height: min(72vh, 760px);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: default;
  border: 0;
  background: transparent;
  touch-action: pan-y;
}
#carousel-modal-content .attachment-slide {
  width: 100%;
  height: 100%;
  min-height: 0;
  padding: 24px 56px 12px;
  display: none;
  align-items: center;
  justify-content: center;
}
#carousel-modal-content .attachment-slide.is-active { display: flex; }
#carousel-modal-content .attachment-media {
  width: auto;
  max-width: 100%;
  max-height: 100%;
  height: auto;
  object-fit: contain;
}
#carousel-modal-content .attachment-carousel-controls {
  inset: 50% 18px auto 18px;
  transform: translateY(-50%);
}
#carousel-modal-content .attachment-carousel-dots {
  padding-top: 10px;
  background: transparent;
  border-radius: 0;
}

.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--panel-3);
  border: 1px solid var(--accent); color: var(--text); padding: 11px 20px; border-radius: 999px; font-size: .9rem;
  z-index: 50; box-shadow: var(--shadow-lg); animation: toast-in .25s var(--ease);
}
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* Admin screen */
.admin-tabs { display: flex; gap: 8px; margin: 10px 0 20px; }
.admin-tab { padding: 9px 15px; border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--panel); color: var(--muted); cursor: pointer; transition: all .15s var(--ease); font-weight: 500; }
.admin-tab:hover { color: var(--text); border-color: var(--muted-2); }
.admin-tab.is-active { background: var(--panel-3); color: var(--text); border-color: var(--accent); font-weight: 700; }
.admin-stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 22px; }
.admin-stat-card { background: var(--panel); border: 1px solid var(--line-soft); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow-sm); transition: transform .15s var(--ease); }
.admin-stat-card:hover { transform: translateY(-2px); }
.admin-stat-card .value { font-size: 1.7rem; font-weight: 800; color: var(--accent); font-variant-numeric: tabular-nums; }
.admin-stat-card .label { color: var(--muted); font-size: .82rem; margin-top: 4px; }
.admin-table { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line-soft); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-sm); }
.admin-table th, .admin-table td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--line-soft); font-size: .88rem; }
.admin-table th { color: var(--muted-2); text-transform: uppercase; font-size: .72rem; letter-spacing: .07em; font-weight: 700; background: var(--panel-2); }
.admin-table tr:last-child td { border-bottom: none; }
.admin-table tbody tr { transition: background .15s var(--ease); }
.admin-table tbody tr:hover { background: var(--panel-2); }
.role-badge { padding: 3px 10px; border-radius: 999px; font-size: .74rem; background: var(--panel-3); border: 1px solid var(--line); font-weight: 600; }
.role-badge.admin { color: var(--accent); border-color: var(--accent); background: rgba(94, 234, 212, .1); }
.deleted-badge { color: var(--danger); font-size: .74rem; font-weight: 600; }

/* Avatars */
.avatar { width: 22px; height: 22px; border-radius: 50%; object-fit: cover; vertical-align: middle; flex-shrink: 0; border: 1px solid var(--line); background: var(--panel-3); }
.avatar-placeholder { display: inline-flex; align-items: center; justify-content: center; font-size: .7rem; color: var(--muted); font-weight: 700; background: linear-gradient(135deg, var(--panel-3), var(--panel-2)); }
.avatar-sm { width: 20px; height: 20px; }
.avatar-lg { width: 68px; height: 68px; font-size: 1.5rem; box-shadow: var(--shadow-sm); }
.nav-avatar-btn { display: inline-flex; align-items: center; gap: 0; background: none; border: none; padding: 0; cursor: pointer; border-radius: 50%; transition: transform .15s var(--ease); }
.nav-avatar-btn:hover { transform: scale(1.06); }
.nav-avatar-btn .avatar { width: 27px; height: 27px; }
.author-line { display: inline-flex; align-items: center; gap: 6px; }
.profile-link { display: inline-flex; align-items: center; gap: 6px; color: inherit; text-decoration: none; }
.profile-link:hover { color: var(--accent-2); }
.comment .profile-link { color: var(--accent-2); font-weight: 700; }
.profile-status { color: var(--text); font-size: 1rem; }
.profile-url { margin: 0 0 18px; overflow-wrap: anywhere; }
.profile-url a { color: var(--accent-2); }
.avatar-preview-row { display: flex; align-items: center; gap: 16px; margin-bottom: 16px; }
.avatar-preview-row input[type="file"] { flex: 1; }

@media (max-width: 860px) {
  .topbar-inner { flex-wrap: wrap; gap: 10px 14px; }
  .search-form { order: 3; flex-basis: 100%; max-width: none; }
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; flex-direction: row; flex-wrap: wrap; }
  .panel { flex: 1; min-width: 220px; }
}

@media (max-width: 420px) {
  .topbar-inner { padding: 10px 14px; }
  .layout { padding: 18px 14px 72px; }
  .sidebar { flex-direction: column; }
  .panel { width: 100%; min-width: 0; }
  .brand { font-size: 1.1rem; }
  .auth-nav { gap: 5px; }
  .auth-nav .btn { padding: 7px 9px; font-size: .82rem; }
  .search-form input { min-width: 0; padding-inline: 11px; }
  .search-form button { padding-inline: 12px; }
}

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

/* Product-specific layout refinements */
.topbar { background: rgba(7, 17, 23, .84); border-bottom-color: rgba(143, 231, 171, .12); }
.topbar-inner { max-width: 1240px; padding: 16px 28px; }
.brand { font-size: 1.45rem; letter-spacing: -.05em; }
.brand-mark { width: 30px; height: 30px; border-radius: 10px; background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #11211d; box-shadow: 0 0 22px rgba(143, 231, 171, .2); }
.search-form { max-width: 500px; }
.search-form input { background: rgba(21, 33, 41, .78); border-color: var(--line); padding: 11px 16px; }
.search-form button { display: none; }
.auth-nav .btn { border-radius: 999px; }
.btn { border-radius: 12px; }
.btn.primary { background: linear-gradient(135deg, var(--accent), #c4f9d3); color: #102213; box-shadow: 0 16px 28px -16px rgba(143, 231, 171, .8); }
.layout { max-width: 1240px; grid-template-columns: 282px minmax(0, 720px); gap: 42px; padding: 52px 28px 100px; }
.sidebar { top: 86px; gap: 22px; }
.sidebar-intro { padding: 12px 8px 4px; }
.eyebrow { color: var(--accent); font-size: .68rem; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }
.sidebar-intro h1 { margin: 10px 0 8px; font-size: 2.05rem; line-height: 1.04; letter-spacing: -.06em; }
.sidebar-intro h1 em { color: var(--accent); font-style: normal; }
.sidebar-intro p { color: var(--muted); font-size: .88rem; line-height: 1.5; max-width: 220px; }
.compose-button { padding: 14px 16px; border-radius: 14px; text-align: left; font-size: .92rem; }
.compose-button span { font-size: 1.2rem; vertical-align: -1px; margin-right: 5px; }
.panel { background: linear-gradient(180deg, rgba(17, 27, 35, .8), rgba(13, 22, 28, .9)); border-color: var(--line-soft); border-radius: 18px; padding: 14px; }
.sort-tab.is-active { background: linear-gradient(135deg, rgba(143, 231, 171, .12), rgba(124, 216, 255, .08)); border-color: rgba(143, 231, 171, .4); color: var(--accent); }
.tag-chip.is-active { background: linear-gradient(135deg, var(--accent), #c4f9d3); border-color: transparent; }
.content { min-width: 0; }
.feed-heading { display: flex; align-items: flex-end; justify-content: space-between; margin: 0 0 18px; }
.feed-heading h2 { margin: 7px 0 0; font-size: 1.7rem; letter-spacing: -.05em; }
.feed-refresh { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; padding: 0; border: 1px solid var(--line); background: rgba(17, 27, 35, .9); border-radius: 50%; font-size: 1.3rem; line-height: 1; }
.feed-list { gap: 10px; }
.post-card { background: linear-gradient(180deg, rgba(19, 29, 36, .96), rgba(13, 22, 28, .92)); border-color: var(--line-soft); border-radius: 18px; padding: 18px 20px; }
.post-card:hover { border-color: rgba(143, 231, 171, .45); transform: translateY(-2px); }
.vote-btn:hover { color: var(--accent); background: rgba(143, 231, 171, .08); }
.vote-score { color: var(--accent); }
.post-title { font-size: 1.07rem; letter-spacing: -.02em; }
.post-title a:hover { color: var(--accent); }
.post-actions { padding-top: 6px; }
.post-actions button:hover { color: var(--accent); }
.mobile-tabbar { display: none; }

@media (max-width: 860px) {
  .topbar-inner { padding: 14px 20px; }
  .layout { grid-template-columns: 1fr; gap: 20px; padding: 28px 20px 96px; }
  .sidebar { display: grid; grid-template-columns: 1fr 1fr; position: static; }
  .sidebar-intro { grid-column: 1 / -1; }
  .sidebar-intro h1 { font-size: 1.8rem; }
  .compose-button { grid-column: 1 / -1; }
  .sidebar .panel { min-width: 0; }
  .sort-tabs { flex-direction: row; }
  .sort-tab { flex: 1; text-align: center; padding-inline: 4px; }
}

@media (max-width: 600px) {
  body { padding-bottom: 74px; }
  .topbar-inner { padding: 12px 16px; }
  .brand { font-size: 1.25rem; }
  .auth-nav .btn { font-size: .76rem; padding: 7px 10px; }
  .layout { padding: 22px 16px 34px; }
  .sidebar { display: block; }
  .sidebar-intro { padding: 6px 3px 4px; }
  .sidebar-intro h1 { font-size: 1.75rem; }
  .sidebar .panel { display: none; }
  .sidebar .panel.mobile-topic-open { display: block; }
  .feed-heading h2 { font-size: 1.45rem; }
  .post-card { padding: 15px 13px; gap: 8px; }
  .vote-col { min-width: 30px; }
  .post-title { font-size: 1rem; }
  .post-meta { gap: 7px; font-size: .74rem; }
  .mobile-tabbar { position: fixed; z-index: 30; right: 0; bottom: 0; left: 0; height: 72px; display: flex; align-items: center; justify-content: space-around; padding: 8px 18px max(8px, env(safe-area-inset-bottom)); background: rgba(10, 23, 19, .92); border-top: 1px solid var(--line-soft); backdrop-filter: blur(18px); }
  .mobile-tab { display: flex; flex: 1; flex-direction: column; align-items: center; gap: 1px; background: none; border: 0; color: var(--muted-2); cursor: pointer; }
  .mobile-tab span { font-size: 1.35rem; line-height: 1.1; }
  .mobile-tab small { font-size: .64rem; font-weight: 600; }
  .mobile-tab.is-active { color: var(--accent); }
  .mobile-compose { width: 48px; height: 48px; margin: -23px 10px 0; border: 4px solid var(--bg); border-radius: 50%; background: var(--accent); color: #15230e; font-size: 1.6rem; cursor: pointer; box-shadow: 0 5px 18px rgba(214, 243, 107, .25); }
}

@media (max-width: 600px) {
  body {
    min-height: 100dvh;
    padding-bottom: calc(76px + env(safe-area-inset-bottom));
  }

  .topbar-inner {
    gap: 8px 12px;
    padding: 10px 14px;
  }

  .search-form {
    flex-basis: 100%;
  }

  .search-form input {
    min-height: 44px;
    padding-inline: 14px;
  }

  .layout {
    gap: 14px;
    padding: 18px 14px 24px;
  }

  .sidebar-intro,
  .compose-button {
    display: none;
  }

  .sidebar .panel {
    display: block;
    min-width: 0;
    margin-bottom: 10px;
    padding: 10px 12px;
    border-radius: 14px;
  }

  .sidebar .panel[hidden] {
    display: none;
  }

  .sidebar #tags-panel {
    display: none;
  }

  .sidebar #tags-panel.mobile-topic-open {
    display: block;
    scroll-margin-bottom: calc(88px + env(safe-area-inset-bottom));
  }

  .sidebar #active-filter-panel:not([hidden]) {
    display: block;
  }

  .panel h3 {
    margin-bottom: 6px;
  }

  .sort-tabs {
    gap: 6px;
  }

  .sort-tab {
    min-height: 44px;
    padding: 8px 6px;
    border-radius: 10px;
  }

  .feed-heading {
    padding-bottom: 14px;
    margin-bottom: 14px;
  }

  .feed-heading h2 {
    font-size: clamp(1.3rem, 6vw, 1.55rem);
  }

  .feed-refresh {
    flex: 0 0 44px;
    width: 44px;
    height: 44px;
  }

  .post-card {
    gap: 10px;
    padding: 14px 12px;
    border-radius: 15px;
  }

  .vote-col {
    min-width: 38px;
  }

  .vote-btn {
    width: 38px;
    height: 40px;
  }

  .post-body-col {
    overflow-wrap: anywhere;
  }

  .post-title {
    font-size: 1rem;
  }

  .post-actions {
    flex-wrap: wrap;
    gap: 4px 12px;
  }

  .post-actions button,
  .comment-actions button {
    min-height: 40px;
    padding: 6px 2px;
  }

  .comment {
    padding-left: 10px;
  }

  .comment-replies {
    margin-left: 2px;
  }

  .modal,
  .modal.wide {
    width: calc(100% - 20px);
    max-width: 640px;
    max-height: calc(100dvh - 24px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    border-radius: 20px;
  }

  .modal-card {
    padding: 18px 16px;
  }

  .modal-card footer {
    flex-wrap: wrap;
  }

  .modal-card footer .btn {
    min-height: 44px;
  }

  .mobile-tabbar {
    height: calc(68px + env(safe-area-inset-bottom));
    padding: 7px 10px calc(7px + env(safe-area-inset-bottom));
  }

  .mobile-tab {
    min-height: 48px;
    justify-content: center;
  }

  .mobile-tab small {
    font-size: .68rem;
  }

  .mobile-compose {
    flex: 0 0 48px;
    margin-inline: 7px;
  }

  .toast {
    bottom: calc(80px + env(safe-area-inset-bottom));
    max-width: calc(100vw - 28px);
    text-align: center;
  }
}

@media (max-width: 360px) {
  .topbar-inner {
    padding-inline: 10px;
  }

  .auth-nav .btn {
    padding: 6px 8px;
    font-size: .72rem;
  }

  .layout {
    padding-inline: 10px;
  }

  .post-card {
    gap: 7px;
    padding-inline: 9px;
  }

  .vote-col {
    min-width: 34px;
  }

  .vote-btn {
    width: 34px;
  }
}
