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

:root {
  --bg:         #f8f7f4;
  --bg-card:    #ffffff;
  --bg-code:    #f0eeea;
  --text:       #1a1917;
  --text-muted: #6b6860;
  --text-faint: #a09e99;
  --accent:     #2d5fc4;
  --accent-dim: #e8eef9;
  --border:     #e4e2dc;
  --border-strong: #ccc9c0;
  --success:    #18794e;
  --danger:     #c23535;
  --radius:     8px;
  --radius-lg:  14px;
  --shadow-sm:  0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md:  0 4px 12px rgba(0,0,0,.08), 0 2px 4px rgba(0,0,0,.04);
  --font-body:  'Inter', system-ui, sans-serif;
  --font-mono:  'JetBrains Mono', 'Fira Code', monospace;
  --max-w:      720px;
  --transition: 150ms ease;
}

html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

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

/* ── Layout ────────────────────────────────────────────────────────────────── */
.container {
  width: 100%;
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 1.25rem;
}

.site-main {
  flex: 1;
  padding: 2rem 0 4rem;
}

/* ── Header ────────────────────────────────────────────────────────────────── */
.site-header {
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(8px);
  background: rgba(255,255,255,.92);
}
.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-top: .85rem;
  padding-bottom: .85rem;
}

.site-brand {
  display: flex;
  flex-direction: column;
  text-decoration: none;
  line-height: 1.2;
}
.brand-name {
  font-size: .95rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -.01em;
}
.brand-sub {
  font-size: .72rem;
  color: var(--text-muted);
  font-weight: 400;
}

.site-nav { display: flex; gap: .15rem; }
.nav-link {
  font-size: .85rem;
  font-weight: 500;
  color: var(--text-muted);
  padding: .35rem .65rem;
  border-radius: var(--radius);
  transition: color var(--transition), background var(--transition);
  text-decoration: none;
}
.nav-link:hover { color: var(--text); background: var(--bg-code); text-decoration: none; }
.nav-link.active { color: var(--accent); background: var(--accent-dim); }

/* ── Footer ────────────────────────────────────────────────────────────────── */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 1.25rem 0;
  font-size: .78rem;
  color: var(--text-faint);
}

/* ── Post List ─────────────────────────────────────────────────────────────── */
.page-heading {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .07em;
  margin-bottom: 1.75rem;
}

.post-list { list-style: none; }
.post-list-item {
  display: flex;
  gap: 1.5rem;
  align-items: baseline;
  padding: .85rem 0;
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}
.post-list-item:last-child { border-bottom: none; }

.post-date {
  flex-shrink: 0;
  font-size: .78rem;
  font-family: var(--font-mono);
  color: var(--text-faint);
  min-width: 6.5rem;
  padding-top: .1rem;
}

.post-title-link {
  font-size: 1rem;
  font-weight: 500;
  color: var(--text);
  text-decoration: none;
  transition: color var(--transition);
  line-height: 1.4;
}
.post-title-link:hover { color: var(--accent); text-decoration: none; }

.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 4rem 0;
  font-size: .95rem;
}

/* ── Single Post ───────────────────────────────────────────────────────────── */
.post-header { margin-bottom: 2.5rem; }
.post-header h1 {
  font-size: 1.85rem;
  font-weight: 600;
  letter-spacing: -.02em;
  line-height: 1.25;
  color: var(--text);
  margin-bottom: .5rem;
}
.post-meta {
  font-size: .8rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}
.post-back {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  font-size: .82rem;
  color: var(--text-muted);
  margin-bottom: 1.75rem;
  transition: color var(--transition);
  text-decoration: none;
}
.post-back:hover { color: var(--accent); text-decoration: none; }

