:root {
  color-scheme: light;
  --bg: #f5f6fa;
  --surface: #ffffff;
  --surface-soft: #f9f9fc;
  --surface-strong: #f0f1f7;
  --ink: #171923;
  --ink-soft: #454957;
  --muted: #73798b;
  --line: #e4e6ef;
  --line-strong: #d5d8e5;
  --primary: #5654d8;
  --primary-dark: #4240b9;
  --primary-soft: #eeedff;
  --success: #16855b;
  --success-soft: #e9f7f1;
  --warning: #a8660b;
  --warning-soft: #fff5df;
  --danger: #b73d4b;
  --danger-soft: #fff0f2;
  --info: #296fb8;
  --info-soft: #eaf4ff;
  --shadow-sm: 0 1px 2px rgba(25, 28, 45, 0.05), 0 8px 28px rgba(44, 47, 70, 0.04);
  --shadow-md: 0 16px 48px rgba(34, 37, 58, 0.11);
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --sidebar-width: 244px;
  --content-max: 1440px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

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

button,
a,
label[for] {
  -webkit-tap-highlight-color: transparent;
}

button {
  color: inherit;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible {
  outline: 3px solid rgba(86, 84, 216, 0.22);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

svg {
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

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

h1,
h2,
h3,
h4 {
  letter-spacing: -0.02em;
}

button,
a {
  text-decoration: none;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 11px;
  color: var(--ink);
  background: var(--surface);
  transition: border-color 150ms ease, box-shadow 150ms ease, background 150ms ease;
}

input,
select {
  min-height: 44px;
  padding: 0 12px;
}

textarea {
  min-height: 108px;
  padding: 11px 12px;
  line-height: 1.65;
  resize: vertical;
}

input:hover,
select:hover,
textarea:hover {
  border-color: #bfc3d5;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(86, 84, 216, 0.1);
  outline: none;
}

input::placeholder,
textarea::placeholder {
  color: #a5a9b7;
}

select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, #85899a 50%), linear-gradient(135deg, #85899a 50%, transparent 50%);
  background-position: calc(100% - 17px) 19px, calc(100% - 12px) 19px;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 34px;
}

.section-kicker,
.eyebrow {
  margin-bottom: 7px;
  color: var(--primary);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 17px;
  border: 1px solid transparent;
  border-radius: 11px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  transition: transform 120ms ease, background 150ms ease, border-color 150ms ease, box-shadow 150ms ease, color 150ms ease;
}

.button:hover:not(:disabled) {
  transform: translateY(-1px);
}

.button:active:not(:disabled) {
  transform: translateY(0);
}

.button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.button svg {
  width: 18px;
  height: 18px;
}

.button-primary {
  color: #fff;
  background: var(--primary);
  border-color: var(--primary);
  box-shadow: 0 9px 20px rgba(86, 84, 216, 0.22);
}

.button-primary:hover:not(:disabled) {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
}

.button-secondary {
  color: var(--ink-soft);
  background: var(--surface);
  border-color: var(--line-strong);
}

.button-secondary:hover:not(:disabled) {
  color: var(--primary);
  border-color: #bab8f2;
  background: #fbfaff;
}

.button-quiet {
  color: var(--ink-soft);
  background: transparent;
  border-color: transparent;
  box-shadow: none;
}

.button-quiet:hover:not(:disabled) {
  background: var(--surface-strong);
}

.button-danger {
  color: var(--danger);
  background: var(--danger-soft);
  border-color: #f4c8cf;
}

.button-small {
  min-height: 38px;
  padding: 0 13px;
  font-size: 13px;
}

.button-large {
  width: 100%;
  min-height: 50px;
  border-radius: 13px;
}

.icon-button {
  display: inline-grid;
  width: 38px;
  height: 38px;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 10px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  transition: color 150ms ease, background 150ms ease;
}

.icon-button:hover {
  color: var(--ink);
  background: var(--surface-strong);
}

.icon-button svg {
  width: 19px;
  height: 19px;
}

.text-button {
  padding: 4px 0;
  border: 0;
  color: var(--primary);
  background: transparent;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.text-button:hover {
  text-decoration: underline;
  text-underline-offset: 4px;
}

/* Login */

.login-view {
  position: relative;
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 36px 24px;
  overflow: hidden;
  background:
    radial-gradient(circle at 15% 20%, rgba(86, 84, 216, 0.12), transparent 30%),
    radial-gradient(circle at 90% 80%, rgba(52, 174, 138, 0.1), transparent 32%),
    #f6f7fb;
}

.login-decoration {
  position: absolute;
  border-radius: 999px;
  filter: blur(2px);
  pointer-events: none;
}

.login-decoration-one {
  top: -170px;
  right: 8%;
  width: 330px;
  height: 330px;
  border: 1px solid rgba(86, 84, 216, 0.14);
}

.login-decoration-two {
  bottom: -220px;
  left: 7%;
  width: 470px;
  height: 470px;
  border: 1px solid rgba(22, 133, 91, 0.13);
}

.login-card {
  position: relative;
  z-index: 1;
  display: grid;
  width: min(1040px, 100%);
  min-height: 630px;
  grid-template-columns: minmax(0, 1.08fr) minmax(360px, 0.92fr);
  overflow: hidden;
  border: 1px solid rgba(223, 225, 235, 0.92);
  border-radius: 28px;
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 30px 90px rgba(41, 44, 68, 0.14);
}

.login-intro {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 62px;
  color: #fff;
  overflow: hidden;
  background: linear-gradient(150deg, #24233f 0%, #3f3da6 62%, #5654d8 100%);
}

.login-intro::before,
.login-intro::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
}

.login-intro::before {
  width: 370px;
  height: 370px;
  top: -210px;
  right: -170px;
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.login-intro::after {
  width: 260px;
  height: 260px;
  bottom: -160px;
  left: -90px;
  background: rgba(255, 255, 255, 0.04);
}

.login-intro .eyebrow {
  position: relative;
  margin-bottom: 13px;
  color: rgba(255, 255, 255, 0.64);
}

.login-intro h1 {
  position: relative;
  max-width: 440px;
  margin-bottom: 18px;
  font-size: clamp(34px, 4vw, 52px);
  line-height: 1.12;
}

.login-lead {
  position: relative;
  max-width: 440px;
  margin-bottom: 44px;
  color: rgba(255, 255, 255, 0.72);
  font-size: 17px;
  line-height: 1.75;
}

.brand-mark {
  display: grid;
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 13px;
  color: #fff;
  background: var(--primary);
}

.brand-mark svg {
  width: 27px;
  height: 27px;
}

.brand-mark svg path:first-child {
  fill: none;
}

.brand-mark svg path:last-child {
  fill: currentColor;
  stroke: none;
}

.brand-mark-large {
  position: relative;
  width: 54px;
  height: 54px;
  margin-bottom: 24px;
  color: #3f3da6;
  background: #fff;
  box-shadow: 0 12px 28px rgba(19, 18, 55, 0.24);
}

.brand-mark-large svg {
  width: 33px;
  height: 33px;
}

.login-features {
  position: relative;
  display: grid;
  gap: 18px;
}

.login-features > div {
  display: grid;
  grid-template-columns: 38px 1fr;
  align-items: start;
  gap: 13px;
}

.login-features > div > span {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 10px;
  color: rgba(255, 255, 255, 0.72);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.login-features p {
  display: grid;
  gap: 4px;
  margin-bottom: 0;
}

.login-features strong {
  font-size: 14px;
}

.login-features small {
  color: rgba(255, 255, 255, 0.58);
  font-size: 12px;
  line-height: 1.5;
}

.login-form-panel {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 58px 54px;
}

.login-form-heading {
  margin-bottom: 31px;
}

.login-form-heading h2 {
  margin-bottom: 9px;
  font-size: 29px;
}

.login-form-heading > p:last-child {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.65;
}

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

.field-label {
  margin-top: 7px;
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 700;
}

.input-shell {
  position: relative;
}

.input-shell > svg {
  position: absolute;
  top: 50%;
  left: 14px;
  width: 19px;
  height: 19px;
  color: #969bab;
  transform: translateY(-50%);
  pointer-events: none;
}

.input-shell input {
  min-height: 48px;
  padding-left: 43px;
}

.input-shell input[type="password"],
.input-shell input[data-password-visible="true"] {
  padding-right: 48px;
}

.password-toggle {
  position: absolute;
  top: 5px;
  right: 5px;
}

.form-error {
  margin: 3px 0 0;
  padding: 10px 12px;
  border: 1px solid #f3c7cd;
  border-radius: 9px;
  color: var(--danger);
  background: var(--danger-soft);
  font-size: 12px;
  line-height: 1.5;
}

.login-form .button-large {
  margin-top: 17px;
}

.login-security {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 25px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.55;
}

.login-security svg {
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  margin-top: 1px;
  color: var(--success);
}

/* App shell */

.app-shell {
  display: grid;
  min-height: 100vh;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  height: 100vh;
  flex-direction: column;
  padding: 22px 15px 17px;
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(16px);
  z-index: 20;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 5px 7px 23px;
}

.sidebar-brand > div:last-child,
.sidebar-footer > div:nth-child(2) {
  display: grid;
  min-width: 0;
  gap: 3px;
}

.sidebar-brand strong {
  font-size: 14px;
  white-space: nowrap;
}

.sidebar-brand small,
.sidebar-footer small {
  color: var(--muted);
  font-size: 11px;
}

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

.nav-button {
  position: relative;
  display: flex;
  min-height: 47px;
  align-items: center;
  gap: 12px;
  padding: 0 12px;
  border: 0;
  border-radius: 12px;
  color: var(--muted);
  background: transparent;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  text-align: left;
  transition: background 150ms ease, color 150ms ease;
}

.nav-button:hover {
  color: var(--ink);
  background: var(--surface-strong);
}

.nav-button.is-active {
  color: var(--primary);
  background: var(--primary-soft);
}

.nav-button svg {
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
}

.nav-button b {
  display: grid;
  min-width: 20px;
  height: 20px;
  margin-left: auto;
  place-items: center;
  padding: 0 5px;
  border-radius: 999px;
  color: #fff;
  background: var(--danger);
  font-size: 10px;
}

.sidebar-footer {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) 38px;
  align-items: center;
  gap: 9px;
  margin-top: auto;
  padding: 13px 4px 0;
  border-top: 1px solid var(--line);
}

.sidebar-footer strong {
  overflow: hidden;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-avatar {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border-radius: 11px;
  color: var(--primary);
  background: var(--primary-soft);
  font-size: 13px;
  font-weight: 800;
}

.main-content {
  min-width: 0;
  padding: 0 clamp(22px, 3vw, 48px) 54px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 15;
  display: flex;
  width: min(100%, var(--content-max));
  min-height: 88px;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin: 0 auto;
  padding: 18px 0;
  background: rgba(245, 246, 250, 0.88);
  backdrop-filter: blur(18px);
}

.topbar h1 {
  margin-bottom: 0;
  font-size: 23px;
}

.topbar .section-kicker {
  margin-bottom: 4px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.system-pill {
  display: grid;
  min-width: 182px;
  grid-template-columns: 8px 1fr;
  grid-template-rows: auto auto;
  align-items: center;
  column-gap: 9px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.86);
}

.status-dot {
  grid-row: 1 / 3;
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #a8adbb;
  box-shadow: 0 0 0 4px rgba(168, 173, 187, 0.12);
}

.system-pill strong {
  font-size: 11px;
  line-height: 1.4;
}

.system-pill small {
  color: var(--muted);
  font-size: 10px;
  line-height: 1.35;
}

.system-pill.is-success .status-dot {
  background: var(--success);
  box-shadow: 0 0 0 4px rgba(22, 133, 91, 0.12);
}

.system-pill.is-warning .status-dot {
  background: var(--warning);
  box-shadow: 0 0 0 4px rgba(168, 102, 11, 0.12);
}

.system-pill.is-danger .status-dot {
  background: var(--danger);
  box-shadow: 0 0 0 4px rgba(183, 61, 75, 0.12);
}

.view {
  width: min(100%, var(--content-max));
  margin: 0 auto;
}

.view-intro {
  display: flex;
  min-height: 170px;
  align-items: center;
  padding: 28px 0 35px;
}

.view-intro h2 {
  margin-bottom: 11px;
  font-size: clamp(27px, 3vw, 38px);
}

.view-intro p:last-child {
  max-width: 710px;
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.75;
}

.split-intro {
  justify-content: space-between;
  gap: 32px;
}

.create-hero {
  display: flex;
  min-height: 205px;
  align-items: center;
  justify-content: space-between;
  gap: 28px;
  margin-bottom: 20px;
  padding: 34px clamp(28px, 4vw, 54px);
  overflow: hidden;
  border: 1px solid #dbdcfb;
  border-radius: var(--radius-lg);
  background:
    radial-gradient(circle at 90% 15%, rgba(86, 84, 216, 0.15), transparent 36%),
    linear-gradient(135deg, #fbfbff, #f3f2ff);
}

.create-hero h2 {
  margin-bottom: 12px;
  font-size: clamp(28px, 3.2vw, 42px);
}

.create-hero p:last-child {
  max-width: 690px;
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.75;
}

.hero-metric {
  display: grid;
  min-width: 170px;
  justify-items: center;
  padding: 23px 28px;
  border: 1px solid rgba(86, 84, 216, 0.16);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.72);
  box-shadow: var(--shadow-sm);
}

.hero-metric small,
.hero-metric span {
  color: var(--muted);
  font-size: 11px;
}

.hero-metric strong {
  margin: 2px 0;
  color: var(--primary);
  font-size: 39px;
  line-height: 1;
}

.panel {
  margin-top: 18px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 21px;
}

.panel-heading > div:first-child {
  display: flex;
  align-items: center;
  gap: 13px;
}

.panel-heading h3 {
  margin-bottom: 3px;
  font-size: 16px;
}

.panel-heading p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.step-number {
  display: grid;
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 10px;
  color: var(--primary);
  background: var(--primary-soft);
  font-size: 12px;
  font-weight: 800;
}

.template-strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(145px, 1fr));
  gap: 10px;
}

.template-choice {
  display: grid;
  min-height: 105px;
  align-content: space-between;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--surface-soft);
  cursor: pointer;
  text-align: left;
  transition: border-color 150ms ease, background 150ms ease, transform 150ms ease;
}

.template-choice:hover {
  transform: translateY(-1px);
  border-color: #c7c5f5;
  background: #fbfaff;
}

.template-choice.is-selected {
  border-color: var(--primary);
  background: var(--primary-soft);
  box-shadow: inset 0 0 0 1px var(--primary);
}

.template-choice span {
  width: fit-content;
  padding: 4px 7px;
  border-radius: 6px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.8);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.05em;
}

.template-choice strong {
  margin-top: 17px;
  font-size: 12px;
  line-height: 1.45;
}

.scheme-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.scheme-button {
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  gap: 7px;
  padding: 0 13px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  color: var(--ink-soft);
  background: var(--surface);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.scheme-button:hover,
.scheme-button.is-selected {
  color: var(--primary);
  border-color: #bab8f2;
  background: var(--primary-soft);
}

.scheme-button small {
  padding: 2px 5px;
  border-radius: 999px;
  color: var(--success);
  background: var(--success-soft);
  font-size: 8px;
}

.notice-list {
  display: grid;
  gap: 7px;
  margin-top: 15px;
}

.notice-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.55;
}

.notice-item svg {
  flex: 0 0 auto;
  width: 15px;
  height: 15px;
  margin-top: 1px;
  color: var(--info);
}

.file-button {
  cursor: pointer;
}

.upload-state {
  margin-bottom: 14px;
  padding: 12px 14px;
  border: 1px solid #c9dcf1;
  border-radius: 10px;
  color: var(--info);
  background: var(--info-soft);
  font-size: 12px;
}

.asset-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(100px, 1fr));
  gap: 11px;
}

