:root {
  --bg: #111219;
  --surface: #1a1c26;
  --surface-2: #222533;
  --surface-3: #2a2d3d;
  --border: #2f3245;
  --border-strong: #3d4157;
  --text: #e8eaf2;
  --muted: #9ba1b8;
  --faint: #6b7088;
  --accent: #7c8cff;
  --accent-strong: #6273f5;
  --accent-soft: rgba(124, 140, 255, 0.14);
  --danger: #ff6b6b;
  --danger-soft: rgba(255, 107, 107, 0.12);
  --ok: #4ade80;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 0 rgba(255, 255, 255, 0.03) inset, 0 12px 40px rgba(0, 0, 0, 0.35);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --page-w: 760px;
  --page-wide: 1100px;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  background:
    radial-gradient(1200px 500px at 50% -200px, rgba(124, 140, 255, 0.10), transparent 70%),
    var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.hidden { display: none !important; }
.icon { flex-shrink: 0; display: block; }

/* ---------- layout ---------- */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  max-width: var(--page-wide);
  margin: 0 auto;
  padding: 18px 20px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-size: 1.05rem;
  letter-spacing: -0.01em;
}
.brand:hover { text-decoration: none; }
.brand b { font-weight: 700; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--accent), #b07cff);
  color: #fff;
  font-weight: 800;
  font-size: 1.1rem;
}
.header-nav { display: flex; align-items: center; gap: 14px; font-size: 0.92rem; }
.header-link { color: var(--muted); }
.header-link:hover { color: var(--text); text-decoration: none; }
.user-chip {
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

main.page {
  flex: 1;
  width: 100%;
  max-width: var(--page-w);
  margin: 0 auto;
  padding: 8px 20px 48px;
}
main.page.wide { max-width: var(--page-wide); }

.site-footer {
  text-align: center;
  padding: 20px;
  color: var(--faint);
  font-size: 0.8rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.page-title {
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 12px 0 6px;
}
.page-sub { color: var(--muted); margin-bottom: 20px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 38px;
  padding: 0 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 500;
  white-space: nowrap;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}
.btn:hover { background: var(--surface-3); border-color: var(--border-strong); text-decoration: none; }
.btn:active { transform: scale(0.97); }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); border-color: transparent; }
.btn-danger { color: var(--danger); background: var(--danger-soft); border-color: transparent; }
.btn-danger:hover { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-lg { min-height: 46px; padding: 0 22px; font-size: 1rem; font-weight: 600; }
.btn-icon { padding: 0; width: 38px; }
.btn .spinner {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.35); border-top-color: #fff;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- composer (home) ---------- */
.composer { padding: 6px; }
.tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  margin: 6px 6px 0;
  background: var(--bg);
  border-radius: 11px;
  width: fit-content;
}
.tab {
  display: inline-flex; align-items: center; gap: 7px;
  border: 0; background: transparent; color: var(--muted);
  padding: 7px 14px; border-radius: 8px; font-size: 0.9rem; font-weight: 500;
}
.tab:hover { color: var(--text); }
.tab[aria-selected="true"] { background: var(--surface-3); color: var(--text); }
.tab .count {
  font-size: 0.75rem; background: var(--accent); color: #fff; border-radius: 999px; padding: 0 7px;
}
.panel { padding: 12px; }

.textarea {
  display: block;
  width: 100%;
  min-height: 260px;
  max-height: 70vh;
  padding: 14px 16px;
  resize: vertical;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--mono);
  font-size: 0.88rem;
  line-height: 1.6;
  tab-size: 4;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.textarea::placeholder { color: var(--faint); }
.textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.composer-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 0 12px 12px;
}
.composer-bar .spacer { flex: 1; }
.hint { color: var(--faint); font-size: 0.8rem; }
kbd {
  font-family: var(--mono); font-size: 0.75rem;
  padding: 1px 5px; border-radius: 4px; border: 1px solid var(--border); background: var(--surface-2);
}

.select {
  appearance: none;
  -webkit-appearance: none;
  min-height: 38px;
  padding: 0 34px 0 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239ba1b8' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") no-repeat right 12px center;
  font-size: 0.9rem;
}
.select:focus { outline: none; border-color: var(--accent); }
.detected { color: var(--muted); font-size: 0.82rem; }

