:root {
  --bg: #ffffff;
  --bg-elevated: #ffffff;
  --fg: #37352f;
  --fg-muted: rgba(55, 53, 47, 0.65);
  --fg-faint: rgba(55, 53, 47, 0.45);
  --sidebar: #f7f7f5;
  --sidebar-active: rgba(55, 53, 47, 0.08);
  --hover: rgba(55, 53, 47, 0.055);
  --border: rgba(55, 53, 47, 0.09);
  --border-strong: rgba(55, 53, 47, 0.16);
  --blue: #2383e2;
  --blue-hover: #1a70c7;
  --blue-bg: rgba(35, 131, 226, 0.1);
  --red: #eb5757;
  --green: #0f7b6c;
  --code-bg: #f7f6f3;
  --code-border: rgba(55, 53, 47, 0.09);
  --quote-border: #37352f;
  --shadow: rgba(15, 15, 15, 0.05) 0 1px 2px, rgba(15, 15, 15, 0.1) 0 0 0 1px;
  --radius: 6px;
  --radius-lg: 10px;
  --content-width: 720px;
  --sidebar-width: 258px;
  --font: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica,
    "Apple Color Emoji", Arial, sans-serif, "Segoe UI Emoji", "Segoe UI Symbol";
  --mono: "SFMono-Regular", Menlo, Consolas, "Liberation Mono", monospace;
}

[data-theme="dark"] {
  --bg: #191919;
  --bg-elevated: #202020;
  --fg: #e9e9e7;
  --fg-muted: rgba(255, 255, 255, 0.66);
  --fg-faint: rgba(255, 255, 255, 0.42);
  --sidebar: #202020;
  --sidebar-active: rgba(255, 255, 255, 0.09);
  --hover: rgba(255, 255, 255, 0.055);
  --border: rgba(255, 255, 255, 0.094);
  --border-strong: rgba(255, 255, 255, 0.16);
  --blue: #529cca;
  --blue-hover: #6eaad4;
  --blue-bg: rgba(82, 156, 202, 0.16);
  --red: #ff7369;
  --green: #4dab9a;
  --code-bg: #252525;
  --code-border: rgba(255, 255, 255, 0.08);
  --quote-border: #e9e9e7;
  --shadow: rgba(0, 0, 0, 0.4) 0 1px 2px, rgba(255, 255, 255, 0.06) 0 0 0 1px;
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--font);
  color: var(--fg);
  background: var(--bg);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: inherit;
  text-decoration: none;
}

::selection {
  background: var(--blue-bg);
}

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--bg);
  padding: 8px 12px;
  z-index: 100;
}
.skip-link:focus {
  left: 12px;
  top: 12px;
}

/* ---------- Layout ---------- */

.layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-width);
  flex: 0 0 var(--sidebar-width);
  background: var(--sidebar);
  border-right: 1px solid var(--border);
  height: 100vh;
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  padding: 12px 10px 14px;
  overflow-y: auto;
  z-index: 40;
}

.sidebar-head {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 2px 4px 12px;
}

.site-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 6px 8px;
  border-radius: var(--radius);
  flex: 1;
}
.site-brand:hover {
  background: var(--hover);
}
.site-logo {
  font-size: 18px;
  line-height: 1;
}
.site-name {
  font-weight: 600;
  font-size: 14.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 5px 9px;
  border-radius: var(--radius);
  color: var(--fg-muted);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-family: inherit;
  line-height: 1.5;
}
.nav-item:hover {
  background: var(--hover);
  color: var(--fg);
}
.nav-item.is-active {
  background: var(--sidebar-active);
  color: var(--fg);
}
.nav-icon {
  font-size: 14px;
  width: 18px;
  text-align: center;
  flex: 0 0 18px;
}

.nav-section {
  margin: 16px 9px 6px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--fg-faint);
}

.nav-tag-name {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tag-dot {
  width: 9px;
  height: 9px;
  border-radius: 2px;
  background: var(--fg-faint);
  flex: 0 0 9px;
  margin-left: 4px;
}
.nav-count {
  font-size: 11.5px;
  color: var(--fg-faint);
  font-variant-numeric: tabular-nums;
}

.sidebar-foot {
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 45px;
  padding: 0 14px;
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 30;
}
.topbar::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 1px;
  background: var(--border);
}

.crumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  color: var(--fg-muted);
  min-width: 0;
  flex: 1;
}
.crumb a {
  padding: 3px 6px;
  border-radius: 4px;
  white-space: nowrap;
}
.crumb a:hover {
  background: var(--hover);
}
.crumb-current {
  color: var(--fg);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.crumb-sep {
  color: var(--fg-faint);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 2px;
}

.icon-btn {
  border: none;
  background: none;
  color: var(--fg-muted);
  cursor: pointer;
  font-size: 16px;
  padding: 5px 7px;
  border-radius: var(--radius);
  line-height: 1;
  font-family: inherit;
}
.icon-btn:hover {
  background: var(--hover);
  color: var(--fg);
}

#sidebar-toggle,
.sidebar-close {
  display: none;
}

.main {
  flex: 1;
  width: 100%;
  max-width: var(--content-width);
  margin: 0 auto;
  padding: 28px 56px 40px;
}

.site-header {
  max-width: var(--content-width);
  width: 100%;
  margin: 0 auto;
  padding: 40px 56px 4px;
}
.site-header-title {
  display: inline-block;
  font-size: 21px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--fg);
}
.site-header-title:hover {
  color: var(--blue);
}

.footer {
  max-width: var(--content-width);
  width: 100%;
  margin: 0 auto;
  padding: 24px 56px 48px;
  color: var(--fg-faint);
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 7px;
}
.footer a:hover {
  color: var(--fg);
  text-decoration: underline;
}
.dot {
  color: var(--fg-faint);
}

/* ---------- Home / list ---------- */

.hero {
  margin-bottom: 26px;
}
.hero-title {
  font-size: 40px;
  line-height: 1.2;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 8px;
}
.hero-sub {
  margin: 0;
  color: var(--fg-muted);
  font-size: 16px;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 26px;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 13px;
  color: var(--fg-muted);
  background: var(--hover);
  transition: background 0.12s ease, color 0.12s ease;
}
.chip:hover {
  background: var(--sidebar-active);
  color: var(--fg);
}
.chip.is-active {
  background: var(--blue-bg);
  color: var(--blue);
  font-weight: 600;
}
.chip-count {
  font-size: 11.5px;
  opacity: 0.7;
}

.search-form {
  display: flex;
  gap: 8px;
  margin-bottom: 22px;
}
.search-form input {
  flex: 1;
  font: inherit;
  padding: 9px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--fg);
}
.search-form input:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 2px var(--blue-bg);
}
.result-note {
  color: var(--fg-muted);
  font-size: 14px;
  margin: 0 0 18px;
}

.post-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 0 -12px;
}

.post-card {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 13px 12px;
  border-radius: var(--radius-lg);
  transition: background 0.12s ease;
}
.post-card:hover {
  background: var(--hover);
}
.post-card-icon {
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  border-radius: var(--radius);
  background: var(--code-bg);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  overflow: hidden;
}
.post-card-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.post-card-hash {
  font-size: 12px;
  font-weight: 600;
  color: var(--fg-muted);
  padding: 0 4px;
  text-align: center;
  overflow: hidden;
}
.post-card-main {
  flex: 1;
  min-width: 0;
}
.post-card-title {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
  line-height: 1.4;
  letter-spacing: -0.01em;
}
.post-card-summary {
  margin: 3px 0 0;
  color: var(--fg-muted);
  font-size: 14px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.post-card-meta {
  margin-top: 7px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 7px;
  font-size: 12.5px;
  color: var(--fg-faint);
}
.post-card-arrow {
  align-self: center;
  color: var(--fg-faint);
  opacity: 0;
  transition: opacity 0.12s ease, transform 0.12s ease;
}
.post-card:hover .post-card-arrow {
  opacity: 1;
  transform: translateX(2px);
}

.tag {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 3px;
  background: var(--hover);
  color: var(--fg-muted);
  font-size: 12px;
  line-height: 1.7;
}
a.tag:hover {
  background: var(--sidebar-active);
  color: var(--fg);
}

.badge {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 3px;
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1.7;
}
.badge-live {
  background: rgba(15, 123, 108, 0.12);
  color: var(--green);
}
.badge-draft {
  background: rgba(55, 53, 47, 0.08);
  color: var(--fg-muted);
}

.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 32px;
}
.pager-info {
  color: var(--fg-faint);
  font-size: 13px;
}

.empty {
  text-align: center;
  padding: 70px 20px;
  color: var(--fg-faint);
}
.empty-icon {
  font-size: 40px;
  margin-bottom: 10px;
}

.site-legal {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 44px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  color: var(--fg-faint);
  font-size: 13px;
}
.site-legal a:hover {
  color: var(--fg);
  text-decoration: underline;
}

