:root {
  color-scheme: light;
  --ink: #172033;
  --muted: #6b7280;
  --line: #e5e7eb;
  --surface: rgba(255, 255, 255, 0.9);
  --surface-solid: #ffffff;
  --soft: #f5f7fb;
  --primary: #3157d5;
  --primary-hover: #2849b8;
  --danger: #c73545;
  --danger-soft: #fff1f2;
  --shadow: 0 24px 70px rgba(31, 41, 55, 0.12);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
}

body {
  color: var(--ink);
  background: #eef2f8;
}

button,
input,
textarea {
  font: inherit;
}

button,
.button-link {
  border: 0;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 650;
  transition: 160ms ease;
}

.deploy-button {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 16px;
  color: #fff;
  background: #172033;
  box-shadow: 0 8px 18px rgba(23, 32, 51, 0.16);
}

.deploy-button:hover {
  background: #263249;
  transform: translateY(-1px);
}

.deploy-button.pending {
  background: #b86b12;
  box-shadow: 0 8px 18px rgba(184, 107, 18, 0.2);
}

.deploy-button.pending:hover {
  background: #9d590d;
}

.deploy-button:disabled {
  cursor: wait;
  opacity: 0.68;
  transform: none;
}

.deploy-indicator {
  width: 7px;
  height: 7px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: #80e1bd;
  box-shadow: 0 0 0 3px rgba(128, 225, 189, 0.14);
}

.deploy-button.pending .deploy-indicator {
  background: #ffe1a6;
  box-shadow: 0 0 0 3px rgba(255, 225, 166, 0.18);
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(49, 87, 213, 0.22);
  outline-offset: 2px;
}

.background {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 15% 15%, rgba(80, 106, 222, 0.18), transparent 33%),
    radial-gradient(circle at 85% 80%, rgba(45, 160, 131, 0.12), transparent 30%),
    linear-gradient(145deg, #f7f8fc, #e9eef8);
}

