:root {
  color-scheme: dark;
  --bg: #101215;
  --bg-2: #171a1f;
  --bg-3: #20252c;
  --surface: rgba(255, 255, 255, 0.055);
  --surface-strong: rgba(255, 255, 255, 0.095);
  --line: rgba(255, 255, 255, 0.11);
  --line-strong: rgba(255, 255, 255, 0.18);
  --text: #f8fafc;
  --soft: #dce3ea;
  --muted: #9aa6b2;
  --primary: #14b8a6;
  --primary-strong: #0f766e;
  --accent: #f59e0b;
  --blue: #38bdf8;
  --green: #22c55e;
  --red: #ef4444;
  --radius: 8px;
  --shadow: 0 22px 70px rgba(0, 0, 0, 0.32);
  --content: min(calc(100% - 32px), 1660px);
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f4f7f8;
  --bg-2: #ffffff;
  --bg-3: #e8eef1;
  --surface: rgba(255, 255, 255, 0.78);
  --surface-strong: rgba(255, 255, 255, 0.92);
  --line: rgba(15, 23, 42, 0.12);
  --line-strong: rgba(15, 23, 42, 0.2);
  --text: #17202a;
  --soft: #243241;
  --muted: #657383;
  --shadow: 0 18px 48px rgba(15, 23, 42, 0.11);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--bg) 96%, var(--primary)), var(--bg) 52%, color-mix(in srgb, var(--bg) 94%, var(--accent)));
  color: var(--text);
  font-family: "Open Sans", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

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

a {
  color: inherit;
}

code {
  color: var(--soft);
  font-family: "Consolas", "SFMono-Regular", ui-monospace, monospace;
}

i[data-lucide],
.lucide {
  width: 17px;
  height: 17px;
  stroke-width: 2.2;
  flex: 0 0 auto;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 18px;
  min-height: 74px;
  padding: 10px max(16px, calc((100vw - 1660px) / 2 + 16px));
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg-2) 90%, transparent);
  backdrop-filter: blur(14px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  color: var(--text);
  text-decoration: none;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px solid color-mix(in srgb, var(--primary) 45%, transparent);
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--primary), color-mix(in srgb, var(--accent) 72%, var(--primary)));
  color: white;
  font-family: "Bebas Neue", "Arial Narrow", sans-serif;
  font-size: 24px;
  line-height: 1;
}

.brand strong,
.brand em {
  display: block;
  line-height: 1;
}

.brand strong {
  font-family: "Bebas Neue", "Arial Narrow", sans-serif;
  font-size: 30px;
  font-weight: 400;
  letter-spacing: 0;
  text-transform: uppercase;
}

.brand em {
  margin-top: 4px;
  color: var(--accent);
  font-size: 10px;
  font-style: normal;
  font-weight: 900;
  text-transform: uppercase;
  background: repeating-linear-gradient(
    90deg,
    var(--accent) 0%,
    color-mix(in srgb, var(--accent) 72%, white) 25%,
    #fff 50%,
    color-mix(in srgb, var(--accent) 72%, white) 75%,
    var(--accent) 100%
  );
  background-size: 200% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  transition: filter 180ms ease;
}

.brand:hover em,
.brand:focus-visible em {
  color: transparent;
  animation: brandShine 1800ms linear infinite;
  filter: drop-shadow(0 0 8px color-mix(in srgb, var(--accent) 28%, transparent));
}

@keyframes brandShine {
  0% { background-position: 200% center; }
  100% { background-position: 0% center; }
}

.view-tabs {
  display: flex;
  align-items: center;
  align-self: center;
  gap: 6px;
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 6px 0;
  scrollbar-color: color-mix(in srgb, var(--primary) 46%, var(--muted)) color-mix(in srgb, var(--surface) 72%, transparent);
  scrollbar-width: thin;
}

.view-tabs::-webkit-scrollbar {
  height: 7px;
}

.view-tabs::-webkit-scrollbar-track {
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface) 72%, transparent);
}