/* ---------- Buttons / forms ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border-strong);
  background: var(--bg-elevated);
  color: var(--fg);
  font: inherit;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.12s ease, border-color 0.12s ease;
}
.btn:hover {
  background: var(--hover);
}
.btn.primary {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
}
.btn.primary:hover {
  background: var(--blue-hover);
  border-color: var(--blue-hover);
}
.btn.danger {
  color: var(--red);
  border-color: var(--border);
}
.btn.danger:hover {
  background: rgba(235, 87, 87, 0.1);
  border-color: rgba(235, 87, 87, 0.4);
}
.btn.small {
  padding: 3px 9px;
  font-size: 12.5px;
}
.btn.block {
  width: 100%;
}
.btn.is-disabled {
  opacity: 0.4;
  pointer-events: none;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}
.field > span {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--fg-muted);
}
.field input,
.field textarea,
.field select {
  font: inherit;
  font-size: 14px;
  padding: 8px 11px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--fg);
  width: 100%;
  resize: vertical;
}
.field input:focus,
.field textarea:focus,
.field select:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 2px var(--blue-bg);
}
.input-with-btn {
  display: flex;
  gap: 8px;
}
.input-with-btn input {
  flex: 1;
}

.alert {
  padding: 10px 13px;
  border-radius: var(--radius);
  font-size: 14px;
  margin-bottom: 16px;
}
.alert-error {
  background: rgba(235, 87, 87, 0.1);
  color: var(--red);
  border: 1px solid rgba(235, 87, 87, 0.25);
}
.alert-warn {
  background: rgba(203, 145, 47, 0.12);
  color: #b26a00;
  border: 1px solid rgba(203, 145, 47, 0.3);
}

/* ---------- Article ---------- */

.article {
  max-width: var(--content-width);
}
.article-head {
  margin-bottom: 26px;
}
.article-tags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.article-title {
  font-size: 40px;
  line-height: 1.2;
  font-weight: 700;
  letter-spacing: -0.022em;
  margin: 0 0 10px;
}
.article-summary {
  margin: 0 0 14px;
  color: var(--fg-muted);
  font-size: 17px;
  line-height: 1.6;
}
.article-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 7px;
  font-size: 13px;
  color: var(--fg-faint);
}
.article-cover {
  margin: 0 0 30px;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border);
}
.article-cover img {
  width: 100%;
  display: block;
}
.article-tools {
  margin-top: 34px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}
.article-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 40px;
  padding-top: 22px;
  border-top: 1px solid var(--border);
}
.article-nav-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  transition: background 0.12s ease;
}
.article-nav-item:hover {
  background: var(--hover);
}
.article-nav-item.is-next {
  text-align: right;
}
.article-nav-label {
  font-size: 12px;
  color: var(--fg-faint);
}
.article-nav-title {
  font-size: 14px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- Notion content ---------- */

.notion-content {
  font-size: 16px;
  line-height: 1.75;
  color: var(--fg);
  word-wrap: break-word;
}
.notion-content > *:first-child {
  margin-top: 0;
}
.notion-content > *:last-child {
  margin-bottom: 0;
}
.notion-content p {
  margin: 0 0 1em;
}
.notion-content h1,
.notion-content h2,
.notion-content h3,
.notion-content h4 {
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -0.01em;
  margin: 1.6em 0 0.5em;
}
.notion-content h1 {
  font-size: 1.85em;
}
.notion-content h2 {
  font-size: 1.45em;
}
.notion-content h3 {
  font-size: 1.2em;
}
.notion-content h4 {
  font-size: 1.05em;
}
.notion-content a {
  color: var(--blue);
  text-decoration: underline;
  text-decoration-color: rgba(35, 131, 226, 0.4);
  text-underline-offset: 2px;
}
.notion-content a:hover {
  text-decoration-color: var(--blue);
}
.notion-content ul,
.notion-content ol {
  margin: 0 0 1em;
  padding-left: 1.6em;
}
.notion-content li {
  margin: 0.25em 0;
}
.notion-content blockquote {
  margin: 1.2em 0;
  padding: 2px 0 2px 14px;
  border-left: 3px solid var(--quote-border);
  color: inherit;
}
.notion-content blockquote p {
  margin: 0.3em 0;
}
.notion-content img {
  max-width: 100%;
  border-radius: var(--radius);
  display: block;
  margin: 1.2em 0;
}
.notion-content hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2em 0;
}
.notion-content code {
  font-family: var(--mono);
  font-size: 85%;
  background: var(--code-bg);
  border: 1px solid var(--code-border);
  border-radius: 4px;
  padding: 0.15em 0.35em;
  color: #eb5757;
}
.notion-content pre {
  background: var(--code-bg);
  border: 1px solid var(--code-border);
  border-radius: var(--radius);
  padding: 14px 16px;
  overflow-x: auto;
  margin: 1.2em 0;
  line-height: 1.55;
}
.notion-content pre code {
  background: none;
  border: none;
  padding: 0;
  color: inherit;
  font-size: 13.5px;
}
.notion-content table {
  border-collapse: collapse;
  width: 100%;
  margin: 1.2em 0;
  font-size: 14.5px;
  overflow: hidden;
}
.notion-content th,
.notion-content td {
  border: 1px solid var(--border-strong);
  padding: 7px 10px;
  text-align: left;
}
.notion-content th {
  background: var(--code-bg);
  font-weight: 600;
}
.notion-content input[type="checkbox"] {
  margin-right: 6px;
}
.notion-content .task-list-item {
  list-style: none;
  margin-left: -1.4em;
}
.notion-content sup {
  font-size: 0.75em;
}

