/* Dark, glassy panels over the day's background, so the pictures stay the star. */
:root {
  color-scheme: dark;
  --bg: #0d0a12;
  --glass: rgb(18 13 26 / 72%);
  --glass-strong: rgb(22 16 32 / 90%);
  --glass-border: rgb(255 255 255 / 10%);
  --surface-2: rgb(255 255 255 / 6%);
  --border: rgb(255 255 255 / 12%);
  --text: #f6f1fb;
  --muted: #b3a8c2;
  --accent: #ff4fa3;
  --accent-2: #ff8a3d;
  --accent-strong: #ff7cbc;
  --accent-soft: rgb(255 79 163 / 18%);
  --on-accent: #1a0710;
  --danger: #ff6b7a;
  --danger-soft: rgb(255 107 122 / 16%);
  --ok: #6fe3a4;
  --ok-soft: rgb(111 227 164 / 14%);
  --cool: #a8b4ff;
  --cool-soft: rgb(168 180 255 / 14%);
  --mention: #c3c9ff;
  --mention-soft: rgb(88 101 242 / 35%);
  --shadow: 0 10px 30px rgb(0 0 0 / 35%);
  --radius: 18px;
  --gradient: linear-gradient(135deg, var(--accent), var(--accent-2));
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { background: var(--bg); }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

h1, h2 { margin: 0; line-height: 1.2; }
h2 { font-size: 1.05rem; }
.muted { color: var(--muted); }
.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;
}
.sprite { display: none; }

.icon {
  width: 22px; height: 22px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}
.icon .fill, .icon use { fill: inherit; }