.view-tabs::-webkit-scrollbar-thumb {
  border: 2px solid color-mix(in srgb, var(--bg-2) 70%, transparent);
  border-radius: 999px;
  background: color-mix(in srgb, var(--primary) 52%, var(--muted));
}

.view-tabs::-webkit-scrollbar-thumb:hover {
  background: color-mix(in srgb, var(--primary) 68%, var(--accent));
}

.view-tabs button,
.secondary-button,
.primary-button,
.danger-button,
.ghost-button,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  border-radius: var(--radius);
  padding: 0 12px;
  color: var(--soft);
  font-weight: 900;
  line-height: 1;
  white-space: nowrap;
  transition: background 160ms ease, border-color 160ms ease, color 160ms ease, transform 160ms ease, filter 160ms ease;
}

.view-tabs button {
  border: 1px solid transparent;
  background: transparent;
  font-size: 12px;
}

.view-tabs button:hover,
.view-tabs button.active,
.secondary-button:hover,
.ghost-button:hover,
.icon-button:hover {
  border-color: color-mix(in srgb, var(--primary) 42%, transparent);
  background: color-mix(in srgb, var(--surface-strong) 80%, transparent);
  color: var(--text);
}

.view-tabs button.active {
  background: color-mix(in srgb, var(--primary) 18%, transparent);
  color: var(--text);
}

.icon-button.active {
  border-color: color-mix(in srgb, var(--primary) 42%, transparent);
  background: color-mix(in srgb, var(--primary) 18%, transparent);
  color: var(--text);
}

.topbar-actions,
.stage-actions,
.row-actions,
.toolbar,
.inline-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  min-width: 0;
}

.user-pill {
  display: grid;
  gap: 2px;
  min-width: 112px;
  max-width: 178px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.user-pill strong,
.user-pill span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-pill strong {
  color: var(--text);
  font-size: 12px;
}

.user-pill span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 900;
  text-transform: uppercase;
}

.cms-workspace {
  width: var(--content);
  margin: 0 auto;
  padding: 16px 0 42px;
}

.app-panel,
.modal-surface {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.stage-header,
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg-2) 78%, transparent);
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin: 0 0 8px;
  color: var(--primary);
  font-size: 11px;
  font-weight: 900;
  line-height: 1.2;
  text-transform: uppercase;
}

h1,
h2,
h3 {
  margin: 0;
  color: var(--text);
  line-height: 1.05;
}

.stage-header h1,
.modal-header h2 {
  font-family: "Bebas Neue", "Arial Narrow", sans-serif;
  font-size: 38px;
  font-weight: 400;
  letter-spacing: 0;
  text-transform: uppercase;
}

.section-panel h2 {
  font-size: 15px;
}

.section-panel h3 {
  font-size: 13px;
}

.stage-body {
  min-height: calc(100vh - 170px);
  padding: 18px;
}

.stage-body::-webkit-scrollbar,
textarea::-webkit-scrollbar,
.modal-body::-webkit-scrollbar {
  width: 9px;
}

.stage-body::-webkit-scrollbar-thumb,
textarea::-webkit-scrollbar-thumb,
.modal-body::-webkit-scrollbar-thumb {
  background: color-mix(in srgb, var(--muted) 32%, transparent);
  border-radius: 999px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.metric {
  display: grid;
  gap: 8px;
  min-height: 106px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface-strong) 74%, transparent);
}

.metric span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.metric strong {
  color: var(--text);
  font-family: "Bebas Neue", "Arial Narrow", sans-serif;
  font-size: 42px;
  font-weight: 400;
  line-height: 0.96;
}

.dashboard-grid,
.two-column,
.visibility-grid,
.mail-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(340px, 0.92fr);
  gap: 16px;
  margin-bottom: 16px;
}

.mail-client-layout {
  display: grid;
  grid-template-columns: 260px minmax(320px, 0.58fr) minmax(420px, 1fr);
  gap: 16px;
  min-height: calc(100vh - 230px);
}