/* ---------- 404 ---------- */

.notfound {
  text-align: center;
  padding: 90px 20px;
}
.notfound-emoji {
  font-size: 56px;
  margin-bottom: 14px;
}
.notfound h1 {
  font-size: 28px;
  margin: 0 0 8px;
}
.notfound p {
  color: var(--fg-muted);
  margin: 0 0 22px;
}

/* ---------- Admin bar ---------- */

.admin-bar {
  display: flex;
  align-items: center;
  gap: 16px;
  height: 52px;
  padding: 0 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 30;
}
.admin-bar .site-brand {
  flex: 0 0 auto;
  width: auto;
}
.admin-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
}
.admin-nav > a,
.admin-nav .link-btn {
  padding: 5px 10px;
  border-radius: var(--radius);
  font-size: 14px;
  color: var(--fg-muted);
  font-weight: 500;
}
.admin-nav > a:hover,
.admin-nav .link-btn:hover {
  background: var(--hover);
  color: var(--fg);
}
.admin-nav > a.is-active {
  background: var(--sidebar-active);
  color: var(--fg);
}
.inline-form {
  display: inline;
  margin: 0;
}
.link-btn {
  border: none;
  background: none;
  cursor: pointer;
  font-family: inherit;
}

.admin-main {
  max-width: 1040px;
  margin: 0 auto;
  padding: 34px 28px 80px;
}

.admin-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 26px;
}
.admin-title {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 4px;
}
.admin-sub {
  margin: 0;
  color: var(--fg-faint);
  font-size: 13.5px;
}

.table-wrap {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.admin-table th {
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: var(--fg-faint);
  padding: 9px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--code-bg);
  white-space: nowrap;
}
.admin-table td {
  padding: 11px 14px;
  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(--hover);
}
.cell-title a {
  font-weight: 600;
  color: var(--fg);
}
.cell-title a:hover {
  color: var(--blue);
}
.cell-slug {
  font-size: 12px;
  color: var(--fg-faint);
  margin-top: 2px;
  font-family: var(--mono);
}
.cell-tags {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.cell-date {
  color: var(--fg-muted);
  white-space: nowrap;
}
.cell-actions {
  text-align: right;
  white-space: nowrap;
}
.cell-actions .btn {
  margin-left: 4px;
}

/* ---------- Editor ---------- */

.page-editor .admin-main {
  max-width: 1200px;
  padding-top: 22px;
}

.editor-bar {
  position: sticky;
  top: 52px;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0 12px;
  margin-bottom: 22px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.editor-bar-left,
.editor-bar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}
.editor-crumb {
  font-size: 14px;
  font-weight: 600;
  color: var(--fg);
}
.saved-hint {
  color: var(--green);
  font-size: 12.5px;
  font-weight: 600;
}

.editor-doc {
  min-width: 0;
}

.editor-title {
  width: 100%;
  border: none;
  background: none;
  font: inherit;
  font-size: 38px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.022em;
  color: var(--fg);
  padding: 2px 0 18px;
}
.editor-title:focus {
  outline: none;
}
.editor-title::placeholder {
  color: var(--fg-faint);
}

.editor-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px;
  padding: 8px 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.tool {
  border: 1px solid transparent;
  background: none;
  font: inherit;
  font-size: 13px;
  line-height: 1.2;
  color: var(--fg-muted);
  padding: 5px 10px;
  border-radius: var(--radius);
  cursor: pointer;
}
.tool:hover {
  background: var(--hover);
  color: var(--fg);
}
.tool[data-wrap="**"] {
  font-weight: 700;
}
.toolbar-spacer {
  flex: 1;
}

.editor-panes {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-top: 18px;
}
.editor-panes > * {
  min-height: 520px;
}

.editor-content {
  width: 100%;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1.75;
  background: var(--bg);
  color: var(--fg);
  resize: vertical;
}
.editor-content:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px var(--blue-bg);
}