/* Post body typography */
.post-body { font-size: 1rem; line-height: 1.8; }
.post-body h1,.post-body h2,.post-body h3,.post-body h4 {
  font-weight: 600; letter-spacing: -.01em; line-height: 1.3;
  margin: 2rem 0 .75rem;
}
.post-body h2 { font-size: 1.3rem; }
.post-body h3 { font-size: 1.1rem; }
.post-body p { margin-bottom: 1.1rem; }
.post-body ul, .post-body ol { padding-left: 1.5rem; margin-bottom: 1.1rem; }
.post-body li { margin-bottom: .3rem; }
.post-body blockquote {
  border-left: 3px solid var(--border-strong);
  padding: .5rem 1rem;
  color: var(--text-muted);
  margin: 1.25rem 0;
  font-style: italic;
}
.post-body code {
  font-family: var(--font-mono);
  font-size: .875em;
  background: var(--bg-code);
  border: 1px solid var(--border);
  padding: .15em .4em;
  border-radius: 4px;
  color: #b5460c;
}
.post-body pre {
  background: #1e1e2e;
  border-radius: var(--radius);
  padding: 1.25rem;
  overflow-x: auto;
  margin: 1.5rem 0;
  box-shadow: var(--shadow-sm);
}
.post-body pre code {
  background: none;
  border: none;
  padding: 0;
  color: #cdd6f4;
  font-size: .85rem;
  line-height: 1.65;
}
.post-body strong { font-weight: 600; }
.post-body em { font-style: italic; }
.post-body s { text-decoration: line-through; color: var(--text-muted); }
.post-body a { color: var(--accent); }
.post-body h1 { font-size: 1.6rem; }
.post-body h5, .post-body h6 { font-size: 1rem; }
.post-body hr { border: none; border-top: 1px solid var(--border); margin: 2rem 0; }
.post-body img { max-width: 100%; border-radius: var(--radius); margin: 1rem 0; }
.post-body table { width: 100%; border-collapse: collapse; margin: 1.25rem 0; font-size: .9rem; }
.post-body th, .post-body td { padding: .55rem .85rem; border: 1px solid var(--border); text-align: left; }
.post-body th { background: var(--bg); font-weight: 600; }
.post-body tr:nth-child(even) td { background: var(--bg); }

/* ── Projects ──────────────────────────────────────────────────────────────── */
.projects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.25rem;
  margin-top: 1.75rem;
}

.project-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.4rem;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition), transform var(--transition), border-color var(--transition);
  display: flex;
  flex-direction: column;
  gap: .75rem;
}
.project-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
  border-color: var(--border-strong);
}

.project-logo {
  width: 44px;
  height: 44px;
  object-fit: contain;
  border-radius: var(--radius);
}
.project-logo-placeholder {
  width: 44px;
  height: 44px;
  background: var(--accent-dim);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
}

.project-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  margin: 0;
}
.project-desc {
  font-size: .875rem;
  color: var(--text-muted);
  line-height: 1.6;
  flex: 1;
}
.project-link {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  font-size: .82rem;
  font-weight: 500;
  color: var(--accent);
  text-decoration: none;
  margin-top: auto;
}
.project-link:hover { text-decoration: underline; }

/* ── Resume Page ───────────────────────────────────────────────────────────── */
.resume-page { padding-bottom: 2rem; }
.resume-page h1 { font-size: 1.6rem; font-weight: 600; margin-bottom: .75rem; }
.resume-page p { color: var(--text-muted); margin-bottom: 2rem; }

/* ── Buttons ───────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  font-size: .875rem;
  font-weight: 500;
  padding: .55rem 1.1rem;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: background var(--transition), border-color var(--transition), color var(--transition), box-shadow var(--transition);
  font-family: var(--font-body);
  line-height: 1;
}
.btn:hover { text-decoration: none; }

.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.btn-primary:hover { background: #2450a8; border-color: #2450a8; box-shadow: 0 2px 8px rgba(45,95,196,.3); }

.btn-secondary {
  background: var(--bg-card);
  color: var(--text);
  border-color: var(--border-strong);
}
.btn-secondary:hover { background: var(--bg-code); }

.btn-danger {
  background: transparent;
  color: var(--danger);
  border-color: #e5c4c4;
}
.btn-danger:hover { background: #fdf0f0; }

.btn-sm { font-size: .78rem; padding: .38rem .75rem; }
.btn-lg { font-size: 1rem; padding: .75rem 1.75rem; }

/* ── Admin ─────────────────────────────────────────────────────────────────── */
.admin-layout { display: flex; flex-direction: column; gap: 2rem; }

.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}
.admin-header h1 { font-size: 1.3rem; font-weight: 600; }

.admin-section { margin-bottom: 2.5rem; }
.admin-section-title {
  font-size: .78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-muted);
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
}
.admin-table th {
  text-align: left;
  padding: .5rem .75rem;
  font-size: .72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}
