:root {
  --ink: #172033;
  --muted: #687086;
  --line: #e6e8ef;
  --surface: #ffffff;
  --canvas: #f6f7fb;
  --primary: #6657d9;
  --primary-dark: #5243c1;
  --primary-soft: #f0eefe;
  --green: #238b61;
  --green-soft: #e8f7f0;
  --amber: #a56a0a;
  --amber-soft: #fff5df;
  --red: #c23d4b;
  --red-soft: #fff0f1;
  --shadow: 0 14px 38px rgba(32, 39, 60, 0.08);
  --radius: 18px;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--canvas); }
body { margin: 0; color: var(--ink); background: var(--canvas); font-size: 15px; }
a { color: inherit; text-decoration: none; }
button, input, textarea, select { font: inherit; }
button { color: inherit; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 10px; font-size: clamp(28px, 4vw, 38px); line-height: 1.12; letter-spacing: -0.035em; }
h2 { margin-bottom: 8px; font-size: 20px; letter-spacing: -0.02em; }
h3 { margin-bottom: 5px; }
p { color: var(--muted); line-height: 1.55; }

.topbar {
  position: sticky; top: 0; z-index: 50;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  height: 72px; padding: 0 max(20px, calc((100vw - 1180px) / 2));
  border-bottom: 1px solid var(--line); background: rgba(255,255,255,.94);
  backdrop-filter: blur(16px);
}
.brand { display: inline-flex; align-items: center; justify-self: start; }
.brand-logo {
  display: block;
  flex: 0 0 40px;
  width: 40px;
  min-width: 40px;
  max-width: 40px;
  height: 40px;
  min-height: 40px;
  max-height: 40px;
  object-fit: contain;
}
.topnav { display: flex; align-self: stretch; gap: 28px; }
.topnav a { display: flex; align-items: center; border-bottom: 2px solid transparent; color: #50576a; font-weight: 600; }
.topnav a:hover, .topnav a.is-active { border-color: var(--primary); color: var(--primary); }
.user-menu { display: flex; align-items: center; justify-self: end; gap: 10px; }
.link-button { padding: 0; border: 0; background: none; cursor: pointer; color: var(--muted); }
.link-button:hover { color: var(--ink); }
.logout-button {
  min-height: 36px; padding: 7px 13px; border: 1px solid var(--line);
  border-radius: 10px; color: #565e71; background: #fff; cursor: pointer;
  font-weight: 650;
}
.logout-button:hover { border-color: #c9cce0; color: var(--ink); background: #fafafe; }

.page-shell { width: min(1180px, calc(100% - 40px)); margin: 0 auto; padding: 48px 0 80px; }
.page-heading { display: flex; justify-content: space-between; align-items: flex-end; gap: 30px; margin-bottom: 30px; }
.dashboard-heading { align-items: center; }
.page-heading p { margin-bottom: 0; }
.eyebrow { margin-bottom: 8px !important; color: var(--primary) !important; font-size: 12px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }

.button {
  display: inline-flex; min-height: 44px; align-items: center; justify-content: center;
  gap: 8px; padding: 10px 18px; border: 1px solid transparent; border-radius: 11px;
  cursor: pointer; font-weight: 700; transition: .18s ease;
}
.button:hover { transform: translateY(-1px); }
.button-primary { color: white; background: var(--primary); box-shadow: 0 7px 16px rgba(102,87,217,.2); }
.button-primary:hover { background: var(--primary-dark); }
.button-secondary { border-color: var(--line); background: white; color: #41495d; box-shadow: 0 3px 8px rgba(28,36,55,.04); }
.button-secondary:hover { border-color: #c9cce0; }
.button-ghost { color: var(--muted); }
.button-wide { width: 100%; }
.button-small { min-height: 38px; padding: 7px 13px; font-size: 13px; }
.button-icon { font-size: 20px; line-height: 0; }
.icon-button {
  display: grid; width: 36px; height: 36px; place-items: center; padding: 0;
  border: 1px solid var(--line); border-radius: 10px; background: white;
  color: #596075; cursor: pointer; font-weight: 800;
}
.icon-button:hover { border-color: #c7cae0; color: var(--primary); }
.icon-danger:hover { border-color: #f0b9bf; color: var(--red); background: var(--red-soft); }
.danger-text { color: var(--red); }

.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 22px; }
.stat-card { display: flex; align-items: center; gap: 15px; padding: 20px; border: 1px solid var(--line); border-radius: 15px; background: var(--surface); }
.stat-card strong, .stat-card span { display: block; }
.stat-card strong { margin-bottom: 2px; font-size: 25px; letter-spacing: -.03em; }
.stat-card div span { color: var(--muted); font-size: 13px; }
.stat-icon { display: grid !important; width: 45px; height: 45px; place-items: center; border-radius: 13px; font-size: 19px; font-weight: 800; }
.stat-icon-purple { background: var(--primary-soft); color: var(--primary); }
.stat-icon-green { background: var(--green-soft); color: var(--green); }
.stat-icon-amber { background: var(--amber-soft); color: var(--amber); }

.panel { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: 0 5px 18px rgba(30,39,60,.035); }
.filter-bar { display: flex; align-items: center; gap: 10px; padding: 17px; border-bottom: 1px solid var(--line); }
.filter-bar select { width: auto; min-width: 160px; }
.filter-reset { color: var(--primary); font-weight: 650; font-size: 13px; }
.search-field { position: relative; flex: 1; }
.search-field input { padding-left: 13px; }

input[type="text"], input[type="password"], input[type="search"], input[type="url"], textarea, select {
  width: 100%; min-height: 46px; padding: 11px 13px; border: 1px solid #d9dce6;
  border-radius: 10px; outline: none; background: white; color: var(--ink);
  transition: border .15s, box-shadow .15s;
}
select {
  appearance: none;
  padding-right: 42px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='m4 6 4 4 4-4' fill='none' stroke='%23687086' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.8'/%3E%3C/svg%3E");
  background-position: right 16px center;
  background-repeat: no-repeat;
  background-size: 16px;
}
textarea { resize: vertical; }
input:focus, textarea:focus, select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(102,87,217,.11); }
input::placeholder, textarea::placeholder { color: #a0a5b4; }
.field { margin-bottom: 22px; }
.field > label, .label-row label { display: block; margin-bottom: 8px; font-weight: 700; }
.field label b { color: var(--red); }
.label-row { display: flex; align-items: center; justify-content: space-between; }
.label-row a { color: var(--primary); font-size: 13px; font-weight: 650; }
.field-hint { display: block; margin-top: 7px; color: #858b9d; font-size: 12px; }
.errorlist { margin: 7px 0 0; padding: 0; list-style: none; color: var(--red); font-size: 13px; }
.form-alert { margin-bottom: 20px; padding: 12px 14px; border: 1px solid #f1b8bf; border-radius: 10px; color: #9f2f3b; background: var(--red-soft); }
.form-alert .errorlist { margin: 0; }

.material-list { padding: 0 18px; }
.material-row { display: flex; align-items: center; gap: 16px; min-height: 120px; padding: 18px 0; border-bottom: 1px solid var(--line); }
.material-row:last-child { border-bottom: 0; }
.material-cover { display: grid; flex: 0 0 76px; width: 76px; height: 76px; place-items: center; overflow: hidden; border-radius: 13px; background: #f0f1f6; color: #9298a9; font-size: 26px; }
.material-cover img { width: 100%; height: 100%; object-fit: cover; }
.material-main { min-width: 0; flex: 1; }
.material-title-line { display: flex; align-items: center; gap: 10px; }
.material-title-line h2 { margin-bottom: 0; font-size: 17px; }
.material-main > p { margin: 7px 0; font-size: 13px; }
.material-meta { display: flex; flex-wrap: wrap; gap: 14px; color: #83899a; font-size: 12px; }
.material-meta span + span::before { content: "•"; margin-right: 14px; color: #c0c3cc; }
.status { padding: 4px 8px; border-radius: 999px; font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; }
.status-published { color: var(--green); background: var(--green-soft); }
.status-draft { color: var(--amber); background: var(--amber-soft); }
.row-actions { display: flex; align-items: center; gap: 8px; }
.pagination {
  display: flex; align-items: center; justify-content: center; gap: 7px;
  padding: 18px; border-top: 1px solid var(--line);
}
.pagination a, .pagination > span {
  display: grid; min-width: 36px; height: 36px; place-items: center;
  border: 1px solid var(--line); border-radius: 10px; background: #fff;
  color: #596075; font-size: 13px; font-weight: 750;
}
.pagination a:hover { border-color: var(--primary); color: var(--primary); }
.pagination .is-current { border-color: var(--primary); color: #fff; background: var(--primary); }
.pagination .is-disabled { color: #bec1cb; background: #f7f7fa; }
.pagination .pagination-gap { border-color: transparent; background: transparent; }

.empty-state { padding: 70px 20px; text-align: center; }
.empty-state.compact { padding: 25px; }
.empty-illustration { display: grid; width: 64px; height: 64px; place-items: center; margin: 0 auto 18px; border-radius: 20px; background: var(--primary-soft); color: var(--primary); font-size: 27px; }
.empty-state p { max-width: 420px; margin: 0 auto 22px; }

.wizard-heading { max-width: 750px; margin: 0 auto 27px; text-align: center; }
.wizard-heading.compact { margin-bottom: 22px; }
.wizard-heading p { margin-bottom: 0; }
.back-link { display: inline-block; margin-bottom: 18px; color: var(--muted); font-size: 13px; font-weight: 650; }
.back-link:hover { color: var(--primary); }
.stepper { display: flex; width: min(820px, 100%); align-items: center; justify-content: center; margin: 0 auto 34px; }
.step { display: flex; align-items: center; gap: 10px; color: #9297a7; }
.step > span { display: grid; flex: 0 0 34px; width: 34px; height: 34px; place-items: center; border: 2px solid #dfe1e8; border-radius: 50%; background: white; font-weight: 800; }
.step strong, .step small { display: block; white-space: nowrap; }
.step strong { font-size: 13px; }
.step small { margin-top: 2px; font-size: 10px; }
.step.is-current { color: var(--ink); }
.step.is-current > span { border-color: var(--primary); color: white; background: var(--primary); box-shadow: 0 4px 12px rgba(102,87,217,.2); }
.step.is-complete { color: var(--green); }
.step.is-complete > span { border-color: var(--green); color: white; background: var(--green); }
.step-line { width: 80px; height: 2px; margin: 0 15px; background: #e3e5ec; }
.step-line.is-complete { background: var(--green); }

.wizard-layout { display: grid; grid-template-columns: minmax(0, 720px) 310px; gap: 24px; align-items: start; width: min(1054px, 100%); margin: auto; }
.form-card { padding: 30px; border: 1px solid var(--line); border-radius: var(--radius); background: white; box-shadow: var(--shadow); }
.section-heading { display: flex; gap: 14px; margin-bottom: 28px; }
.section-heading h2, .section-heading p { margin-bottom: 3px; }
.section-number { display: grid; flex: 0 0 34px; width: 34px; height: 34px; place-items: center; border-radius: 10px; color: white; background: var(--primary); font-weight: 800; }
.wizard-aside { position: sticky; top: 96px; }
.tip-card { display: flex; gap: 12px; padding: 18px; border: 1px solid #e5e1fd; border-radius: 14px; background: #f8f6ff; }
.tip-card > span { font-size: 20px; }
.tip-card strong { display: block; margin-bottom: 5px; }
.tip-card p { margin: 0; font-size: 12px; }
.aside-actions { display: grid; gap: 8px; margin-top: 16px; }
.upload-zone { position: relative; display: flex; min-height: 96px; align-items: center; gap: 14px; padding: 18px; overflow: hidden; border: 1.5px dashed #cfd2de; border-radius: 12px; background: #fafafe; }
.upload-zone:hover { border-color: var(--primary); background: #f8f6ff; }
.upload-zone input[type="file"] { position: absolute; inset: 0; width: 100%; opacity: 0; cursor: pointer; }
.upload-zone strong, .upload-zone small { display: block; }
.upload-zone small { margin-top: 4px; color: var(--muted); }
.upload-icon { display: grid; width: 43px; height: 43px; place-items: center; border-radius: 12px; background: var(--primary-soft); color: var(--primary); font-size: 21px; }
.selected-file-list { display: grid; gap: 8px; margin-top: 10px; }
.selected-file-list:empty { display: none; }
.selected-file-list.is-replaced,
.selected-file-list.is-removed { display: none; }
.selected-file {
  display: flex; align-items: center; gap: 11px; min-height: 58px; padding: 9px 11px;
  border: 1px solid #dfe2ea; border-radius: 11px; background: #fff;
  animation: file-in .18s ease-out;
}
.selected-file > div { min-width: 0; flex: 1; }
.selected-file strong, .selected-file small { display: block; }
.selected-file strong { overflow: hidden; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.selected-file small { margin-top: 3px; color: var(--muted); font-size: 11px; }
.file-kind {
  display: grid; flex: 0 0 38px; width: 38px; height: 38px; place-items: center;
  border-radius: 9px; color: var(--primary); background: var(--primary-soft);
  font-size: 9px; font-weight: 900; letter-spacing: .04em;
}
.file-open { color: var(--primary); font-size: 12px; font-weight: 700; }
.file-remove {
  display: grid; flex: 0 0 29px; width: 29px; height: 29px; place-items: center;
  padding: 0; border: 0; border-radius: 8px; color: #858b9a; background: #f3f4f7;
  cursor: pointer; font-size: 19px; line-height: 1;
}
.file-remove:hover { color: var(--red); background: var(--red-soft); }
.button-spinner {
  display: none; width: 16px; height: 16px; border: 2px solid rgba(255,255,255,.45);
  border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite;
}
.is-uploading .button-spinner { display: inline-block; }
.is-uploading button[type="submit"]:disabled { cursor: wait; opacity: .82; transform: none; }
.is-uploading .selected-file { border-color: #d9d5f8; background: #faf9ff; }
.is-uploading .file-state { color: var(--primary); }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes file-in { from { opacity: 0; transform: translateY(-4px); } }

.content-builder { padding: 26px; border: 1px solid var(--line); border-radius: var(--radius); background: white; box-shadow: var(--shadow); }
.builder-heading { display: flex; justify-content: space-between; align-items: center; gap: 20px; padding-bottom: 22px; border-bottom: 1px solid var(--line); }
.builder-heading p { margin-bottom: 0; }
.block-list { margin-top: 8px; }
.content-block { display: flex; align-items: center; gap: 14px; padding: 17px 8px; border-bottom: 1px solid var(--line); }
.drag-handle { color: #b2b6c1; letter-spacing: -3px; }
.block-icon { display: grid; flex: 0 0 46px; width: 46px; height: 46px; place-items: center; border-radius: 13px; background: var(--primary-soft); color: var(--primary); font-size: 20px; font-weight: 800; }
.block-youtube { color: #d73d4b; background: #fff0f1; }
.block-image { color: #237a63; background: #e9f7f2; }
.block-copy { min-width: 0; flex: 1; }
.block-copy h3 { font-size: 15px; }
.block-copy p { margin: 0; font-size: 12px; }
.block-type { display: block; margin-bottom: 4px; color: var(--primary); font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; }
.block-actions { display: flex; gap: 5px; }
.empty-builder { padding: 65px 20px; text-align: center; }
.empty-builder-icon { display: grid; width: 66px; height: 66px; place-items: center; margin: auto auto 18px; border: 2px dashed #c7c3ea; border-radius: 20px; color: var(--primary); background: var(--primary-soft); font-size: 28px; }
.empty-builder p { margin-bottom: 22px; }
.wizard-footer { display: flex; justify-content: space-between; margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--line); }

.attachment-card { width: min(790px, 100%); margin: auto; }
.type-grid > div, .type-grid ul { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; padding: 0; list-style: none; }
.type-grid > div > div, .type-grid li { min-width: 0; }
.type-grid label { position: relative; display: flex; min-height: 48px; align-items: center; gap: 8px; padding: 10px; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; font-size: 13px; font-weight: 650; }
.type-grid label:hover { border-color: #beb8ec; background: #faf9ff; }
.type-grid label:has(input:checked) { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); box-shadow: 0 0 0 2px rgba(102,87,217,.08); }
.type-grid input { accent-color: var(--primary); }
.form-divider { height: 1px; margin: 27px 0; background: var(--line); }
.conditional-field[hidden] { display: none !important; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 28px; padding-top: 20px; border-top: 1px solid var(--line); }

.review-layout { display: grid; grid-template-columns: minmax(0, 760px) 320px; gap: 22px; align-items: start; }
.review-card { overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: white; box-shadow: var(--shadow); }
.review-hero { display: grid; grid-template-columns: 180px 1fr; gap: 24px; padding: 30px; border-bottom: 1px solid var(--line); }
.review-hero > img, .review-cover-placeholder { width: 180px; height: 145px; object-fit: cover; border-radius: 14px; }
.review-cover-placeholder { display: grid; place-items: center; color: #a1a6b5; background: #f0f1f5; font-size: 35px; }
.review-hero h1 { margin: 9px 0; font-size: 27px; text-align: left; }
.review-hero p { margin-bottom: 10px; }
.category-chip { display: inline-flex; padding: 5px 9px; border-radius: 999px; color: var(--primary); background: var(--primary-soft); font-size: 11px; font-weight: 800; }
.tag-row { display: flex; flex-wrap: wrap; gap: 6px; color: var(--primary); font-size: 12px; }
.review-content { padding: 28px 30px; }
.review-block { display: grid; grid-template-columns: 32px 1fr; gap: 14px; padding: 20px 0; border-top: 1px solid var(--line); }
.review-index { display: grid; width: 30px; height: 30px; place-items: center; border-radius: 9px; color: var(--primary); background: var(--primary-soft); font-size: 12px; font-weight: 800; }
.review-block small { color: var(--primary); font-weight: 800; text-transform: uppercase; letter-spacing: .06em; }
.review-block h3 { margin-top: 5px; }
.review-block a { color: var(--primary); text-decoration: underline; overflow-wrap: anywhere; }
.article-preview { margin-top: 12px; color: #464e61; line-height: 1.65; }
.article-preview p { color: inherit; }
.file-preview { color: var(--green); font-weight: 650; }
.image-preview { max-width: 100%; max-height: 300px; margin-top: 12px; border-radius: 12px; }
.review-warning { padding: 17px; border-radius: 10px; color: var(--amber); background: var(--amber-soft); }
.publish-card { position: sticky; top: 96px; padding: 26px; border: 1px solid #dedaf8; border-radius: var(--radius); background: #faf9ff; text-align: center; }
.publish-icon { display: grid; width: 56px; height: 56px; place-items: center; margin: 0 auto 14px; border-radius: 50%; color: white; background: var(--primary); font-size: 23px; font-weight: 900; box-shadow: 0 8px 20px rgba(102,87,217,.22); }
.publish-card form { display: grid; gap: 9px; }
.edit-content-link { display: inline-block; margin-top: 16px; color: var(--primary); font-size: 13px; font-weight: 650; }
.danger-zone { margin-top: 24px; padding-top: 17px; border-top: 1px solid #e4e0fa; }

.categories-layout { display: grid; grid-template-columns: 340px 1fr; gap: 20px; align-items: start; }
.category-form-card { padding: 25px; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; padding: 22px; border-bottom: 1px solid var(--line); }
.panel-heading h2 { margin: 0; }
.panel-heading span { padding: 4px 8px; border-radius: 999px; color: var(--primary); background: var(--primary-soft); font-weight: 800; }
.category-list { padding: 0 22px; }
.category-list article { display: flex; align-items: center; gap: 13px; padding: 15px 0; border-bottom: 1px solid var(--line); }
.category-list article:last-child { border: 0; }
.category-list article > div { flex: 1; }
.category-list strong, .category-list small { display: block; }
.category-list small { margin-top: 3px; color: var(--muted); }
.category-avatar { display: grid; width: 40px; height: 40px; place-items: center; border-radius: 11px; color: var(--primary); background: var(--primary-soft); font-weight: 800; }

.login-page { min-height: 100vh; background: radial-gradient(circle at 20% 15%, #eeebff 0, transparent 30%), radial-gradient(circle at 85% 80%, #e8f7f3 0, transparent 30%), #f8f8fc; }
.login-shell { display: grid; min-height: 100vh; place-items: center; padding: 30px 20px; }
.login-card { width: min(430px, 100%); padding: 38px; border: 1px solid rgba(218,219,230,.85); border-radius: 24px; background: rgba(255,255,255,.92); box-shadow: 0 30px 80px rgba(36,40,70,.13); backdrop-filter: blur(15px); }
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 37px; }
.brand-logo-large {
  flex-basis: 52px;
  width: 52px;
  min-width: 52px;
  max-width: 52px;
  height: 52px;
  min-height: 52px;
  max-height: 52px;
}
.login-brand strong { display: block; }
.login-brand strong { font-size: 18px; }
.login-copy h1 { font-size: 31px; }
.login-copy > p:last-child { margin-bottom: 25px; }

.toast-stack { position: fixed; top: 86px; right: 22px; z-index: 100; display: grid; gap: 8px; }
.toast { max-width: 380px; padding: 13px 17px; border: 1px solid #cbded5; border-radius: 12px; color: #216647; background: #f0fbf5; box-shadow: var(--shadow); transition: opacity .25s, transform .25s; }
.toast-error { border-color: #f0b9bf; color: #9f2f3b; background: var(--red-soft); }
.toast.is-hiding { opacity: 0; transform: translateY(-8px); pointer-events: none; }

@media (max-width: 900px) {
  .topbar { grid-template-columns: 1fr auto; padding: 0 20px; }
  .topnav { display: none; }
  .wizard-layout, .review-layout, .categories-layout { grid-template-columns: 1fr; }
  .wizard-aside, .publish-card { position: static; }
  .aside-actions { display: flex; justify-content: flex-end; }
  .review-layout { max-width: 760px; margin: auto; }
}

@media (max-width: 680px) {
  .page-shell { width: min(100% - 24px, 1180px); padding-top: 28px; }
  .page-heading, .builder-heading { align-items: stretch; flex-direction: column; }
  .stats-grid { grid-template-columns: 1fr; }
  .filter-bar { align-items: stretch; flex-direction: column; }
  .filter-bar select { width: 100%; }
  .material-row { align-items: flex-start; flex-wrap: wrap; }
  .material-main { min-width: calc(100% - 95px); }
  .row-actions { width: 100%; justify-content: flex-end; }
  .step div { display: none; }
  .step-line { width: 45px; margin: 0 8px; }
  .form-card, .content-builder { padding: 20px; }
  .type-grid > div, .type-grid ul { grid-template-columns: repeat(2, 1fr); }
  .content-block { align-items: flex-start; flex-wrap: wrap; }
  .block-copy { min-width: calc(100% - 90px); }
  .block-actions { width: 100%; justify-content: flex-end; }
  .review-hero { grid-template-columns: 1fr; padding: 22px; }
  .review-hero > img, .review-cover-placeholder { width: 100%; height: 190px; }
  .review-content { padding: 22px; }
  .login-card { padding: 28px 22px; }
  .toast-stack { right: 12px; left: 12px; }
}
