:root {
  --primary: #a78bfa;
  --primary-dark: #7c3aed;
  --primary-light: #c4b5fd;
  --bg-overlay-dark: rgba(0,0,0,0.55);
  --bg-overlay-light: rgba(0,0,0,0.15);
  --card-bg: rgba(255,255,255,0.06);
  --card-border: rgba(255,255,255,0.08);
  --card-hover-border: rgba(167,139,250,0.4);
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --nav-bg: rgba(255,255,255,0.08);
  --nav-border: rgba(255,255,255,0.08);
  --nav-text: #cbd5e1;
  --nav-hover-bg: rgba(255,255,255,0.1);
  --nav-hover-text: #fff;
  --nav-active-bg: rgba(167,139,250,0.2);
  --nav-active-text: #a78bfa;
}

html.light {
  --bg-overlay-dark: rgba(0,0,0,0.15);
  --bg-overlay-light: rgba(0,0,0,0.05);
  --card-bg: rgba(255,255,255,0.85);
  --card-border: rgba(0,0,0,0.06);
  --card-hover-border: rgba(124,58,237,0.3);
  --text-primary: #1e293b;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --nav-bg: rgba(255,255,255,0.7);
  --nav-border: rgba(0,0,0,0.06);
  --nav-text: #64748b;
  --nav-hover-bg: rgba(0,0,0,0.05);
  --nav-hover-text: #1e293b;
  --nav-active-bg: rgba(124,58,237,0.1);
  --nav-active-text: #7c3aed;
}

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

body {
  font-family: 'Inter', 'Noto Sans SC', -apple-system, BlinkMacSystemFont, sans-serif;
  color: var(--text-primary);
  line-height: 1.6;
  transition: color 0.3s;
  overflow-x: hidden;
  min-height: 100vh;
  background: #0b1020;
}

