@import url('https://fonts.googleapis.com/css2?family=Fira+Code:wght@400;500&family=Fira+Sans:wght@400;500;600;700&display=swap');

:root {
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-soft: #eff6ff;
  --accent: #059669;
  --bg: #f8fafc;
  --card: #ffffff;
  --border: #e2e8f0;
  --text: #0f172a;
  --muted: #64748b;
  --muted-bg: #f1f5f9;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --ok: #059669;
  --sidebar: #0f172a;
  --sidebar-hover: #1e293b;
  --sidebar-text: #94a3b8;
  --sidebar-active: #ffffff;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.08);
  --radius: 10px;
  --radius-sm: 6px;
  --transition: 180ms ease;
  --brand: var(--primary);
  --brand-dark: var(--primary-hover);
}

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

body {
  font: 14px/1.6 'Fira Sans', -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Microsoft YaHei', sans-serif;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

body.auth-loading #login-screen,
body.auth-loading #app {
  display: none !important;
}

.auth-loading-screen {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  color: var(--muted);
  font-size: 14px;
}

body:not(.auth-loading) .auth-loading-screen {
  display: none !important;
}

a { color: var(--primary); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--primary-hover); }

/* Login */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: radial-gradient(ellipse at top, #dbeafe 0%, var(--bg) 55%);
}

.login-box {
  background: var(--card);
  padding: 2rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-md);
}

.login-brand {
  margin-bottom: 1.75rem;
}

.login-box h1 { font-size: 1.25rem; font-weight: 700; letter-spacing: -.02em; }
.login-box p { color: var(--muted); font-size: 13px; margin-top: .15rem; }

.login-box label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  margin: .875rem 0 .35rem;
  color: var(--muted);
}

.login-box input {
  width: 100%;
  padding: .625rem .75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font: inherit;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.login-box input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.error { color: var(--danger); font-size: 12px; margin-top: .75rem; }

/* Layout */
html, body { min-height: 100%; }

.app {
  display: flex;
  width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
}

.content-wrap {
  flex: 1 1 0%;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}

.main {
  flex: 1 1 auto;
  width: 100%;
  max-width: none;
  padding: 1.5rem 2rem;
  overflow-x: hidden;
  overflow-y: auto;
}

.mobile-header { display: none; }

.sidebar-backdrop { display: none; }

.aside {
  width: 240px;
  background: var(--sidebar);
  color: var(--sidebar-text);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  border-right: 1px solid rgba(255, 255, 255, 0.06);
}

.aside-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-close {
  display: none;
  width: 44px;
  height: 44px;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--sidebar-text);
  cursor: pointer;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
  margin-right: .25rem;
  transition: background var(--transition);
}

.sidebar-close:hover { background: var(--sidebar-hover); }

.close-icon {
  position: relative;
  width: 18px;
  height: 18px;
}

.close-icon::before,
.close-icon::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 18px;
  height: 2px;
  background: currentColor;
  border-radius: 1px;
}

.close-icon::before { transform: translate(-50%, -50%) rotate(45deg); }
.close-icon::after { transform: translate(-50%, -50%) rotate(-45deg); }

.brand {
  display: flex;
  align-items: center;
  padding: 1.125rem 1rem;
  font-weight: 600;
  font-size: 15px;
  color: var(--sidebar-active);
  flex: 1;
  min-width: 0;
}

.nav { flex: 1; padding: .75rem 0; overflow-y: auto; }

.nav-group { margin-bottom: .5rem; }

.nav-label {
  display: block;
  padding: .5rem 1rem .25rem;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: #64748b;
}

.nav a {
  display: flex;
  align-items: center;
  gap: .625rem;
  padding: .55rem 1rem;
  margin: 1px .5rem;
  color: var(--sidebar-text);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  border-radius: var(--radius-sm);
  border-left: none;
  transition: background var(--transition), color var(--transition);
}

.nav a:hover {
  background: var(--sidebar-hover);
  color: #e2e8f0;
}

.nav a.active {
  background: rgba(37, 99, 235, 0.18);
  color: #fff;
}

.nav-external { opacity: .85; }

.nav-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  opacity: .75;
  background: currentColor;
  mask-size: contain;
  mask-repeat: no-repeat;
  mask-position: center;
  -webkit-mask-size: contain;
  -webkit-mask-repeat: no-repeat;
  -webkit-mask-position: center;
}

.nav a.active .nav-icon { opacity: 1; }