.compact-grid {
  grid-template-columns: minmax(320px, 0.9fr) minmax(0, 1.1fr);
}

.content-layout {
  display: grid;
  grid-template-columns: minmax(260px, 0.32fr) minmax(0, 1fr);
  gap: 16px;
}

.content-sidebar {
  align-content: start;
  overflow: hidden;
}

.sidebar-subheader {
  border-top: 1px solid var(--line);
}

.file-manager-layout {
  display: grid;
  grid-template-columns: minmax(420px, 0.92fr) minmax(360px, 0.68fr);
  gap: 16px;
}

.calendar-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(330px, 0.36fr);
  gap: 16px;
}

.calendar-weekdays {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 1px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  text-align: center;
  text-transform: uppercase;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 1px;
  background: color-mix(in srgb, var(--line) 72%, transparent);
}

.calendar-day {
  display: grid;
  grid-template-rows: auto minmax(58px, 1fr);
  gap: 8px;
  min-height: 118px;
  border-radius: 0;
  padding: 10px;
  background: color-mix(in srgb, var(--bg-2) 72%, transparent);
  color: var(--text);
  text-align: left;
}

.calendar-day:hover,
.calendar-day.selected {
  background: color-mix(in srgb, var(--primary) 15%, var(--surface-strong));
}

.calendar-day.muted-day {
  color: color-mix(in srgb, var(--muted) 78%, transparent);
  background: color-mix(in srgb, var(--surface) 42%, transparent);
}

.calendar-day.today .calendar-day-number {
  border-color: color-mix(in srgb, var(--primary) 50%, transparent);
  background: color-mix(in srgb, var(--primary) 20%, transparent);
  color: var(--text);
}

.calendar-day-number {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border: 1px solid transparent;
  border-radius: 999px;
  color: inherit;
  font-weight: 900;
}

.calendar-day-events {
  display: grid;
  align-content: start;
  gap: 5px;
  min-width: 0;
}

.calendar-day-events span,
.calendar-day-events em {
  overflow: hidden;
  border-radius: 6px;
  padding: 4px 6px;
  background: color-mix(in srgb, var(--primary) 16%, transparent);
  color: var(--soft);
  font-size: 10px;
  font-style: normal;
  font-weight: 900;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.calendar-agenda {
  display: grid;
  align-content: start;
  gap: 10px;
}

.calendar-event-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
  min-height: 78px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--primary);
  border-radius: var(--radius);
  padding: 12px;
  background: color-mix(in srgb, var(--surface) 76%, transparent);
}

.calendar-event-card.warn {
  border-left-color: var(--accent);
}

.calendar-event-card.fail {
  border-left-color: var(--red);
}

.calendar-event-card strong,
.calendar-event-card span {
  display: block;
}

.calendar-event-card strong {
  margin-bottom: 4px;
  color: var(--text);
  font-size: 14px;
}

.calendar-event-card span {
  color: var(--soft);
  font-size: 12px;
}

.calendar-event-check {
  display: grid;
  place-items: center;
  min-height: 40px;
}

.calendar-repeat-card {
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  background: color-mix(in srgb, var(--surface) 72%, transparent);
}

.repeat-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 34px;
}

.repeat-card-header strong {
  color: var(--text);
  font-size: 14px;
}

.repeat-card-header span,
.field-caption {
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.calendar-repeat-grid {
  align-items: end;
}

.calendar-weekday-group {
  display: grid;
  gap: 8px;
}

.calendar-weekday-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.calendar-weekday {
  position: relative;
  display: inline-grid;
  gap: 0;
  width: auto;
  color: var(--soft);
  font-size: 12px;
  font-weight: 900;
  text-transform: none;
}

.calendar-weekday input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.calendar-weekday span {
  display: grid;
  place-items: center;
  width: 42px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.calendar-weekday input:checked + span {
  border-color: color-mix(in srgb, var(--primary) 58%, transparent);
  background: color-mix(in srgb, var(--primary) 18%, transparent);
  color: var(--text);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 12%, transparent);
}

.calendar-repeat-hidden {
  display: none !important;
}

.section-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface-strong) 60%, transparent);
}

