/* ──────────────────────────────────────────────
   Design tokens
─────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:ital,wght@0,400;0,600;0,700;1,400&family=Inter:wght@400;500;600&family=Noto+Serif+SC:wght@400;600&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  --bg:            #faf9f7;
  --bg-card:       #ffffff;
  --bg-dark:       #0f172a;
  --bg-dark2:      #1e293b;
  --text:          #1e1e2e;
  --text-muted:    #64748b;
  --text-light:    #94a3b8;
  --border:        #e8e4dc;
  --accent:        #e05c2e;
  --accent-dark:   #c44b1f;
  --accent-light:  #fff0eb;
  --tag-bg:        #f1f5f9;
  --tag-text:      #475569;
  --shadow-sm:     0 1px 4px rgba(0,0,0,.06);
  --shadow-md:     0 4px 16px rgba(0,0,0,.10);
  --shadow-lg:     0 8px 32px rgba(0,0,0,.12);
  --radius:        10px;
  --radius-lg:     16px;
  --font-sans:     'Inter', -apple-system, 'PingFang SC', sans-serif;
  --font-serif:    'Playfair Display', 'Noto Serif SC', Georgia, serif;
  --font-mono:     'JetBrains Mono', 'Fira Code', monospace;
  --max-w:         760px;
  --nav-h:         64px;
}

/* ──────────────────────────────────────────────
   Reset & base
─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }

/* ──────────────────────────────────────────────
   Navigation
─────────────────────────────────────────────── */
.site-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--nav-h);
  background: var(--bg-dark);
  border-bottom: 1px solid rgba(255,255,255,.06);
  display: flex;
  align-items: center;
}
.nav-inner {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.nav-logo {
  font-family: var(--font-serif);
  font-size: 1.25rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: -.5px;
}
.nav-logo span { color: var(--accent); }
.nav-links { display: flex; gap: 8px; list-style: none; }
.nav-links a {
  color: rgba(255,255,255,.7);
  font-size: .875rem;
  font-weight: 500;
  padding: 6px 14px;
  border-radius: 6px;
  transition: all .2s;
}
.nav-links a:hover {
  color: #fff;
  background: rgba(255,255,255,.1);
}

/* ──────────────────────────────────────────────
   Hero
─────────────────────────────────────────────── */
.hero {
  background: linear-gradient(160deg, var(--bg-dark) 0%, #1a1035 100%);
  padding: 0 24px 0;
  text-align: center;
  position: relative;
  overflow: hidden;
}
.hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse 70% 60% at 50% 90%, rgba(224,92,46,.15) 0%, transparent 65%);
  pointer-events: none;
}
/* Tokyo skyline SVG decoration */
.hero-skyline {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 160px;
  pointer-events: none;
}
.hero-skyline svg {
  width: 100%;
  height: 100%;
}
.hero-inner {
  position: relative;
  z-index: 2;
  padding: 72px 0 120px;
}
.hero-avatar {
  width: 84px;
  height: 84px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent) 0%, #f59e0b 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-serif);
  font-size: 2rem;
  font-weight: 700;
  color: #fff;
  margin: 0 auto 24px;
  box-shadow: 0 0 0 4px rgba(224,92,46,.25), 0 8px 24px rgba(0,0,0,.3);
}
.hero h1 {
  font-family: var(--font-serif);
  font-size: clamp(2rem, 5vw, 3rem);
  font-weight: 700;
  color: #fff;
  letter-spacing: -.5px;
  line-height: 1.2;
  margin-bottom: 16px;
}
.hero h1 em { font-style: italic; color: var(--accent); }
.hero-bio {
  font-size: 1rem;
  color: rgba(255,255,255,.65);
  max-width: 520px;
  margin: 0 auto 28px;
}
.hero-tags { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.hero-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: .75rem;
  font-weight: 500;
  color: rgba(255,255,255,.6);
  border: 1px solid rgba(255,255,255,.15);
  padding: 5px 14px;
  border-radius: 999px;
}
.hero-tag svg { opacity: .7; flex-shrink: 0; }