.nav-icon[data-icon="dashboard"] { mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='white'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M4 6h16M4 12h16M4 18h7'/%3E%3C/svg%3E"); -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='white'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M4 6h16M4 12h16M4 18h7'/%3E%3C/svg%3E"); }
.nav-icon[data-icon="write"] { mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='white'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z'/%3E%3C/svg%3E"); -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='white'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z'/%3E%3C/svg%3E"); }
.nav-icon[data-icon="import"] { mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='white'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-4l-4 4m0 0l-4-4m4 4V4'/%3E%3C/svg%3E"); -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='white'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-4l-4 4m0 0l-4-4m4 4V4'/%3E%3C/svg%3E"); }
.nav-icon[data-icon="posts"] { mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='white'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z'/%3E%3C/svg%3E"); -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='white'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z'/%3E%3C/svg%3E"); }
.nav-icon[data-icon="pages"] { mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='white'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z'/%3E%3C/svg%3E"); -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='white'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z'/%3E%3C/svg%3E"); }
.nav-icon[data-icon="comments"] { mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='white'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z'/%3E%3C/svg%3E"); -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='white'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z'/%3E%3C/svg%3E"); }
.nav-icon[data-icon="media"] { mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='white'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z'/%3E%3C/svg%3E"); -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='white'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z'/%3E%3C/svg%3E"); }
.nav-icon[data-icon="attachments"] { mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='white'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M15.172 7l-6.586 6.586a2 2 0 102.828 2.828l6.414-6.586a4 4 0 00-5.656-5.656l-6.415 6.585a6 6 0 108.486 8.486L20.5 13'/%3E%3C/svg%3E"); -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='white'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M15.172 7l-6.586 6.586a2 2 0 102.828 2.828l6.414-6.586a4 4 0 00-5.656-5.656l-6.415 6.585a6 6 0 108.486 8.486L20.5 13'/%3E%3C/svg%3E"); }
.nav-icon[data-icon="categories"] { mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='white'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M3 7v10a2 2 0 002 2h14a2 2 0 002-2V9a2 2 0 00-2-2h-6l-2-2H5a2 2 0 00-2 2z'/%3E%3C/svg%3E"); -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='white'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M3 7v10a2 2 0 002 2h14a2 2 0 002-2V9a2 2 0 00-2-2h-6l-2-2H5a2 2 0 00-2 2z'/%3E%3C/svg%3E"); }
.nav-icon[data-icon="tags"] { mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='white'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M7 7h.01M7 3h5c.512 0 1.024.195 1.414.586l7 7a2 2 0 010 2.828l-7 7a2 2 0 01-2.828 0l-7-7A1.994 1.994 0 013 12V7a4 4 0 014-4z'/%3E%3C/svg%3E"); -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='white'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M7 7h.01M7 3h5c.512 0 1.024.195 1.414.586l7 7a2 2 0 010 2.828l-7 7a2 2 0 01-2.828 0l-7-7A1.994 1.994 0 013 12V7a4 4 0 014-4z'/%3E%3C/svg%3E"); }
.nav-icon[data-icon="keywords"] { mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='white'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z'/%3E%3C/svg%3E"); -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='white'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z'/%3E%3C/svg%3E"); }
.nav-icon[data-icon="settings"] { mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='white'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z'/%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M15 12a3 3 0 11-6 0 3 3 0 016 0z'/%3E%3C/svg%3E"); -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='white'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z'/%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M15 12a3 3 0 11-6 0 3 3 0 016 0z'/%3E%3C/svg%3E"); }
.nav-icon[data-icon="external"] { mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='white'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14'/%3E%3C/svg%3E"); -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='white'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14'/%3E%3C/svg%3E"); }

.aside-foot {
  padding: .875rem 1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.user-chip {
  display: flex;
  align-items: center;
  gap: .5rem;
  margin-bottom: .5rem;
}

.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, #475569, #64748b);
}

.user-name {
  font-size: 13px;
  font-weight: 500;
  color: #e2e8f0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.btn-text {
  background: none;
  border: none;
  color: var(--sidebar-text);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
  padding: 0;
  transition: color var(--transition);
}

.btn-text:hover { color: #fff; }

.badge {
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 999px;
  margin-left: auto;
}

.page-head { margin-bottom: 1.25rem; }
.page-head h1, .main > h1, .toolbar h1 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -.02em;
  margin-bottom: .25rem;
}

.page-desc { color: var(--muted); font-size: 13px; }

/* Tabs */
.tabs-bar {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
  padding: .35rem;
  background: var(--muted-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 1.25rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.tabs-bar::-webkit-scrollbar { display: none; }

.tab-btn {
  padding: .45rem .875rem;
  border: none;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  border-radius: var(--radius-sm);
  cursor: pointer;
  flex-shrink: 0;
  white-space: nowrap;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  transition: background var(--transition), color var(--transition), box-shadow var(--transition);
}

.tab-btn:hover { color: var(--text); background: rgba(255, 255, 255, 0.6); }

.tab-btn.active {
  background: var(--card);
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}

.tab-panel { animation: fadeIn .2s ease; }

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

@media (prefers-reduced-motion: reduce) {
  .tab-panel { animation: none; }
  .aside,
  .sidebar-backdrop { transition: none !important; }
  *, *::before, *::after { transition-duration: 0.01ms !important; }
}

/* Cards & stats */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow-sm);
  width: 100%;
}

.card-title {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 1rem;
  color: var(--text);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.125rem;
  box-shadow: var(--shadow-sm);
}

.stat-card .stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
  font-family: 'Fira Code', monospace;
}

.stat-card .stat-label {
  font-size: 12px;
  color: var(--muted);
  margin-top: .25rem;
}

.stat-card.highlight { border-color: #bfdbfe; background: var(--primary-soft); }
.stat-card.warn { border-color: #fecaca; background: var(--danger-soft); }

.storage-stats-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-bottom: 1rem;
}

.storage-stat-card {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 88px;
}

.storage-stat-card .stat-value-sm {
  font-size: 1.125rem;
  font-weight: 700;
  font-family: inherit;
  line-height: 1.35;
  word-break: break-word;
}

.storage-blocks {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}

.storage-block {
  margin: 0;
  padding: 1rem 1.125rem;
}

.storage-block-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  margin-bottom: .75rem;
}

.storage-block-title {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

.storage-status {
  flex-shrink: 0;
  padding: .18rem .55rem;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.35;
}

.storage-status.ok {
  background: #dcfce7;
  color: #166534;
}

.storage-status.off {
  background: var(--muted-bg);
  color: var(--muted);
  border: 1px solid var(--border);
}

.storage-block-rows {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--muted-bg);
}

.storage-block-row {
  display: grid;
  grid-template-columns: 3.5rem 1fr auto;
  gap: .5rem;
  align-items: center;
  padding: .55rem .75rem;
  font-size: 13px;
  background: var(--card);
}

.storage-block-row + .storage-block-row {
  border-top: 1px solid var(--border);
}

.storage-type {
  color: var(--muted);
  font-weight: 500;
}

.storage-count {
  font-variant-numeric: tabular-nums;
}

.storage-size {
  font-variant-numeric: tabular-nums;
  font-family: 'Fira Code', Monaco, Menlo, monospace;
  font-size: 12px;
  color: var(--muted);
  text-align: right;
}

.storage-block-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .35rem;
  margin-top: .75rem;
  font-size: 12px;
}

.storage-foot-divider {
  color: var(--muted);
}

.storage-actions-card {
  padding: 1rem 1.125rem;
}

.settings-tabs-bar {
  flex-wrap: nowrap;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scroll-snap-type: x proximity;
  margin-bottom: 1rem;
}

.settings-tabs-bar .tab-btn {
  flex: 0 0 auto;
  white-space: nowrap;
  scroll-snap-align: start;
}

/* Forms */
.form-label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  margin: .75rem 0 .35rem;
}

.form-label:first-child { margin-top: 0; }

.form-control {
  width: 100%;
  padding: .5rem .75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: 13px;
  background: var(--card);
  transition: border-color var(--transition), box-shadow var(--transition);
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.form-control.mono { font-family: 'Fira Code', Monaco, Menlo, monospace; font-size: 12px; }

.form-check {
  display: flex;
  align-items: center;
  gap: .5rem;
  margin: .5rem 0;
  font-size: 13px;
  cursor: pointer;
}

.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .875rem;
}

.form-row-inline {
  display: flex;
  gap: .5rem;
  align-items: center;
}

.form-row-inline .form-control { flex: 1; min-width: 0; }

.img-field {
  display: flex;
  flex-direction: column;
  gap: .5rem;
}

.img-field .form-control {
  width: 100%;
}

.img-field-actions {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
  align-items: center;
}

.img-field-actions .btn.sm {
  white-space: nowrap;
  padding: .32rem .6rem;
  font-size: 12px;
  line-height: 1.35;
}

.form-save-row {
  margin-top: 1.25rem;
}

.form-save-row .btn {
  width: auto;
  min-width: 96px;
}

.slider-rows {
  display: flex;
  flex-direction: column;
  gap: .75rem;
}

.slider-rows-empty {
  margin: 0;
  padding: .75rem 0;
}

.slider-add-btn {
  margin-top: .75rem;
}

.slider-row {
  display: block;
  padding: 1rem 1.125rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow-sm);
}

.slider-row-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  margin-bottom: .875rem;
}

.slider-row-index {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.slider-row-body {
  display: grid;
  grid-template-columns: 148px minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
}

.slider-preview-col {
  min-width: 0;
}

.slider-preview {
  aspect-ratio: 16 / 9;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--muted-bg);
  border: 1px solid var(--border);
}

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

.slider-preview-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 84px;
  color: var(--muted);
  font-size: 12px;
}

.slider-fields-col {
  min-width: 0;
}

.slider-meta-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .75rem;
  margin-top: .75rem;
}

.slider-row .slider-img-col {
  min-width: 0;
}

.modal-box.modal-wide {
  max-width: 720px;
}

.image-picker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: .5rem;
  max-height: 52vh;
  overflow-y: auto;
  margin-top: .75rem;
}

.image-picker-item {
  aspect-ratio: 1;
  cursor: pointer;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--surface-2, #f5f6f7);
  transition: border-color var(--transition), box-shadow var(--transition);
}

.image-picker-item:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-sm);
}

.image-picker-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.main.page-loading {
  opacity: 0.72;
  pointer-events: none;
  transition: opacity .15s ease;
}

.image-picker-tabs {
  display: flex;
  gap: .35rem;
  flex-wrap: wrap;
  margin-top: .5rem;
}

.logo-preview {
  margin: .5rem 0 1rem;
  padding: .75rem 1rem;
  background: var(--surface-2, #f5f6f7);
  border-radius: 8px;
  display: inline-block;
}

.logo-preview img {
  height: 36px;
  width: auto;
  display: block;
}

.form-hint { font-size: 12px; color: var(--muted); margin-top: .35rem; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .35rem;
  padding: .5rem 1rem;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  border-radius: var(--radius-sm);
  transition: background var(--transition), border-color var(--transition), color var(--transition), box-shadow var(--transition);
}

.btn:hover { background: var(--muted-bg); }
.btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

.btn.primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.btn.primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }

.btn.danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn.danger:hover { background: #b91c1c; }

.btn.sm { padding: .3rem .625rem; font-size: 12px; }
.btn.block { width: 100%; margin-top: .5rem; }

.grid-2 {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 320px);
  gap: 1.25rem;
  align-items: start;
  width: 100%;
}

.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
  gap: 1rem;
  flex-wrap: wrap;
  width: 100%;
}

