:host {
  display: block;
  min-height: 100vh;
}

button {
  border: 0;
  border-radius: 0.7em;
  padding: 0.72em 1.15em;
  background: #243b53;
  color: #fff;
  cursor: pointer;
  font: inherit;
  line-height: 1;
}

button:hover {
  background: #1c3147;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.link-button {
  background: transparent;
  color: #2f4a63;
  padding: 0.45em 0.65em;
  text-decoration: none;
}

.link-button:hover {
  background: #f1f3f5;
  color: #1c3147;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid #e8e5df;
  border-radius: 0.7em;
  background: #fff;
  color: #232428;
  padding: 0.8em 0.95em;
  outline: 0;
}

input:focus,
select:focus,
textarea:focus {
  border-color: #9aa9b6;
  box-shadow: 0 0 0 0.14em rgb(36 59 83 / 5%);
}

label {
  display: grid;
  gap: 0.5em;
  color: #55575d;
  font-size: 0.9em;
}

.body-field {
  display: grid;
  gap: 0.5em;
  color: #55575d;
  font-size: 0.9em;
}

textarea {
  resize: vertical;
  line-height: 1.7;
}

.loading-shell,
.shell {
  width: 100%;
  min-height: 100vh;
  background: #fff;
}

.loading-shell {
  display: grid;
  place-items: center;
  color: #777b82;
}

.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: #fff;
}

.login-panel {
  width: min(90vw, 27em);
  display: grid;
  gap: 1.2em;
  border: 1px solid #eee;
  padding: 2em;
  border-radius: 0.9em;
  background: #fff;
}

.topbar {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.1em 25%;
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 0.6em;
  min-width: 0;
  color: #777b82;
  font-size: 0.92em;
}

.breadcrumb a,
.breadcrumb button {
  border-radius: 0.65em;
  background: transparent;
  color: #2f4a63;
  padding: 0.35em 0.45em;
  text-decoration: none;
}

.breadcrumb a:hover,
.breadcrumb button:hover {
  background: #f1f3f5;
  color: #1c3147;
}

.breadcrumb span:last-child {
  overflow: hidden;
  color: #3d3d3f;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-menu {
  position: relative;
  flex: 0 0 auto;
}

.user-menu summary {
  list-style: none;
  border-radius: 0.75em;
  color: #2f4a63;
  cursor: pointer;
  padding: 0.55em 0.8em;
}

.user-menu summary::-webkit-details-marker {
  display: none;
}

.user-menu summary::after {
  content: "⌄";
  margin-left: 0.45em;
  color: #777b82;
}

.user-menu summary:hover {
  background: #f1f3f5;
}

.user-menu-panel {
  position: absolute;
  top: calc(100% + 0.45em);
  right: 0;
  z-index: 10;
  min-width: 8em;
  display: grid;
  gap: 0.2em;
  border: 1px solid #eee;
  border-radius: 0.75em;
  background: #fff;
  padding: 0.45em;
}

.user-menu-panel button {
  width: 100%;
  border-radius: 0.55em;
  background: transparent;
  color: #2f4a63;
  padding: 0.6em 0.8em;
  text-align: left;
}

.user-menu-panel button:hover {
  background: #f1f3f5;
  color: #1c3147;
}

.list-view,
.editor-view {
  width: 50%;
  margin: 0 auto;
  padding: 3em 0 4em;
}

.feedback-toast {
  position: fixed;
  top: 1.2em;
  right: 1.2em;
  z-index: 30;
  width: min(92vw, 22em);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1em;
  border: 1px solid #eee;
  border-left: 0.28em solid #2f7d4f;
  border-radius: 0.75em;
  background: #fff;
  box-shadow: 0 0.25em 1.2em rgb(35 36 40 / 8%);
  color: #3d3d3f;
  padding: 0.9em 1em;
}

.feedback-toast.info {
  border-left-color: #2f4a63;
}

.feedback-toast.error {
  border-left-color: #9b332c;
}

.feedback-toast div {
  display: grid;
  gap: 0.3em;
}

.feedback-toast strong {
  color: #232428;
  font-size: 0.92em;
}

.feedback-toast span {
  color: #676b72;
  font-size: 0.86em;
  line-height: 1.45;
}

.feedback-toast button {
  flex: 0 0 auto;
  border-radius: 50%;
  background: transparent;
  color: #777b82;
  padding: 0.25em 0.4em;
}

.feedback-toast button:hover {
  background: #f1f3f5;
  color: #1c3147;
}

.page-heading,
.editor-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1em;
  margin-bottom: 2em;
}

.page-heading h1,
.editor-head h1,
.login-panel h1 {
  margin: 0;
  line-height: 1.2;
}

.page-actions {
  display: flex;
  align-items: center;
  gap: 0.6em;
}

.page-actions select,
.page-actions button {
  width: auto;
  min-height: 2.55em;
  border-radius: 0.65em;
  font-size: 0.9em;
  line-height: 1;
}

