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

:root {
  --bg: #ffffff;
  --bg-subtle: #f9fafb;
  --surface: #ffffff;
  --ink: #111827;
  --muted: #6b7280;
  --line: #e5e7eb;
  --accent: #0f172a;
  --accent-strong: #000000;
  --danger: #ef4444;
  --danger-bg: #fef2f2;
  --danger-border: #fecaca;
  --danger-text: #b91c1c;
  --success-bg: #f0fdf4;
  --success-border: #bbf7d0;
  --success-text: #15803d;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background-color: var(--bg);
  color: var(--ink);
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

a {
  color: var(--muted);
  text-decoration: none;
  transition: color 0.2s ease;
}

a:hover {
  color: var(--accent);
}

.container {
  width: min(800px, calc(100% - 2rem));
  margin: 4rem auto;
  flex-grow: 1;
}

/* Header */
.site-header {
  margin-bottom: 3.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--line);
}

.header-main {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1.5rem;
}

.author-info {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.author-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--line);
}

.author-text {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.author-text h1 {
  margin: 0;
  font-size: clamp(1.5rem, 4vw, 2rem);
  font-weight: 700;
  letter-spacing: -0.04em;
  color: var(--ink);
  line-height: 1.1;
}

.author-text p {
  margin: 0;
  color: var(--muted);
  font-size: 1rem;
}

/* Buttons */
.button,
button {
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #ffffff;
  padding: 0.5rem 1.25rem;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.button:hover,
button:hover {
  background: var(--accent-strong);
  color: #ffffff;
}

.button.ghost,
button.ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--ink);
}

.button.ghost:hover,
button.ghost:hover {
  background: var(--bg-subtle);
  border-color: var(--muted);
}

.button.danger,
button.danger {
  background: var(--danger);
  color: white;
}

.button.danger:hover,
button.danger:hover {
  background: #dc2626;
  color: white;
}

.icon-button {
  padding: 0.5rem;
  min-width: 40px;
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
}

.icon-button svg {
  stroke: currentColor;
}

/* Post Grid & Cards */
.post-grid {
  display: flex;
  flex-direction: column;
  gap: 2.5rem;
}

.post-card {
  padding-bottom: 2.5rem;
  border-bottom: 1px solid var(--line);
}

.post-card:last-child {
  border-bottom: none;
}

.post-card h2 {
  margin: 0 0 0.5rem 0;
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.post-card h2 a {
  color: var(--ink);
}

.post-card h2 a:hover {
  color: var(--muted);
}

.post-card>p {
  color: var(--muted);
  margin: 0 0 1rem 0;
  font-size: 1.05rem;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.post-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  font-size: 0.875rem;
  color: var(--muted);
  margin-bottom: 0.75rem;
}

.post-meta a {
  text-decoration: underline;
  text-decoration-color: var(--line);
  text-underline-offset: 4px;
}

.post-meta a:hover {
  text-decoration-color: var(--muted);
  color: var(--ink);
}

/* Tags */
.tags {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.tag {
  background: var(--bg-subtle);
  color: var(--ink);
  border: 1px solid var(--line);
  font-size: 0.75rem;
  font-weight: 500;
  border-radius: 999px;
  padding: 0.2rem 0.6rem;
  letter-spacing: 0.02em;
}

/* Article Page */
.article-page {
  max-width: 680px;
}

.back-link {
  display: inline-flex;
  align-items: center;
  margin-bottom: 3rem;
  font-size: 0.875rem;
  color: var(--muted);
  font-weight: 500;
}

.back-link:hover {
  color: var(--ink);
}

.article h1 {
  margin: 0 0 1rem 0;
  font-size: clamp(2rem, 6vw, 3rem);
  font-weight: 700;
  letter-spacing: -0.05em;
  line-height: 1.1;
}

.article .post-meta {
  margin-bottom: 2rem;
  padding-bottom: 2rem;
  border-bottom: 1px solid var(--line);
}

.article-excerpt {
  color: var(--muted);
  font-size: 1.25rem;
  font-style: italic;
  line-height: 1.6;
  margin-bottom: 2rem;
}

.article-content {
  font-size: 1.125rem;
  line-height: 1.75;
  color: var(--ink);
}

.article-content p {
  margin-top: 1.5rem;
  margin-bottom: 1.5rem;
}

.article-content h2,
.article-content h3 {
  font-weight: 600;
  letter-spacing: -0.03em;
  margin-top: 3rem;
  margin-bottom: 1rem;
  color: var(--ink);
}

.article-content h2 {
  font-size: 1.75rem;
}

.article-content h3 {
  font-size: 1.5rem;
}

.article-content ul,
.article-content ol {
  padding-left: 1.5rem;
  margin-bottom: 1.5rem;
}

.article-content li {
  margin-bottom: 0.5rem;
}

.article-content blockquote {
  border-left: 3px solid var(--ink);
  margin: 2rem 0;
  padding-left: 1.5rem;
  font-style: italic;
  color: var(--muted);
}

.article-content img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-md);
  margin: 2rem 0;
}

