/* ==========================================================================
   confess — crimson glassmorphism, mobile-first
   ========================================================================== */

:root{
  --bg-0: #050101;
  --bg-1: #0b0202;
  --panel: rgba(20, 5, 5, 0.7);
  --panel-solid: #140505;
  --border: rgba(220, 38, 38, 0.28);
  --border-strong: rgba(239, 68, 68, 0.55);
  --crimson: #dc2626;
  --crimson-light: #ef4444;
  --crimson-glow: rgba(239, 68, 68, 0.35);
  --text-hi: #f5f5f5;
  --text-mid: #c9c3c3;
  --text-lo: #8a8181;
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

*{ box-sizing: border-box; }

html{
  background: var(--bg-0);
  scroll-padding-top: var(--safe-top);
}

body{
  margin: 0;
  font-family: var(--font);
  background: radial-gradient(120% 60% at 50% 0%, #140404 0%, var(--bg-0) 55%), var(--bg-0);
  color: var(--text-hi);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
}

button{ font-family: inherit; }

::selection{ background: var(--crimson-glow); color: #fff; }

/* scrollbar (webkit) kept minimal */
::-webkit-scrollbar{ width: 6px; }
::-webkit-scrollbar-thumb{ background: rgba(220,38,38,0.35); border-radius: 4px; }

/* ==========================================================================
   App shell
   ========================================================================== */

.app{
  max-width: 480px;
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  position: relative;
  border-left: 1px solid rgba(255,255,255,0.03);
  border-right: 1px solid rgba(255,255,255,0.03);
}

/* ==========================================================================
   Header
   ========================================================================== */

.app-header{
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(14px + var(--safe-top)) 16px 14px;
  background: rgba(5, 1, 1, 0.75);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}

.brand{ display: flex; align-items: center; gap: 12px; min-width: 0; }

.brand-mark{
  position: relative;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  background: linear-gradient(160deg, #150404, #0b0202);
  border: 1px solid var(--border-strong);
  box-shadow: 0 0 16px var(--crimson-glow);
  overflow: hidden;
}

.brand-mark img{
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.brand-mark-fallback{
  display: none;
  position: absolute;
  inset: 0;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 18px;
  color: var(--crimson-light);
  text-shadow: 0 0 12px var(--crimson-glow);
}

.brand-mark img.broken{ display: none; }
.brand-mark img.broken + .brand-mark-fallback{ display: flex; }

.brand-text h1{
  margin: 0;
  font-size: 19px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text-hi);
}

.brand-text p{
  margin: 1px 0 0;
  font-size: 11.5px;
  color: var(--text-lo);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.icon-btn{
  width: 38px;
  height: 38px;
  border-radius: 11px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.02);
  color: var(--text-mid);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: border-color .15s ease, color .15s ease, background .15s ease;
}
.icon-btn:hover{ color: var(--crimson-light); border-color: var(--border-strong); }
.icon-btn:active{ transform: scale(0.94); }

/* ==========================================================================
   Filter bar
   ========================================================================== */

.filter-bar{
  position: sticky;
  top: calc(68px + var(--safe-top));
  z-index: 19;
  display: flex;
  gap: 8px;
  padding: 10px 16px;
  overflow-x: auto;
  scrollbar-width: none;
  background: rgba(5,1,1,0.55);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(220,38,38,0.14);
}
.filter-bar::-webkit-scrollbar{ display: none; }

.chip{
  flex: 0 0 auto;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.02);
  color: var(--text-mid);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s ease;
  white-space: nowrap;
}
.chip:active{ transform: scale(0.96); }
.chip.active{
  color: #fff;
  background: linear-gradient(160deg, rgba(220,38,38,0.35), rgba(220,38,38,0.12));
  border-color: var(--border-strong);
  box-shadow: 0 0 14px rgba(220,38,38,0.25);
}

/* ==========================================================================
   Feed & post cards
   ========================================================================== */

.feed{
  flex: 1;
  padding: 16px 16px calc(96px + var(--safe-bottom));
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.post-card{
  background: var(--panel);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  position: relative;
  animation: rise .35s ease both;
}

@keyframes rise{
  from{ opacity: 0; transform: translateY(8px); }
  to{ opacity: 1; transform: translateY(0); }
}

.post-top{
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.post-tag{
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: var(--crimson-light);
  background: rgba(220,38,38,0.12);
  border: 1px solid var(--border);
  padding: 4px 10px;
  border-radius: 999px;
}

.post-time{ font-size: 11.5px; color: var(--text-lo); }

.post-text{
  font-size: 15px;
  line-height: 1.55;
  color: var(--text-hi);
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0 0 12px;
}

.post-actions{
  display: flex;
  align-items: center;
  gap: 18px;
  border-top: 1px solid rgba(255,255,255,0.05);
  padding-top: 10px;
}

.action-btn{
  display: flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  color: var(--text-mid);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 2px;
}
.action-btn svg{ transition: transform .18s ease; }
.action-btn:active svg{ transform: scale(1.25); }

.action-btn.liked{ color: var(--crimson-light); }
.action-btn.liked svg{ fill: var(--crimson-light); stroke: var(--crimson-light); }

.admin-delete{
  margin-left: auto;
  color: #ff8a8a;
  opacity: 0.75;
}
.admin-delete:hover{ opacity: 1; }

/* comments */
.comments{
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid rgba(255,255,255,0.05);
  display: none;
  flex-direction: column;
  gap: 10px;
}
.comments.open{ display: flex; }

.comment-item{
  background: rgba(255,255,255,0.02);
  border: 1px solid rgba(255,255,255,0.04);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-size: 13px;
  color: var(--text-mid);
  line-height: 1.4;
}
.comment-item span{
  display: block;
  font-size: 10.5px;
  color: var(--text-lo);
  margin-top: 4px;
}

.comment-form{
  display: flex;
  gap: 8px;
}

.comment-form input{
  flex: 1;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 9px 14px;
  color: var(--text-hi);
  font-size: 13px;
  outline: none;
}
.comment-form input:focus{ border-color: var(--border-strong); }

.comment-send{
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
  background: rgba(220,38,38,0.18);
  color: var(--crimson-light);
  display: grid;
  place-items: center;
  cursor: pointer;
  flex: 0 0 auto;
}
.comment-send:disabled{ opacity: 0.35; cursor: default; }

/* empty state */
.empty-state{
  text-align: center;
  padding: 60px 32px;
  color: var(--text-lo);
}
.empty-glyph{ font-size: 34px; margin-bottom: 10px; opacity: 0.7; }
.empty-state h2{ color: var(--text-hi); font-size: 17px; margin: 0 0 6px; }
.empty-state p{ font-size: 13.5px; line-height: 1.5; margin: 0; }

/* ==========================================================================
   FAB
   ========================================================================== */

.fab{
  position: fixed;
  right: max(20px, calc((100vw - 480px) / 2 + 20px));
  bottom: calc(24px + var(--safe-bottom));
  width: 58px;
  height: 58px;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
  background: linear-gradient(160deg, var(--crimson-light), var(--crimson));
  color: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: 0 6px 24px rgba(220,38,38,0.45), 0 0 0 6px rgba(220,38,38,0.08);
  z-index: 30;
  transition: transform .15s ease;
}
.fab:active{ transform: scale(0.92); }

/* ==========================================================================
   Bottom sheets (compose / admin)
   ========================================================================== */

.sheet-backdrop{
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease;
  z-index: 50;
}
.sheet-backdrop.show{ opacity: 1; pointer-events: auto; }

.sheet{
  width: 100%;
  max-width: 480px;
  background: linear-gradient(180deg, #140505 0%, #0b0202 100%);
  border: 1px solid var(--border-strong);
  border-bottom: none;
  border-radius: 22px 22px 0 0;
  padding: 10px 18px calc(20px + var(--safe-bottom));
  transform: translateY(100%);
  transition: transform .28s cubic-bezier(.32,.72,0,1);
  box-shadow: 0 -10px 40px rgba(0,0,0,0.5);
  max-height: 88vh;
  overflow-y: auto;
}
.sheet-backdrop.show .sheet{ transform: translateY(0); }

.sheet-handle{
  width: 40px;
  height: 4px;
  border-radius: 2px;
  background: rgba(255,255,255,0.15);
  margin: 4px auto 14px;
}

.sheet-header{
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.sheet-header h2{ margin: 0; font-size: 18px; font-weight: 800; }

.category-picker{
  display: flex;
  gap: 8px;
  overflow-x: auto;
  margin-bottom: 14px;
  scrollbar-width: none;
}
.category-picker::-webkit-scrollbar{ display: none; }

.cat-chip{
  flex: 0 0 auto;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.02);
  color: var(--text-mid);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}
.cat-chip.active{
  color: #fff;
  background: rgba(220,38,38,0.25);
  border-color: var(--border-strong);
}

#composeText{
  width: 100%;
  resize: none;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px;
  color: var(--text-hi);
  font-size: 14.5px;
  line-height: 1.5;
  font-family: inherit;
  outline: none;
}
#composeText:focus{ border-color: var(--border-strong); }

.sheet-footer{
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 12px;
}

.char-counter{ font-size: 12px; color: var(--text-lo); }
.char-counter.limit{ color: var(--crimson-light); }

.cooldown-note{
  margin: 10px 0 0;
  font-size: 12px;
  color: var(--text-lo);
  text-align: center;
}

.btn-primary{
  background: linear-gradient(160deg, var(--crimson-light), var(--crimson));
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 12px 20px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 18px rgba(220,38,38,0.35);
  transition: opacity .15s ease, transform .15s ease;
}
.btn-primary:disabled{
  opacity: 0.35;
  box-shadow: none;
  cursor: not-allowed;
}
.btn-primary:active:not(:disabled){ transform: scale(0.97); }
.btn-primary.btn-sm{ padding: 8px 14px; font-size: 12.5px; }

.btn-secondary{
  width: 100%;
  margin-top: 14px;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border);
  color: var(--text-mid);
  border-radius: 999px;
  padding: 11px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
}

/* ==========================================================================
   Admin
   ========================================================================== */

.admin-hint{ font-size: 13px; color: var(--text-mid); margin: 0 0 12px; }

#adminPasscode{
  width: 100%;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 13px 14px;
  color: var(--text-hi);
  font-size: 14px;
  outline: none;
  margin-bottom: 10px;
  letter-spacing: 0.08em;
}
#adminPasscode:focus{ border-color: var(--border-strong); }

.admin-error{ color: #ff6b6b; font-size: 12.5px; margin: -2px 0 10px; }

#adminUnlock{ width: 100%; }

.admin-stats{
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
}
.admin-stats > div{
  flex: 1;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px;
  text-align: center;
}
.admin-stats strong{ display: block; font-size: 19px; }
.admin-stats span{ font-size: 10.5px; color: var(--text-lo); }

.admin-list{ display: flex; flex-direction: column; gap: 8px; max-height: 46vh; overflow-y: auto; }

.admin-row{
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: rgba(255,255,255,0.02);
  border: 1px solid rgba(255,255,255,0.05);
  border-radius: var(--radius-sm);
  padding: 10px;
}
.admin-row p{
  margin: 0;
  font-size: 12.5px;
  color: var(--text-mid);
  line-height: 1.4;
  flex: 1;
  word-break: break-word;
}
.admin-row button{
  flex: 0 0 auto;
  background: rgba(220,38,38,0.16);
  border: 1px solid var(--border-strong);
  color: #ff8a8a;
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 11.5px;
  font-weight: 700;
  cursor: pointer;
}

/* ==========================================================================
   Install banner
   ========================================================================== */

.install-banner{
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: calc(12px + var(--safe-bottom));
  max-width: 456px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--panel-solid);
  border: 1px solid var(--border-strong);
  border-radius: 16px;
  padding: 10px 12px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.5);
  z-index: 40;
  animation: rise .3s ease both;
}
.install-banner img{ width: 34px; height: 34px; border-radius: 9px; flex: 0 0 auto; }
.install-copy{ display: flex; flex-direction: column; min-width: 0; flex: 1; }
.install-copy strong{ font-size: 13px; }
.install-copy span{ font-size: 11px; color: var(--text-lo); line-height: 1.3; }

/* ==========================================================================
   Toast
   ========================================================================== */

.toast{
  position: fixed;
  left: 50%;
  bottom: calc(100px + var(--safe-bottom));
  transform: translate(-50%, 12px);
  background: var(--panel-solid);
  border: 1px solid var(--border-strong);
  color: var(--text-hi);
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: all .25s ease;
  z-index: 60;
  white-space: nowrap;
}
.toast.show{ opacity: 1; transform: translate(-50%, 0); }

/* ==========================================================================
   Accessibility & small screens
   ========================================================================== */

:focus-visible{ outline: 2px solid var(--crimson-light); outline-offset: 2px; }

@media (max-width: 340px){
  .brand-text p{ display: none; }
}

@media (prefers-reduced-motion: reduce){
  *{ animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}