.page-actions select {
  min-width: 8em;
  padding: 0 2.2em 0 0.9em;
}

.page-actions button {
  padding: 0 1em;
}

.log-actions {
  max-width: 100%;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.log-actions input {
  width: min(20em, 100%);
  min-height: 2.55em;
  border-radius: 0.65em;
  font-size: 0.9em;
}

.editor-head h1 {
  display: flex;
  align-items: center;
  gap: 0.4em;
}

.eyebrow {
  margin: 0 0 0.35em;
  color: #8b8175;
  font-size: 0.78em;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.dirty-dot {
  width: 0.45em;
  height: 0.45em;
  border-radius: 50%;
  background: #a86a2d;
}

.post-table {
  --post-table-columns: minmax(0, 1.5fr) minmax(8em, 0.8fr) 6em 10em 5.6em;

  display: grid;
  border-top: 1px solid #eee;
}

.post-table-head,
.post-table-row {
  width: 100%;
  display: grid;
  grid-template-columns: var(--post-table-columns);
  align-items: center;
  gap: 1em;
  border-bottom: 1px solid #eee;
  padding: 0.9em 0.75em;
}

.post-table-head {
  color: #777b82;
  line-height: 1.2;
}

.post-table-head span {
  font-size: 0.78em;
}

.post-table-row {
  background: #fff;
  color: #232428;
  cursor: pointer;
  text-align: left;
}

.post-table-row:hover {
  background: #fafafa;
}

.log-table {
  overflow-x: auto;
}

.log-table-head,
.log-table-row {
  min-width: 58em;
  display: grid;
  grid-template-columns: 10em 7em 8em 14em minmax(14em, 1fr) 8em;
  align-items: center;
  gap: 1em;
  border-bottom: 1px solid #eee;
  padding: 0.9em 0.75em;
}

.log-table-head {
  color: #777b82;
  font-size: 0.78em;
  line-height: 1.2;
}

.log-table-row {
  color: #777b82;
  font-size: 0.86em;
}

.log-details {
  overflow: hidden;
  color: #3d3d3f;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.post-row-title {
  overflow: hidden;
  font-weight: 700;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.post-row-tags,
.post-table-row > span {
  color: #777b82;
  font-size: 0.86em;
}

.row-actions {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0.75em;
}

.table-action {
  color: #2f4a63;
  cursor: pointer;
}

.table-action:hover {
  color: #1c3147;
}

.table-action.danger {
  color: #9b332c;
}

.empty-message {
  margin: 3em 0;
  color: #777b82;
  text-align: center;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.45em;
  margin-top: 2em;
  color: #6d7179;
  font-size: 0.9em;
}

.page-numbers {
  display: inline-flex;
  align-items: center;
  gap: 0.45em;
}

.page-numbers {
  justify-content: center;
}

.page-number {
  min-width: 2.2em;
  border-radius: 0.55em;
  background: transparent;
  color: #2f4a63;
  padding: 0.45em 0.65em;
}

.page-number:hover,
.page-number.active {
  background: #f1f3f5;
  color: #1c3147;
}

.editor-form {
  display: grid;
  gap: 1.2em;
}

.editor-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.25em;
  border: 1px solid #eee;
  border-radius: 0.8em;
  background: #fff;
  padding: 0.35em;
  box-shadow: 0 0.08em 0.35em rgb(35 36 40 / 4%);
}

.editor-actions button {
  min-height: 2.45em;
  border-radius: 0.62em;
  padding: 0 0.9em;
  font-size: 0.88em;
  white-space: nowrap;
}

.editor-actions .save-button,
.editor-actions .build-button {
  background: transparent;
  color: #2f4a63;
}

.editor-actions .save-button:hover,
.editor-actions .build-button:hover {
  background: #243b53;
  color: #fff;
}

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

.slug-control {
  position: relative;
  display: block;
}

.slug-control input {
  padding-right: 3.05em;
}

.slug-ai-button {
  position: absolute;
  top: 50%;
  right: 0.35em;
  width: 2.25em;
  height: 2.25em;
  display: inline-grid;
  place-items: center;
  border-radius: 0.62em;
  background: #fff;
  color: #2f4a63;
  padding: 0;
  transform: translateY(-50%);
}

.slug-ai-button:hover {
  background: #f1f3f5;
  color: #1c3147;
}

.slug-ai-button span {
  display: block;
  font-size: 1.05em;
  line-height: 1;
}

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

.body-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1em;
}

.body-tools {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.45em;
  justify-content: flex-end;
}

.image-upload-button {
  width: auto;
  min-height: 2.35em;
  display: inline-grid;
  place-items: center;
  border: 1px solid #eee;
  border-radius: 0.65em;
  background: #fff;
  color: #2f4a63;
  cursor: pointer;
  font-size: 0.9em;
  line-height: 1;
  padding: 0 0.8em;
}

.image-upload-button:hover {
  background: #f1f3f5;
  color: #1c3147;
}

.image-upload-button.disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.image-upload-button input {
  display: none;
}

.mode-switch {
  display: inline-flex;
  align-items: center;
  gap: 0.2em;
  border: 1px solid #eee;
  border-radius: 0.7em;
  padding: 0.2em;
}

.mode-switch button {
  border-radius: 0.55em;
  background: transparent;
  color: #2f4a63;
  padding: 0.45em 0.7em;
  font-size: 0.9em;
}

.mode-switch button:hover,
.mode-switch button.active {
  background: #f1f3f5;
  color: #1c3147;
}

.markdown-workspace {
  display: grid;
  gap: 1em;
}

.markdown-workspace.split {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

.body-field textarea,
.markdown-preview {
  min-height: 48vh;
}

.body-field textarea {
  font-family:
    "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.95em;
}

.markdown-preview {
  container-type: inline-size;
  overflow: auto;
  border: 1px solid #e8e5df;
  border-radius: 0.7em;
  color: #3d3d3f;
  font-size: 1em;
  line-height: 1.75;
  padding: 1em 1.1em;
}

.markdown-preview :first-child {
  margin-top: 0;
}

.markdown-preview :last-child {
  margin-bottom: 0;
}

.markdown-preview h1,
.markdown-preview h2,
.markdown-preview h3 {
  color: #232428;
  line-height: 1.35;
}

.markdown-preview a {
  color: #2f4a63;
  text-decoration: underline;
  text-underline-offset: 0.22em;
}

.markdown-preview img {
  display: block;
  max-width: 80%;
  max-width: min(100%, 80cqw);
  max-height: min(48vh, 72cqw);
  width: auto;
  height: auto;
  border-radius: 0.7em;
  margin: 1.2em auto;
  object-fit: contain;
}

:host ::ng-deep .markdown-preview p > img,
:host ::ng-deep .markdown-preview img {
  display: block;
  max-width: 80%;
  max-width: min(100%, 80cqw);
  max-height: min(48vh, 72cqw);
  width: auto;
  height: auto;
  border-radius: 0.7em;
  margin: 1.2em auto;
  object-fit: contain;
}

:host ::ng-deep .markdown-preview p:has(> img:only-child) {
  margin: 1.2em 0;
}

.markdown-preview pre {
  overflow: auto;
  border-radius: 0.7em;
  background: #20242b;
  color: #f2f2ee;
  padding: 1em;
}

.markdown-preview code {
  border-radius: 0.35em;
  background: #f3f4f6;
  padding: 0.12em 0.32em;
}

.markdown-preview pre code {
  background: transparent;
  padding: 0;
}

.message {
  min-height: 1.4em;
  margin: 0;
  color: #7b4f27;
  font-size: 0.9em;
}

.editor-status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1em;
}

.autosave-status {
  color: #777b82;
  font-size: 0.82em;
  white-space: nowrap;
}

.build-panel {
  display: grid;
  gap: 1em;
  border: 1px solid #eee;
  border-radius: 0.8em;
  background: #fbfaf7;
  padding: 1em;
}

.build-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1em;
}

