:root {
  color-scheme: light;
  font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
  --bg: #f3f6fb;
  --panel: #ffffff;
  --ink: #172033;
  --muted: #66758a;
  --line: #dfe7f1;
  --soft: #f8fafc;
  --primary: #0f766e;
  --primary-dark: #0b5f59;
  --blue: #24507f;
  --danger: #b42318;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
}

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

/* Front landing page */
.landing-body {
  min-height: 100vh;
  min-height: 100svh;
  background: #0f172a;
  overflow-x: hidden;
}

.landing-page {
  width: 100vw;
  min-width: 100vw;
  min-height: 100vh;
  min-height: 100dvh;
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: 0;
  background:
    linear-gradient(135deg, rgba(15, 23, 42, 0.68), rgba(127, 29, 29, 0.44)),
    var(--landing-bg, linear-gradient(135deg, #0f172a, #b91c1c));
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  overflow: hidden;
}

.clickable-page {
  cursor: pointer;
}

.landing-content {
  position: relative;
  width: 100vw;
  min-height: 100vh;
  min-height: 100dvh;
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: max(22px, env(safe-area-inset-top)) 20px max(24px, env(safe-area-inset-bottom));
  overflow: hidden;
  text-align: center;
  color: #ffffff;
}

.main-image {
  position: absolute;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
}

.landing-copy {
  position: relative;
  z-index: 1;
  width: min(100%, 360px);
  display: grid;
  justify-items: center;
  gap: 10px;
  padding: 14px 8px;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.48);
}

.landing-content h1 {
  margin: 0 0 14px;
  max-width: 100%;
  font-size: clamp(20px, 6vw, 34px);
  line-height: 1.16;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

.landing-content p {
  margin: 0 auto 8px;
  max-width: 24em;
  font-size: clamp(13px, 3.8vw, 17px);
  line-height: 1.45;
  color: rgba(255, 255, 255, 0.88);
  overflow-wrap: anywhere;
}

.cta-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: min(100%, 240px);
  min-height: 48px;
  padding: 12px 22px;
  border-radius: 8px;
  text-decoration: none;
  font-weight: 700;
  font-size: clamp(14px, 4vw, 16px);
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.28);
  overflow-wrap: anywhere;
}

@media (orientation: landscape) and (max-height: 520px) {
  .landing-content {
    min-height: 100svh;
    padding: 12px;
  }

  .landing-copy {
    gap: 6px;
    padding: 8px;
  }

  .landing-content h1 {
    font-size: clamp(18px, 4vh, 26px);
    margin-bottom: 4px;
  }

  .landing-content p {
    font-size: clamp(12px, 3vh, 14px);
    line-height: 1.3;
  }

  .cta-button {
    width: min(100%, 210px);
    min-height: 40px;
    padding: 9px 16px;
  }
}

/* Admin console */
.console-body {
  min-height: 100vh;
  color: var(--ink);
  background: var(--bg);
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 10;
  width: 232px;
  display: grid;
  grid-template-rows: auto 1fr auto;
  padding: 20px 16px;
  color: #dbeafe;
  background: #111827;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #ffffff;
  text-decoration: none;
  margin-bottom: 24px;
}

.sidebar-brand span {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  color: #ffffff;
  background: var(--primary);
  font-weight: 900;
}

.sidebar-brand strong {
  font-size: 18px;
}

.side-nav {
  display: grid;
  gap: 6px;
  align-content: start;
}

.side-nav a,
.sidebar-foot a,
.sidebar-foot button {
  min-height: 42px;
  display: flex;
  align-items: center;
  padding: 10px 12px;
  border: 0;
  border-radius: 8px;
  color: #cbd5e1;
  background: transparent;
  text-decoration: none;
  cursor: pointer;
  text-align: left;
}

.side-nav a.active,
.side-nav a:hover,
.sidebar-foot a:hover,
.sidebar-foot button:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.1);
}

.sidebar-foot {
  display: grid;
  gap: 6px;
}

.sidebar-foot form {
  margin: 0;
}

.console-main {
  width: calc(100% - 232px);
  min-height: 100vh;
  margin-left: 232px;
  padding: 26px 30px 48px;
}