html.light body { background:#eef2ff }
button, input, select, textarea { font:inherit }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid rgba(167,139,250,.55);
  outline-offset: 3px;
}
.skip-link { position:fixed; top:10px; left:10px; z-index:100000; padding:8px 12px; color:#fff; background:#7c3aed; border-radius:8px; transform:translateY(-150%); transition:transform .2s }
.skip-link:focus { transform:translateY(0) }

.fixed { position:fixed }
.absolute { position:absolute }
.relative { position:relative }
.inset-0 { top:0;right:0;bottom:0;left:0 }
.overflow-hidden { overflow:hidden }
.w-full { width:100% }
.top-0 { top:0 }
.z-50 { z-index:50 }
.max-w-5xl { max-width:1024px }
.mx-auto { margin-left:auto; margin-right:auto }
.flex { display:flex }
.items-center { align-items:center }
.justify-between { justify-content:space-between }
.gap-1 { gap:4px }
.px-6 { padding-left:24px; padding-right:24px }
.py-3 { padding-top:12px; padding-bottom:12px }
.py-8 { padding-top:32px; padding-bottom:32px }
.pb-20 { padding-bottom:80px }
.mb-8 { margin-bottom:32px }
.mt-20 { margin-top:80px }
.text-center { text-align:center }
.text-sm { font-size:14px }
.text-xl { font-size:20px }
.font-bold { font-weight:700 }
.text-gray-500 { color:var(--text-muted) }
.border-t { border-top-width:1px; border-top-style:solid }
.border-white\/10 { border-color:rgba(255,255,255,.1) }

/* Header */
header { z-index:9999 }
header nav { background:var(--nav-bg) !important; border-color:var(--nav-border) !important }

nav a, nav button { text-decoration:none }
.brand { font-size:20px; font-weight:700; color:#a78bfa; background:linear-gradient(135deg,#c4b5fd,#7c3aed); -webkit-background-clip:text; background-clip:text; -webkit-text-fill-color:transparent; white-space:nowrap }
.nav-actions, .filter-group { display:flex; align-items:center; gap:4px }

.nav-link {
  background: transparent;
  border: none;
  color: var(--nav-text);
  padding: 6px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s;
  font-family: inherit;
}

.nav-link:hover {
  background: var(--nav-hover-bg);
  color: var(--nav-hover-text);
}

.nav-link.active {
  background: var(--nav-active-bg);
  color: var(--nav-active-text);
}

.write-btn {
  background: linear-gradient(135deg, #a78bfa, #7c3aed);
  border: none;
  color: #fff;
  padding: 6px 18px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  transition: opacity 0.2s;
  margin-left: 8px;
  font-family: inherit;
}

.write-btn:hover { opacity:0.85 }

.theme-btn {
  background: transparent;
  border: none;
  color: var(--nav-text);
  padding: 6px;
  border-radius: 8px;
  cursor: pointer;
  margin-left: 4px;
  transition: all 0.2s;
}

.theme-btn:hover { background:var(--nav-hover-bg); color:var(--nav-hover-text) }

.theme-btn svg { width:20px; height:20px; display:block }

html.dark .sun-icon { display:block }
html.dark .moon-icon { display:none }
html.light .sun-icon { display:none }
html.light .moon-icon { display:block }

/* Hero */
.hero {
  min-height: 50vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 120px 0 60px;
}

.avatar-wrap { margin-bottom:24px; display:flex; justify-content:center }

.avatar-border {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background: linear-gradient(135deg, #a78bfa, #7c3aed);
  padding: 3px;
}

.avatar-inner {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: rgba(30,30,60,0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 40px;
  font-weight: 700;
  color: #a78bfa;
  border: 2px solid rgba(30,30,60,0.8);
}

html.light .avatar-inner {
  background: #fff;
  border-color: #fff;
}

.hero-title {
  font-size: 56px;
  font-weight: 700;
  margin-bottom: 12px;
  background: linear-gradient(135deg, #a78bfa, #7c3aed);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

@media (max-width:640px) { .hero-title { font-size:36px } }

.hero-subtitle {
  font-size: 18px;
  color: var(--text-secondary);
}

/* Section */
.section-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
}

.post-count { font-size:14px; color:var(--text-muted) }

/* Posts */
.posts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 20px;
}

@media (max-width:640px) { .posts-grid { grid-template-columns:1fr } }

.post-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  padding: 24px;
  transition: all 0.3s;
  animation: fadeIn 0.3s ease;
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}

.post-card:hover {
  border-color: var(--card-hover-border);
  transform: translateY(-2px);
  box-shadow: 0 8px 30px rgba(167,139,250,0.1);
}

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

.post-tags { display:flex; gap:6px; margin-bottom:10px }

.post-tag {
  display: inline-block;
  font-size: 12px;
  padding: 2px 10px;
  border-radius: 999px;
  font-weight: 500;
}

.tag-study {
  background: rgba(167,139,250,0.15);
  color: #a78bfa;
}

.tag-life {
  background: rgba(251,146,60,0.15);
  color: #fb923c;
}

.post-date {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.post-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 10px;
  transition: color 0.2s;
}

.post-card:hover .post-title {
  color: var(--primary);
}

.post-content {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.post-actions { margin-top:16px; text-align:right }

.delete-btn {
  background: transparent;
  border: 1px solid var(--card-border);
  color: var(--text-muted);
  padding: 4px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  transition: all 0.2s;
  font-family: inherit;
}

.delete-btn:hover {
  border-color: #ef4444;
  color: #ef4444;
  background: rgba(239,68,68,0.1);
}

.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 80px 20px;
  color: var(--text-muted);
  font-size: 15px;
}
.empty-state strong { display:block; margin-bottom:6px; color:var(--text-secondary); font-size:17px }

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 99999;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}

.modal-overlay.hidden { display:none }

.modal-content {
  background: #1e1e3a;
  border: 1px solid rgba(167,139,250,0.2);
  border-radius: 16px;
  padding: 32px;
  width: 100%;
  max-width: 540px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}

html.light .modal-content {
  background: #fff;
  border-color: rgba(0,0,0,0.08);
  box-shadow: 0 20px 60px rgba(0,0,0,0.15);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.modal-header h3 {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 28px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
  transition: color 0.2s;
}

.modal-close:hover { color: var(--text-primary) }

.form-group { margin-bottom: 18px }

.form-group label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid rgba(167,139,250,0.2);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  background: rgba(255,255,255,0.05);
  color: var(--text-primary);
  transition: border-color 0.3s;
}

html.light .form-group input,
html.light .form-group select,
html.light .form-group textarea {
  background: #f8fafc;
  border-color: #e2e8f0;
  color: #1e293b;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: #a78bfa;
  box-shadow: 0 0 0 3px rgba(167,139,250,0.15);
}

.form-group textarea { resize:vertical }

.submit-btn {
  width: 100%;
  background: linear-gradient(135deg, #a78bfa, #7c3aed);
  color: #fff;
  border: none;
  padding: 11px;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s;
  font-family: inherit;
  margin-top: 4px;
}

.submit-btn:hover { opacity:0.85 }

body.modal-open { overflow:hidden }

@media (max-width: 680px) {
  nav { padding-inline:14px !important }
  nav .max-w-5xl { align-items:flex-start }
  .nav-actions { justify-content:flex-end; flex-wrap:wrap }
  .filter-group { order:2; width:100%; justify-content:flex-end }
  .nav-link { padding:5px 10px }
  .write-btn { margin-left:4px; padding-inline:12px }
  .hero { padding-top:150px; min-height:48vh }
  .modal-content { padding:24px 20px }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior:auto !important; animation-duration:.01ms !important; animation-iteration-count:1 !important; transition-duration:.01ms !important }
}
