/* ---- Post + Post Index styles ---- */
.post-container {
  max-width: var(--w-narrow);
  margin: 8rem auto 4rem;
  padding: 0 2rem;
}

.post-header {
  margin-bottom: 3rem;
  padding-bottom: 2rem;
  border-bottom: 1px solid var(--c-border);
}

.post-back {
  display: inline-block;
  margin-bottom: 1.5rem;
  font-size: 0.9rem;
  color: var(--c-text-dim);
  text-decoration: none;
  transition: color 0.3s var(--ease);
}

.post-back:hover {
  color: var(--c-accent);
}

.post-title {
  font-family: var(--font-display);
  font-size: 3rem;
  font-weight: 400;
  color: var(--c-heading);
  line-height: 1.15;
  margin-bottom: 1rem;
}

.post-meta {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  font-size: 0.9rem;
  color: var(--c-text-dim);
}

.post-tags,
.post-list-tags {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.post-tag {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  border: 1px solid var(--c-border);
  border-radius: 999px;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.post-body {
  line-height: 1.8;
  color: var(--c-text-dim);
  font-size: 1.05rem;
}

.post-body h1,
.post-body h2,
.post-body h3,
.post-body h4 {
  font-family: var(--font-display);
  color: var(--c-heading);
  margin-top: 2.5rem;
  margin-bottom: 1rem;
  font-weight: 400;
  line-height: 1.3;
}

.post-body h2 { font-size: 2rem; }
.post-body h3 { font-size: 1.5rem; }
.post-body h4 { font-size: 1.2rem; }

.post-body p { margin-bottom: 1.5rem; }
.post-body ul, .post-body ol { margin-bottom: 1.5rem; padding-left: 2rem; }
.post-body li { margin-bottom: 0.5rem; }
.post-body a { color: var(--c-accent); text-decoration: none; }
.post-body a:hover { text-decoration: underline; }

.post-body blockquote {
  margin: 1.5rem 0;
  padding: 1rem 1.5rem;
  border-left: 3px solid var(--c-accent);
  background: var(--c-bg-alt);
  color: var(--c-text);
  font-style: italic;
}

.post-body pre {
  background: var(--c-bg-alt);
  padding: 1.5rem;
  border-radius: 4px;
  overflow-x: auto;
  margin-bottom: 1.5rem;
  border: 1px solid var(--c-border);
}

.post-body code {
  font-family: 'Fira Code', 'Consolas', monospace;
  font-size: 0.9rem;
}

.post-body :not(pre) > code {
  background: var(--c-bg-alt);
  padding: 0.15rem 0.4rem;
  border-radius: 3px;
}

.post-body img,
.post-body picture {
  max-width: 100%;
  height: auto;
  border-radius: 4px;
  margin: 1.5rem 0;
}

.post-body .mermaid {
  background: var(--c-bg-alt);
  padding: 1.5rem;
  border-radius: 4px;
  border: 1px solid var(--c-border);
  margin: 1.5rem 0;
  text-align: center;
}

.post-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
}

.post-body th,
.post-body td {
  padding: 0.75rem 1rem;
  border: 1px solid var(--c-border);
  text-align: left;
}

.post-body th {
  background: var(--c-bg-alt);
  color: var(--c-heading);
  font-weight: 600;
}

/* ---- Post index ---- */
.post-index-header {
  margin-bottom: 3rem;
  padding-bottom: 2rem;
  border-bottom: 1px solid var(--c-border);
}

.post-index-title {
  font-family: var(--font-display);
  font-size: 3rem;
  font-weight: 400;
  color: var(--c-heading);
  margin-bottom: 0.5rem;
}

.post-index-intro {
  color: var(--c-text-dim);
  font-size: 1.1rem;
}

.post-list {
  list-style: none;
  padding: 0;
}

.post-list-item {
  margin-bottom: 1rem;
}

.post-list-link {
  display: flex !important;
  gap: 2rem;
  padding: 1.5rem 2rem;
  background: var(--c-bg-alt);
  border: 1px solid var(--c-border);
  border-radius: 4px;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.3s var(--ease), transform 0.3s var(--ease);
  align-items: center;
}

.post-list-link:hover {
  border-color: var(--c-accent);
  transform: translateY(-2px);
}

.post-list-thumb {
  flex-shrink: 0;
  width: 120px;
  height: 80px;
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid var(--c-border);
  background: var(--c-bg);
}

.post-list-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.post-list-content {
  flex: 1;
}

.post-list-title {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 400;
  color: var(--c-heading);
  margin-bottom: 0.5rem;
}

.post-list-date {
  display: block;
  font-size: 0.85rem;
  color: var(--c-text-dim);
  margin-bottom: 0.5rem;
}

.post-empty {
  padding: 3rem;
  text-align: center;
  color: var(--c-text-dim);
  background: var(--c-bg-alt);
  border-radius: 4px;
  border: 1px solid var(--c-border);
}

/* ---- TipTap editor ---- */
.tiptap-toolbar {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.5rem;
  background: var(--c-bg-alt);
  border: 1px solid var(--c-border);
  border-bottom: none;
  border-radius: 4px 4px 0 0;
  flex-wrap: wrap;
}

.tiptap-toolbar button {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 3px;
  color: var(--c-text);
  padding: 0.35rem 0.65rem;
  font-size: 0.9rem;
  cursor: pointer;
  font-family: var(--font-body);
  transition: background 0.15s, border-color 0.15s;
  margin: 0;
}

.tiptap-toolbar button:hover {
  background: var(--c-bg);
  border-color: var(--c-border);
}

.tiptap-toolbar .tt-sep {
  width: 1px;
  height: 1.25rem;
  background: var(--c-border);
  margin: 0 0.25rem;
}

.tiptap-toolbar .tt-flex {
  flex: 1;
  background: transparent;
}

.tiptap-editor {
  border: 1px solid var(--c-border);
  border-radius: 0 0 4px 4px;
  background: var(--c-bg);
  min-height: 400px;
  padding: 1.5rem;
  color: var(--c-text);
  line-height: 1.7;
}

.tiptap-editor .ProseMirror {
  outline: none;
  min-height: 360px;
}

.tiptap-editor .ProseMirror p { margin: 0 0 1rem; }
.tiptap-editor .ProseMirror h1,
.tiptap-editor .ProseMirror h2,
.tiptap-editor .ProseMirror h3 {
  font-family: var(--font-display);
  font-weight: 400;
  color: var(--c-heading);
  margin: 1.5rem 0 0.75rem;
  line-height: 1.3;
}
.tiptap-editor .ProseMirror h2 { font-size: 1.75rem; }
.tiptap-editor .ProseMirror h3 { font-size: 1.35rem; }
.tiptap-editor .ProseMirror ul,
.tiptap-editor .ProseMirror ol { padding-left: 1.5rem; margin: 0 0 1rem; }
.tiptap-editor .ProseMirror blockquote {
  border-left: 3px solid var(--c-accent);
  padding-left: 1rem;
  margin: 1rem 0;
  color: var(--c-text-dim);
  font-style: italic;
}
.tiptap-editor .ProseMirror code {
  background: var(--c-bg-alt);
  padding: 0.15rem 0.4rem;
  border-radius: 3px;
  font-family: 'Fira Code', 'Consolas', monospace;
  font-size: 0.9rem;
}
.tiptap-editor .ProseMirror pre {
  background: var(--c-bg-alt);
  padding: 1rem 1.25rem;
  border-radius: 4px;
  border: 1px solid var(--c-border);
  overflow-x: auto;
  margin: 1rem 0;
}
.tiptap-editor .ProseMirror pre code {
  background: transparent;
  padding: 0;
}
.tiptap-editor .ProseMirror a {
  color: var(--c-accent);
  text-decoration: underline;
}
.tiptap-editor .ProseMirror p.is-editor-empty:first-child::before {
  content: attr(data-placeholder);
  float: left;
  color: var(--c-text-dim);
  pointer-events: none;
  height: 0;
}

.tt-hidden {
  display: none !important;
}

/* ---- Save banner ---- */
.save-banner {
  margin-bottom: 1.5rem;
  padding: 1rem 1.5rem;
  background: var(--c-bg-alt);
  border: 1px solid var(--c-accent);
  border-left-width: 4px;
  border-radius: 4px;
  color: var(--c-text);
  font-size: 0.95rem;
}

.save-banner code {
  background: var(--c-bg);
  padding: 0.15rem 0.4rem;
  border-radius: 3px;
  font-family: 'Fira Code', 'Consolas', monospace;
}

.save-banner a {
  color: var(--c-accent);
  font-weight: 600;
}

/* ---- Edit form additions ---- */
.edit-meta-row {
  display: grid;
  grid-template-columns: 1fr 1.5fr 2fr auto;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
  align-items: end;
}

.edit-meta-row .edit-input {
  margin-bottom: 0;
}

.edit-published {
  white-space: nowrap;
  padding-bottom: 1rem;
}

.edit-published label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
  cursor: pointer;
}

@media (max-width: 700px) {
  .edit-meta-row {
    grid-template-columns: 1fr;
  }
  .post-title {
    font-size: 2rem;
  }
}