/* ──────────────────────────────────────────────
   Post list
─────────────────────────────────────────────── */
.posts-section {
  max-width: 1100px;
  margin: 0 auto;
  padding: 56px 24px 80px;
}
.section-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 36px;
}
.section-title {
  font-family: var(--font-serif);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
}
.section-line {
  flex: 1;
  height: 1px;
  background: var(--border);
}
.posts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 24px;
}
.post-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: transform .2s, box-shadow .2s, border-color .2s;
  cursor: pointer;
}
.post-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
  border-color: var(--accent);
}
.post-card-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: .75rem;
  color: var(--text-light);
}
.post-card-meta .dot { color: var(--border); }
.post-card-tags { display: flex; gap: 6px; flex-wrap: wrap; }
.post-tag {
  font-size: .7rem;
  font-weight: 500;
  color: var(--accent);
  background: var(--accent-light);
  padding: 2px 8px;
  border-radius: 4px;
}
.post-card h2 {
  font-family: var(--font-serif);
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.4;
  transition: color .2s;
}
.post-card:hover h2 { color: var(--accent); }
.post-card-excerpt {
  font-size: .9rem;
  color: var(--text-muted);
  line-height: 1.6;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.post-card-footer {
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.read-more {
  font-size: .8rem;
  font-weight: 600;
  color: var(--accent);
  display: flex;
  align-items: center;
  gap: 4px;
  transition: gap .2s;
}
.read-more:hover { gap: 8px; }

/* Feather icon sizing */
.icon { width: 16px; height: 16px; flex-shrink: 0; }
[data-feather].icon { width: 16px; height: 16px; }
.toolbar-btn { display: inline-flex; align-items: center; gap: 5px; }

/* ──────────────────────────────────────────────
   Single post page
─────────────────────────────────────────────── */
.post-hero {
  background: linear-gradient(135deg, var(--bg-dark) 0%, var(--bg-dark2) 100%);
  padding: 64px 24px 56px;
  text-align: center;
}
.post-hero-tags { margin-bottom: 20px; display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; }
.post-hero-tag {
  font-size: .75rem;
  font-weight: 600;
  color: var(--accent);
  background: rgba(224,92,46,.15);
  border: 1px solid rgba(224,92,46,.3);
  padding: 3px 12px;
  border-radius: 999px;
}
.post-hero h1 {
  font-family: var(--font-serif);
  font-size: clamp(1.75rem, 4vw, 2.5rem);
  font-weight: 700;
  color: #fff;
  line-height: 1.3;
  max-width: 760px;
  margin: 0 auto 20px;
}
.post-hero-meta {
  font-size: .875rem;
  color: rgba(255,255,255,.5);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
}
.post-hero-meta .sep { opacity: .3; }

.post-body-wrap {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 56px 24px 80px;
}
.post-content {
  font-family: var(--font-sans);
  font-size: 1.05rem;
  color: var(--text);
  line-height: 1.85;
}
.post-content h1, .post-content h2, .post-content h3 {
  font-family: var(--font-serif);
  font-weight: 700;
  margin: 2em 0 .75em;
  line-height: 1.3;
}
.post-content h1 { font-size: 2rem; }
.post-content h2 { font-size: 1.5rem; border-bottom: 2px solid var(--border); padding-bottom: .4em; }
.post-content h3 { font-size: 1.2rem; }
.post-content p { margin-bottom: 1.25em; }
.post-content a { color: var(--accent); border-bottom: 1px solid rgba(224,92,46,.3); transition: border-color .2s; }
.post-content a:hover { border-color: var(--accent); }
.post-content ul, .post-content ol { padding-left: 1.5em; margin-bottom: 1.25em; }
.post-content li { margin-bottom: .4em; }
.post-content blockquote {
  border-left: 4px solid var(--accent);
  padding: 12px 20px;
  background: var(--accent-light);
  border-radius: 0 var(--radius) var(--radius) 0;
  margin: 1.5em 0;
  color: var(--text-muted);
  font-style: italic;
}
.post-content code {
  font-family: var(--font-mono);
  font-size: .875em;
  background: #f1f5f9;
  color: #c7254e;
  padding: 2px 6px;
  border-radius: 4px;
}
.post-content pre {
  background: #0f172a;
  border-radius: var(--radius);
  padding: 20px;
  overflow-x: auto;
  margin: 1.5em 0;
  box-shadow: var(--shadow-md);
}
.post-content pre code {
  background: none;
  color: #e2e8f0;
  padding: 0;
  font-size: .875rem;
  line-height: 1.6;
}
.post-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5em 0;
  font-size: .9rem;
}
.post-content th, .post-content td { border: 1px solid var(--border); padding: 10px 14px; text-align: left; }
.post-content th { background: var(--bg); font-weight: 600; }
.post-content img { border-radius: var(--radius); margin: 1.5em 0; box-shadow: var(--shadow-md); }

.post-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: .875rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 40px;
  transition: color .2s;
}
.post-back:hover { color: var(--accent); }