.section-panel > header,
.code-preview > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 66px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.equal-header > header {
  min-height: 70px;
}

.section-panel-body {
  padding: 16px;
}

.score-row {
  display: grid;
  grid-template-columns: 122px minmax(0, 1fr);
  gap: 16px;
  align-items: center;
}

.score-ring {
  display: grid;
  place-items: center;
  width: 112px;
  height: 112px;
  border-radius: 50%;
  background: conic-gradient(var(--score-color) calc(var(--score) * 1%), color-mix(in srgb, var(--muted) 18%, transparent) 0);
}

.score-ring strong {
  display: grid;
  place-items: center;
  width: 82px;
  height: 82px;
  border-radius: 50%;
  background: var(--bg-2);
  color: var(--text);
  font-family: "Bebas Neue", "Arial Narrow", sans-serif;
  font-size: 38px;
  font-weight: 400;
}

.check-list,
.task-list,
.file-list,
.signal-list,
.editor-stack,
.page-list {
  display: grid;
  gap: 10px;
}

.check-item,
.task-item,
.file-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  min-height: 48px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface) 76%, transparent);
}

.check-item i,
.task-item i {
  margin-top: 2px;
}

.check-item.ok i,
.task-item.ok i {
  color: var(--green);
}

.check-item.warn i,
.task-item.warn i {
  color: var(--accent);
}

.check-item.fail i,
.task-item.fail i {
  color: var(--red);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th,
.data-table td {
  padding: 13px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

.data-table th {
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.data-table tr:last-child td {
  border-bottom: 0;
}

.data-table td:last-child {
  text-align: right;
}

.file-tree-wrap {
  overflow: auto;
  padding: 0;
}

.file-table th,
.file-table td {
  padding-block: 10px;
}

.file-table tr.selected-row td {
  background: color-mix(in srgb, var(--primary) 9%, transparent);
}

.file-tree-button {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 44px;
  border-radius: var(--radius);
  padding: 7px 10px 7px calc(10px + var(--depth, 0) * 18px);
  background: transparent;
  color: inherit;
  text-align: left;
}

.file-tree-button:hover {
  background: color-mix(in srgb, var(--surface-strong) 78%, transparent);
}

.file-detail-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.folder-summary {
  display: grid;
  gap: 4px;
  min-height: 86px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.folder-summary strong {
  color: var(--text);
  font-size: 17px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--bg-2) 72%, transparent);
  color: var(--text);
  outline: 0;
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

input::placeholder,
textarea::placeholder {
  color: color-mix(in srgb, var(--muted) 70%, transparent);
}

input:focus,
select:focus,
textarea:focus {
  border-color: color-mix(in srgb, var(--primary) 58%, transparent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent);
}

input,
select {
  height: 42px;
  padding: 0 12px;
}

textarea {
  min-height: 120px;
  padding: 12px;
  line-height: 1.5;
  resize: vertical;
}

input[readonly],
textarea[readonly],
select:disabled {
  border-color: color-mix(in srgb, var(--line) 80%, transparent);
  background: color-mix(in srgb, var(--bg-3) 48%, transparent);
  color: color-mix(in srgb, var(--text) 76%, var(--muted));
}

label,
.form-label {
  display: grid;
  gap: 7px;
  color: var(--soft);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

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

.form-grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

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

.primary-button {
  background: linear-gradient(135deg, var(--primary), color-mix(in srgb, var(--accent) 82%, var(--primary)));
  color: white;
  box-shadow: 0 12px 26px color-mix(in srgb, var(--primary) 20%, transparent);
}

.primary-button:hover {
  filter: brightness(1.04);
  transform: translateY(-1px);
}

.secondary-button,
.ghost-button,
.icon-button {
  border: 1px solid var(--line);
  background: var(--surface);
}

.danger-button {
  border: 1px solid color-mix(in srgb, var(--red) 38%, transparent);
  background: color-mix(in srgb, var(--red) 15%, transparent);
  color: color-mix(in srgb, var(--red) 36%, var(--text));
}

.danger-button:hover {
  background: color-mix(in srgb, var(--red) 22%, transparent);
}

.ghost-button {
  background: transparent;
}

.icon-button {
  width: 40px;
  padding: 0;
}

.status-chip,
.mini-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 24px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 9px;
  color: var(--soft);
  font-size: 10px;
  font-weight: 900;
  text-transform: uppercase;
  white-space: nowrap;
}

.status-chip.ok,
.mini-chip.ok {
  border-color: color-mix(in srgb, var(--green) 38%, transparent);
  background: color-mix(in srgb, var(--green) 14%, transparent);
}

.status-chip.warn,
.mini-chip.warn {
  border-color: color-mix(in srgb, var(--accent) 42%, transparent);
  background: color-mix(in srgb, var(--accent) 16%, transparent);
}

.status-chip.fail,
.mini-chip.fail {
  border-color: color-mix(in srgb, var(--red) 38%, transparent);
  background: color-mix(in srgb, var(--red) 14%, transparent);
}

.cell-title {
  display: block;
  color: var(--text);
  font-size: 14px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.cell-sub,
.muted,
.help-line {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.site-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
}

.tag-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.page-button {
  display: grid;
  gap: 8px;
  width: 100%;
  min-height: 78px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  background: var(--surface);
  color: inherit;
  text-align: left;
}

.page-button.active,
.page-button:hover {
  border-color: color-mix(in srgb, var(--primary) 48%, transparent);
  background: color-mix(in srgb, var(--primary) 10%, transparent);
}

.url-field {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 40px;
  gap: 8px;
}

.code-preview {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--bg-2) 72%, transparent);
}

.code-preview pre {
  min-height: 240px;
  max-height: 360px;
  margin: 0;
  padding: 16px;
  overflow: auto;
  color: var(--soft);
  font-family: "Consolas", "SFMono-Regular", ui-monospace, monospace;
  font-size: 12px;
  line-height: 1.55;
  white-space: pre-wrap;
}

.block-preview-panel {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface) 70%, transparent);
}

