:root {
  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans GB", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: #f2f5f7;
  color: #18212a;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.92), rgba(242,245,247,0.94)),
    #f2f5f7;
}

a {
  color: inherit;
  text-decoration: none;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

p,
small,
.muted,
.hint {
  color: #63717d;
  line-height: 1.65;
}

.app-shell {
  display: grid;
  grid-template-columns: 248px 1fr;
  min-height: 100vh;
}

.shell {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 28px;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px;
  background: #102d46;
  color: #fff;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 28px;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: #102d46;
  background: #f0c24b;
  font-weight: 900;
  font-size: 22px;
}

.brand-lockup strong,
.brand-lockup span,
.account-card strong,
.account-card span,
.account-card small {
  display: block;
}

.brand-lockup span,
.account-card span,
.account-card small {
  opacity: 0.72;
  font-size: 12px;
  margin-top: 3px;
}

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

.side-nav a {
  padding: 11px 12px;
  border-radius: 8px;
  color: rgba(255,255,255,0.78);
}

.side-nav a.active,
.side-nav a:hover {
  color: #fff;
  background: rgba(255,255,255,0.12);
}

.account-card {
  padding: 14px;
  border-radius: 8px;
  background: rgba(255,255,255,0.1);
}

.main-stage {
  min-width: 0;
  padding: 28px;
}

.page-head {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: end;
  margin-bottom: 20px;
}

.page-head h1 {
  font-size: 30px;
  line-height: 1.18;
  margin-bottom: 8px;
  letter-spacing: 0;
}

.eyebrow {
  display: block;
  color: #176b93;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.metric-row {
  display: grid;
  grid-template-columns: repeat(3, 96px);
  gap: 10px;
}

.metric-row div {
  height: 70px;
  border: 1px solid rgba(16,45,70,0.1);
  border-radius: 8px;
  background: #fff;
  padding: 12px;
  box-shadow: 0 12px 32px rgba(16,45,70,0.06);
}

.metric-row strong {
  display: block;
  font-size: 24px;
  line-height: 1;
}

.metric-row span {
  display: block;
  color: #687783;
  font-size: 12px;
  margin-top: 8px;
}

.studio-grid,
.workspace {
  display: grid;
  grid-template-columns: minmax(420px, 520px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.panel {
  background: rgba(255,255,255,0.94);
  border: 1px solid rgba(16,45,70,0.1);
  border-radius: 8px;
  box-shadow: 0 18px 50px rgba(16,45,70,0.08);
}

.compose-panel,
.form-panel,
.result-panel,
.history-panel {
  padding: 20px;
}

.compose-panel,
.form-panel {
  position: sticky;
  top: 18px;
}

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

.section-head.compact {
  margin-bottom: 10px;
}

.section-head h2,
.topline h1,
.result-head h1,
.result-head h2 {
  margin-bottom: 5px;
  font-size: 20px;
  line-height: 1.25;
}

.section-head p,
.topline p,
.result-head p {
  margin-bottom: 0;
  font-size: 13px;
}

.status-pill,
.badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 10px;
  border-radius: 999px;
  background: #e7f3f6;
  color: #176b93;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.status-pill.success {
  background: #eef8ef;
  color: #277542;
}

.form-block {
  padding: 16px 0;
  border-top: 1px solid rgba(16,45,70,0.08);
}

.form-block:first-of-type {
  border-top: 0;
  padding-top: 0;
}

h3 {
  font-size: 14px;
  margin: 0 0 12px;
  color: #314555;
}

label {
  display: grid;
  gap: 7px;
  margin-bottom: 13px;
  color: #465967;
  font-size: 13px;
  font-weight: 700;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid rgba(16,45,70,0.18);
  border-radius: 8px;
  padding: 11px 12px;
  font: inherit;
  font-weight: 500;
  color: #18212a;
  background: #fff;
  outline: none;
}

input:focus,
textarea:focus,
select:focus {
  border-color: #176b93;
  box-shadow: 0 0 0 3px rgba(23,107,147,0.12);
}

textarea {
  resize: vertical;
}

.upload-zone {
  padding: 14px;
  border: 1px dashed rgba(23,107,147,0.35);
  border-radius: 8px;
  background: #f6fbfd;
}

.upload-zone.secondary {
  background: #fbfaf6;
  border-color: rgba(181,133,29,0.28);
}

.upload-zone small {
  font-weight: 500;
}

.grid {
  display: grid;
  gap: 12px;
}

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

.three {
  grid-template-columns: 1fr 1fr 118px;
  align-items: end;
}

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

button,
.primary,
.ghost {
  border: 0;
  border-radius: 8px;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.primary {
  height: 45px;
  padding: 0 16px;
  color: #fff;
  background: #176b93;
}

.primary:hover {
  background: #105577;
}

.ghost {
  height: 38px;
  color: #fff;
  background: rgba(255,255,255,0.14);
  margin-top: 12px;
}

.full {
  width: 100%;
}

.result-stack {
  display: grid;
  gap: 18px;
}

.result-panel {
  min-height: 520px;
}

.copy-showcase {
  display: grid;
  gap: 6px;
  padding: 16px;
  border-radius: 8px;
  background: linear-gradient(135deg, #f8fbfd, #fff8e3);
  border: 1px solid rgba(16,45,70,0.08);
  margin-bottom: 16px;
}

.copy-showcase strong {
  font-size: 22px;
}

.copy-showcase span,
.copy-showcase small {
  color: #176b93;
  font-weight: 700;
}

.gallery {
  display: grid;
  gap: 14px;
}

.poster-gallery {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.thumb-gallery,
.gallery.small {
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

.gallery img,
.upload-preview,
.template-card img,
.history-item img {
  width: 100%;
  display: block;
  border-radius: 8px;
  border: 1px solid rgba(16,45,70,0.1);
  background: #fff;
}

.poster-gallery img {
  max-height: 760px;
  object-fit: contain;
}

.empty-state,
.empty,
.error {
  min-height: 360px;
  display: grid;
  align-content: center;
  padding: 28px;
  border-radius: 8px;
  background: #f7fafc;
}

.alert,
.success,
.error.slim {
  display: grid;
  gap: 4px;
  min-height: auto;
  padding: 12px;
  border-radius: 8px;
  margin-bottom: 14px;
}

.alert.error,
.error,
.error.slim {
  background: #fff1ed;
  color: #9d3424;
}

.success {
  background: #eef8ef;
  color: #277542;
}

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

.history-item {
  display: grid;
  grid-template-columns: 74px 1fr;
  gap: 12px;
  align-items: center;
  padding: 10px;
  border-radius: 8px;
  background: #f8fafb;
}

.history-item img,
.history-placeholder {
  width: 74px;
  height: 92px;
  object-fit: cover;
}

.history-placeholder {
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #e9eef2;
  color: #63717d;
  font-size: 12px;
}

.history-item strong,
.history-item span,
.history-item small {
  display: block;
}

.history-item span {
  color: #63717d;
  font-size: 13px;
  margin: 4px 0;
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 430px;
  gap: 24px;
  align-items: stretch;
  padding: 28px;
}

.auth-visual {
  display: grid;
  align-content: center;
  padding: 54px;
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(16,45,70,0.94), rgba(23,107,147,0.84)),
    #102d46;
  color: #fff;
}

.auth-visual h1 {
  max-width: 680px;
  font-size: 44px;
  line-height: 1.12;
  margin: 70px 0 14px;
}

.auth-visual p {
  color: rgba(255,255,255,0.78);
  max-width: 560px;
}

.auth-points {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 30px;
}

.auth-points span {
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(255,255,255,0.12);
}

.auth-panel {
  align-self: center;
  padding: 28px;
}

.auth-panel h2 {
  font-size: 26px;
  margin-bottom: 18px;
}

.auth-switch {
  text-align: center;
  margin: 14px 0;
  color: #176b93;
  font-weight: 700;
}

.hint {
  padding: 12px;
  border-radius: 8px;
  background: #f6fbfd;
  font-size: 12px;
}

.quick-links,
.top-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.quick-links a,
.admin-link {
  height: 36px;
  display: inline-flex;
  align-items: center;
  padding: 0 12px;
  border-radius: 8px;
  color: #176b93;
  background: #e7f3f6;
  font-weight: 800;
  font-size: 13px;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid rgba(16,45,70,0.1);
  border-radius: 8px;
  background: #fff;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th,
td {
  padding: 10px 12px;
  border-bottom: 1px solid rgba(16,45,70,0.08);
  text-align: left;
  vertical-align: top;
}

th {
  background: #f5f8fa;
  color: #455b6b;
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  color: #2f475a;
  word-break: break-all;
}

.template-workspace {
  grid-template-columns: 420px 1fr;
}

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

.template-card {
  display: grid;
  gap: 10px;
  padding: 12px;
  border-radius: 8px;
  background: #f8fafb;
}

.template-card span,
.template-card strong,
.template-card code {
  display: block;
  margin-bottom: 5px;
}

.loading {
  position: fixed;
  inset: 0;
  display: none;
  place-items: center;
  background: rgba(16,45,70,0.34);
  backdrop-filter: blur(8px);
  z-index: 20;
}

.loading.show {
  display: grid;
}

.loader-card {
  width: min(320px, calc(100vw - 40px));
  display: grid;
  justify-items: center;
  gap: 12px;
  padding: 26px;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 24px 80px rgba(16,45,70,0.22);
}

.spinner {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 4px solid #d9e7ee;
  border-top-color: #176b93;
  animation: spin 0.9s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 1080px) {
  .app-shell,
  .auth-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    grid-template-rows: auto;
  }

  .studio-grid,
  .workspace,
  .template-workspace {
    grid-template-columns: 1fr;
  }

  .compose-panel,
  .form-panel {
    position: static;
  }

  .page-head {
    display: grid;
  }

  .metric-row {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 640px) {
  .main-stage,
  .auth-shell {
    padding: 14px;
  }

  .auth-visual {
    padding: 28px;
  }

  .auth-visual h1 {
    font-size: 30px;
    margin-top: 42px;
  }

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

  .page-head h1 {
    font-size: 25px;
  }
}
