:root {
  --bg: #07110e;
  --bg-2: #0d1a15;
  --panel: rgba(14, 28, 22, 0.88);
  --ink: #e8f2ec;
  --muted: #8ea39a;
  --line: rgba(184, 242, 58, 0.14);
  --lime: #b8f23a;
  --lime-ink: #0a140c;
  --amber: #ffb347;
  --danger: #ff6b5a;
  --ok: #6dffb0;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
  --radius: 20px;
  --font: "Sora", system-ui, sans-serif;
  --display: "Anybody", "Sora", sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(900px 500px at 12% -8%, rgba(184, 242, 58, 0.16), transparent 55%),
    radial-gradient(700px 420px at 95% 8%, rgba(255, 179, 71, 0.1), transparent 50%),
    linear-gradient(165deg, var(--bg) 0%, var(--bg-2) 55%, #06140f 100%);
  min-height: 100vh;
}

.noise {
  pointer-events: none;
  position: fixed;
  inset: 0;
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  z-index: 0;
}

.hidden { display: none !important; }

button, input, select, textarea {
  font: inherit;
  color: inherit;
}

/* —— Login —— */
.login-view {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px 20px;
  overflow: hidden;
}

.login-stage {
  width: min(460px, 100%);
  animation: rise 0.55s ease both;
}

.login-glow {
  position: absolute;
  width: 480px;
  height: 480px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(184, 242, 58, 0.22), transparent 65%);
  filter: blur(8px);
  top: 18%;
  right: -8%;
  animation: pulse 6s ease-in-out infinite;
  z-index: -1;
}

.eyebrow {
  margin: 0 0 10px;
  text-transform: uppercase;
  letter-spacing: 0.22em;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--lime);
}

.brand {
  margin: 0;
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(3.4rem, 12vw, 5.4rem);
  line-height: 0.88;
  letter-spacing: -0.04em;
  text-transform: uppercase;
}

.lede {
  margin: 16px 0 28px;
  color: var(--muted);
  font-size: 1.02rem;
  line-height: 1.5;
  max-width: 34ch;
}

.login-form {
  display: grid;
  gap: 14px;
}

.field {
  display: grid;
  gap: 8px;
}