.block-preview-panel > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 58px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}

.block-preview-frame {
  display: block;
  width: 100%;
  min-height: 220px;
  border: 0;
  background: white;
}

.system-footnote {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 18px;
  min-height: 18px;
  margin: 10px 4px -6px;
  padding: 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
  opacity: 0.78;
}

.connector-block {
  display: grid;
  gap: 10px;
}

.connector-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 12px;
}

.connector-toggle,
.connector-card {
  display: grid;
  gap: 10px;
  min-height: 74px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.connector-toggle {
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
}

.connector-toggle span,
.connector-card header span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--soft);
  font-size: 12px;
  font-weight: 900;
  text-transform: none;
}

.connector-card header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.connector-card input[type="checkbox"],
.connector-toggle input,
.toggle-card input {
  width: 18px;
  height: 18px;
}

.connector-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.connector-status > span:first-child {
  color: var(--soft);
  font-size: 12px;
  font-weight: 900;
}

.connector-status .status-chip i {
  width: 13px;
  height: 13px;
}

.upload-file-field {
  align-content: stretch;
}

.media-dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  min-height: 160px;
  margin: 0;
  padding: 26px 18px;
  border: 2px dashed color-mix(in srgb, var(--primary) 35%, var(--line));
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface) 70%, transparent);
  color: var(--soft);
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.media-dropzone:hover {
  border-color: color-mix(in srgb, var(--primary) 55%, transparent);
  background: color-mix(in srgb, var(--surface-strong) 80%, transparent);
}

.media-dropzone.dragover {
  border-color: var(--primary);
  background: color-mix(in srgb, var(--primary) 14%, transparent);
}