.asset-card {
  position: relative;
  min-width: 0;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-soft);
}

.asset-thumb {
  position: relative;
  aspect-ratio: 9 / 14;
  overflow: hidden;
  border-radius: 8px;
  background: var(--surface-strong);
}

.asset-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.asset-card-info {
  display: grid;
  gap: 3px;
  padding: 8px 2px 2px;
}

.asset-card-info strong {
  overflow: hidden;
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.asset-card-info small {
  color: var(--muted);
  font-size: 9px;
}

.asset-badge {
  position: absolute;
  top: 6px;
  left: 6px;
  padding: 3px 6px;
  border-radius: 6px;
  color: #fff;
  background: rgba(23, 25, 35, 0.66);
  font-size: 8px;
  font-weight: 700;
  backdrop-filter: blur(4px);
}

.asset-delete {
  position: absolute;
  top: 5px;
  right: 5px;
  display: grid;
  width: 26px;
  height: 26px;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 8px;
  color: #fff;
  background: rgba(183, 61, 75, 0.78);
  cursor: pointer;
  backdrop-filter: blur(4px);
}

.asset-delete svg {
  width: 14px;
  height: 14px;
}

.matrix-rows {
  display: grid;
  gap: 13px;
}

.matrix-empty,
.empty-state {
  display: grid;
  min-height: 220px;
  place-items: center;
  padding: 30px;
  border: 1px dashed var(--line-strong);
  border-radius: 14px;
  color: var(--muted);
  background: var(--surface-soft);
  text-align: center;
}

.empty-state svg,
.matrix-empty svg {
  width: 36px;
  height: 36px;
  margin: 0 auto 12px;
  color: #a6aabb;
}

.empty-state strong,
.matrix-empty strong {
  display: block;
  margin-bottom: 5px;
  color: var(--ink-soft);
  font-size: 14px;
}

.empty-state p,
.matrix-empty p {
  max-width: 430px;
  margin-bottom: 0;
  font-size: 12px;
  line-height: 1.65;
}

.matrix-row {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-soft);
}