input, select, textarea, button { font: inherit; color: inherit; }
input[type="password"], input[type="search"], input[type="text"], input[type="number"], select, textarea {
  width: 100%;
  background: rgb(0 0 0 / 35%);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
textarea { resize: vertical; min-height: 80px; line-height: 1.5; }
textarea.over { border-color: var(--danger); }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
select { width: auto; cursor: pointer; }
option { background: #1b1424; }
::placeholder { color: rgb(255 255 255 / 35%); }

/* ---------- The background and the falling stickers ---------- */

.scene { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.bg {
  position: absolute; inset: -2%;
  background: radial-gradient(circle at 30% 20%, #3a1647, #0d0a12 70%) center / cover no-repeat;
  opacity: 0; transform: scale(1.04);
  transition: opacity 0.6s ease, transform 8s ease-out;
}
.bg.shown { opacity: 1; transform: scale(1); }
.bg-shade {
  position: absolute; inset: 0;
  background:
    radial-gradient(ellipse at 50% 0%, rgb(13 10 18 / 15%), rgb(13 10 18 / 60%) 70%),
    linear-gradient(rgb(13 10 18 / 25%), rgb(13 10 18 / 55%));
}
.fall { position: absolute; inset: 0; }
.sticker {
  position: absolute; top: 0; height: auto; opacity: 0;
  filter: drop-shadow(0 6px 10px rgb(0 0 0 / 45%));
  will-change: transform, opacity;
}

#login, #app { position: relative; z-index: 1; }

/* ---------- Buttons ---------- */

.round-btn, .icon-btn, .fab, .chip-btn, .avatar-btn {
  display: inline-grid; place-items: center; flex: none;
  border: 1px solid var(--glass-border); cursor: pointer;
  transition: transform 0.15s, background 0.15s, border-color 0.15s, color 0.15s, opacity 0.15s, box-shadow 0.15s;
}
.round-btn {
  width: 48px; height: 48px; border-radius: 50%;
  background: var(--glass-strong); color: var(--text);
  text-decoration: none;
}
.round-btn.small { width: 36px; height: 36px; }
.round-btn.small .icon { width: 18px; height: 18px; }
.round-btn:hover:not(:disabled) { transform: translateY(-1px); border-color: rgb(255 255 255 / 25%); }
.round-btn.primary { background: var(--gradient); color: var(--on-accent); border-color: transparent; box-shadow: 0 6px 20px rgb(255 79 163 / 35%); }
.round-btn.primary .icon { stroke-width: 2.6; }
.round-btn:disabled, .fab:disabled { opacity: 0.4; cursor: not-allowed; transform: none; box-shadow: none; }

.icon-btn {
  width: 34px; height: 34px; border-radius: 10px;
  background: transparent; border-color: transparent; color: var(--muted);
}
.icon-btn .icon { width: 18px; height: 18px; }
.icon-btn:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
.icon-btn.armed { background: var(--danger); color: #fff; animation: wobble 0.35s; }
@keyframes wobble { 25% { transform: rotate(-8deg); } 75% { transform: rotate(8deg); } }

.fab {
  width: 52px; height: 52px; border-radius: 16px;
  background: var(--gradient); color: var(--on-accent); border-color: transparent;
  box-shadow: 0 8px 24px rgb(255 79 163 / 40%);
}
.fab .icon { width: 26px; height: 26px; stroke-width: 2.8; }
.fab:hover:not(:disabled) { transform: translateY(-2px) rotate(90deg); }

.chip-btn {
  width: 44px; height: 44px; border-radius: 14px;
  background: var(--glass); color: var(--muted); backdrop-filter: blur(12px);
}
.chip-btn[aria-pressed="true"] { color: #ffd34f; border-color: rgb(255 211 79 / 45%); background: rgb(255 211 79 / 14%); }
.chip-btn[aria-pressed="true"] .icon { fill: currentColor; }

.round-btn:focus-visible, .icon-btn:focus-visible, .fab:focus-visible, .chip-btn:focus-visible,
.avatar-btn:focus-visible, .views button:focus-visible, .seg button:focus-visible, .btn:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}

/* The owner's pages still use labelled buttons. */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid transparent; border-radius: 10px; padding: 9px 16px;
  font-weight: 600; cursor: pointer; white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, color 0.15s, opacity 0.15s;
}
.btn.primary { background: var(--gradient); color: var(--on-accent); }
.btn.ghost { background: transparent; border-color: var(--border); }
.btn.ghost:hover:not(:disabled) { background: var(--surface-2); }
.btn.danger { background: var(--danger); color: #fff; }
.btn.small { padding: 5px 11px; font-size: 0.875rem; border-radius: 8px; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.error { color: var(--danger); margin: 0; font-size: 0.9rem; min-height: 1.35em; }
.error:empty { min-height: 0; }

/* ---------- Login ---------- */

.login {
  min-height: 100vh; display: grid; place-content: center; justify-items: center; gap: 28px;
  padding: 24px 16px; text-align: center;
}
.login-logo {
  width: min(220px, 60vw); height: auto; border-radius: 50%;
  background: rgb(13 10 18 / 45%);
  box-shadow: 0 0 0 6px rgb(255 255 255 / 8%), 0 0 60px rgb(255 79 163 / 55%), 0 0 140px rgb(255 138 61 / 30%);
  animation: float 5s ease-in-out infinite;
}
@keyframes float { 50% { transform: translateY(-10px) rotate(-2deg); } }
.round-btn.discord {
  width: 76px; height: 76px; background: #5865f2; color: #fff; border-color: transparent;
  box-shadow: 0 10px 30px rgb(88 101 242 / 55%);
}
.round-btn.discord .icon { width: 40px; height: 40px; fill: currentColor; stroke: none; }
.round-btn.discord:hover { transform: translateY(-2px) scale(1.05); background: #6b77f5; }
.login-form { display: flex; gap: 10px; width: min(320px, 100%); }
.login-form input { flex: 1; border-radius: 24px; padding: 12px 18px; background: var(--glass-strong); }
.login .error {
  max-width: 340px; padding: 8px 14px; border-radius: 12px; background: var(--glass-strong);
}

/* ---------- Top bar ---------- */

.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 12px;
  max-width: 1180px; margin: 0 auto; padding: 12px 16px;
}
.topbar::before {
  content: ""; position: absolute; inset: 6px 8px; z-index: -1;
  background: var(--glass); border: 1px solid var(--glass-border); border-radius: 22px;
  backdrop-filter: blur(16px) saturate(140%);
}
.brand { width: 44px; height: 44px; border-radius: 50%; flex: none; margin-left: 4px; }
.views { display: inline-flex; gap: 4px; padding: 4px; border-radius: 16px; background: rgb(0 0 0 / 25%); }
.views button {
  display: grid; place-items: center; width: 46px; height: 40px;
  border: 0; border-radius: 12px; background: transparent; color: var(--muted); cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.views button:hover { color: var(--text); background: var(--surface-2); }
.views button[aria-current="page"] { background: var(--gradient); color: var(--on-accent); }
.views button[aria-current="page"] .icon { stroke-width: 2.4; }

.server-pick { display: flex; align-items: center; gap: 8px; margin-left: auto; min-width: 0; }
.server-pick img, .server-fallback { width: 34px; height: 34px; border-radius: 50%; flex: none; }
.server-fallback {
  display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent-strong); font-weight: 700; font-size: 0.8rem;
}
.server-pick select { max-width: 220px; min-width: 0; border-radius: 12px; }
.server-pick.single select { display: none; }

.avatar-btn {
  width: 44px; height: 44px; border-radius: 50%; padding: 0; overflow: hidden;
  background: var(--glass-strong); color: var(--muted); margin-right: 4px;
}
.avatar-btn img { width: 100%; height: 100%; object-fit: cover; }
.avatar-btn:hover { border-color: var(--danger); color: var(--danger); }
.server-pick + .avatar-btn { margin-left: 0; }
.views + .avatar-btn, .server-pick[hidden] + .avatar-btn { margin-left: auto; }

/* ---------- Content ---------- */

.content { max-width: 1180px; margin: 0 auto; padding: 10px 16px 64px; display: grid; gap: 18px; }
.view { display: grid; gap: 18px; }

.toolbar { display: flex; align-items: center; gap: 10px; }
.seg {
  display: inline-flex; gap: 2px; padding: 3px; border-radius: 16px;
  background: var(--glass); border: 1px solid var(--glass-border); backdrop-filter: blur(12px);
}
.seg button {
  display: inline-flex; align-items: center; justify-content: center; gap: 2px;
  min-width: 46px; height: 38px; padding: 0 10px; border: 0; border-radius: 12px;
  background: transparent; color: var(--muted); cursor: pointer;
}
.seg button:hover { color: var(--text); }
.seg button[aria-pressed="true"] { background: rgb(255 255 255 / 12%); color: var(--text); }
.seg .dir { width: 16px; height: 16px; transition: transform 0.2s; }
.seg button[aria-pressed="false"] .dir { opacity: 0.35; }
.seg button.oldest .dir { transform: rotate(180deg); }

.search {
  position: relative; display: flex; align-items: center; flex: 1; max-width: 300px; margin-left: auto;
}
.search .icon { position: absolute; z-index: 1; left: 12px; width: 18px; height: 18px; color: var(--muted); pointer-events: none; }
.search input { padding-left: 38px; border-radius: 14px; background: var(--glass); backdrop-filter: blur(12px); height: 44px; }

/* Cards */
.entries { display: grid; gap: 22px; }
/* Rows, so newest-first reads left to right. */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; align-items: start; }
.entry {
  display: grid; gap: 10px;
  padding: 12px; border-radius: var(--radius);
  background: var(--glass); border: 1px solid var(--glass-border);
  backdrop-filter: blur(14px) saturate(140%); box-shadow: var(--shadow);
  transition: transform 0.2s, border-color 0.2s;
}
.entry:hover { transform: translateY(-2px); border-color: rgb(255 255 255 / 20%); }
.entry.flash { animation: pop 1.4s ease-out; }
@keyframes pop {
  0% { transform: scale(0.9); border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft), var(--shadow); }
  40% { transform: scale(1.02); }
  100% { transform: none; }
}
.entry-media {
  display: block; width: 100%; max-height: 360px; object-fit: cover;
  border-radius: 12px; background: rgb(0 0 0 / 30%);
}
.entry-text { margin: 0 2px; font-size: 1rem; overflow-wrap: anywhere; white-space: pre-wrap; }
.entry-foot { display: flex; align-items: center; gap: 8px; min-height: 34px; }
.entry-foot time { color: var(--muted); font-size: 0.78rem; font-variant-numeric: tabular-nums; }
.entry-actions { display: flex; gap: 2px; margin-left: auto; opacity: 0.55; transition: opacity 0.15s; }
.entry:hover .entry-actions, .entry:focus-within .entry-actions { opacity: 1; }

.avatar { border-radius: 50%; flex: none; object-fit: cover; }
.avatar.small { width: 26px; height: 26px; }
.avatar.big { width: 44px; height: 44px; box-shadow: 0 0 0 3px rgb(255 255 255 / 12%); }
.avatar.initial {
  display: inline-grid; place-items: center; font-weight: 800; color: #fff;
  background: hsl(var(--hue) 70% 45%);
}
.avatar.small.initial { font-size: 0.75rem; }
.avatar.big.initial { font-size: 1.2rem; }

.group { display: grid; gap: 12px; }
.group-head {
  display: inline-flex; align-items: center; gap: 10px; justify-self: start;
  padding: 5px 14px 5px 5px; border-radius: 999px;
  background: var(--glass); border: 1px solid var(--glass-border); backdrop-filter: blur(12px);
}

.nothing { display: grid; place-items: center; padding: 60px 0; }
.nothing img { opacity: 0.85; filter: drop-shadow(0 8px 20px rgb(0 0 0 / 50%)); animation: float 4s ease-in-out infinite; }

.mention { background: var(--mention-soft); color: var(--mention); font-weight: 600; border-radius: 4px; padding: 0 3px; }
.media-link {
  display: inline-grid; place-items: center; vertical-align: middle;
  width: 28px; height: 24px; border-radius: 6px; background: var(--accent-soft); color: var(--accent-strong);
}
.media-link .icon { width: 16px; height: 16px; }
.plain-link { color: var(--accent-strong); overflow-wrap: anywhere; }

.pill {
  display: inline-block; min-width: 24px; padding: 0 8px; border-radius: 999px;
  background: var(--surface-2); color: var(--muted); font-size: 0.8rem; font-weight: 700; text-align: center;
}

/* ---------- The add / edit box ---------- */

.composer {
  width: min(480px, calc(100vw - 32px)); padding: 0; border: 1px solid var(--glass-border); border-radius: 24px;
  background: var(--glass-strong); color: var(--text); box-shadow: 0 30px 80px rgb(0 0 0 / 60%);
  backdrop-filter: blur(20px);
}
.composer[open] { animation: rise 0.22s ease-out; }
@keyframes rise { from { opacity: 0; transform: translateY(16px) scale(0.97); } }
.composer::backdrop { background: rgb(5 3 8 / 60%); backdrop-filter: blur(4px); }
.composer form { display: grid; gap: 14px; padding: 18px; }
.drop {
  position: relative; display: grid; place-items: center; min-height: 150px;
  border: 2px dashed rgb(255 255 255 / 18%); border-radius: 16px; background: rgb(0 0 0 / 25%);
  transition: border-color 0.15s, background 0.15s;
}
.drop.filled { border-style: solid; border-color: transparent; background: transparent; min-height: 0; }
.drop.over { border-color: var(--accent); background: var(--accent-soft); }
.drop-empty {
  display: grid; place-items: center; width: 100%; height: 150px; border: 0; background: none;
  color: var(--muted); cursor: pointer; border-radius: 14px;
}
.drop-empty .icon { width: 44px; height: 44px; stroke-width: 1.6; transition: transform 0.2s, color 0.2s; }
.drop-empty:hover .icon { transform: scale(1.12); color: var(--accent-strong); }
.media-preview { width: 100%; }
.media-preview .entry-media { max-height: 300px; object-fit: contain; }
.floating { position: absolute; top: 8px; right: 8px; }
.spinner {
  width: 40px; height: 40px; border-radius: 50%;
  border: 4px solid rgb(255 255 255 / 15%); border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.composer textarea { min-height: 96px; background: rgb(0 0 0 / 35%); }
.composer-actions { display: flex; justify-content: flex-end; gap: 10px; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 20;
  background: var(--glass-strong); border: 1px solid var(--glass-border); backdrop-filter: blur(12px);
  color: var(--text); padding: 10px 18px; border-radius: 14px; box-shadow: var(--shadow);
  font-weight: 600; max-width: calc(100vw - 32px);
}
.toast.error { background: var(--danger); color: #fff; border-color: transparent; }

/* ---------- The owner's pages ---------- */

.card {
  background: var(--glass); border: 1px solid var(--glass-border); border-radius: var(--radius);
  backdrop-filter: blur(14px) saturate(140%); box-shadow: var(--shadow); padding: 20px;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.actions-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 12px; }
.buttons { display: flex; gap: 8px; align-items: center; }
.preview { margin-top: 14px; padding: 12px 14px; border-radius: 12px; background: rgb(0 0 0 / 25%); border: 1px dashed var(--border); }
.preview .roast-text { margin: 0; }
.count { font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--muted); font-size: 0.85rem; }
.count.over { color: var(--danger); font-weight: 600; }

.tools { display: flex; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.tools input { flex: 1; min-width: 160px; }
.send-row { margin-bottom: 10px; }
.send-row select { width: 100%; max-width: 360px; }
.find-row { display: flex; gap: 8px; margin-bottom: 4px; }
.find-row input { flex: 1; }

.roast-list { list-style: none; margin: 0; padding: 0; }
.roast {
  display: grid; grid-template-columns: 44px 1fr auto; gap: 12px; align-items: start;
  padding: 12px 4px; border-top: 1px solid var(--border);
}
.roast:first-child { border-top: 0; }
.roast-id { font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; padding-top: 1px; }
.roast-text { margin: 0 0 4px; overflow-wrap: anywhere; }
.roast-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; font-size: 0.82rem; color: var(--muted); }
.roast-meta a { color: inherit; }
.roast-actions { display: flex; gap: 2px; }
.roast.editing { grid-template-columns: 44px 1fr; }
.message { grid-template-columns: 1fr auto; }
.message.editing { grid-template-columns: 1fr; }
.message-text { margin: 0 0 6px; white-space: pre-wrap; overflow-wrap: anywhere; }
.attachments { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 6px; }
.attachment { font-size: 0.8rem; padding: 2px 8px; border-radius: 6px; background: var(--surface-2); color: var(--muted); }
.edit-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.edit-foot .buttons { margin-left: auto; }
.empty { text-align: center; color: var(--muted); padding: 32px 12px; margin: 0; }

.badge { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 999px; font-size: 0.76rem; font-weight: 650; }
.badge.cooling { background: var(--cool-soft); color: var(--cool); }
.badge.ready { background: var(--ok-soft); color: var(--ok); }
.badge.kind { background: var(--surface-2); color: var(--muted); }
.badge.kind-roast { background: var(--accent-soft); color: var(--accent-strong); }
.badge.kind-dashboard { background: var(--mention-soft); color: var(--mention); }

.list-head { align-items: center; }
.list-source { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.list-add { margin-bottom: 14px; }
.list-add .actions-row { margin-top: 8px; }
.list-search { margin-bottom: 6px; }
.list-search input { max-width: 320px; }
.link-button { border: 0; background: none; padding: 0; color: var(--accent-strong); font: inherit; text-decoration: underline; cursor: pointer; }

.bot-card { display: flex; align-items: center; gap: 16px; }
.bot-card img { width: 56px; height: 56px; border-radius: 50%; }
.bot-card p { margin: 2px 0 0; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin-bottom: 14px; }
.field { display: grid; gap: 5px; align-content: start; }
.field.wide { grid-column: 1 / -1; }
.field select { width: 100%; }
.field-label { font-weight: 650; font-size: 0.9rem; }
.field-help { color: var(--muted); font-size: 0.82rem; }
.field-help:empty { display: none; }

/* ---------- Phones ---------- */

@media (max-width: 720px) {
  .topbar { flex-wrap: wrap; gap: 8px; padding: 10px 12px; }
  .brand { width: 38px; height: 38px; }
  .views button { width: 42px; height: 36px; }
  .server-pick { order: 3; width: 100%; margin: 0 4px 2px; }
  .server-pick select { max-width: none; flex: 1; }
  .server-pick.single { order: 0; width: auto; margin: 0 0 0 auto; }
  .server-pick.single + .avatar-btn { margin-left: 0; }
  .avatar-btn { width: 38px; height: 38px; margin-left: auto; }
  .content { padding: 6px 16px 48px; }
  .toolbar { flex-wrap: wrap; }
  .search { order: 4; max-width: none; width: 100%; flex-basis: 100%; }
  .fab { margin-left: auto; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .entry { padding: 10px; }
  .roast { grid-template-columns: 1fr; gap: 6px; }
  .roast.editing { grid-template-columns: 1fr; }
  .roast-actions { justify-content: flex-end; }
  .form-grid { grid-template-columns: 1fr; }
  .list-source { justify-content: flex-start; }
}

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