.media-dropzone.has-file {
  border-style: solid;
  border-color: color-mix(in srgb, var(--green) 50%, transparent);
  background: color-mix(in srgb, var(--green) 12%, transparent);
}

.media-dropzone i {
  width: 30px;
  height: 30px;
  color: var(--primary);
}

.media-dropzone strong {
  font-size: 14px;
  color: var(--text);
  overflow-wrap: anywhere;
}

.media-dropzone span {
  font-size: 12px;
}

.image-editor {
  display: grid;
  gap: 14px;
}

.image-editor-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.image-editor-toolbar .secondary-button.active,
.image-editor-toolbar .icon-button.active {
  border-color: var(--primary);
  color: var(--primary);
}

.image-editor-stage {
  position: relative;
  display: block;
  width: fit-content;
  max-width: 100%;
  margin: 0 auto;
  overflow: hidden;
  line-height: 0;
  touch-action: none;
  background: color-mix(in srgb, var(--bg-3) 72%, transparent);
  border-radius: var(--radius);
}

.image-editor-stage canvas {
  display: block;
  max-width: 100%;
  max-height: 60vh;
  height: auto;
  width: auto;
}

.crop-overlay {
  position: absolute;
  border: 2px solid var(--primary);
  background: color-mix(in srgb, var(--primary) 12%, transparent);
  box-shadow: 0 0 0 100vmax rgba(0, 0, 0, 0.45);
  pointer-events: none;
}

.image-editor-controls label.wide {
  display: grid;
  gap: 6px;
}

.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}

.media-card {
  display: grid;
  gap: 10px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  background: var(--surface);
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.media-card:hover {
  border-color: color-mix(in srgb, var(--primary) 45%, transparent);
  background: color-mix(in srgb, var(--surface-strong) 80%, transparent);
}

.media-preview {
  display: grid;
  place-items: center;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--bg-3) 72%, transparent);
}

.media-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.media-preview i {
  width: 34px;
  height: 34px;
  color: var(--muted);
}

.detail-preview {
  aspect-ratio: auto;
  min-height: 320px;
  max-height: min(68vh, 720px);
  padding: 12px;
  overflow: auto;
  background:
    linear-gradient(45deg, color-mix(in srgb, var(--bg-3) 82%, transparent) 25%, transparent 25%),
    linear-gradient(-45deg, color-mix(in srgb, var(--bg-3) 82%, transparent) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, color-mix(in srgb, var(--bg-3) 82%, transparent) 75%),
    linear-gradient(-45deg, transparent 75%, color-mix(in srgb, var(--bg-3) 82%, transparent) 75%),
    var(--surface);
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
  background-size: 16px 16px;
}

.detail-preview img {
  width: auto;
  max-width: 100%;
  height: auto;
  max-height: calc(min(68vh, 720px) - 24px);
  object-fit: contain;
  border-radius: calc(var(--radius) - 2px);
}

.asset-detail {
  display: grid;
  grid-template-columns: minmax(280px, 0.8fr) minmax(0, 1.2fr);
  gap: 16px;
}

.media-picker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
}

.media-picker-card {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px;
  background: var(--surface);
  color: var(--soft);
  text-align: left;
}

.media-picker-card img {
  width: 100%;
  aspect-ratio: 16 / 10;
  border-radius: var(--radius);
  object-fit: cover;
}

.manual-url {
  margin-top: 14px;
}

.toggle-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  min-height: 58px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.mail-sidebar-panel,
.mail-list-panel,
.mail-reader-panel {
  min-width: 0;
  overflow: hidden;
}

.mail-sidebar {
  display: grid;
  align-content: start;
  gap: 16px;
}

.mail-account-stack,
.mail-folder-stack,
.mail-message-list {
  display: grid;
  gap: 8px;
}

.mail-account-button,
.mail-folder-button,
.mail-message-row {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: inherit;
  text-align: left;
}

.mail-account-button {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  min-height: 68px;
  padding: 11px;
}