.build-panel h3 {
  margin: 0;
}

.build-meta {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.8em;
  margin: 0;
}

.build-meta div {
  min-width: 0;
}

.build-meta dt {
  color: #777b82;
  font-size: 0.78em;
}

.build-meta dd {
  overflow-wrap: anywhere;
  margin: 0.25em 0 0;
  color: #35383f;
  font-size: 0.88em;
}

.build-error {
  margin: 0;
  color: #9b332c;
  font-size: 0.9em;
}

.build-log {
  max-height: 22em;
  overflow: auto;
  margin: 0;
  border-radius: 0.7em;
  background: #20242b;
  color: #f2f2ee;
  padding: 1em;
  font-size: 0.84em;
  line-height: 1.55;
  white-space: pre-wrap;
}

@media (max-width: 1100px) {
  .topbar {
    padding-inline: 8%;
  }

  .list-view,
  .editor-view {
    width: 84%;
  }
}

@media (max-width: 760px) {
  .topbar,
  .page-heading,
  .editor-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar {
    padding: 1em 5%;
  }

  .breadcrumb {
    width: 100%;
    flex-wrap: wrap;
  }

  .user-menu {
    align-self: flex-end;
  }

  .list-view,
  .editor-view {
    width: 90%;
    padding-top: 2em;
  }

  .post-table-head {
    display: none;
  }

  .post-table-row {
    grid-template-columns: 1fr;
    gap: 0.35em;
  }

  .page-actions {
    width: 100%;
    flex-wrap: wrap;
  }

  .row-actions {
    justify-content: flex-start;
  }

  .fields-grid,
  .build-meta,
  .markdown-workspace.split {
    grid-template-columns: 1fr;
  }

  .editor-actions,
  .editor-status-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .editor-actions {
    width: 100%;
    align-items: stretch;
  }

  .editor-actions button {
    width: 100%;
  }

  .autosave-status {
    white-space: normal;
  }

  .body-label-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .body-tools {
    width: 100%;
    justify-content: flex-start;
  }
}