.matrix-row-header {
  display: flex;
  min-height: 52px;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
  padding: 10px 13px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.row-identity {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 10px;
}

.row-index {
  display: grid;
  flex: 0 0 auto;
  width: 29px;
  height: 29px;
  place-items: center;
  border-radius: 9px;
  color: var(--primary);
  background: var(--primary-soft);
  font-size: 11px;
  font-weight: 800;
}

.row-identity > div {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.row-identity strong {
  overflow: hidden;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row-identity small {
  color: var(--muted);
  font-size: 9px;
}

.row-actions {
  display: flex;
  align-items: center;
  gap: 3px;
}

.row-actions .icon-button {
  width: 32px;
  height: 32px;
}

.matrix-row-body {
  display: grid;
  grid-template-columns: minmax(160px, 0.68fr) minmax(0, 1.45fr);
  gap: 14px;
  padding: 15px;
}

.row-fields,
.row-prompt {
  display: grid;
  align-content: start;
  gap: 11px;
}

.row-field,
.settings-grid label {
  display: grid;
  gap: 6px;
  color: var(--ink-soft);
  font-size: 11px;
  font-weight: 700;
}

.row-field input,
.row-field select,
.settings-grid input,
.settings-grid select {
  min-height: 40px;
  font-size: 12px;
}

.row-prompt textarea {
  min-height: 157px;
  background: var(--surface);
  font-size: 12px;
}

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

.asset-selects.is-single {
  grid-template-columns: 1fr;
}

.selected-assets {
  display: flex;
  gap: 6px;
  min-height: 42px;
}

.selected-asset-thumb {
  width: 40px;
  height: 40px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
}

.selected-asset-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.row-details {
  grid-column: 1 / -1;
  border-top: 1px solid var(--line);
}

.row-details summary {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 11px 15px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  list-style: none;
}

.row-details summary::-webkit-details-marker {
  display: none;
}

.row-details summary::before {
  content: "+";
  display: grid;
  width: 18px;
  height: 18px;
  place-items: center;
  border-radius: 6px;
  color: var(--primary);
  background: var(--primary-soft);
}

.row-details[open] summary::before {
  content: "−";
}

.row-details-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 11px;
  padding: 0 15px 15px;
}

.row-details-grid textarea {
  min-height: 85px;
  font-size: 12px;
}

.settings-grid {
  display: grid;
  grid-template-columns: 1.4fr repeat(5, minmax(100px, 0.8fr));
  gap: 12px;
}

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

.toggle-card {
  display: flex;
  min-height: 70px;
  align-items: center;
  gap: 11px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-soft);
  cursor: pointer;
}

.toggle-card input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.toggle-switch {
  position: relative;
  flex: 0 0 auto;
  width: 38px;
  height: 22px;
  border-radius: 999px;
  background: #d7d9e3;
  transition: background 150ms ease;
}

.toggle-switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 5px rgba(20, 22, 33, 0.17);
  transition: transform 150ms ease;
}