.console-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
}

.console-top p {
  margin: 0 0 4px;
  color: var(--muted);
}

.console-top h1 {
  margin: 0;
  font-size: 30px;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.panel,
.metric-card,
.quick-card,
.template-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 10px 24px rgba(20, 32, 55, 0.05);
}

.panel {
  padding: 22px;
  margin-top: 18px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 14px;
}

.metric-card {
  padding: 18px;
}

.metric-card span {
  display: block;
  margin-bottom: 10px;
  color: var(--muted);
}

.metric-card strong {
  font-size: 30px;
}

.quick-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-top: 18px;
}

.quick-card {
  display: grid;
  gap: 8px;
  padding: 18px;
  color: var(--ink);
  text-decoration: none;
}

.quick-card span {
  color: var(--muted);
  line-height: 1.5;
}

.content-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin-top: 18px;
}

.content-grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.section-head.compact {
  align-items: center;
}

.section-head h2,
.panel h2 {
  margin: 0;
}

.section-head p {
  margin: 6px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.muted,
.empty {
  color: var(--muted);
}

.text-link {
  color: var(--blue);
  text-decoration: none;
  font-weight: 700;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid #cbd6e3;
  border-radius: 8px;
  padding: 11px 12px;
  background: #ffffff;
  color: var(--ink);
}

input[type="color"] {
  height: 44px;
  padding: 4px;
}

label {
  display: grid;
  gap: 8px;
}

label span {
  color: #46566d;
  font-weight: 700;
}

.form-stack,
.settings-form {
  display: grid;
  gap: 18px;
}

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

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

.toggle-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.toggle-row input {
  width: auto;
}

.primary-button,
.secondary-button,
.danger-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 10px 16px;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  font-weight: 700;
  white-space: nowrap;
}

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

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

.secondary-button {
  color: var(--blue);
  background: #eef5ff;
  border-color: #c9ddf5;
}

.danger-button {
  color: var(--danger);
  background: #fff4f2;
  border-color: #f3b7b0;
}

.page-toolbar,
.create-strip,
.inline-create,
.filter-bar {
  display: grid;
  gap: 10px;
}

.create-strip {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
}

.inline-create {
  grid-template-columns: repeat(4, minmax(0, 1fr)) auto;
  align-items: end;
}

.domain-create {
  grid-template-columns: 1.1fr 1.3fr 0.8fr 1fr auto;
}

.channel-create {
  grid-template-columns: repeat(5, minmax(0, 1fr)) auto;
}

.filter-bar {
  grid-template-columns: repeat(2, minmax(0, 260px));
  align-items: end;
}

.manager-layout {
  display: grid;
  grid-template-columns: 310px minmax(0, 1fr);
  gap: 18px;
}

.page-list {
  align-self: start;
  position: sticky;
  top: 24px;
}

.page-links {
  display: grid;
  gap: 10px;
}

.page-links a {
  display: grid;
  gap: 5px;
  padding: 12px;
  color: var(--ink);
  text-decoration: none;
  border: 1px solid #e1e9f2;
  border-radius: 8px;
  background: #fbfdff;
}

.page-links a.active {
  border-color: var(--primary);
  background: #eefbf8;
}

.page-links span {
  color: var(--muted);
}

.actions-row,
.row-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.table-wrap,
.compact-table {
  overflow-x: auto;
}

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

th,
td {
  padding: 12px 10px;
  text-align: left;
  border-bottom: 1px solid #e5ecf4;
  vertical-align: middle;
}

th {
  color: #52627a;
  background: var(--soft);
}