.editor-preview {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--bg-elevated);
}
.editor-pane-head {
  padding: 9px 16px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--fg-faint);
  background: var(--code-bg);
  border-bottom: 1px solid var(--border);
}
.editor-preview .notion-content {
  flex: 1;
  overflow-y: auto;
  padding: 18px 22px 44px;
  font-size: 15px;
}

.settings-dialog {
  width: min(560px, calc(100vw - 32px));
  max-height: calc(100vh - 80px);
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--bg-elevated);
  color: var(--fg);
  box-shadow: 0 24px 64px rgba(15, 15, 15, 0.28);
  overflow: hidden;
}
.settings-dialog::backdrop {
  background: rgba(15, 15, 15, 0.42);
}
.settings-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  font-size: 15px;
  font-weight: 600;
}
.settings-body {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 20px 18px;
  max-height: 62vh;
  overflow-y: auto;
}
.settings-body .editor-panel {
  border: none;
  border-radius: 0;
  background: none;
  padding: 0;
}
.settings-foot {
  display: flex;
  justify-content: flex-end;
  padding: 12px 18px;
  border-top: 1px solid var(--border);
  background: var(--bg);
}
.editor-panel {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-elevated);
  padding: 15px 16px;
}
.editor-panel-head {
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--fg-faint);
  margin-bottom: 12px;
}
.editor-panel .field {
  margin-bottom: 12px;
}
.editor-panel .field:last-child {
  margin-bottom: 0;
}
.editor-panel textarea {
  min-height: 68px;
}
.editor-hint {
  margin: 10px 0 0;
  font-size: 12px;
  line-height: 1.55;
  color: var(--fg-faint);
}
.cover-field {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.cover-preview {
  aspect-ratio: 16 / 9;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--code-bg);
  display: flex;
  align-items: center;
  justify-content: center;
}
.cover-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.cover-preview.is-empty span {
  font-size: 12.5px;
  color: var(--fg-faint);
}
.cover-actions {
  display: flex;
  gap: 8px;
}
.hidden {
  display: none !important;
}

/* ---------- Media ---------- */

.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}
.media-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--bg-elevated);
  display: flex;
  flex-direction: column;
}
.media-thumb {
  aspect-ratio: 4 / 3;
  background: var(--code-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.media-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.media-meta {
  padding: 10px 12px;
  min-width: 0;
}
.media-name {
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.media-date {
  font-size: 11.5px;
  color: var(--fg-faint);
  margin-top: 2px;
}
.media-card .copy-btn {
  margin: 0 12px 12px;
}

/* ---------- Login ---------- */

.login-wrap {
  min-height: calc(100vh - 52px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
}
.login-card {
  width: 100%;
  max-width: 380px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px 28px;
  box-shadow: var(--shadow);
  background: var(--bg-elevated);
}
.login-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 14px;
  color: var(--fg-muted);
  margin-bottom: 18px;
}
.login-title {
  font-size: 22px;
  font-weight: 700;
  margin: 0 0 22px;
}
.login-form .field {
  margin-bottom: 14px;
}
.login-back {
  display: inline-block;
  margin-top: 20px;
  font-size: 13px;
  color: var(--fg-faint);
}
.login-back:hover {
  color: var(--fg);
}

/* ---------- Responsive ---------- */

@media (max-width: 900px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    transform: translateX(-100%);
    transition: transform 0.18s ease;
    box-shadow: var(--shadow);
  }
  body.sidebar-open .sidebar {
    transform: translateX(0);
  }
  #sidebar-toggle,
  .sidebar-close {
    display: inline-flex;
  }
  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 15, 15, 0.3);
    z-index: 35;
  }
  .main,
  .footer,
  .site-header {
    padding-left: 22px;
    padding-right: 22px;
  }
  .hero-title,
  .article-title {
    font-size: 30px;
  }
  .admin-table .cell-tags,
  .admin-table .cell-date {
    display: none;
  }
}

@media (max-width: 1080px) {
  .editor-panes {
    grid-template-columns: 1fr;
  }
}

@media (min-width: 901px) {
  .sidebar-backdrop {
    display: none;
  }
}