.toggle-card input:checked + .toggle-switch {
  background: var(--primary);
}

.toggle-card input:checked + .toggle-switch::after {
  transform: translateX(16px);
}

.toggle-card > span:last-child {
  display: grid;
  gap: 3px;
}

.toggle-card strong {
  font-size: 12px;
}

.toggle-card small {
  color: var(--muted);
  font-size: 10px;
  line-height: 1.4;
}

.submit-dock {
  position: sticky;
  bottom: 18px;
  z-index: 12;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-top: 18px;
  padding: 14px 16px 14px 19px;
  border: 1px solid rgba(214, 216, 228, 0.94);
  border-radius: 15px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 15px 44px rgba(39, 42, 64, 0.13);
  backdrop-filter: blur(18px);
}

.submit-dock > div {
  display: grid;
  gap: 3px;
}

.submit-dock strong {
  font-size: 14px;
}

.submit-dock span {
  color: var(--muted);
  font-size: 10px;
}

.submit-dock .button span {
  color: inherit;
  font-size: 13px;
}

/* Template library */

.template-library {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 17px;
}

.template-card {
  display: flex;
  min-height: 365px;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.template-card-cover {
  position: relative;
  display: grid;
  min-height: 148px;
  place-items: center;
  overflow: hidden;
  color: var(--primary);
  background:
    radial-gradient(circle at 70% 25%, rgba(86, 84, 216, 0.16), transparent 35%),
    linear-gradient(145deg, #f9f9ff, #efeffb);
}

.template-card-cover img {
  width: 100%;
  height: 178px;
  object-fit: cover;
}

.template-card-cover > svg {
  width: 48px;
  height: 48px;
  opacity: 0.66;
}

.template-card-badge {
  position: absolute;
  top: 12px;
  left: 12px;
  padding: 5px 8px;
  border-radius: 7px;
  color: #fff;
  background: rgba(23, 25, 35, 0.72);
  font-size: 9px;
  font-weight: 800;
  backdrop-filter: blur(5px);
}

.template-card-body {
  display: flex;
  flex: 1;
  flex-direction: column;
  padding: 18px;
}

.template-card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 700;
}

.template-card h3 {
  margin-bottom: 8px;
  font-size: 17px;
}

.template-card-description {
  margin-bottom: 14px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.65;
}

.template-scheme-list {
  display: grid;
  gap: 6px;
  margin: 0 0 17px;
  padding: 0;
  list-style: none;
}

.template-scheme-list li {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  color: var(--ink-soft);
  font-size: 10px;
  line-height: 1.45;
}

.template-scheme-list li::before {
  content: "";
  flex: 0 0 auto;
  width: 5px;
  height: 5px;
  margin-top: 5px;
  border-radius: 50%;
  background: var(--primary);
}

.template-card .button {
  width: 100%;
  margin-top: auto;
}

/* Tasks */

.overview-cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(90px, 1fr));
  gap: 9px;
}