.mail-account-button strong,
.mail-account-button em {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mail-account-button em {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
}

.mail-folder-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 42px;
  padding: 0 11px;
}

.mail-folder-button span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  color: var(--soft);
  font-weight: 900;
}

.mail-folder-button strong {
  color: var(--muted);
  font-size: 12px;
}

.mail-account-button.active,
.mail-account-button:hover,
.mail-folder-button.active,
.mail-folder-button:hover,
.mail-message-row.active,
.mail-message-row:hover {
  border-color: color-mix(in srgb, var(--primary) 46%, transparent);
  background: color-mix(in srgb, var(--primary) 10%, transparent);
}

.mail-message-list {
  max-height: calc(100vh - 318px);
  overflow: auto;
  padding: 12px;
}

.mail-message-row {
  display: grid;
  gap: 7px;
  min-height: 112px;
  padding: 12px;
}

.mail-message-row.unread {
  border-color: color-mix(in srgb, var(--primary) 38%, transparent);
  background: color-mix(in srgb, var(--primary) 8%, var(--surface));
}

.mail-row-top,
.mail-row-subject {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
}

.mail-row-top strong,
.mail-row-subject {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mail-row-top time {
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  white-space: nowrap;
}

.mail-row-subject {
  justify-content: flex-start;
  color: var(--text);
  font-weight: 900;
}

.mail-reader-body,
.mail-compose {
  max-height: calc(100vh - 318px);
  overflow: auto;
}

.mail-meta-grid {
  display: grid;
  gap: 7px;
  margin-bottom: 16px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.mail-meta-grid span {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr);
  gap: 8px;
  color: var(--soft);
  overflow-wrap: anywhere;
}

.mail-meta-grid strong {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
}

.mail-body {
  min-height: 280px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  background: color-mix(in srgb, var(--bg-2) 76%, transparent);
  color: var(--text);
  line-height: 1.6;
  overflow-wrap: anywhere;
}

.mail-body pre {
  margin: 0;
  white-space: pre-wrap;
  font-family: inherit;
}

.mail-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.mail-compose-text {
  min-height: 360px;
}

.mail-empty-card {
  display: grid;
  gap: 6px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.modal {
  width: min(780px, calc(100vw - 28px));
  max-height: calc(100vh - 28px);
  border: 0;
  border-radius: var(--radius);
  padding: 0;
  background: transparent;
}

.modal.wide-modal {
  width: min(1180px, calc(100vw - 28px));
}

.modal::backdrop {
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(10px);
}

.modal-surface {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  max-height: calc(100vh - 28px);
  overflow: hidden;
  background: color-mix(in srgb, var(--bg-2) 98%, transparent);
}

.modal-body {
  min-height: 0;
  overflow: auto;
  padding: 18px;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 18px;
  border-top: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg-2) 88%, transparent);
}

.ide-shell {
  display: grid;
  gap: 12px;
}

.ide-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.ide-pane {
  min-width: 0;
}

.ace-code-editor {
  min-height: min(62vh, 620px);
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
}

.ide-shell.has-ace .fallback-code-editor {
  display: none;
}

.ide-shell:not(.has-ace) .ace-code-editor {
  display: none;
}