/* ──────────────────────────────────────────────
   Footer
─────────────────────────────────────────────── */
.site-footer {
  background: var(--bg-dark);
  color: rgba(255,255,255,.4);
  text-align: center;
  padding: 32px 24px;
  font-size: .8rem;
}
.site-footer a { color: rgba(255,255,255,.6); transition: color .2s; }
.site-footer a:hover { color: var(--accent); }

/* ──────────────────────────────────────────────
   Admin layout
─────────────────────────────────────────────── */
.admin-body {
  background: #f1f5f9;
  min-height: 100vh;
  font-family: var(--font-sans);
}

/* Login */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, var(--bg-dark) 0%, var(--bg-dark2) 100%);
  padding: 24px;
}
.login-card {
  background: #fff;
  border-radius: var(--radius-lg);
  padding: 48px 40px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-lg);
}
.login-logo {
  font-family: var(--font-serif);
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text);
  text-align: center;
  margin-bottom: 8px;
}
.login-logo span { color: var(--accent); }
.login-subtitle {
  text-align: center;
  color: var(--text-muted);
  font-size: .875rem;
  margin-bottom: 36px;
}
.form-group { margin-bottom: 20px; }
.form-label {
  display: block;
  font-size: .8rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: 8px;
}
.form-input {
  width: 100%;
  padding: 12px 16px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: .95rem;
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  transition: border-color .2s;
  outline: none;
}
.form-input:focus { border-color: var(--accent); background: #fff; }
.btn-primary {
  width: 100%;
  padding: 13px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: .95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .2s, transform .1s;
}
.btn-primary:hover { background: var(--accent-dark); }
.btn-primary:active { transform: scale(.98); }
.error-msg {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #dc2626;
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: .875rem;
  margin-bottom: 20px;
}

/* Sidebar */
.admin-layout { display: flex; min-height: 100vh; }
.admin-sidebar {
  width: 240px;
  background: var(--bg-dark);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 50;
  overflow-y: auto;
}
.sidebar-brand {
  padding: 24px 20px;
  border-bottom: 1px solid rgba(255,255,255,.07);
}
.sidebar-logo {
  font-family: var(--font-serif);
  font-size: 1.2rem;
  font-weight: 700;
  color: #fff;
}
.sidebar-logo span { color: var(--accent); }
.sidebar-subtitle {
  font-size: .7rem;
  color: rgba(255,255,255,.35);
  margin-top: 3px;
}
.sidebar-nav { padding: 16px 12px; flex: 1; }
.sidebar-section {
  font-size: .65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: rgba(255,255,255,.3);
  padding: 8px 8px 6px;
  margin-top: 8px;
}
.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  font-size: .875rem;
  font-weight: 500;
  color: rgba(255,255,255,.65);
  transition: all .15s;
  margin-bottom: 2px;
}
.sidebar-link:hover, .sidebar-link.active {
  background: rgba(255,255,255,.08);
  color: #fff;
}
.sidebar-link.active { background: rgba(224,92,46,.2); color: var(--accent); }
.sidebar-link .icon { font-size: 1rem; width: 20px; text-align: center; }
.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,.07);
}
.sidebar-user {
  font-size: .8rem;
  color: rgba(255,255,255,.4);
}
.sidebar-user strong { display: block; color: rgba(255,255,255,.8); }
.sidebar-logout {
  display: block;
  margin-top: 8px;
  font-size: .75rem;
  color: rgba(255,255,255,.35);
  transition: color .2s;
}
.sidebar-logout:hover { color: var(--accent); }

.admin-main {
  margin-left: 240px;
  flex: 1;
  display: flex;
  flex-direction: column;
}
.admin-topbar {
  background: #fff;
  border-bottom: 1px solid var(--border);
  padding: 0 32px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.page-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
}
.admin-content { padding: 32px; flex: 1; }