.overview-card {
  display: grid;
  min-width: 105px;
  gap: 3px;
  padding: 13px 15px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}

.overview-card strong {
  font-size: 20px;
}

.overview-card small {
  color: var(--muted);
  font-size: 9px;
}

.batch-list {
  display: grid;
  gap: 15px;
}

.batch-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 17px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.batch-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(170px, 0.45fr) auto;
  align-items: center;
  gap: 18px;
  padding: 18px;
}

.batch-title {
  display: grid;
  min-width: 0;
  gap: 5px;
}

.batch-title-line {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 9px;
}

.batch-title h3 {
  overflow: hidden;
  margin-bottom: 0;
  font-size: 15px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.batch-title small {
  color: var(--muted);
  font-size: 10px;
}

.status-badge {
  display: inline-flex;
  flex: 0 0 auto;
  min-height: 24px;
  align-items: center;
  padding: 0 8px;
  border-radius: 999px;
  color: var(--muted);
  background: var(--surface-strong);
  font-size: 9px;
  font-weight: 800;
}

.status-badge.is-success {
  color: var(--success);
  background: var(--success-soft);
}

.status-badge.is-running,
.status-badge.is-queued,
.status-badge.is-composing {
  color: var(--info);
  background: var(--info-soft);
}

.status-badge.is-attention,
.status-badge.is-partial,
.status-badge.is-download_failed {
  color: var(--warning);
  background: var(--warning-soft);
}

.status-badge.is-error,
.status-badge.is-indeterminate {
  color: var(--danger);
  background: var(--danger-soft);
}

.batch-progress {
  display: grid;
  gap: 5px;
}

.batch-progress > div {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 9px;
}

.batch-progress progress {
  width: 100%;
  height: 7px;
  overflow: hidden;
  border: 0;
  border-radius: 999px;
  background: var(--surface-strong);
}

.batch-progress progress::-webkit-progress-bar {
  background: var(--surface-strong);
}

.batch-progress progress::-webkit-progress-value {
  border-radius: 999px;
  background: var(--primary);
}

.batch-progress progress::-moz-progress-bar {
  border-radius: 999px;
  background: var(--primary);
}

.batch-actions {
  display: flex;
  gap: 5px;
}

.batch-toggle {
  border-top: 1px solid var(--line);
}

.batch-toggle > summary {
  display: flex;
  min-height: 48px;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
  padding: 0 18px;
  color: var(--ink-soft);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  list-style: none;
  background: var(--surface-soft);
}

.batch-toggle > summary::-webkit-details-marker {
  display: none;
}

.batch-toggle > summary::after {
  content: "+";
  display: grid;
  width: 23px;
  height: 23px;
  place-items: center;
  border-radius: 7px;
  color: var(--primary);
  background: var(--primary-soft);
}

.batch-toggle[open] > summary::after {
  content: "−";
}

.batch-content {
  padding: 16px;
}

.composition-section {
  margin-bottom: 17px;
  padding-bottom: 17px;
  border-bottom: 1px solid var(--line);
}

.content-section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.content-section-title h4 {
  margin-bottom: 0;
  font-size: 12px;
}

.content-section-title small {
  color: var(--muted);
  font-size: 9px;
}

.composition-grid,
.job-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.job-card,
.composition-card {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-soft);
}