.article-content a {
  color: var(--ink);
  text-decoration: underline;
  text-decoration-color: var(--line);
  text-underline-offset: 4px;
}

.article-content a:hover {
  text-decoration-color: var(--ink);
}

/* Admin Panel */
.admin-shell {
  display: grid;
  grid-template-columns: 1fr 350px;
  gap: 3rem;
  align-items: start;
  max-width: 1000px;
  width: min(1000px, calc(100% - 2rem));
  margin: 4rem auto;
}

.admin-panel,
.admin-list {
  background: var(--surface);
}

.admin-panel h1 {
  margin: 0 0 0.5rem 0;
  font-size: 2rem;
  font-weight: 600;
  letter-spacing: -0.03em;
}

.admin-panel>p {
  color: var(--muted);
  margin-bottom: 2rem;
}

.admin-list h2 {
  margin: 0 0 0.5rem 0;
  font-size: 1.5rem;
  font-weight: 600;
}

.admin-list>p {
  color: var(--muted);
  margin-bottom: 1.5rem;
}

form {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

label {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--ink);
}

input,
textarea,
select {
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  padding: 0.75rem;
  font-family: inherit;
  font-size: 1rem;
  color: var(--ink);
  background: var(--surface);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  width: 100%;
}

input:focus,
textarea:focus {
  outline: none;
  border-color: var(--muted);
  box-shadow: 0 0 0 3px var(--bg-subtle);
}

input::placeholder,
textarea::placeholder {
  color: #9ca3af;
}

textarea {
  min-height: 120px;
  resize: vertical;
  line-height: 1.5;
}

#content {
  min-height: 300px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.875rem;
}

.actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-top: 0.5rem;
  align-items: center;
}

.admin-item {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  margin-bottom: 1rem;
  background: var(--surface);
  transition: border-color 0.2s ease;
}

.admin-item:hover {
  border-color: #d1d5db;
}

.admin-item h3 {
  margin: 0 0 0.5rem 0;
  font-size: 1.125rem;
  font-weight: 600;
  line-height: 1.3;
}

.admin-item .admin-meta {
  font-size: 0.875rem;
  color: var(--muted);
  margin-bottom: 1rem;
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.admin-item .admin-meta .badge {
  display: inline-flex;
  align-items: center;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  background: var(--bg-subtle);
  border: 1px solid var(--line);
}

.admin-item .admin-meta .badge.published {
  background: var(--success-bg);
  border-color: var(--success-border);
  color: var(--success-text);
}

.admin-item .actions {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}

/* Notices */
.notice {
  padding: 1rem;
  border-radius: var(--radius-md);
  margin-bottom: 1.5rem;
  font-size: 0.95rem;
  border: 1px solid var(--success-border);
  background: var(--success-bg);
  color: var(--success-text);
  font-weight: 500;
}

.notice.error {
  border-color: var(--danger-border);
  background: var(--danger-bg);
  color: var(--danger-text);
}

.empty-state {
  text-align: center;
  padding: 4rem 2rem;
  background: var(--bg-subtle);
  border-radius: var(--radius-lg);
  border: 1px dashed var(--line);
}

.empty-state h2,
.empty-state h1 {
  margin: 0 0 0.5rem 0;
  font-size: 1.5rem;
  font-weight: 600;
}

.empty-state p {
  color: var(--muted);
  margin: 0;
}

@media (max-width: 768px) {
  .admin-shell {
    grid-template-columns: 1fr;
    gap: 2rem;
  }

  .header-main {
    flex-direction: column;
    align-items: stretch;
  }

  .header-actions {
    display: flex;
    justify-content: flex-end;
  }
}

/* Footer */
.site-footer {
  margin-top: auto;
  padding: 2rem 0;
  background: var(--bg);
  border-top: 1px solid var(--line);
}

.footer-content {
  width: min(800px, calc(100% - 2rem));
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
}

.footer-info {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  color: var(--ink);
  font-size: 0.875rem;
  font-weight: 500;
}

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

.footer-links {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
  justify-content: center;
}

.footer-links a {
  color: var(--muted);
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: underline;
  text-decoration-color: transparent;
  transition: all 0.2s ease;
}

.footer-links a:hover {
  color: var(--ink);
  text-decoration-color: var(--line);
}

@media (min-width: 640px) {
  .footer-content {
    flex-direction: row;
    justify-content: space-between;
    text-align: left;
  }
}