.toolbar-actions { display: flex; gap: .5rem; flex-wrap: wrap; }

.posts-filter-bar { margin-bottom: 1rem; padding: .875rem 1rem; }

.posts-filters {
  display: grid;
  grid-template-columns: minmax(180px, 2fr) repeat(2, minmax(120px, 1fr)) auto auto;
  gap: .625rem;
  align-items: center;
}

.posts-summary { margin: .75rem 1rem 0; }

.posts-pager { padding: 0 1rem 1rem; }

/* Table */
.table-wrap { width: 100%; overflow-x: auto; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }

table.data-table { table-layout: fixed; }

table.data-table .col-title { width: auto; }

table.data-table .col-compact { width: 110px; white-space: nowrap; }

table.data-table .col-actions { width: 200px; white-space: nowrap; text-align: right; }

table.data-table .col-actions .btn { margin-left: .25rem; }

th, td {
  padding: .75rem .875rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

th {
  color: var(--muted);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .04em;
  background: var(--muted-bg);
}

tr:hover td { background: #fafbfc; }

.status {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
}

.status-published { background: #dcfce7; color: #166534; }
.status-draft { background: #fef9c3; color: #854d0e; }
.status-waiting { background: #fee2e2; color: #991b1b; }
.status-approved { background: #dcfce7; color: #166534; }
.status-spam { background: var(--muted-bg); color: var(--muted); }

.panel {
  background: var(--muted-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1rem;
}

.panel h3 {
  font-size: 12px;
  margin-bottom: 0;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  margin-bottom: .75rem;
}

.panel-head h3 { flex: 1; min-width: 0; }

.panel-head .btn.sm {
  padding: .2rem .5rem;
  font-size: 11px;
  flex-shrink: 0;
}

.panel-head label {
  display: block;
  font-size: 12px;
  margin: 0;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.panel-quick {
  background: var(--primary-soft);
  border-color: #bfdbfe;
}

.panel-quick .btn.block { width: 100%; }

.panel-quick .form-hint { margin-top: .5rem; margin-bottom: 0; text-align: center; }

.panel > h3 { margin-bottom: .75rem; }

.panel-field { margin-bottom: .75rem; }

.panel-field:last-child { margin-bottom: 0; }

.panel-field > label {
  display: block;
  font-size: 12px;
  margin: 0 0 .35rem;
  color: var(--muted);
}

.panel-checks {
  display: flex;
  flex-direction: column;
  gap: .625rem;
  margin-top: .75rem;
  padding-top: .75rem;
  border-top: 1px solid var(--border);
}

.panel .form-check {
  display: flex;
  align-items: center;
  gap: .5rem;
  margin: 0;
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  user-select: none;
}

.panel .form-check input[type="checkbox"],
.panel .form-check input[type="radio"] {
  width: 1rem;
  height: 1rem;
  margin: 0;
  flex-shrink: 0;
  accent-color: var(--primary);
  cursor: pointer;
}

.panel-note {
  font-size: 11px;
  color: var(--muted);
  margin-top: .35rem;
  line-height: 1.5;
}

.write-sidebar {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-width: 0;
}

.panel input:not([type="checkbox"]):not([type="radio"]),
.panel select,
.panel textarea {
  width: 100%;
  padding: .45rem .625rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  background: var(--card);
}

.panel textarea { min-height: 72px; resize: vertical; }

.write-title {
  font-size: 1.625rem;
  font-weight: 700;
  width: 100%;
  border: none;
  border-bottom: 2px solid var(--border);
  padding: .5rem 0;
  margin-bottom: 1rem;
  outline: none;
  background: transparent;
  letter-spacing: -.02em;
}

.write-title:focus { border-bottom-color: var(--primary); }

.write-slug { font-size: 12px; color: var(--muted); margin-bottom: 1rem; }
.write-slug input {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .3rem .5rem;
  width: 200px;
  margin-left: .5rem;
  font-family: 'Fira Code', monospace;
}

.write-editor-wrap { margin-bottom: .75rem; }

.write-editor-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  flex-wrap: wrap;
  margin-bottom: .5rem;
}

.write-editor-meta {
  display: flex;
  align-items: center;
  gap: .75rem;
  font-size: 12px;
  color: var(--muted);
}

.write-editor-count {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.write-fullscreen-btn {
  font-size: 12px;
  padding: .2rem 0;
}

.write-editor-tabs {
  display: flex;
  gap: .35rem;
  flex-wrap: wrap;
}

.write-editor-tabs .tab-btn {
  padding: .35rem .75rem;
  font-size: 12px;
}

.write-editor-pane {
  position: relative;
}

.write-editor-wrap.mode-split .write-editor-pane {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .75rem;
  align-items: stretch;
}

.write-editor-wrap.mode-split .write-body,
.write-editor-wrap.mode-split .write-preview {
  min-height: 420px;
  max-height: 70vh;
}

.write-editor-wrap.mode-split .write-preview {
  display: block !important;
}

.write-editor-wrap.mode-split .write-body {
  display: block !important;
}

.write-editor-wrap.is-fullscreen {
  position: fixed;
  inset: 0;
  z-index: 1500;
  background: var(--bg);
  padding: 1rem;
  margin: 0;
  overflow: auto;
}

.write-editor-wrap.is-fullscreen .write-body,
.write-editor-wrap.is-fullscreen .write-preview {
  min-height: calc(100vh - 220px);
}

body.editor-fullscreen { overflow: hidden; }

.write-editor-foot {
  margin: .5rem 0 0;
  font-size: 11px;
}

.md-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .35rem .5rem;
  padding: .5rem .6rem;
  margin-bottom: .5rem;
  background: var(--muted-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.md-toolbar-group {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  flex-wrap: nowrap;
}

.md-toolbar-divider {
  width: 1px;
  height: 22px;
  background: var(--border);
  margin: 0 .15rem;
  flex-shrink: 0;
}

.md-tool {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 30px;
  padding: 0 .65rem;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 12px;
  line-height: 1.2;
  white-space: nowrap;
  flex-shrink: 0;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition), color var(--transition);
  user-select: none;
}

.md-tool-compact {
  min-width: 30px;
  padding: 0 .45rem;
}

.md-tool:hover {
  background: var(--card);
  border-color: var(--border);
}

.md-tool:active,
.md-tool.active {
  background: var(--primary-soft);
  border-color: #bfdbfe;
  color: var(--primary);
}

.md-tool-mono {
  font-family: 'Fira Code', Monaco, Menlo, monospace;
  font-size: 11px;
}

.md-tool input[type="file"] { display: none; }

.write-body {
  width: 100%;
  min-height: 420px;
  border: 1px solid var(--border);
  border-top-left-radius: 0;
  border-top-right-radius: 0;
  border-bottom-left-radius: var(--radius-sm);
  border-bottom-right-radius: var(--radius-sm);
  border-top: none;
  padding: .875rem;
  font-family: 'Fira Code', Monaco, Menlo, monospace;
  font-size: 13px;
  resize: vertical;
  line-height: 1.7;
  transition: border-color var(--transition), background var(--transition);
}

.md-toolbar + .write-editor-pane .write-body {
  border-top: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.write-body:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.write-body.drag-over { border-color: var(--primary); background: var(--primary-soft); }
.write-body.uploading { opacity: .65; pointer-events: none; }

.write-editor-wrap.mode-split .write-body,
.write-editor-wrap.mode-split .write-preview {
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.write-preview {
  width: 100%;
  min-height: 420px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1rem 1.125rem;
  background: #fff;
  overflow: auto;
  line-height: 1.75;
  font-size: 14px;
}

.post-title-link {
  color: var(--text);
  text-decoration: none;
  font-weight: 500;
}

.post-title-link:hover {
  color: var(--primary);
  text-decoration: underline;
}

.post-preview-modal .post-preview-body {
  min-height: 200px;
  max-height: 55vh;
  margin-top: .75rem;
}

.media-preview-modal .media-preview-body {
  text-align: center;
  margin: .75rem 0;
  max-height: 65vh;
  overflow: auto;
  background: var(--muted-bg);
  border-radius: var(--radius-sm);
  padding: .5rem;
}

.media-preview-modal .media-preview-body img {
  max-width: 100%;
  max-height: 60vh;
  object-fit: contain;
  display: block;
  margin: 0 auto;
  border-radius: var(--radius-sm);
}

.media-preview-url {
  word-break: break-all;
  font-size: 11px;
  margin-bottom: 0;
}

.data-table .muted-color {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.write-preview img {
  max-width: 100%;
  height: auto;
  border-radius: 6px;
  margin: .75rem 0;
}

.write-preview pre {
  background: #0f172a;
  color: #e2e8f0;
  padding: .875rem 1rem;
  border-radius: 6px;
  overflow: auto;
  font-size: 13px;
  line-height: 1.6;
}

.write-preview code {
  font-family: 'Fira Code', Monaco, Menlo, monospace;
  font-size: .9em;
}

.write-preview blockquote {
  margin: .75rem 0;
  padding-left: 1rem;
  border-left: 3px solid var(--border);
  color: var(--muted);
}

.write-md-tools {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .5rem .75rem;
  margin-top: .5rem;
}
.write-md-tools .form-hint { margin: 0; }
.md-sample {
  margin: .5rem 0 .75rem;
  padding: .65rem .75rem;
  background: #0f172a;
  color: #e2e8f0;
  border-radius: 6px;
  font-size: 12px;
  line-height: 1.5;
  overflow-x: auto;
  white-space: pre-wrap;
}

.cat-tree {
  max-height: 160px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .5rem;
  background: var(--card);
}

.cat-tree label,
.cat-tree .cat-item {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: 13px;
  margin: .15rem 0;
  padding: .35rem .5rem;
  border-radius: var(--radius-sm);
  color: var(--text);
  cursor: pointer;
  transition: background var(--transition);
}

.cat-tree label:hover,
.cat-tree .cat-item:hover { background: var(--muted-bg); }

.cat-tree label span,
.cat-tree .cat-item span { flex: 1; min-width: 0; }

.cat-tree input[type="checkbox"] {
  width: 1rem;
  height: 1rem;
  margin: 0;
  flex-shrink: 0;
  accent-color: var(--primary);
}

.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
  gap: 1rem;
}

.media-item {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .5rem;
  background: var(--card);
  transition: border-color var(--transition), box-shadow var(--transition);
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.media-item:hover {
  border-color: #cbd5e1;
  box-shadow: var(--shadow-sm);
}

.media-thumb {
  position: relative;
  cursor: zoom-in;
  border-radius: var(--radius-sm);
  overflow: hidden;
  aspect-ratio: 1;
  background: var(--muted-bg);
  margin-bottom: .5rem;
}

.media-thumb-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 42, 0.42);
  color: #fff;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: .02em;
  opacity: 0;
  transition: opacity var(--transition);
  pointer-events: none;
}

.media-thumb:hover .media-thumb-overlay { opacity: 1; }

.media-badge {
  position: absolute;
  top: .4rem;
  left: .4rem;
  padding: .12rem .4rem;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 600;
  line-height: 1.35;
  color: #fff;
  pointer-events: none;
  z-index: 1;
  backdrop-filter: blur(4px);
}

.media-badge.github { background: rgba(36, 41, 46, .78); }
.media-badge.r2 { background: rgba(245, 158, 11, .88); }

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

.attachment-table .attachment-file-cell {
  display: flex;
  align-items: center;
  gap: .75rem;
  min-width: 0;
}

.attachment-ext-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 42px;
  height: 42px;
  padding: 0 .35rem;
  border-radius: var(--radius-sm);
  background: var(--muted-bg);
  border: 1px solid var(--border);
  font-size: 11px;
  font-weight: 600;
  color: var(--primary);
  flex-shrink: 0;
}

.attachment-file-meta {
  display: flex;
  flex-direction: column;
  gap: .15rem;
  min-width: 0;
}

.attachment-file-name {
  font-weight: 500;
  word-break: break-all;
}

.attachment-file-mime {
  font-size: 11px;
  color: var(--muted);
}

.attachment-actions {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
  align-items: center;
}

.attachment-actions .btn {
  white-space: nowrap;
  flex-shrink: 0;
}

.attachment-table .source-badge {
  position: static;
  display: inline-block;
  padding: .15rem .5rem;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.35;
  color: #fff;
  pointer-events: none;
}

.attachment-table .source-badge.github { background: rgba(36, 41, 46, .88); }
.attachment-table .source-badge.r2,
.source-badge.r2 { background: rgba(245, 158, 11, .92); }

.source-badge {
  display: inline-block;
  padding: .15rem .5rem;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.35;
  color: #fff;
}

.source-badge.github { background: rgba(36, 41, 46, .88); }

.attachment-mobile-head {
  display: flex;
  align-items: flex-start;
  gap: .75rem;
}

.attachment-mobile-head .admin-mobile-card-title {
  margin: 0;
  font-size: 15px;
}

.attachment-mobile-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .45rem .65rem;
  margin-top: .65rem;
  font-size: 12px;
  color: var(--muted);
}

.attachment-mobile-actions {
  display: grid !important;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: .5rem !important;
  margin-top: .85rem !important;
}

.attachment-mobile-actions .btn {
  width: 100%;
  min-height: 40px;
  justify-content: center;
  padding: .45rem .5rem !important;
  font-size: 13px !important;
}

.media-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  min-width: 0;
}

.media-meta {
  flex: 1;
  min-width: 0;
  font-size: 11px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.4;
}

.media-icon-actions {
  display: inline-flex;
  align-items: center;
  gap: .15rem;
  flex-shrink: 0;
}

.media-act {
  width: 30px;
  height: 30px;
  padding: 0;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition), color var(--transition);
}

.media-act:hover {
  background: var(--muted-bg);
  color: var(--text);
}

.media-act-danger:hover {
  background: var(--danger-soft);
  color: var(--danger);
}

.media-act svg {
  display: block;
  width: 15px;
  height: 15px;
}

/* legacy */
.media-actions {
  display: none;
}

.theme-card {
  display: inline-block;
  width: 168px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin: .5rem .5rem 0 0;
  text-align: center;
  cursor: pointer;
  vertical-align: top;
  transition: border-color var(--transition), background var(--transition), box-shadow var(--transition);
}

.theme-card:hover { border-color: #93c5fd; }
.theme-card.active { border-color: var(--primary); background: var(--primary-soft); box-shadow: var(--shadow-sm); }

.quick-links { list-style: none; }
.quick-links li { margin: .4rem 0; }
.quick-links a { font-size: 13px; font-weight: 500; }

.toast {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  background: var(--sidebar);
  color: #fff;
  padding: .75rem 1.125rem;
  font-size: 13px;
  border-radius: var(--radius-sm);
  z-index: 999;
  box-shadow: var(--shadow-md);
  animation: fadeIn .2s ease;
}

.preset-list label {
  display: block;
  padding: .625rem .75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: .5rem;
  cursor: pointer;
  font-size: 13px;
  transition: background var(--transition);
}

.preset-list label:hover { background: var(--muted-bg); }
.preset-list input { margin-right: .5rem; }

.widget-check label { display: block; margin: .4rem 0; font-size: 13px; cursor: pointer; }

.route-preview-box {
  background: var(--primary-soft);
  border: 1px solid #bfdbfe;
  border-radius: var(--radius);
  padding: 1.125rem;
  margin-bottom: 1rem;
}

.route-preview-box h3 { font-size: 13px; color: var(--text); margin-bottom: .75rem; font-weight: 600; }

.route-preview-table { width: 100%; font-size: 13px; }
.route-preview-table td { padding: .5rem .625rem; border-bottom: 1px solid rgba(37, 99, 235, 0.12); vertical-align: top; }
.route-preview-table td:first-child { color: var(--muted); width: 90px; white-space: nowrap; }
.route-preview-real thead th { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; text-align: left; padding-bottom: .5rem; border-bottom: 1px solid #bfdbfe; }
.route-preview-real .tpl { color: var(--muted); font-size: 12px; font-family: 'Fira Code', monospace; }
.route-preview-real .real-url a { color: var(--primary); word-break: break-all; }
.real-title { color: var(--muted); font-size: 12px; }
.real-fallback { color: var(--danger); font-size: 12px; }

.help-box {
  background: var(--primary-soft);
  border: 1px solid #bfdbfe;
  border-radius: var(--radius-sm);
  padding: 1rem 1.125rem;
  margin: 1rem 0;
  font-size: 13px;
  line-height: 1.65;
}

.help-box-title {
  font-weight: 600;
  font-size: 13px;
  margin-bottom: .5rem;
  color: var(--text);
}

.help-box ol {
  margin: .5rem 0 .75rem 1.25rem;
  color: var(--muted);
}

.help-box li { margin: .35rem 0; }

.help-box li strong { color: var(--text); font-weight: 600; }

.quick-links {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  margin-top: .75rem;
}

.quick-links .btn { font-size: 12px; padding: .4rem .75rem; }

.github-fields { margin-top: .75rem; }

.url-preview-box {
  background: var(--muted-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .75rem;
  font-size: 12px;
}

.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
}

.modal-box {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-md);
}

.modal-box h2 { font-size: 1.125rem; font-weight: 600; margin-bottom: 1rem; }
.modal-box label { display: block; font-size: 12px; color: var(--muted); margin: .65rem 0 .25rem; }
.modal-box input, .modal-box textarea, .modal-box select {
  width: 100%;
  padding: .5rem .75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
}

.modal-box textarea { min-height: 72px; resize: vertical; }
.modal-actions { display: flex; justify-content: flex-end; gap: .5rem; margin-top: 1.25rem; }

.cat-indent { color: var(--muted); margin-right: .25rem; font-family: 'Fira Code', monospace; }
.sort-btns { display: inline-flex; gap: 2px; margin-right: .5rem; }
.sort-btns button { padding: 0 .35rem; font-size: 11px; line-height: 1.4; }
.page-url { font-size: 12px; color: var(--muted); }
.page-url a { color: var(--primary); }

.drag-handle { cursor: grab; color: var(--muted); width: 28px; text-align: center; user-select: none; font-size: 14px; letter-spacing: -2px; }
.drag-handle:active { cursor: grabbing; }
tr.drag-row.dragging { opacity: .45; background: var(--primary-soft); }
tr.drag-row.drag-over td { background: #dbeafe; box-shadow: inset 0 2px 0 var(--primary); }
tr.drag-row.drag-invalid td { opacity: .4; }
tbody.drag-sortable tr.drag-row { transition: background .15s; }

.route-field { margin-bottom: 1rem; }
.route-field label { display: block; font-size: 13px; font-weight: 500; margin-bottom: .35rem; }
.route-field input {
  width: 100%;
  padding: .5rem .75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: 'Fira Code', monospace;
}

.route-field .preview { font-size: 12px; color: var(--muted); margin-top: .35rem; }
.route-field .preview code { color: var(--primary); background: var(--primary-soft); padding: .1rem .35rem; border-radius: 3px; }

.admin-mobile-only { display: none; }
.admin-desktop-only { display: block; }

.muted-color { color: var(--muted); }

@media (max-width: 900px) {
  .mobile-header {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .625rem 1rem;
    padding-top: max(.625rem, env(safe-area-inset-top));
    background: var(--card);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-sm);
  }

  .menu-toggle {
    width: 44px;
    height: 44px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--card);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background var(--transition), border-color var(--transition);
  }

  .menu-toggle:hover { background: var(--muted-bg); }
  .menu-toggle:active { background: var(--primary-soft); border-color: #bfdbfe; }
  .menu-toggle:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

  .menu-icon {
    display: block;
    width: 18px;
    height: 2px;
    background: var(--text);
    border-radius: 1px;
    box-shadow: 0 -6px 0 var(--text), 0 6px 0 var(--text);
  }

  .mobile-title {
    font-weight: 600;
    font-size: 15px;
    color: var(--text);
    letter-spacing: -.02em;
  }

  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    z-index: 200;
    opacity: 0;
    pointer-events: none;
    transition: opacity 220ms ease;
  }

  .app.sidebar-open .sidebar-backdrop {
    opacity: 1;
    pointer-events: auto;
  }

  body.sidebar-open { overflow: hidden; }

  .aside {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(280px, 88vw);
    max-width: 100%;
    z-index: 300;
    transform: translateX(-105%);
    transition: transform 220ms ease;
    box-shadow: none;
  }

  .app.sidebar-open .aside {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(15, 23, 42, 0.18);
  }

  .sidebar-close { display: inline-flex; }

  .nav a {
    min-height: 44px;
    padding-top: .65rem;
    padding-bottom: .65rem;
  }

  .aside-foot .btn-text {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
  }

  .grid-2 { grid-template-columns: 1fr; }
  .main {
    padding: 1rem;
    max-width: none;
    flex: 1;
  }
  .form-grid-2 { grid-template-columns: 1fr; }

  .form-row-inline {
    flex-direction: column;
    align-items: stretch;
  }

  .form-row-inline .form-control {
    width: 100%;
    flex: none;
  }

  .form-row-inline .btn:not(.sm) {
    width: 100%;
    max-width: 240px;
  }

  .img-field-actions .btn.sm {
    flex: 0 1 auto;
    padding: .28rem .55rem;
    font-size: 11px;
  }

  .form-save-row .btn.primary {
    width: 100%;
    max-width: 240px;
  }

  .slider-row {
    padding: .875rem 1rem;
  }

  .slider-row-body {
    grid-template-columns: 1fr;
    gap: .875rem;
  }

  .slider-preview {
    max-width: 100%;
  }

  .slider-meta-grid {
    grid-template-columns: 1fr;
    gap: .65rem;
  }

  .slider-add-btn {
    width: 100%;
    justify-content: center;
  }

  .slider-row-head .btn.danger {
    flex-shrink: 0;
  }

  .theme-card {
    display: block;
    width: 100%;
    margin: .5rem 0 0;
  }

  .stats-grid { grid-template-columns: repeat(2, 1fr); }

  .storage-stats-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: .5rem;
  }

  .storage-stat-card {
    min-height: 0;
    padding: .75rem .5rem;
    text-align: center;
  }

  .storage-stat-card .stat-value {
    font-size: 1.35rem;
  }

  .storage-stat-card .stat-value-sm {
    font-size: .95rem;
  }

  .storage-stat-card .stat-label {
    font-size: 10px;
    line-height: 1.35;
  }

  .storage-blocks {
    grid-template-columns: 1fr;
    gap: .75rem;
  }

  .storage-block {
    padding: .875rem 1rem;
  }

  .storage-block-row {
    grid-template-columns: 3rem 1fr auto;
    padding: .5rem .65rem;
    font-size: 12px;
  }

  .storage-block-foot {
    font-size: 13px;
  }

  .storage-actions-card .btn {
    width: 100%;
    justify-content: center;
  }

  .settings-tabs-bar .tab-btn {
    padding: .4rem .75rem;
    font-size: 13px;
  }

  .toolbar { flex-direction: column; align-items: stretch; }
  .toolbar-actions {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    gap: .35rem;
    justify-content: flex-start;
  }
  .toolbar-actions .btn { flex: 0 1 auto; }
  .toolbar-actions .btn.primary { flex: 1 1 auto; max-width: 100%; }
  th, td { padding: .5rem .375rem; font-size: 12px; }
  .write-editor-wrap.mode-split .write-editor-pane {
    grid-template-columns: 1fr;
  }

  .write-split-btn { display: none; }

  .md-toolbar-divider { display: none; }

  .write-body { min-height: 280px; }
  .posts-filters { grid-template-columns: 1fr; }
  .comments-filters { grid-template-columns: 1fr; }
  .posts-filter-bar .posts-filters .btn { width: 100%; }
  .posts-summary,
  .posts-pager { padding: 0; margin-top: 1rem !important; }

  .admin-mobile-only { display: block; }
  .admin-desktop-only { display: none !important; }

  .admin-mobile-list {
    display: flex;
    flex-direction: column;
    gap: .75rem;
  }

  .admin-mobile-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    box-shadow: var(--shadow-sm);
  }

  .admin-mobile-card-indent {
    margin-left: .75rem;
    border-left: 3px solid #bfdbfe;
  }

  .admin-mobile-card-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
    margin-bottom: .5rem;
  }

  .admin-mobile-card-id {
    font-size: 12px;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
  }

  .admin-mobile-card-badges {
    display: flex;
    flex-wrap: wrap;
    gap: .35rem;
    justify-content: flex-end;
  }

  .admin-mobile-card-title {
    font-size: 15px;
    font-weight: 600;
    line-height: 1.45;
    color: var(--text);
    word-break: break-word;
  }

  a.admin-mobile-card-title {
    display: block;
  }

  .admin-mobile-card-body {
    font-size: 13px;
    line-height: 1.55;
    color: var(--text);
    word-break: break-word;
  }

  .admin-mobile-card-meta {
    font-size: 12px;
    color: var(--muted);
    margin-top: .35rem;
    line-height: 1.5;
    word-break: break-word;
  }

  .admin-mobile-card-actions {
    display: flex;
    flex-wrap: wrap;
    gap: .35rem;
    margin-top: .75rem;
    align-items: center;
  }

  .admin-mobile-card-actions .btn,
  .admin-mobile-card-actions a.btn {
    width: auto;
    min-height: 0;
    padding: .28rem .6rem;
    font-size: 12px;
    line-height: 1.35;
  }

  .admin-mobile-sort-btns {
    display: inline-flex;
    gap: .25rem;
    margin-right: .15rem;
  }

  .admin-mobile-sort-btns .btn {
    padding: .22rem .45rem;
    min-width: 2rem;
  }

  .admin-mobile-empty {
    text-align: center;
    color: var(--muted);
    font-size: 13px;
    padding: 2.5rem 1rem;
    background: var(--card);
    border: 1px dashed var(--border);
    border-radius: var(--radius);
  }

  .toolbar-stack {
    flex-direction: column;
    align-items: stretch;
    gap: .75rem;
  }

  .comments-status-tabs {
    margin-bottom: 0;
    width: 100%;
  }

  .comments-status-tabs .tab-btn {
    flex: 1 1 calc(50% - .25rem);
    justify-content: center;
  }

  .media-grid { grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); gap: .75rem; }

  .media-act {
    width: 32px;
    height: 32px;
  }

  .users-add-form {
    display: grid;
    grid-template-columns: 1fr;
    gap: .75rem;
  }

  .users-add-form .btn { width: 100%; }

  .attachment-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .attachment-toolbar .toolbar-actions {
    width: 100%;
  }

  .attachment-upload-btn {
    width: 100%;
    justify-content: center;
    min-height: 42px;
  }

  .attachment-tabs .tab-btn {
    flex: 1 1 auto;
    justify-content: center;
  }

  .attachment-foot-note {
    font-size: 12px;
    line-height: 1.55;
  }

  .attachment-mobile-list {
    gap: .75rem;
  }

  .attachment-mobile-card {
    padding: .875rem 1rem;
  }
}

@media (min-width: 901px) {
  .sidebar-backdrop { display: none !important; }
  .sidebar-close { display: none !important; }
}

@media (min-width: 901px) and (max-width: 1199px) {
  .storage-stats-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (min-width: 1200px) {
  .main { padding: 1.75rem 2.5rem; }
  .grid-2 { grid-template-columns: minmax(0, 1fr) minmax(300px, 380px); }
  .stats-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
  .storage-stats-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .media-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
}

.import-fetch-options { margin-top: .75rem; }
.import-fetch-options .form-hint { margin-top: .35rem; }
.import-meta-hint { color: var(--muted); }
.import-url-label { display: block; font-weight: 600; margin-bottom: .5rem; }
.import-url-row {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
}
.import-url-input {
  flex: 1 1 280px;
  min-width: 0;
  padding: .625rem .75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
}
.import-preview-grid { margin-top: 1rem; align-items: start; }
.import-preview-main label {
  display: block;
  font-weight: 600;
  margin: .875rem 0 .375rem;
}
.import-preview-main label:first-of-type { margin-top: 0; }
.import-section-title {
  margin: 0 0 .75rem;
  font-size: 1.05rem;
}
.import-content-editor {
  width: 100%;
  min-height: 320px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: .875rem;
  line-height: 1.55;
  padding: .75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  resize: vertical;
}
.import-preview-side { display: flex; flex-direction: column; gap: .875rem; }
.import-cover {
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--surface);
}
.import-cover img { display: block; width: 100%; height: auto; max-height: 220px; object-fit: cover; }
.import-actions-panel .btn.block { width: 100%; margin-top: .5rem; }
.import-actions-panel .btn.block:first-child { margin-top: 0; }

@media (max-width: 900px) {
  .import-url-row .btn { width: 100%; }
  .import-content-editor { min-height: 240px; }
}