.job-card-header,
.composition-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 9px;
}

.job-card h4,
.composition-card h4 {
  overflow: hidden;
  margin-bottom: 3px;
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.job-card-header small,
.composition-card-header small {
  color: var(--muted);
  font-size: 8px;
}

.job-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 5px 9px;
  margin-bottom: 9px;
  color: var(--muted);
  font-size: 9px;
}

.job-error {
  margin-bottom: 9px;
  padding: 8px;
  border-radius: 8px;
  color: var(--danger);
  background: var(--danger-soft);
  font-size: 9px;
  line-height: 1.55;
}

.job-video {
  width: 100%;
  aspect-ratio: 9 / 16;
  max-height: 265px;
  border-radius: 9px;
  background: #11131a;
  object-fit: contain;
}

.job-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 9px;
}

.job-actions .button {
  min-height: 32px;
  padding: 0 10px;
  font-size: 9px;
}

/* Library */

.library-tools {
  display: flex;
  align-items: center;
  gap: 9px;
}

.search-field {
  position: relative;
  width: min(290px, 40vw);
}

.search-field svg {
  position: absolute;
  top: 50%;
  left: 12px;
  width: 17px;
  height: 17px;
  color: var(--muted);
  transform: translateY(-50%);
  pointer-events: none;
}

.search-field input {
  padding-left: 38px;
  background: var(--surface);
}

.library-tools select {
  width: 125px;
}

.inline-warning {
  margin-bottom: 14px;
  padding: 11px 13px;
  border: 1px solid #f1d6aa;
  border-radius: 10px;
  color: var(--warning);
  background: var(--warning-soft);
  font-size: 11px;
  line-height: 1.55;
}

.library-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 15px;
}

.library-card {
  display: flex;
  min-width: 0;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.library-cover {
  position: relative;
  display: grid;
  aspect-ratio: 9 / 12;
  max-height: 310px;
  place-items: center;
  overflow: hidden;
  color: #fff;
  background: linear-gradient(145deg, #333450, #171923);
}

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

.library-cover > svg {
  width: 46px;
  height: 46px;
  opacity: 0.5;
}

.library-play {
  position: absolute;
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.42);
  border-radius: 50%;
  color: #fff;
  background: rgba(17, 19, 26, 0.52);
  cursor: pointer;
  backdrop-filter: blur(7px);
}

.library-play:hover {
  background: rgba(86, 84, 216, 0.8);
}

.library-play svg {
  width: 21px;
  height: 21px;
  margin-left: 2px;
  fill: currentColor;
  stroke: none;
}

.library-source {
  position: absolute;
  top: 9px;
  left: 9px;
  padding: 4px 7px;
  border-radius: 7px;
  color: #fff;
  background: rgba(17, 19, 26, 0.62);
  font-size: 8px;
  font-weight: 800;
  backdrop-filter: blur(5px);
}

.library-card-body {
  display: flex;
  flex: 1;
  flex-direction: column;
  padding: 13px;
}

.library-card h3 {
  display: -webkit-box;
  overflow: hidden;
  margin-bottom: 6px;
  font-size: 12px;
  line-height: 1.5;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.library-card-description {
  display: -webkit-box;
  overflow: hidden;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 9px;
  line-height: 1.6;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.library-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 5px 9px;
  margin-top: auto;
  color: var(--muted);
  font-size: 8px;
}

.library-card-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
  margin-top: 12px;
}

.library-card-actions .button {
  min-height: 34px;
  padding: 0 9px;
  font-size: 9px;
}

/* Dialogs and toasts */

.dialog {
  width: min(520px, calc(100vw - 28px));
  max-height: calc(100vh - 30px);
  padding: 0;
  overflow: visible;
  border: 0;
  border-radius: 20px;
  background: transparent;
  box-shadow: none;
}

.dialog::backdrop {
  background: rgba(20, 22, 31, 0.52);
  backdrop-filter: blur(5px);
}

.dialog-card,
.preview-card {
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.42);
  border-radius: 20px;
  background: var(--surface);
  box-shadow: var(--shadow-md);
}

.dialog-card {
  display: grid;
  gap: 18px;
  padding: 25px;
}

.dialog-icon {
  display: grid;
  width: 43px;
  height: 43px;
  place-items: center;
  border-radius: 13px;
  color: var(--warning);
  background: var(--warning-soft);
}

.dialog-icon svg {
  width: 22px;
  height: 22px;
}

.dialog-card h2,
.preview-card h2 {
  margin-bottom: 7px;
  font-size: 21px;
}