.field > span {
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.field-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.field-row > span:first-child {
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.btn.sm {
  padding: 7px 12px;
  font-size: 0.78rem;
  flex-shrink: 0;
}

.field em {
  font-style: normal;
  text-transform: none;
  letter-spacing: 0;
  opacity: 0.7;
}

input, select, textarea {
  width: 100%;
  border: 1px solid rgba(232, 242, 236, 0.12);
  background: rgba(6, 16, 12, 0.72);
  border-radius: 14px;
  padding: 13px 14px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}

input:focus, select:focus, textarea:focus {
  border-color: rgba(184, 242, 58, 0.55);
  box-shadow: 0 0 0 3px rgba(184, 242, 58, 0.12);
}

textarea {
  min-height: 170px;
  resize: vertical;
  line-height: 1.5;
}

.btn {
  appearance: none;
  border: 0;
  border-radius: 999px;
  padding: 12px 18px;
  font-weight: 700;
  cursor: pointer;
  transition: transform .12s, background .15s, opacity .15s, border-color .15s;
}

.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.wide { width: 100%; }
.btn.icon { padding: 10px 12px; min-width: 42px; }

.btn.primary {
  background: var(--lime);
  color: var(--lime-ink);
}
.btn.primary:hover:not(:disabled) { filter: brightness(1.05); }

.btn.accent {
  background: transparent;
  color: var(--amber);
  border: 1px solid rgba(255, 179, 71, 0.45);
}
.btn.accent:hover:not(:disabled) { background: rgba(255, 179, 71, 0.1); }

.btn.ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid rgba(232, 242, 236, 0.14);
}
.btn.ghost:hover:not(:disabled) { background: rgba(232, 242, 236, 0.05); }

.btn.danger {
  background: rgba(255, 107, 90, 0.12);
  color: var(--danger);
  border: 1px solid rgba(255, 107, 90, 0.25);
}

.banner {
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 0.92rem;
  line-height: 1.4;
}
.banner.err {
  background: rgba(255, 107, 90, 0.12);
  color: #ffc2ba;
  border: 1px solid rgba(255, 107, 90, 0.28);
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 60;
  max-width: min(360px, calc(100vw - 36px));
  padding: 13px 16px;
  border-radius: 14px;
  background: #13241c;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  animation: rise .25s ease;
}
.toast.ok { border-color: rgba(109, 255, 176, 0.35); color: var(--ok); }
.toast.err { border-color: rgba(255, 107, 90, 0.4); color: #ffc2ba; }

/* —— App —— */
.app-view {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr;
}

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 22px;
  border-bottom: 1px solid rgba(232, 242, 236, 0.08);
  background: rgba(7, 17, 14, 0.72);
  backdrop-filter: blur(14px);
  position: sticky;
  top: 0;
  z-index: 20;
}

.top-left { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.top-right { display: flex; align-items: center; gap: 10px; }

.top-brand {
  margin: 0;
  font-family: var(--display);
  font-size: 1.55rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  text-transform: uppercase;
}
.top-brand span { color: var(--lime); }

.user-pill {
  font-size: 0.85rem;
  color: var(--muted);
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid rgba(232, 242, 236, 0.1);
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tab {
  appearance: none;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}
.tab:hover { color: var(--ink); }
.tab.active {
  color: var(--lime-ink);
  background: var(--lime);
}

.shell {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 0;
}

.rail {
  padding: 22px 18px 32px;
  border-right: 1px solid rgba(232, 242, 236, 0.08);
  background: rgba(8, 18, 14, 0.55);
  display: grid;
  gap: 12px;
  align-content: start;
}

.rail h2 {
  margin: 0 0 4px;
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.rail-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.account-meta {
  font-size: 0.82rem;
  line-height: 1.45;
  color: var(--muted);
  padding: 10px 12px;
  border: 1px solid rgba(232, 242, 236, 0.1);
  border-radius: 10px;
  background: rgba(8, 18, 14, 0.65);
}
.account-meta b {
  color: var(--ink);
  font-weight: 600;
}
.account-meta .meta-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}
.account-meta .meta-row + .meta-row {
  margin-top: 4px;
}

.account-watermark {
  align-self: end;
  margin-bottom: 4px;
}

.inline-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.group-members {
  display: grid;
  gap: 10px;
  padding-top: 4px;
  border-top: 1px solid rgba(232, 242, 236, 0.08);
}

.members-list {
  display: grid;
  gap: 6px;
  font-size: 0.86rem;
  color: var(--muted);
}
.members-list .member {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(8, 18, 14, 0.55);
  border: 1px solid rgba(232, 242, 236, 0.08);
}
.members-list .member b { color: var(--ink); }

.empty-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 16px;
  flex-wrap: wrap;
}

.stage {
  padding: 22px 24px 48px;
  min-width: 0;
  animation: rise 0.4s ease both;
}

.stage-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: end;
  margin-bottom: 16px;
}

.stage-head h2 {
  margin: 0;
  font-family: var(--display);
  font-size: clamp(1.8rem, 3vw, 2.4rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  text-transform: uppercase;
}

.stage-sub {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.pager {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.88rem;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}

.stat {
  padding: 14px 16px;
  border-radius: 16px;
  border: 1px solid rgba(232, 242, 236, 0.08);
  background: rgba(14, 28, 22, 0.55);
}
.stat b {
  display: block;
  font-family: var(--display);
  font-size: 1.7rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--lime);
}
.stat span {
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.feed {
  display: grid;
  gap: 10px;
}

.feed-loading,
.feed-end {
  text-align: center;
  color: var(--muted, #8a968e);
  font-size: 0.9rem;
  padding: 16px 8px 8px;
}

.load-sentinel {
  height: 1px;
  width: 100%;
  pointer-events: none;
}

.post {
  display: grid;
  grid-template-columns: 88px 1fr auto;
  gap: 14px;
  align-items: start;
  padding: 14px;
  border-radius: var(--radius);
  border: 1px solid rgba(232, 242, 236, 0.08);
  background: var(--panel);
  transition: border-color .15s, transform .15s;
  animation: rise 0.35s ease both;
}
.post:hover {
  border-color: rgba(184, 242, 58, 0.28);
}

.thumb {
  width: 88px;
  height: 88px;
  border-radius: 14px;
  object-fit: cover;
  background: linear-gradient(135deg, #163528, #0d1f18);
  border: 1px solid rgba(232, 242, 236, 0.08);
}
.thumb.placeholder {
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.post-body { min-width: 0; }
.post-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 7px 10px;
  margin-bottom: 8px;
  font-size: 0.78rem;
  color: var(--muted);
}

.chip {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(184, 242, 58, 0.1);
  color: var(--lime);
  font-weight: 700;
  font-size: 0.72rem;
}
.chip.warn { background: rgba(255, 179, 71, 0.14); color: var(--amber); }
.chip.ok { background: rgba(109, 255, 176, 0.12); color: var(--ok); }
.chip.bad { background: rgba(255, 107, 90, 0.14); color: var(--danger); }

.source-link {
  color: var(--accent, #6ec8ff);
  text-decoration: none;
  font-weight: 600;
}
.source-link:hover { text-decoration: underline; }

.caption {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.45;
  max-height: 6.8em;
  overflow: hidden;
  color: #d7e6dd;
}

.post-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.empty {
  padding: 48px 20px;
  text-align: center;
  border: 1px dashed rgba(232, 242, 236, 0.16);
  border-radius: var(--radius);
  color: var(--muted);
}
.empty strong {
  display: block;
  color: var(--ink);
  font-family: var(--display);
  font-size: 1.5rem;
  margin-bottom: 8px;
  text-transform: uppercase;
}

/* —— Modal —— */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(2, 8, 6, 0.72);
  backdrop-filter: blur(8px);
}

.modal {
  width: min(640px, 100%);
  max-height: min(92vh, 860px);
  overflow: auto;
  background: #0d1b15;
  border: 1px solid rgba(184, 242, 58, 0.18);
  border-radius: 24px;
  box-shadow: var(--shadow);
  padding: 20px;
  animation: rise 0.25s ease;
}

.modal-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
  margin-bottom: 14px;
}
.modal-head h2 {
  margin: 0;
  font-family: var(--display);
  font-size: 1.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: -0.03em;
}
.hint {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.modal-form { display: grid; gap: 12px; }
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
}

.check {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.92rem;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}
.check input {
  width: auto;
}

.preview {
  width: 100%;
  max-height: 180px;
  object-fit: cover;
  border-radius: 14px;
  border: 1px solid rgba(232, 242, 236, 0.1);
}

@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}
@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 0.7; }
  50% { transform: scale(1.08); opacity: 1; }
}

@media (max-width: 920px) {
  .shell { grid-template-columns: 1fr; }
  .rail {
    border-right: 0;
    border-bottom: 1px solid rgba(232, 242, 236, 0.08);
  }
  .top { flex-direction: column; align-items: stretch; }
  .top-right { justify-content: space-between; }
}

@media (max-width: 640px) {
  .post { grid-template-columns: 72px 1fr; }
  .post-actions { grid-column: 1 / -1; flex-direction: row; justify-content: flex-end; }
  .thumb { width: 72px; height: 72px; }
  .stats { grid-template-columns: 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
}