.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 260px;
  padding: 24px;
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--muted);
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.dropzone:hover { border-color: var(--accent); }
.dropzone.dragging { border-color: var(--accent); background: var(--accent-soft); color: var(--text); }
.dropzone .big-icon { color: var(--accent); margin-bottom: 4px; }
.dropzone strong { color: var(--text); font-size: 1.02rem; }
.dropzone small { color: var(--faint); }

.login-note {
  display: flex; gap: 10px; align-items: center; justify-content: center; flex-wrap: wrap;
  padding: 10px 12px; margin-bottom: 10px;
  border-radius: var(--radius-sm); background: var(--accent-soft); color: var(--text); font-size: 0.9rem;
}

/* full-page drop overlay */
.drop-overlay {
  position: fixed; inset: 0; z-index: 900;
  display: grid; place-items: center;
  background: rgba(17, 18, 25, 0.82);
  backdrop-filter: blur(3px);
  border: 3px dashed var(--accent);
  color: var(--text); font-size: 1.3rem; font-weight: 600;
  pointer-events: none;
}

.file-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
}
.file-tile {
  position: relative;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  overflow: hidden;
}
.file-thumb {
  aspect-ratio: 4 / 3;
  display: grid;
  place-items: center;
  background: var(--surface-2);
  color: var(--muted);
  overflow: hidden;
}
.file-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.file-meta { padding: 8px 10px; min-width: 0; }
.file-meta .name { font-size: 0.82rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-meta .size { font-size: 0.75rem; color: var(--faint); }
.file-remove {
  position: absolute; top: 6px; right: 6px;
  display: grid; place-items: center;
  width: 28px; height: 28px; border-radius: 50%;
  border: 0; background: rgba(0, 0, 0, 0.6); color: #fff;
}
.file-remove:hover { background: var(--danger); }
.file-tile.add-tile {
  align-items: center; justify-content: center; gap: 6px;
  min-height: 140px; border-style: dashed; color: var(--muted); cursor: pointer; font-size: 0.85rem;
}
.file-tile.add-tile:hover { border-color: var(--accent); color: var(--text); }

.progress {
  height: 4px; border-radius: 4px; background: var(--surface-3); overflow: hidden; margin: 0 12px 12px;
}
.progress > div { height: 100%; width: 0; background: var(--accent); transition: width 0.2s; }

/* ---------- recent posts ---------- */
.section-head {
  display: flex; align-items: baseline; justify-content: space-between;
  margin: 32px 2px 10px;
}
.section-head h2 { font-size: 1rem; font-weight: 600; }
.section-head span { color: var(--faint); font-size: 0.82rem; }
.post-list { list-style: none; overflow: hidden; }
.post-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px 10px 14px;
  border-top: 1px solid var(--border);
}
.post-row:first-child { border-top: 0; }
.post-row:hover { background: var(--surface-2); }
.post-row .type-icon {
  display: grid; place-items: center; width: 34px; height: 34px; border-radius: 9px;
  background: var(--surface-3); color: var(--muted);
}
.post-row .info { flex: 1; min-width: 0; }
.post-row .title {
  display: block; color: var(--text); font-size: 0.92rem;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.post-row .title:hover { text-decoration: none; color: var(--accent); }
.post-row .sub { color: var(--faint); font-size: 0.78rem; }
.empty { padding: 18px; color: var(--faint); text-align: center; font-size: 0.9rem; }

/* ---------- post page ---------- */
.post-head { margin: 8px 0 14px; }
.post-head h1 {
  font-size: 1.35rem; font-weight: 700; letter-spacing: -0.01em;
  overflow-wrap: anywhere;
}
.post-meta {
  display: flex; flex-wrap: wrap; gap: 4px 10px; margin-top: 4px;
  color: var(--muted); font-size: 0.85rem;
}
.post-meta .dot { color: var(--faint); }
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 1px 8px; border-radius: 999px; background: var(--surface-3); color: var(--muted); font-size: 0.78rem;
}

.toolbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  padding: 8px 0;
  margin-bottom: 12px;
  background: linear-gradient(var(--bg) 80%, transparent);
}
.toolbar .spacer { flex: 1; }
.segmented {
  display: inline-flex; padding: 3px; gap: 2px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border);
}
.segmented button {
  border: 0; background: transparent; color: var(--muted);
  padding: 5px 12px; border-radius: 7px; font-size: 0.85rem;
}
.segmented button[aria-pressed="true"] { background: var(--surface-3); color: var(--text); }