.segmented {
  display: inline-flex;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.segmented button {
  min-height: 38px;
  padding: 0 14px;
  background: transparent;
  color: var(--soft);
  font-weight: 900;
}

.segmented button.active {
  background: color-mix(in srgb, var(--primary) 18%, transparent);
  color: var(--text);
}

.code-editor {
  min-height: min(62vh, 620px);
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  background: var(--surface);
  color: var(--text);
  font-family: "Consolas", "SFMono-Regular", ui-monospace, monospace;
  font-size: 13px;
  line-height: 1.55;
  white-space: pre;
  overflow: auto;
  resize: vertical;
}

.project-file-preview pre {
  min-height: 420px;
  white-space: pre;
}

.empty-state {
  display: grid;
  place-items: center;
  gap: 10px;
  min-height: 150px;
  color: var(--muted);
  text-align: center;
}

.empty-state i {
  width: 38px;
  height: 38px;
}

.hidden,
[hidden] {
  display: none !important;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 80;
  max-width: min(360px, calc(100vw - 36px));
  border: 1px solid color-mix(in srgb, var(--primary) 38%, transparent);
  border-radius: var(--radius);
  padding: 12px 14px;
  background: color-mix(in srgb, var(--bg-2) 96%, transparent);
  color: var(--text);
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity 160ms ease, transform 160ms ease;
}

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

.login-page {
  display: grid;
  min-height: 100vh;
}

.login-shell {
  display: grid;
  place-items: center;
  width: min(100%, 1180px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 28px 18px;
}

.login-card {
  display: grid;
  gap: 24px;
  width: min(100%, 500px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 28px;
  background: var(--surface-strong);
  box-shadow: var(--shadow);
}

.setup-page .login-card {
  width: min(100%, 540px);
}

.login-brand {
  display: grid;
  grid-template-columns: 58px 1fr;
  gap: 15px;
  align-items: center;
}

.login-brand h1 {
  margin: 0;
  color: var(--text);
  font-family: "Bebas Neue", "Arial Narrow", sans-serif;
  font-size: 42px;
  font-weight: 400;
  line-height: 0.98;
  text-transform: uppercase;
}

.login-form {
  display: grid;
  gap: 14px;
}

.login-note {
  margin: 0;
  border: 1px solid color-mix(in srgb, var(--primary) 24%, var(--line));
  border-radius: var(--radius);
  padding: 12px 14px;
  background: color-mix(in srgb, var(--primary) 8%, var(--surface));
  color: var(--soft);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.45;
}

.login-input {
  display: grid;
  grid-template-columns: 18px 1fr auto;
  align-items: center;
  gap: 9px;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0 11px;
  background: var(--surface);
}

.login-input:focus-within {
  border-color: color-mix(in srgb, var(--primary) 58%, transparent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent);
}

.login-input input {
  height: 44px;
  border: 0;
  padding: 0;
  background: transparent;
  box-shadow: none;
}

.password-toggle {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: var(--radius);
  background: transparent;
  color: var(--soft);
}

.login-error {
  min-height: 20px;
  margin: 0;
  color: var(--red);
  font-size: 13px;
  font-weight: 800;
}

.login-partner {
  padding-top: 16px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  text-align: center;
  text-transform: uppercase;
}

@media (max-width: 1220px) {
  .topbar {
    grid-template-columns: 1fr auto;
  }

  .view-tabs {
    grid-column: 1 / -1;
    order: 3;
  }

  .dashboard-grid,
  .two-column,
  .visibility-grid,
  .mail-layout,
  .mail-client-layout,
  .file-manager-layout,
  .calendar-layout,
  .content-layout,
  .asset-detail {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  body {
    font-size: 13px;
  }

  .topbar {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .topbar-actions {
    justify-content: stretch;
    flex-wrap: wrap;
  }

  .user-pill {
    flex: 1;
  }

  .cms-workspace {
    width: 100%;
    padding: 12px;
  }

  .stage-header,
  .modal-header,
  .repeat-card-header {
    flex-direction: column;
    align-items: stretch;
  }

  .stage-actions,
  .row-actions,
  .toolbar,
  .inline-actions,
  .ide-toolbar {
    justify-content: stretch;
    flex-wrap: wrap;
  }

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

  .data-table {
    min-width: 720px;
  }

  .section-panel.table-wrap,
  .table-wrap {
    overflow: auto;
  }

  .score-row {
    grid-template-columns: 1fr;
  }

  .calendar-grid,
  .calendar-weekdays {
    min-width: 720px;
  }

  .calendar-main-panel {
    overflow: auto;
  }

  .stage-header h1,
  .modal-header h2 {
    font-size: 31px;
  }
}