.login-shell {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(100%, 430px);
  padding: 44px;
  border: 1px solid rgba(255, 255, 255, 0.85);
  border-radius: 24px;
  background: var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.brand-mark {
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
  border-radius: 17px;
  color: #fff;
  background: linear-gradient(145deg, #172033, #3157d5);
  box-shadow: 0 12px 24px rgba(49, 87, 213, 0.25);
  font-family: Georgia, "Noto Serif SC", serif;
  font-size: 26px;
  font-weight: 700;
}

.brand-mark.compact {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  font-size: 19px;
}

.eyebrow {
  margin: 22px 0 8px;
  color: var(--primary);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.18em;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 12px;
  font-size: 30px;
  letter-spacing: -0.035em;
}

h2 {
  margin-bottom: 0;
  font-size: 21px;
}

.muted {
  color: var(--muted);
  line-height: 1.7;
}

.login-card form {
  margin-top: 30px;
}

label,
.field > span {
  color: #40485a;
  font-size: 13px;
  font-weight: 650;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--ink);
  background: #fff;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

input {
  height: 43px;
  padding: 0 13px;
}

textarea {
  padding: 11px 13px;
  resize: vertical;
}

input:focus,
textarea:focus {
  border-color: rgba(49, 87, 213, 0.65);
  box-shadow: 0 0 0 3px rgba(49, 87, 213, 0.08);
}

.password-row {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.primary,
.ghost,
.danger {
  min-height: 40px;
  padding: 0 16px;
}

.primary {
  color: #fff;
  background: var(--primary);
  box-shadow: 0 8px 18px rgba(49, 87, 213, 0.2);
}

.primary:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
}

.ghost {
  color: #4b5563;
  background: #f0f2f6;
}

.ghost:hover {
  color: var(--ink);
  background: #e6e9ef;
}

.danger {
  color: var(--danger);
  background: var(--danger-soft);
}

.danger:hover {
  background: #ffe2e6;
}

.small {
  min-height: 36px;
  padding: 0 12px;
  font-size: 12px;
}

.wide {
  width: 100%;
  margin-top: 18px;
}

.form-error {
  min-height: 20px;
  margin: 12px 0 0;
  color: var(--danger);
  font-size: 13px;
}

.app-shell {
  position: relative;
  z-index: 1;
  min-height: 100vh;
}

.topbar {
  height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  border-bottom: 1px solid rgba(229, 231, 235, 0.9);
  background: rgba(255, 255, 255, 0.87);
  backdrop-filter: blur(16px);
}

.brand-inline,
.topbar-actions,
.toolbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-inline > div:last-child {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.brand-inline span:last-child {
  color: var(--muted);
  font-size: 11px;
}

.button-link {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  padding: 0 16px;
  text-decoration: none;
}

.workspace {
  height: calc(100vh - 68px);
  display: grid;
  grid-template-columns: 350px minmax(0, 1fr);
  background: rgba(248, 250, 252, 0.75);
}

.sidebar {
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 25px 20px 20px;
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.86);
}

.sidebar-title,
.editor-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidebar-title .eyebrow,
.editor-toolbar .eyebrow {
  margin: 0 0 6px;
}

.icon-button {
  width: 40px;
  padding: 0;
  font-size: 24px;
  line-height: 1;
}

.search-box {
  height: 42px;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 20px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--soft);
}

.search-box span {
  color: var(--muted);
  font-size: 20px;
}

.search-box input {
  height: auto;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.filters {
  display: flex;
  gap: 4px;
  margin: 14px 0;
  padding: 4px;
  border-radius: 10px;
  background: var(--soft);
}

.filter {
  flex: 1;
  min-height: 32px;
  padding: 0 7px;
  color: var(--muted);
  background: transparent;
  font-size: 12px;
}

.filter span {
  margin-left: 3px;
  font-variant-numeric: tabular-nums;
}

.filter.active {
  color: var(--ink);
  background: #fff;
  box-shadow: 0 2px 7px rgba(31, 41, 55, 0.08);
}

.post-list {
  min-height: 0;
  overflow-y: auto;
  padding-right: 4px;
}

.taxonomy-button {
  min-height: 38px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0 0 10px;
  padding: 0 12px;
  border: 1px solid var(--line);
  color: #4b5563;
  background: #fff;
  font-size: 12px;
  text-align: left;
}

.taxonomy-button:hover {
  color: var(--primary);
  border-color: rgba(49, 87, 213, 0.3);
}

.post-card {
  width: 100%;
  display: block;
  margin-bottom: 8px;
  padding: 14px;
  border: 1px solid transparent;
  border-radius: 12px;
  text-align: left;
  background: transparent;
}

.post-card:hover {
  background: var(--soft);
}

.post-card.active {
  border-color: rgba(49, 87, 213, 0.24);
  background: #eef2ff;
}

.post-card strong {
  display: block;
  overflow: hidden;
  color: var(--ink);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.post-meta,
.post-tags {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 7px;
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}

.status-dot {
  width: 7px;
  height: 7px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: #2f9e70;
}

.status-dot.draft {
  background: #e09a28;
}

.post-tags span {
  padding: 3px 6px;
  border-radius: 6px;
  background: rgba(107, 114, 128, 0.08);
}

.list-empty {
  padding: 34px 10px;
  color: var(--muted);
  text-align: center;
  font-size: 13px;
  line-height: 1.7;
}

.editor-panel {
  min-width: 0;
  min-height: 0;
  background: rgba(255, 255, 255, 0.6);
}

.empty-state {
  height: 100%;
  display: grid;
  place-content: center;
  justify-items: center;
  padding: 30px;
  text-align: center;
}

.empty-state p {
  max-width: 470px;
  margin: 12px 0 22px;
  color: var(--muted);
  line-height: 1.7;
}

.empty-icon {
  margin-bottom: 18px;
  color: var(--primary);
  font-size: 46px;
}

#editor-form {
  height: 100%;
}

.editor-toolbar {
  min-height: 78px;
  padding: 15px 30px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.88);
}

.editor-scroll {
  height: calc(100% - 78px);
  overflow-y: auto;
  padding: 26px 30px 50px;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 17px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.span-2 {
  grid-column: span 2;
}

.input-suffix {
  display: flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}

.input-suffix input {
  border: 0;
  box-shadow: none;
}

.input-suffix span {
  padding-right: 13px;
  color: var(--muted);
  font-size: 13px;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 22px;
  padding-top: 24px;
}

.check-row label {
  display: flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
}

.check-row input {
  width: 17px;
  height: 17px;
  accent-color: var(--primary);
}

.content-tabs {
  display: flex;
  gap: 4px;
  margin-top: 28px;
  border-bottom: 1px solid var(--line);
}

.content-tab {
  padding: 10px 16px;
  border-radius: 8px 8px 0 0;
  color: var(--muted);
  background: transparent;
}

.content-tab.active {
  color: var(--primary);
  box-shadow: inset 0 -2px var(--primary);
}

.markdown-editor,
.preview-pane {
  width: 100%;
  min-height: 500px;
  margin-top: 16px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}

.markdown-editor {
  resize: vertical;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 14px;
  line-height: 1.75;
  tab-size: 2;
}

.preview-pane {
  color: #242b38;
  line-height: 1.8;
}

.preview-pane h1,
.preview-pane h2,
.preview-pane h3 {
  margin-top: 1.5em;
  margin-bottom: 0.55em;
}

.preview-pane h1 {
  font-size: 28px;
}

.preview-pane h2 {
  font-size: 22px;
}

.preview-pane h3 {
  font-size: 18px;
}

.preview-pane p,
.preview-pane ul,
.preview-pane ol,
.preview-pane blockquote {
  margin: 0 0 1em;
}

.preview-pane code {
  padding: 2px 5px;
  border-radius: 5px;
  background: #f0f2f6;
  font-family: "SFMono-Regular", Consolas, monospace;
}

.preview-pane pre {
  overflow-x: auto;
  padding: 16px;
  border-radius: 10px;
  color: #e5e7eb;
  background: #172033;
}

.preview-pane pre code {
  padding: 0;
  color: inherit;
  background: transparent;
}

.preview-pane img {
  max-width: 100%;
  border-radius: 10px;
}

.preview-pane blockquote {
  padding-left: 14px;
  border-left: 3px solid var(--primary);
  color: var(--muted);
}

.toast {
  position: fixed;
  z-index: 20;
  right: 24px;
  bottom: 24px;
  max-width: min(390px, calc(100vw - 48px));
  padding: 12px 16px;
  border-radius: 11px;
  color: #fff;
  background: #172033;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: 180ms ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.toast.error {
  background: var(--danger);
}

dialog {
  width: min(430px, calc(100vw - 36px));
  padding: 0;
  border: 0;
  border-radius: 17px;
  box-shadow: var(--shadow);
}

dialog::backdrop {
  background: rgba(23, 32, 51, 0.45);
  backdrop-filter: blur(3px);
}

dialog form {
  padding: 28px;
}

dialog p {
  margin: 12px 0 24px;
  color: var(--muted);
  line-height: 1.65;
}

.taxonomy-dialog {
  width: min(620px, calc(100vw - 36px));
  max-height: min(720px, calc(100vh - 40px));
}

.taxonomy-dialog-content {
  padding: 26px;
}

.taxonomy-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.taxonomy-heading .eyebrow {
  margin: 0 0 6px;
}

.taxonomy-hint {
  margin: 14px 0 18px;
  font-size: 13px;
}

.taxonomy-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.taxonomy-tab {
  min-height: 34px;
  padding: 0 13px;
  color: var(--muted);
  background: transparent;
  font-size: 13px;
}

.taxonomy-tab.active {
  color: #fff;
  background: var(--primary);
}

.taxonomy-list {
  max-height: 420px;
  overflow-y: auto;
}

.taxonomy-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.taxonomy-item:last-child {
  border-bottom: 0;
}

.taxonomy-item-label {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.taxonomy-item-label strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}

.taxonomy-item-label small {
  color: var(--muted);
  font-size: 11px;
}

.taxonomy-item-actions {
  flex: 0 0 auto;
  display: flex;
  gap: 5px;
}

.taxonomy-item-actions button {
  min-height: 32px;
}

.taxonomy-edit-dialog {
  width: min(430px, calc(100vw - 36px));
}

.taxonomy-edit-dialog .field {
  margin-bottom: 20px;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 9px;
}

[hidden] {
  display: none !important;
}

@media (max-width: 820px) {
  .topbar {
    padding: 0 16px;
  }

  .workspace {
    height: auto;
    min-height: calc(100vh - 68px);
    grid-template-columns: 1fr;
  }

  .sidebar {
    max-height: 46vh;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .editor-panel {
    min-height: 54vh;
  }

  #editor-form {
    min-height: 720px;
  }

  .editor-toolbar,
  .editor-scroll {
    padding-left: 18px;
    padding-right: 18px;
  }
}

@media (max-width: 560px) {
  .login-card {
    padding: 32px 24px;
  }

  .topbar-actions .button-link {
    display: none;
  }

  .deploy-button {
    padding: 0 11px;
  }

  .field-grid {
    grid-template-columns: 1fr;
  }

  .span-2 {
    grid-column: auto;
  }

  .editor-toolbar {
    align-items: flex-start;
    gap: 10px;
  }

  .toolbar-actions {
    gap: 6px;
  }

  .primary,
  .ghost,
  .danger {
    padding: 0 11px;
  }
}