/* Stats cards */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 20px;
  margin-bottom: 32px;
}
.stat-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow-sm);
}
.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  flex-shrink: 0;
}
.stat-icon.orange { background: rgba(224,92,46,.12); }
.stat-icon.blue   { background: rgba(59,130,246,.12); }
.stat-icon.green  { background: rgba(34,197,94,.12);  }
.stat-icon.purple { background: rgba(139,92,246,.12); }
.stat-info { flex: 1; }
.stat-number { font-size: 1.75rem; font-weight: 700; color: var(--text); line-height: 1; }
.stat-label { font-size: .8rem; color: var(--text-muted); margin-top: 4px; }

/* Tables */
.admin-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  margin-bottom: 24px;
}
.card-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card-title { font-size: 1rem; font-weight: 700; color: var(--text); }
.admin-table { width: 100%; border-collapse: collapse; }
.admin-table th {
  padding: 12px 20px;
  font-size: .75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
  text-align: left;
}
.admin-table td {
  padding: 14px 20px;
  border-bottom: 1px solid #f1f5f9;
  font-size: .9rem;
  color: var(--text);
  vertical-align: middle;
}
.admin-table tr:last-child td { border-bottom: none; }
.admin-table tr:hover td { background: #f8fafc; }
.badge {
  display: inline-flex;
  align-items: center;
  font-size: .7rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
}
.badge-green { background: #dcfce7; color: #15803d; }
.badge-gray  { background: #f1f5f9; color: #64748b; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: .875rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  text-decoration: none;
  transition: all .15s;
}
.btn-sm { padding: 5px 10px; font-size: .775rem; }
.btn-accent { background: var(--accent); color: #fff; }
.btn-accent:hover { background: var(--accent-dark); }
.btn-outline { background: transparent; border: 1.5px solid var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--text-muted); }
.btn-danger { background: #fef2f2; color: #dc2626; border: 1.5px solid #fecaca; }
.btn-danger:hover { background: #fee2e2; }

/* Post editor */
.editor-wrap { padding: 32px; }
.editor-form .form-group { margin-bottom: 24px; }
.editor-form .form-input { background: #fff; }
.editor-form textarea.form-input {
  font-family: var(--font-mono);
  font-size: .875rem;
  line-height: 1.7;
  resize: vertical;
  min-height: 400px;
}
.editor-toolbar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.toggle-wrap { display: flex; align-items: center; gap: 12px; }
.toggle { position: relative; display: inline-block; width: 44px; height: 24px; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute;
  inset: 0;
  background: #cbd5e1;
  border-radius: 999px;
  cursor: pointer;
  transition: .3s;
}
.toggle-slider::before {
  content: '';
  position: absolute;
  width: 18px; height: 18px;
  left: 3px; bottom: 3px;
  background: #fff;
  border-radius: 50%;
  transition: .3s;
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.toggle input:checked + .toggle-slider { background: var(--accent); }
.toggle input:checked + .toggle-slider::before { transform: translateX(20px); }
.toggle-label { font-size: .9rem; color: var(--text); font-weight: 500; }

/* File manager */
.files-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
  padding: 24px;
}
.file-card {
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: #fff;
  transition: border-color .2s, box-shadow .2s;
}
.file-card:hover { border-color: var(--accent); box-shadow: var(--shadow-sm); }
.file-preview {
  height: 120px;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
  color: var(--text-light);
}
.file-img-preview { width: 100%; height: 120px; object-fit: cover; }
.file-info { padding: 12px; }
.file-name {
  font-size: .8rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.file-meta { font-size: .7rem; color: var(--text-muted); margin-top: 2px; }
.file-actions { display: flex; gap: 6px; margin-top: 10px; }

/* Upload drop zone */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: 40px 24px;
  text-align: center;
  cursor: pointer;
  transition: all .2s;
  background: var(--bg);
  margin: 24px;
}
.upload-zone:hover, .upload-zone.drag-over {
  border-color: var(--accent);
  background: var(--accent-light);
}
.upload-zone-icon { font-size: 2.5rem; margin-bottom: 12px; }
.upload-zone-text { font-size: .9rem; color: var(--text-muted); margin-bottom: 16px; }

/* Responsive tweaks */
@media (max-width: 768px) {
  .admin-sidebar { width: 100%; position: static; height: auto; flex-direction: row; }
  .admin-main { margin-left: 0; }
  .posts-grid { grid-template-columns: 1fr; }
}