.admin-table td {
  padding: .65rem .75rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.admin-table tr:last-child td { border-bottom: none; }
.admin-table tr:hover td { background: var(--bg); }

.badge {
  display: inline-block;
  font-size: .68rem;
  font-weight: 600;
  padding: .2em .55em;
  border-radius: 99px;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.badge-green { background: #dcf3e8; color: var(--success); }
.badge-gray  { background: var(--bg-code); color: var(--text-muted); }

/* ── Forms ─────────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 1.25rem; }
.form-label {
  display: block;
  font-size: .8rem;
  font-weight: 500;
  margin-bottom: .4rem;
  color: var(--text);
}
.form-input, .form-textarea, .form-select {
  width: 100%;
  font-family: var(--font-body);
  font-size: .9rem;
  color: var(--text);
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: .6rem .85rem;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
  appearance: none;
}
.form-input:focus, .form-textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(45,95,196,.12);
}
.form-textarea {
  resize: vertical;
  min-height: 200px;
  line-height: 1.6;
}
.form-check {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: .875rem;
}

.form-hint { font-size: .75rem; color: var(--text-muted); margin-top: .3rem; }

/* ── Editor toolbar ────────────────────────────────────────────────────────── */
.editor-split {
  display: flex;
  gap: 1rem;
  width: 100%;
}
.editor-split > .editor-wrap {
  flex: 1 1 50%;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.editor-wrap { border: 1px solid var(--border-strong); border-radius: var(--radius); overflow: hidden; background: var(--bg-card); }
.editor-wrap:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(45,95,196,.12); }

.editor-toolbar {
  display: flex;
  gap: .15rem;
  padding: .45rem .5rem;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  align-items: center;
}

.toolbar-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0 0.5rem;
}

.toolbar-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-body);
  font-size: .8rem;
  font-weight: 600;
  color: var(--text-muted);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 5px;
  padding: .3rem .55rem;
  cursor: pointer;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
  line-height: 1;
}
.toolbar-btn:hover { background: var(--bg-card); color: var(--text); border-color: var(--border); }
.toolbar-btn.mono { font-family: var(--font-mono); }
.toolbar-sep { width: 1px; height: 1.2rem; background: var(--border); margin: 0 .2rem; }

.btn-ai {
  color: #7b4acb; /* Sparkle color */
  margin-left: auto;
}
.btn-ai:hover {
  color: #5c359d;
  background: #f3eefe;
  border-color: #e2d2fb;
}
.btn-ai.loading {
  opacity: 0.6;
  pointer-events: none;
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0% { opacity: 0.6; }
  50% { opacity: 0.3; }
  100% { opacity: 0.6; }
}

.editor-textarea {
  width: 100%;
  flex: 1;
  font-family: var(--font-mono);
  font-size: .85rem;
  color: var(--text);
  background: transparent;
  border: none;
  outline: none;
  padding: 1rem;
  resize: vertical;
  min-height: 420px;
  line-height: 1.7;
  tab-size: 4;
}

.visual-editor {
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.8;
  overflow-y: auto;
}
.visual-editor:empty:before {
  content: attr(placeholder);
  color: var(--text-faint);
  pointer-events: none;
}

/* Word count badge in toolbar */
.editor-wc {
  margin-left: auto;
  font-size: .72rem;
  color: var(--text-faint);
  font-family: var(--font-mono);
  padding: .2rem .4rem;
  align-self: center;
  white-space: nowrap;
}

/* Shortcut hint line below editor */
.form-hint {
  font-size: .78rem;
  color: var(--text-muted);
  margin-top: .45rem;
  line-height: 1.6;
}

/* ── Login ─────────────────────────────────────────────────────────────────── */
.login-wrap {
  max-width: 380px;
  margin: 5rem auto;
}
.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2rem;
  box-shadow: var(--shadow-md);
}
.login-title { font-size: 1.15rem; font-weight: 600; margin-bottom: .4rem; }
.login-sub { font-size: .82rem; color: var(--text-muted); margin-bottom: 1.75rem; }

.alert {
  font-size: .82rem;
  padding: .65rem .9rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  border: 1px solid transparent;
}
.alert-info { background: var(--accent-dim); color: var(--accent); border-color: #c5d5f5; }
.alert-error { background: #fdf0f0; color: var(--danger); border-color: #e9c4c4; }
.alert-success { background: #e9f9f1; color: var(--success); border-color: #b6e8d0; }

/* ── Resume editor ─────────────────────────────────────────────────────────── */
.tex-textarea {
  font-family: var(--font-mono);
  font-size: .82rem;
  line-height: 1.65;
  min-height: 540px;
}

/* ── 404 ───────────────────────────────────────────────────────────────────── */
.error-page { text-align: center; padding: 6rem 0; }
.error-page h1 { font-size: 3rem; font-weight: 700; color: var(--border-strong); margin-bottom: .5rem; }
.error-page p { color: var(--text-muted); margin-bottom: 1.5rem; }

/* ── Responsive ────────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  .site-header .container { flex-direction: column; align-items: flex-start; gap: .5rem; }
  .brand-sub { display: none; }
  .post-list-item { flex-direction: column; gap: .15rem; }
  .post-date { min-width: unset; }
  .post-header h1 { font-size: 1.4rem; }
  .projects-grid { grid-template-columns: 1fr; }
  .admin-table { font-size: .8rem; }
}
