:root {
  color-scheme: light;
  font-family: Arial, Helvetica, sans-serif;
  color: #23315d;
  background: #f3f5fa;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* { box-sizing: border-box; }

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background: #f3f5fa;
  color: #26345f;
  font-size: 15px;
}

a { color: #27387e; }

.app-header {
  display: flex;
  min-height: 72px;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 14px max(24px, calc((100% - 1320px) / 2));
  background: #27387e;
  color: #fff;
}

.brand {
  color: #fff;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: .12em;
  text-decoration: none;
}

.brand span {
  display: block;
  margin-top: 3px;
  color: #d7ddf2;
  font-size: 10px;
  letter-spacing: .22em;
}

.user-menu,
.user-menu form,
.dashboard-heading,
.editor-topbar,
.editor-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.app-nav { display: flex; flex-wrap: wrap; align-items: center; gap: 18px; }
.app-nav a { color: #eef0fb; font-size: 13px; font-weight: 600; text-decoration: none; }
.app-nav a:hover { color: #fff; text-decoration: underline; text-underline-offset: 4px; }
.app-nav a.active { padding: 8px 11px; border-radius: 5px; background: rgba(255,255,255,.16); color: #fff; }
.user-menu { color: #eef0fb; font-size: 13px; }
.user-menu form { margin: 0; }
.app-main { width: min(1320px, calc(100% - 40px)); margin: 36px auto 80px; }

h1 { margin: 0; color: #23315d; font-size: clamp(28px, 4vw, 38px); line-height: 1.15; }
h2 { margin: 0 0 16px; font-size: 18px; }

.eyebrow {
  margin: 0 0 8px;
  color: #697594;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.button {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  padding: 8px 15px;
  border: 1px solid #c8cede;
  border-radius: 6px;
  background: #fff;
  color: #27387e;
  cursor: pointer;
  font: inherit;
  font-weight: 600;
  text-decoration: none;
}

.button:hover { background: #f7f8fc; }
.button-primary { border-color: #27387e; background: #27387e; color: #fff; }
.button-primary:hover { border-color: #1d2b63; background: #1d2b63; color: #fff; }
.button-danger { border-color: #b94a48; background: #fff; color: #9e302d; }
.button-danger:hover { background: #fff1f0; }
.button:disabled { cursor: wait; opacity: .65; }

.text-button {
  padding: 4px 8px;
  border: 0;
  background: none;
  color: inherit;
  cursor: pointer;
  font: inherit;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.dashboard-heading { margin-bottom: 24px; }
.filters { display: flex; flex-wrap: wrap; gap: 10px; margin: 22px 0; }
.filters input[type="search"] { flex: 1 1 280px; }
.filters input, .filters select, .editor-form input:not([type="checkbox"]):not([type="file"]), .editor-form textarea {
  width: 100%;
  min-height: 42px;
  padding: 9px 11px;
  border: 1px solid #c6ccda;
  border-radius: 5px;
  background: #fff;
  color: #27314a;
  font: inherit;
}
.section-editor-form input:not([type="checkbox"]):not([type="file"]), .section-editor-form textarea {
  width: 100%;
  min-height: 42px;
  padding: 9px 11px;
  border: 1px solid #c6ccda;
  border-radius: 5px;
  background: #fff;
  color: #27314a;
  font: inherit;
}
.section-editor-form textarea { min-height: 240px; resize: vertical; line-height: 1.65; }
.section-editor-form .title-input { min-height: 58px !important; font-size: 27px !important; font-weight: 600; }
.filters select { width: auto; min-width: 160px; }
input:focus, textarea:focus, select:focus, button:focus-visible, a:focus-visible, [contenteditable="true"]:focus {
  outline: 2px solid #c76e50;
  outline-offset: 2px;
}

.article-table-wrap, .sidebar-card, .editor-main, .auth-card {
  border: 1px solid #d5dae5;
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 5px 20px rgba(39, 56, 126, .06);
}
.article-table-wrap { overflow-x: auto; }
.article-table { width: 100%; border-collapse: collapse; text-align: left; }
.article-table th, .article-table td { padding: 15px 18px; border-bottom: 1px solid #e8eaf0; }
.article-table th { color: #596681; font-size: 12px; letter-spacing: .06em; text-transform: uppercase; }
.article-table tr:last-child td { border-bottom: 0; }
.article-title { display: block; color: #27387e; font-weight: 700; text-decoration: none; }
.article-title:hover { text-decoration: underline; }
.article-slug { display: block; margin-top: 4px; color: #727d94; font-size: 12px; }
.status { display: inline-block; padding: 4px 9px; border-radius: 20px; font-size: 12px; font-weight: 700; }
.status-draft { background: #fff1d7; color: #76520c; }
.status-published { background: #e4f5ec; color: #236040; }
.status-archived { background: #edf0f5; color: #536078; }
.empty-state { padding: 36px !important; color: #64708a; text-align: center; }

.editor-form { display: block; }
.editor-topbar { position: sticky; z-index: 4; top: 0; margin: -20px -20px 24px; padding: 12px 20px; border-bottom: 1px solid #d5dae5; background: rgba(243,245,250,.96); backdrop-filter: blur(8px); }
.editor-topbar > a { font-weight: 600; text-decoration: none; }
.save-state { color: #67728a; font-size: 13px; }
.editor-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; align-items: start; gap: 22px; }
.editor-main { min-width: 0; padding: clamp(18px, 3vw, 34px); }
.field-label { display: block; margin: 20px 0 7px; color: #2b385f; font-size: 13px; font-weight: 700; }
.editor-main > .field-label:first-child { margin-top: 0; }
.editor-form .title-input { min-height: 58px !important; font-size: 27px !important; font-weight: 600; }
.editor-form .slug-input { color: #63708a !important; }
.editor-form textarea { min-height: 96px; resize: vertical; }
.rich-editor { overflow: hidden; border: 1px solid #bdc5d5; border-radius: 6px; background: #fff; }
.toolbar { display: flex; flex-wrap: wrap; gap: 5px; padding: 8px; border-bottom: 1px solid #d8dce5; background: #f6f7fa; }
.toolbar button { min-width: 34px; min-height: 34px; padding: 5px 8px; border: 1px solid transparent; border-radius: 4px; background: transparent; color: #27365e; cursor: pointer; font: inherit; }
.toolbar button:hover { border-color: #d4d9e5; background: #fff; }
.toolbar-divider { width: 1px; margin: 3px 4px; background: #d4d9e5; }
.editable-body { min-height: 420px; padding: 18px; color: #2e3851; font-size: 16px; line-height: 1.75; }
.section-editable-body { min-height: 360px; }
.editable-body:empty::before { color: #9299a8; content: "Start writing your article…"; pointer-events: none; }
.editable-body img { display: block; max-width: 100%; height: auto; margin: 18px 0; border-radius: 8px; }
.body-source { display: none; }
.field-help { margin: 7px 0 0; color: #68748e; font-size: 12px; line-height: 1.5; }
.editor-sidebar { display: grid; gap: 16px; }
.sidebar-card { padding: 18px; }
.sidebar-card > p { margin: 8px 0 0; }
.topic-list { display: grid; max-height: 250px; gap: 9px; overflow: auto; }
.topic-choice { display: flex; align-items: flex-start; gap: 8px; color: #36415a; font-size: 14px; }
.topic-choice input { margin-top: 3px; }
.new-topic-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px; margin-top: 15px; }
.new-topic-row .button { min-height: 38px; padding: 6px 10px; }
.featured-preview { display: grid; min-height: 130px; place-items: center; overflow: hidden; border: 1px dashed #c5cbda; border-radius: 6px; background: #f6f7fa; color: #788198; font-size: 13px; }
.featured-preview img { display: block; width: 100%; max-height: 220px; object-fit: cover; }
.editor-form input[type="file"] { margin-top: 12px; font-size: 12px; }
.text-button { color: #596681; }
.editor-feedback { position: fixed; right: 24px; bottom: 24px; z-index: 5; max-width: min(420px, calc(100% - 48px)); color: #31405f; }
.notice { margin: 15px 0; padding: 12px 15px; border-radius: 6px; line-height: 1.5; }
.notice-error { border: 1px solid #e4b7b2; background: #fff1f0; color: #8d2923; }
.notice-success { border: 1px solid #b9ddc9; background: #edf9f2; color: #225d3c; }
.auth-card { width: min(460px, 100%); margin: 8vh auto; padding: clamp(22px, 5vw, 38px); }
.auth-card h1 { margin-bottom: 24px; font-size: 30px; }
.auth-card form { display: grid; gap: 17px; }
.auth-card label { display: grid; gap: 7px; color: #35415f; font-size: 13px; font-weight: 700; }
.auth-card input { width: 100%; min-height: 44px; padding: 9px 11px; border: 1px solid #c6ccda; border-radius: 5px; font: inherit; }
.auth-card .button { margin-top: 4px; }
.access-layout { display: grid; grid-template-columns: minmax(280px, .85fr) minmax(0, 1.15fr); align-items: start; gap: 20px; }
.access-layout > section, .user-access-form { padding: 20px; }
.access-layout h2, .pending-invitations h2 { margin-bottom: 12px; }
.permission-list { display: grid; gap: 10px; margin: 18px 0; }
.permission-choice { display: flex; align-items: flex-start; gap: 9px; color: #35415f; font-size: 13px; }
.permission-choice input { flex: 0 0 auto; margin: 3px 0 0; }
.permission-choice span { display: grid; gap: 3px; }
.permission-choice small { color: #68748e; font-size: 12px; line-height: 1.45; }
.user-access-form { margin-bottom: 14px; }
.user-access-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.user-access-heading .field-help { margin-top: 5px; }
.active-choice { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.invite-link-card { margin-bottom: 20px; padding: 20px; }
.invite-link-card .invite-link { width: 100%; min-height: 42px; margin-top: 12px; padding: 8px 10px; border: 1px solid #c6ccda; border-radius: 5px; background: #f7f8fb; color: #27387e; font: inherit; }
.pending-invitations { margin-top: 32px; }

@media (max-width: 850px) {
  .editor-layout { grid-template-columns: minmax(0, 1fr) 260px; gap: 14px; }
  .access-layout { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 680px) {
  .app-header { align-items: flex-start; flex-wrap: wrap; padding: 14px 18px; }
  .app-nav { order: 3; width: 100%; gap: 14px; }
  .user-menu > span { display: none; }
  .app-main { width: calc(100% - 24px); margin-top: 22px; }
  .dashboard-heading, .editor-topbar { align-items: flex-start; }
  .editor-topbar { position: static; flex-direction: column; margin: -10px -8px 15px; padding: 10px 8px; }
  .editor-actions { width: 100%; flex-wrap: wrap; justify-content: flex-end; }
  .editor-layout { grid-template-columns: minmax(0, 1fr); }
  .editor-sidebar { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
  .editor-main { padding: 18px; }
  .article-table th, .article-table td { padding: 12px; }
}