.dialog-card > div:nth-child(2) > p:last-child {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.65;
}

.confirm-metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.confirm-metric {
  display: grid;
  gap: 3px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-soft);
}

.confirm-metric strong {
  font-size: 18px;
}

.confirm-metric small {
  color: var(--muted);
  font-size: 9px;
}

.dialog-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
}

.preview-dialog {
  width: min(620px, calc(100vw - 28px));
}

.preview-card {
  padding: 17px;
}

.preview-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
  margin-bottom: 13px;
}

.preview-heading h2 {
  margin-bottom: 0;
}

.preview-card video {
  width: 100%;
  max-height: 66vh;
  border-radius: 12px;
  background: #101119;
}

.preview-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 13px;
}

.toast-region {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 100;
  display: grid;
  width: min(360px, calc(100vw - 36px));
  gap: 9px;
  pointer-events: none;
}

.toast {
  display: grid;
  grid-template-columns: 24px 1fr;
  align-items: start;
  gap: 9px;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow-md);
  animation: toast-in 180ms ease both;
  pointer-events: auto;
}

.toast svg {
  width: 21px;
  height: 21px;
  color: var(--success);
}

.toast.is-error svg {
  color: var(--danger);
}

.toast strong {
  display: block;
  margin-bottom: 3px;
  font-size: 11px;
}

.toast p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.5;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Responsive */