.viewer { overflow: hidden; }
.state-msg { padding: 60px 20px; text-align: center; color: var(--muted); }
.state-msg h2 { color: var(--text); font-size: 1.2rem; margin-bottom: 6px; }

/* code */
.code-view { position: relative; }
.code-view pre {
  margin: 0;
  padding: 14px 0;
  overflow: auto;
  max-height: none;
  font-family: var(--mono);
  font-size: 0.85rem;
  line-height: 1.6;
  tab-size: 4;
}
.code-view pre code.hljs { background: transparent; padding: 0 16px; overflow: visible; }
.code-view.wrap pre { white-space: pre-wrap; overflow-wrap: anywhere; }
.hljs-ln { border-collapse: collapse; }
.hljs-ln td { padding: 0; vertical-align: top; }
td.hljs-ln-numbers {
  user-select: none; -webkit-user-select: none;
  text-align: right; color: var(--faint); padding-right: 16px !important;
  border-right: 1px solid var(--border); min-width: 44px;
}
td.hljs-ln-code { padding-left: 16px !important; }
.code-view .hljs { color: #d6deeb; }

/* markdown */
.markdown-body {
  padding: 28px 32px;
  font-size: 1rem;
  line-height: 1.7;
  overflow-wrap: break-word;
}
.markdown-body > *:first-child { margin-top: 0 !important; }
.markdown-body > *:last-child { margin-bottom: 0 !important; }
.markdown-body h1, .markdown-body h2, .markdown-body h3,
.markdown-body h4, .markdown-body h5, .markdown-body h6 {
  margin: 1.6em 0 0.6em; line-height: 1.3; font-weight: 700; letter-spacing: -0.01em;
}
.markdown-body h1 { font-size: 1.8em; padding-bottom: 0.3em; border-bottom: 1px solid var(--border); }
.markdown-body h2 { font-size: 1.45em; padding-bottom: 0.3em; border-bottom: 1px solid var(--border); }
.markdown-body h3 { font-size: 1.2em; }
.markdown-body h4 { font-size: 1.05em; }
.markdown-body h5, .markdown-body h6 { font-size: 0.95em; color: var(--muted); }
.markdown-body p, .markdown-body ul, .markdown-body ol, .markdown-body blockquote,
.markdown-body table, .markdown-body pre, .markdown-body details { margin: 0 0 1em; }
.markdown-body ul, .markdown-body ol { padding-left: 1.6em; }
.markdown-body li + li { margin-top: 0.25em; }
.markdown-body li > ul, .markdown-body li > ol { margin: 0.25em 0 0; }
.markdown-body li > p { margin: 0; }
.markdown-body ul.contains-task-list { list-style: none; padding-left: 0.4em; }
.markdown-body input[type="checkbox"] { margin-right: 0.45em; accent-color: var(--accent); vertical-align: -1px; }
.markdown-body a { text-decoration: underline; text-underline-offset: 3px; text-decoration-color: rgba(124, 140, 255, 0.4); }
.markdown-body a:hover { text-decoration-color: var(--accent); }
.markdown-body strong { font-weight: 700; color: #fff; }
.markdown-body hr { border: 0; height: 1px; background: var(--border); margin: 2em 0; }
.markdown-body blockquote {
  padding: 0.2em 1em; border-left: 3px solid var(--accent); color: var(--muted);
}
.markdown-body blockquote > :last-child { margin-bottom: 0; }
.markdown-body img, .markdown-body video { max-width: 100%; height: auto; border-radius: 8px; }
.markdown-body .table-wrap { overflow-x: auto; margin: 0 0 1em; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.markdown-body .table-wrap table { margin: 0; }
.markdown-body table { border-collapse: collapse; width: 100%; font-size: 0.93em; }
.markdown-body th, .markdown-body td { padding: 8px 12px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.markdown-body tr:last-child td { border-bottom: 0; }
.markdown-body th { background: var(--surface-2); font-weight: 600; white-space: nowrap; }
.markdown-body code {
  font-family: var(--mono); font-size: 0.86em;
  padding: 0.15em 0.4em; border-radius: 5px; background: var(--surface-3);
}
.markdown-body pre {
  position: relative;
  padding: 14px 16px; border-radius: var(--radius-sm);
  background: var(--bg); border: 1px solid var(--border);
  overflow-x: auto; line-height: 1.55;
}
.markdown-body pre code { padding: 0; background: transparent; font-size: 0.85em; }
.markdown-body pre code.hljs { padding: 0; background: transparent; }
.markdown-body .copy-code {
  position: absolute; top: 8px; right: 8px;
  min-height: 28px; padding: 0 9px; font-size: 0.78rem;
  opacity: 0; transition: opacity 0.15s;
}
.markdown-body pre:hover .copy-code, .markdown-body .copy-code:focus { opacity: 1; }
.markdown-body details { padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.markdown-body summary { cursor: pointer; font-weight: 600; }
.markdown-body kbd { font-size: 0.82em; }

/* media */
.media-view { display: grid; place-items: center; padding: 12px; background: #0b0c11; }
.media-view img { max-width: 100%; max-height: 78vh; border-radius: 8px; display: block; cursor: zoom-in; }
.media-view img.zoomed { max-height: none; cursor: zoom-out; }
.media-view video { width: 100%; max-height: 78vh; border-radius: 8px; background: #000; }
.audio-view { padding: 28px 20px; display: flex; flex-direction: column; align-items: center; gap: 16px; }
.audio-view .disc {
  width: 96px; height: 96px; border-radius: 50%;
  display: grid; place-items: center; color: #fff;
  background: linear-gradient(135deg, var(--accent), #b07cff);
}
.audio-view audio { width: 100%; max-width: 560px; }
.pdf-view iframe { display: block; width: 100%; height: 82vh; border: 0; background: #fff; }
.pdf-fallback { padding: 10px 14px; display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; color: var(--muted); font-size: 0.88rem; border-bottom: 1px solid var(--border); }

.file-view {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  padding: 48px 20px; text-align: center;
}
.file-view .file-badge {
  width: 72px; height: 88px; border-radius: 10px;
  display: grid; place-items: center;
  background: var(--surface-3); color: var(--muted);
  font-family: var(--mono); font-size: 0.8rem; font-weight: 700; text-transform: uppercase;
}
.file-view .name { font-weight: 600; overflow-wrap: anywhere; }
.file-view .size { color: var(--faint); font-size: 0.85rem; margin-bottom: 8px; }

/* gallery */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; padding: 12px; }
.gallery-item {
  position: relative; border-radius: var(--radius-sm); overflow: hidden;
  background: var(--surface-2); border: 1px solid var(--border);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.gallery-item.selected { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.gallery-item .thumb { display: block; aspect-ratio: 4 / 3; background: #0b0c11; }
.gallery-item .thumb img { width: 100%; height: 100%; object-fit: contain; display: block; }
.gallery-item .thumb .file-badge { width: 100%; height: 100%; display: grid; place-items: center; color: var(--muted); font-family: var(--mono); text-transform: uppercase; }
.gallery-item .bar { display: flex; align-items: center; gap: 4px; padding: 6px 6px 6px 10px; }
.gallery-item .bar .name { flex: 1; min-width: 0; font-size: 0.8rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gallery-item .bar .btn { min-height: 30px; width: 30px; }
.gallery-item .check {
  position: absolute; top: 8px; left: 8px;
  display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%;
  border: 2px solid #fff; background: rgba(0, 0, 0, 0.45); color: transparent;
}
.gallery-item.selected .check { background: var(--accent); border-color: var(--accent); color: #fff; }

/* lightbox */
.lightbox {
  position: fixed; inset: 0; z-index: 950;
  display: grid; place-items: center; padding: 16px;
  background: rgba(5, 6, 10, 0.92);
}
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 6px; }
.lightbox .btn { position: absolute; top: 14px; right: 14px; }

/* ---------- login ---------- */
.auth-card { max-width: 380px; margin: 6vh auto 0; padding: 28px; }
.auth-card h1 { font-size: 1.4rem; margin-bottom: 4px; }
.auth-card p.sub { color: var(--muted); margin-bottom: 20px; font-size: 0.92rem; }
.field { display: block; margin-bottom: 14px; }
.field span { display: block; font-size: 0.85rem; color: var(--muted); margin-bottom: 6px; }
.input {
  width: 100%; min-height: 44px; padding: 0 14px;
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: 1rem;
}
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input-wrap { position: relative; }
.input-wrap .input { padding-right: 70px; }
.input-wrap .reveal { position: absolute; right: 4px; top: 4px; min-height: 36px; font-size: 0.8rem; }
.form-error {
  margin-bottom: 14px; padding: 9px 12px; border-radius: var(--radius-sm);
  background: var(--danger-soft); color: var(--danger); font-size: 0.88rem;
}
.auth-card .btn-primary { width: 100%; }

.auth-alt { margin-top: 16px; text-align: center; color: var(--muted); font-size: 0.9rem; }
.field textarea.input { min-height: 80px; padding: 10px 14px; resize: vertical; }
.field small { display: block; margin-top: 5px; color: var(--faint); font-size: 0.8rem; }
.form-ok { text-align: center; padding: 8px 0; }
.form-ok .big { display: grid; place-items: center; width: 56px; height: 56px; margin: 0 auto 12px; border-radius: 50%; background: rgba(74, 222, 128, 0.12); color: var(--ok); }
.form-ok p { color: var(--muted); margin-top: 6px; }
.pill-count { display: inline-block; margin-left: 6px; min-width: 18px; padding: 0 5px; border-radius: 999px; background: var(--danger); color: #fff; font-size: 0.72rem; font-weight: 700; text-align: center; line-height: 18px; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom));
  z-index: 1000;
  display: flex; align-items: center; gap: 9px;
  max-width: calc(100vw - 32px);
  padding: 11px 18px; border-radius: 999px;
  background: var(--surface-3); border: 1px solid var(--border-strong); color: var(--text);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  font-size: 0.92rem;
  opacity: 0; transform: translate(-50%, 16px);
  transition: opacity 0.25s, transform 0.3s cubic-bezier(0.2, 0.9, 0.3, 1.2);
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast-ok .icon { color: var(--ok); }
.toast-error { border-color: rgba(255, 107, 107, 0.5); }
.toast-error .icon { color: var(--danger); }

/* ---------- mobile ---------- */
@media (max-width: 640px) {
  body { font-size: 15px; }
  .site-header { padding: 12px 16px; }
  main.page { padding: 4px 12px 32px; }
  .page-title { font-size: 1.35rem; }
  .composer { padding: 4px; border-radius: 12px; }
  .panel { padding: 10px 8px; }
  .composer-bar { padding: 0 8px 10px; }
  .composer-bar .hint { display: none; }
  .composer-bar .select { flex: 1; min-width: 0; }
  .composer-bar .btn-primary { flex: 1 1 100%; }
  .textarea { min-height: 200px; font-size: 0.85rem; }
  .dropzone { min-height: 190px; }
  .file-grid { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); }

  .toolbar { gap: 4px; }
  .toolbar .btn { padding: 0 10px; }
  .toolbar .btn .label { display: none; }
  .toolbar .btn.keep-label .label { display: inline; }

  .markdown-body { padding: 18px 16px; font-size: 0.97rem; }
  .markdown-body h1 { font-size: 1.55em; }
  .markdown-body h2 { font-size: 1.3em; }
  .markdown-body .copy-code { opacity: 1; }
  .code-view pre { font-size: 0.8rem; }
  td.hljs-ln-numbers { min-width: 32px; padding-right: 10px !important; }
  td.hljs-ln-code { padding-left: 10px !important; }
  .gallery { grid-template-columns: repeat(2, 1fr); gap: 8px; padding: 8px; }
  .pdf-view iframe { height: 70vh; }
  .auth-card { margin-top: 2vh; padding: 22px 18px; }
}

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

/* ---------- admin ---------- */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin: 8px 0 22px; }
.stat { display: flex; flex-direction: column; gap: 2px; padding: 14px 16px; box-shadow: none; }
.stat .label { color: var(--muted); font-size: 0.8rem; }
.stat .value { font-size: 1.5rem; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.stat .sub { color: var(--faint); font-size: 0.78rem; }
.admin-tabs { margin: 0 0 14px; background: var(--surface); border: 1px solid var(--border); }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.filters .input { flex: 1 1 240px; min-height: 38px; font-size: 0.92rem; }
.bulk {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 8px 8px 8px 14px; margin-bottom: 12px;
  border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--border);
  font-size: 0.9rem; color: var(--muted);
}
.bulk .spacer { flex: 1; }
.table-card { overflow: hidden; box-shadow: none; }
.data-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.data-table th {
  text-align: left; font-weight: 500; font-size: 0.78rem; color: var(--faint);
  text-transform: uppercase; letter-spacing: 0.04em;
  padding: 10px 12px; border-bottom: 1px solid var(--border); background: var(--surface);
}
.data-table td { padding: 8px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover { background: var(--surface-2); }
.data-table tr.selected { background: var(--accent-soft) !important; }
.data-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.data-table .col-check { width: 40px; }
.data-table input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; }
.data-table .col-actions { width: 1%; text-align: right; white-space: nowrap; }
.data-table .wide-actions .btn { min-height: 32px; font-size: 0.82rem; padding: 0 10px; }
.data-table .cell-name { display: flex; align-items: center; gap: 10px; min-width: 0; }
.data-table .type-icon {
  display: grid; place-items: center; flex-shrink: 0; width: 30px; height: 30px; border-radius: 8px;
  background: var(--surface-3); color: var(--muted); font-weight: 700; font-size: 0.85rem;
}
.data-table .avatar { border-radius: 50%; background: var(--accent-soft); color: var(--accent); }
.name-wrap { display: flex; flex-direction: column; min-width: 0; }
.name-wrap a, .name-wrap b, .name-wrap .mono { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 46ch; }
.name-wrap .sub { color: var(--faint); font-size: 0.78rem; }
.mono { font-family: var(--mono); font-size: 0.85rem; }
.muted { color: var(--faint); }
.warn { color: #fbbf24; }
.danger-hover:hover { color: var(--danger); background: var(--danger-soft); }
.table-foot { padding: 10px 14px; color: var(--faint); font-size: 0.82rem; border-top: 1px solid var(--border); }
.data-table .empty { text-align: center; padding: 28px; }
.status { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 0.76rem; font-weight: 600; text-transform: capitalize; }
.s-active { background: rgba(74, 222, 128, 0.12); color: var(--ok); }
.s-disabled { background: var(--danger-soft); color: var(--danger); }
.s-pending { background: rgba(251, 191, 36, 0.12); color: #fbbf24; }
.s-admin { background: var(--accent-soft); color: var(--accent); }
.sub-head { font-size: 0.95rem; font-weight: 600; margin: 4px 2px 10px; }
.request-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; margin-bottom: 22px; }
.request { display: flex; flex-direction: column; gap: 8px; padding: 14px; box-shadow: none; border-color: rgba(251, 191, 36, 0.35); }
.request .who { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.request .who .sub { color: var(--faint); font-size: 0.78rem; }
.request .note { color: var(--muted); font-size: 0.88rem; overflow-wrap: anywhere; }
.request .actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: auto; }

@media (max-width: 800px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 640px) {
  .stats { gap: 8px; margin-bottom: 16px; }
  .stat { padding: 10px 12px; }
  .stat .value { font-size: 1.2rem; }
  .filters .select { flex: 1 1 30%; min-width: 0; }
  /* Tables become stacked cards */
  .data-table thead { display: none; }
  .data-table, .data-table tbody { display: block; }
  .data-table tr {
    display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; align-items: center;
    padding: 10px 12px; border-bottom: 1px solid var(--border);
  }
  .data-table tbody tr:last-child { border-bottom: 0; }
  .data-table td { display: block; padding: 0; border: 0; }
  .data-table td.col-name { grid-column: 1; grid-row: 1; }
  .data-table td.col-actions { grid-column: 2; grid-row: 1; width: auto; }
  .data-table td.col-check { display: none; }
  .data-table td[data-label] { grid-column: 1 / -1; font-size: 0.82rem; color: var(--muted); text-align: left; padding-left: 40px; }
  .data-table td[data-label]::before { content: attr(data-label) ": "; color: var(--faint); }
  .data-table td[data-label=""] { padding-left: 0; }
  .data-table td[data-label=""]::before { content: none; }
  .data-table td.empty { grid-column: 1 / -1; }
  .name-wrap a, .name-wrap b, .name-wrap .mono { max-width: 60vw; }
  .data-table .wide-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 4px; }
}