.copy-code {
  display: block;
  max-width: 430px;
  padding: 8px;
  overflow-x: auto;
  color: #0f3a5f;
  border-radius: 8px;
  background: #f7fbff;
  border: 1px solid #dbe8f6;
  white-space: nowrap;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.tag-list span {
  padding: 8px 10px;
  border: 1px solid #dbe8f6;
  border-radius: 8px;
  color: #31517a;
  background: #f7fbff;
}

.image-preview {
  display: grid;
  grid-template-columns: 86px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  min-height: 86px;
  padding: 10px;
  border: 1px solid #dbe8f6;
  border-radius: 8px;
  color: var(--blue);
  background: #f7fbff;
  text-decoration: none;
}

.image-preview img {
  width: 86px;
  height: 66px;
  border-radius: 8px;
  object-fit: cover;
  background: #e5ecf4;
}

.image-preview span {
  min-width: 0;
  color: #31517a;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.activity-list {
  display: grid;
  gap: 10px;
}

.activity-item {
  display: grid;
  gap: 4px;
  padding: 12px;
  border: 1px solid #e1e9f2;
  border-radius: 8px;
  background: #fbfdff;
}

.activity-item span,
.activity-item small {
  color: var(--muted);
}

.messages {
  display: grid;
  gap: 10px;
  margin-bottom: 16px;
}

.message {
  padding: 12px 14px;
  border-radius: 8px;
  border: 1px solid #d5dfeb;
  background: #ffffff;
}

.message.success {
  border-color: #8fd7a5;
  background: #eefbf2;
}

.message.error {
  border-color: #f2a1a1;
  background: #fff1f1;
}

/* Login */
.login-body {
  min-height: 100vh;
  background: #f3f6fb;
}

.login-main {
  width: min(560px, calc(100% - 32px));
  min-height: 100vh;
  display: grid;
  place-items: center;
  margin: 0 auto;
}

.login-card {
  width: 100%;
  display: grid;
  gap: 24px;
  padding: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 18px 42px rgba(20, 32, 55, 0.08);
}

.login-copy span {
  color: var(--primary);
  font-weight: 800;
}

.login-copy h1 {
  margin: 8px 0;
  font-size: 34px;
}

.login-copy p {
  margin: 0;
  color: var(--muted);
}

/* Template library */
.library-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 22px;
}

.library-hero h1 {
  margin: 4px 0 10px;
}

.eyebrow {
  margin: 0;
  color: var(--primary);
  font-weight: 800;
}

.library-summary {
  display: grid;
  place-items: center;
  min-width: 116px;
  min-height: 96px;
  border: 1px solid #cfe3ef;
  border-radius: 8px;
  background: #f7fbff;
}

.library-summary strong {
  font-size: 38px;
  line-height: 1;
}

.library-summary span {
  color: var(--muted);
}

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

.template-card {
  display: grid;
  gap: 16px;
  padding: 22px;
}

.template-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.template-card h2,
.template-card h3,
.template-card p {
  margin: 0;
}

.template-card h2 {
  margin-top: 5px;
  font-size: 22px;
}

.template-card h3 {
  margin-bottom: 6px;
  font-size: 15px;
  color: #46566d;
}

.template-card small {
  color: var(--muted);
}

.template-kind,
.badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 9px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 800;
}

.template-kind {
  color: #0f5e57;
  background: #e8f7f4;
}

.badge {
  color: #7a4b00;
  background: #fff2d5;
}

.template-info p {
  color: #334155;
  line-height: 1.55;
}

.asset-list {
  display: grid;
  overflow: hidden;
  border: 1px solid #e1e9f2;
  border-radius: 8px;
}

.asset-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  padding: 10px 12px;
  border-bottom: 1px solid #e8eef6;
  background: #fbfdff;
}

.asset-row:last-child {
  border-bottom: 0;
}

.asset-row span {
  color: #46566d;
}

.asset-row strong {
  white-space: nowrap;
}

.warning-note {
  padding: 12px;
  border: 1px solid #f1dfb6;
  border-radius: 8px;
  background: #fffbeb;
}

@media (max-width: 1180px) {
  .metric-grid,
  .quick-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .content-grid,
  .content-grid.two,
  .template-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 820px) {
  .sidebar {
    position: static;
    width: 100%;
  }

  .console-main {
    width: 100%;
    margin-left: 0;
    padding: 18px;
  }

  .console-top,
  .section-head,
  .library-hero,
  .template-card-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .metric-grid,
  .quick-grid,
  .form-grid,
  .manager-layout,
  .create-strip,
  .inline-create,
  .domain-create,
  .channel-create,
  .filter-bar {
    grid-template-columns: 1fr;
  }

  .page-list {
    position: static;
  }

  .panel {
    padding: 18px;
  }
}