@media (max-width: 1250px) {
  .template-strip {
    grid-template-columns: repeat(3, minmax(145px, 1fr));
  }

  .asset-grid {
    grid-template-columns: repeat(5, minmax(100px, 1fr));
  }

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

  .template-library,
  .composition-grid,
  .job-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

@media (max-width: 1020px) {
  :root {
    --sidebar-width: 210px;
  }

  .main-content {
    padding-inline: 23px;
  }

  .create-hero {
    min-height: 185px;
  }

  .asset-grid {
    grid-template-columns: repeat(4, minmax(90px, 1fr));
  }

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

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

  .batch-header {
    grid-template-columns: minmax(0, 1fr) minmax(150px, 0.5fr) auto;
  }

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

@media (max-width: 820px) {
  .app-shell {
    display: block;
  }

  .sidebar {
    position: fixed;
    top: auto;
    right: 0;
    bottom: 0;
    left: 0;
    width: auto;
    height: calc(66px + env(safe-area-inset-bottom));
    padding: 6px 8px env(safe-area-inset-bottom);
    border-top: 1px solid var(--line);
    border-right: 0;
    background: rgba(255, 255, 255, 0.96);
  }

  .sidebar-brand,
  .sidebar-footer {
    display: none;
  }

  .sidebar-nav {
    display: grid;
    width: 100%;
    grid-template-columns: repeat(4, 1fr);
    gap: 3px;
  }

  .nav-button {
    display: grid;
    min-height: 53px;
    place-items: center;
    align-content: center;
    gap: 3px;
    padding: 3px;
    border-radius: 10px;
    font-size: 9px;
    text-align: center;
  }

  .nav-button svg {
    width: 19px;
    height: 19px;
  }

  .nav-button b {
    position: absolute;
    top: 2px;
    left: calc(50% + 7px);
    min-width: 17px;
    height: 17px;
    margin: 0;
    padding: 0 4px;
    font-size: 8px;
  }

  .main-content {
    padding: 0 16px calc(90px + env(safe-area-inset-bottom));
  }

  .topbar {
    min-height: 72px;
    padding: 12px 0;
  }

  .topbar h1 {
    font-size: 19px;
  }

  .topbar .section-kicker {
    font-size: 9px;
  }

  .topbar-actions .button-quiet span,
  .system-pill small {
    display: none;
  }

  .topbar-actions .button-quiet {
    width: 39px;
    padding: 0;
  }

  .system-pill {
    min-width: 132px;
    grid-template-rows: auto;
    padding: 8px 10px;
  }

  .status-dot {
    grid-row: auto;
  }

  .create-hero {
    min-height: auto;
    align-items: flex-start;
    margin-bottom: 14px;
    padding: 25px 21px;
  }

  .create-hero h2 {
    font-size: 28px;
  }

  .create-hero p:last-child {
    font-size: 12px;
  }

  .hero-metric {
    min-width: 112px;
    padding: 16px;
  }

  .hero-metric strong {
    font-size: 31px;
  }

  .panel {
    margin-top: 13px;
    padding: 17px;
  }

  .panel-heading {
    margin-bottom: 17px;
  }

  .panel-heading p {
    display: none;
  }

  .template-strip {
    display: flex;
    margin-inline: -17px;
    padding: 0 17px 5px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
  }

  .template-choice {
    flex: 0 0 155px;
    min-height: 96px;
    scroll-snap-align: start;
  }

  .asset-grid {
    display: flex;
    margin-inline: -17px;
    padding: 0 17px 5px;
    overflow-x: auto;
  }

  .asset-card {
    flex: 0 0 105px;
  }

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

  .settings-grid label:first-child {
    grid-column: 1 / -1;
  }

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

  .submit-dock {
    bottom: calc(76px + env(safe-area-inset-bottom));
  }

  .view-intro,
  .split-intro {
    min-height: 145px;
    align-items: flex-start;
    flex-direction: column;
    justify-content: center;
    gap: 20px;
    padding: 24px 0;
  }

  .view-intro h2 {
    font-size: 28px;
  }

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

  .overview-cards {
    width: 100%;
  }

  .batch-header {
    grid-template-columns: 1fr auto;
  }

  .batch-progress {
    grid-column: 1 / -1;
    grid-row: 2;
  }

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

  .library-tools {
    width: 100%;
  }

  .search-field {
    flex: 1;
    width: auto;
  }
}

@media (max-width: 640px) {
  .login-view {
    display: block;
    min-height: 100svh;
    padding: 0;
    background: var(--surface);
  }

  .login-decoration {
    display: none;
  }

  .login-card {
    display: block;
    width: 100%;
    min-height: 100svh;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .login-intro {
    display: block;
    min-height: 250px;
    padding: 34px 24px 32px;
  }

  .brand-mark-large {
    width: 46px;
    height: 46px;
    margin-bottom: 21px;
  }

  .login-intro h1 {
    margin-bottom: 10px;
    font-size: 31px;
  }

  .login-lead {
    margin-bottom: 0;
    font-size: 13px;
  }

  .login-features {
    display: none;
  }

  .login-form-panel {
    min-height: calc(100svh - 250px);
    justify-content: flex-start;
    padding: 35px 24px 30px;
  }

  .login-form-heading h2 {
    font-size: 24px;
  }

  .main-content {
    padding-inline: 12px;
  }

  .topbar {
    min-height: 64px;
    gap: 8px;
    padding: 9px 0;
  }

  .topbar > div:first-child {
    min-width: 0;
  }

  .topbar h1 {
    overflow: hidden;
    font-size: 18px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .topbar-actions {
    flex: 0 0 auto;
    gap: 6px;
  }

  .system-pill {
    min-width: 116px;
    max-width: 132px;
    padding: 8px 9px;
  }

  .system-pill strong {
    overflow: hidden;
    font-size: 11px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .create-hero {
    display: block;
    padding: 18px 16px;
    border-radius: 16px;
  }

  .create-hero .section-kicker,
  .create-hero > div:first-child > p:last-child {
    display: none;
  }

  .create-hero h2 {
    margin-bottom: 0;
    font-size: 23px;
    line-height: 1.3;
  }

  .hero-metric {
    display: flex;
    min-width: 0;
    align-items: baseline;
    justify-content: flex-start;
    gap: 5px;
    margin-top: 18px;
    padding: 11px 13px;
  }

  .hero-metric strong {
    margin: 0;
    font-size: 25px;
  }

  .panel {
    padding: 14px;
    border-radius: 14px;
  }

  .panel-heading {
    gap: 10px;
    margin-bottom: 14px;
  }

  input,
  select,
  textarea {
    font-size: 16px;
  }

  .row-field input,
  .row-field select,
  .settings-grid input,
  .settings-grid select {
    min-height: 46px;
    font-size: 16px;
  }

  .row-prompt textarea,
  .row-details-grid textarea {
    font-size: 16px;
  }

  .panel-heading {
    align-items: flex-start;
  }

  .panel-heading > div:first-child {
    align-items: flex-start;
  }

  .panel-heading .button,
  .panel-heading .text-button {
    flex: 0 0 auto;
  }

  .panel-heading .button span {
    display: none;
  }

  .panel-heading .button {
    width: 44px;
    min-height: 44px;
    padding: 0;
  }

  .template-strip,
  .asset-grid {
    margin-inline: -14px;
    padding-inline: 14px;
  }

  .step-number {
    width: 34px;
    height: 34px;
  }

  .matrix-row-header {
    padding: 12px;
  }

  .row-actions .icon-button {
    width: 40px;
    height: 40px;
  }

  .matrix-row-body {
    padding: 12px;
  }

  .asset-selects {
    grid-template-columns: 1fr;
  }

  .row-details-grid,
  .settings-grid {
    grid-template-columns: 1fr;
  }

  .settings-grid label:first-child {
    grid-column: auto;
  }

  .submit-dock {
    bottom: calc(74px + env(safe-area-inset-bottom));
    align-items: center;
    gap: 10px;
    margin-top: 12px;
    padding: 10px 11px;
    border-radius: 14px;
  }

  .submit-dock > div {
    min-width: 0;
  }

  .submit-dock > div span {
    display: none;
  }

  .submit-dock strong {
    font-size: 13px;
    white-space: nowrap;
  }

  .submit-dock .button {
    min-height: 44px;
    padding: 0 13px;
  }

  .template-library,
  .library-grid,
  .composition-grid,
  .job-grid {
    grid-template-columns: 1fr;
  }

  .template-card {
    min-height: 330px;
  }

  .template-card-cover img {
    height: 210px;
  }

  .batch-header {
    gap: 12px;
    padding: 14px;
  }

  .batch-actions .button-danger {
    width: 34px;
    padding: 0;
  }

  .batch-actions .button-danger span {
    display: none;
  }

  .library-tools {
    align-items: stretch;
    flex-direction: column;
  }

  .library-tools select,
  .search-field {
    width: 100%;
  }

  .library-cover {
    max-height: 360px;
  }

  .confirm-metrics {
    grid-template-columns: 1fr;
  }

  .dialog-actions {
    grid-template-columns: 1fr;
  }

  .preview-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
