:root {
  --blue: #1268b3;
  --blue-dark: #0b4f8c;
  --blue-soft: #eaf4ff;
  --navy: #10243b;
  --text: #17283b;
  --muted: #60758a;
  --line: #d8e2ec;
  --surface: #fff;
  --page: #f4f7fa;
  --danger: #a61b1b;
  --success: #177145;
  --shadow: 0 18px 45px rgb(20 52 82 / 10%);
  --radius: 14px;
}

* {
  box-sizing: border-box;
}

html {
  color: var(--text);
  background: var(--page);
  font-family:
    Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    'Segoe UI',
    sans-serif;
}

body {
  min-width: 320px;
  margin: 0;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

[hidden] {
  display: none !important;
}

.login-shell {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 1.5rem;
  background:
    radial-gradient(circle at 20% 10%, rgb(47 151 224 / 16%), transparent 35%),
    linear-gradient(135deg, #eef7ff 0%, #f8fbfd 50%, #e8f3fb 100%);
}

.login-card {
  width: min(100%, 430px);
  padding: clamp(2rem, 6vw, 3.25rem);
  border: 1px solid rgb(18 104 179 / 14%);
  border-radius: 20px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.brand-mark {
  display: grid;
  width: 3rem;
  height: 3rem;
  margin-bottom: 1.25rem;
  place-items: center;
  border-radius: 10px;
  color: #fff;
  background: linear-gradient(135deg, var(--blue), #47a6e6);
  font-size: 1.5rem;
  font-weight: 800;
}

.eyebrow,
.status-kicker {
  margin: 0 0 0.35rem;
  color: var(--blue);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

h1,
h2 {
  margin-top: 0;
  color: var(--navy);
}

.login-card h1 {
  margin-bottom: 0.5rem;
  font-size: 2rem;
}

.muted {
  margin-top: 0;
  color: var(--muted);
}

label {
  display: block;
  margin: 1rem 0 0.45rem;
  color: var(--navy);
  font-size: 0.9rem;
  font-weight: 700;
}

input,
textarea,
.rich-editor {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--text);
  background: #fff;
  outline: none;
  transition:
    border-color 160ms ease,
    box-shadow 160ms ease;
}

input,
textarea {
  padding: 0.78rem 0.85rem;
}

input:focus,
textarea:focus,
.rich-editor:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgb(18 104 179 / 12%);
}

input:disabled {
  color: var(--muted);
  background: #edf1f5;
}

.button {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.65rem 1rem;
  border: 1px solid transparent;
  border-radius: 9px;
  font-weight: 750;
  line-height: 1;
  text-decoration: none;
}

.button-primary {
  color: #fff;
  background: var(--blue);
}

.button-primary:hover {
  background: var(--blue-dark);
}

.button-secondary {
  border-color: var(--line);
  color: var(--navy);
  background: #fff;
}

.button-secondary:hover {
  border-color: #9eb6ca;
  background: #f8fafc;
}

.button-full {
  width: 100%;
}

.login-card .button {
  margin-top: 1.35rem;
}

.form-message,
.validation-message {
  min-height: 1.4em;
  margin: 0.85rem 0 0;
  color: var(--danger);
  font-size: 0.9rem;
}

.app-header {
  display: flex;
  min-height: 88px;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  padding: 1rem clamp(1.25rem, 3vw, 3rem);
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.app-header h1 {
  margin: 0;
  font-size: 1.55rem;
}

.header-actions,
.editor-actions,
.image-field,
.label-row {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.workspace {
  display: grid;
  min-height: calc(100vh - 88px);
  grid-template-columns: 300px minmax(0, 1fr);
}

.post-sidebar {
  padding: 1.35rem;
  border-right: 1px solid var(--line);
  background: #fff;
}

.search-label {
  margin-top: 1.5rem;
}

.post-list {
  display: grid;
  gap: 0.55rem;
  margin-top: 1rem;
}

.post-list-empty {
  padding: 1rem 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.post-list-button {
  width: 100%;
  padding: 0.8rem;
  border: 1px solid transparent;
  border-radius: 9px;
  color: var(--text);
  background: transparent;
  text-align: left;
}

.post-list-button:hover,
.post-list-button[aria-current='true'] {
  border-color: #c7ddf0;
  background: var(--blue-soft);
}

.post-list-title {
  display: block;
  margin-bottom: 0.3rem;
  font-size: 0.9rem;
  font-weight: 750;
  line-height: 1.3;
}

.post-list-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  color: var(--muted);
  font-size: 0.74rem;
}

.status-badge {
  padding: 0.18rem 0.4rem;
  border-radius: 99px;
  color: var(--blue-dark);
  background: #dfefff;
  font-weight: 800;
  text-transform: capitalize;
}

.status-badge.draft {
  color: #815100;
  background: #fff0ca;
}

.editor-panel {
  width: min(100%, 1120px);
  padding: clamp(1.5rem, 4vw, 3rem);
}

.editor-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.editor-heading h2 {
  margin-bottom: 0;
}

.save-state {
  color: var(--success);
  font-size: 0.9rem;
  font-weight: 700;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 1.25rem;
}

.field-wide {
  grid-column: 1 / -1;
}

.label-row {
  justify-content: space-between;
}

.label-row small,
small {
  color: var(--muted);
}

.slug-field {
  display: grid;
  align-items: center;
  grid-template-columns: auto minmax(8rem, 1fr) auto;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #f5f8fa;
}

.slug-field span {
  padding: 0 0.65rem;
  color: var(--muted);
  font-size: 0.82rem;
}

.slug-field input {
  border-width: 0 1px;
  border-radius: 0;
}

.image-field {
  align-items: stretch;
}

.upload-button {
  margin: 0;
}

.content-field {
  margin-top: 1.35rem;
}

.editor-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  padding: 0.55rem;
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 9px 9px 0 0;
  background: #f6f8fa;
}

.editor-toolbar button {
  min-height: 34px;
  padding: 0.35rem 0.6rem;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--navy);
  background: transparent;
  font-size: 0.82rem;
}

.editor-toolbar button:hover {
  border-color: var(--line);
  background: #fff;
}

.rich-editor {
  min-height: 430px;
  padding: 1.2rem;
  border-radius: 0 0 9px 9px;
  line-height: 1.7;
}

.rich-editor:empty::before {
  color: #8b9bab;
  content: attr(data-placeholder);
  pointer-events: none;
}

.rich-editor h2,
.rich-editor h3 {
  color: var(--navy);
}

.rich-editor img {
  max-width: 100%;
  height: auto;
}

.editor-actions {
  justify-content: flex-end;
  margin-top: 1.25rem;
}

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  overflow: hidden !important;
  clip: rect(1px, 1px, 1px, 1px) !important;
  white-space: nowrap !important;
}

dialog {
  width: min(1100px, calc(100% - 2rem));
  height: min(850px, calc(100% - 2rem));
  padding: 0;
  border: 0;
  border-radius: 16px;
  box-shadow: 0 24px 80px rgb(10 35 58 / 28%);
}

dialog::backdrop {
  background: rgb(10 35 58 / 62%);
}

.preview-header {
  display: flex;
  min-height: 82px;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.35rem;
  border-bottom: 1px solid var(--line);
}

.preview-header h2 {
  margin: 0;
}

#preview-frame {
  width: 100%;
  height: calc(100% - 82px);
  border: 0;
}

@media (max-width: 850px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .post-sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .post-list {
    max-height: 280px;
    overflow-y: auto;
  }
}

@media (max-width: 640px) {
  .app-header,
  .editor-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .header-actions .button {
    flex: 1;
  }

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

  .field-wide {
    grid-column: auto;
  }

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

  .slug-field span {
    padding: 0.5rem 0.75rem;
  }

  .slug-field input {
    border-width: 1px 0;
  }

  .image-field,
  .editor-actions {
    align-items: stretch;
    flex-direction: column;
  }
}
