/* PhotoAlive admin — single design system for /admin, /admin/batch, /admin/playground and login. */
:root {
  color-scheme: light;
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f9fafb;
  --surface-3: #f2f4f7;
  --line: #e4e7ec;
  --line-soft: #eef0f3;
  --line-strong: #d0d5dd;
  --text: #101828;
  --text-2: #344054;
  --muted: #667085;
  --muted-2: #98a2b3;
  --accent: #5b4fe9;
  --accent-hover: #4b3fd6;
  --accent-soft: #f1efff;
  --accent-line: #d9d4ff;
  --accent-text: #4335c9;
  --green: #067647;
  --green-soft: #ecfdf3;
  --green-line: #abefc6;
  --yellow: #b54708;
  --yellow-soft: #fffaeb;
  --yellow-line: #fedf89;
  --red: #d92d20;
  --red-soft: #fef3f2;
  --red-line: #fecdca;
  --blue: #175cd3;
  --blue-soft: #eff8ff;
  --blue-line: #b2ddff;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow-xs: 0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow-md: 0 4px 12px -2px rgba(16, 24, 40, 0.08), 0 2px 4px -2px rgba(16, 24, 40, 0.04);
  --shadow-xl: 0 24px 48px -12px rgba(16, 24, 40, 0.22);
  --ring: 0 0 0 3px rgba(91, 79, 233, 0.18);
  --sidebar-w: 248px;
  --topbar-h: 64px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", Inter, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  /* Legacy names kept for any inline usage. */
  --panel: var(--surface);
  --panel2: var(--surface-2);
  --panel3: var(--surface-3);
  --soft: var(--line-soft);
  --muted2: var(--muted-2);
}
* {
  box-sizing: border-box;
}
html,
body {
  min-height: 100%;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}
a {
  color: var(--accent-text);
}
h1,
h2,
h3 {
  color: var(--text);
}
:focus-visible {
  outline: none;
  box-shadow: var(--ring);
}
[hidden],
.hidden {
  display: none !important;
}
::selection {
  background: #dcd8ff;
}

/* ---------- Shell ---------- */
.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
}
.app-shell.drawer-open {
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr) 440px;
}
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 16px 12px 12px;
  border-right: 1px solid var(--line);
  background: #fbfbfc;
  display: flex;
  flex-direction: column;
  z-index: 5;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 40px;
  padding: 0 10px;
  margin-bottom: 6px;
  color: var(--text);
  font-size: 16px;
  font-weight: 650;
  letter-spacing: -0.015em;
  text-decoration: none;
}
.brand-symbol {
  width: 28px;
  height: 28px;
  flex: 0 0 auto;
  display: block;
  object-fit: contain;
  border-radius: 8px;
}
.navigation {
  flex: 1;
  overflow-y: auto;
  scrollbar-width: none;
  margin: 0 -4px;
  padding: 0 4px;
}
.navigation::-webkit-scrollbar {
  display: none;
}
.nav-label {
  margin: 18px 10px 6px;
  color: var(--muted-2);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.nav-item {
  width: 100%;
  height: 34px;
  margin: 1px 0;
  padding: 0 10px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-2);
  font-size: 13.5px;
  font-weight: 500;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.nav-item > span {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.nav-icon {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  color: var(--muted);
  transition: color 0.12s;
}
.nav-item:hover {
  background: #eff0f3;
  color: var(--text);
}
.nav-item:hover .nav-icon {
  color: var(--text-2);
}
.nav-item.active {
  background: var(--accent-soft);
  color: var(--accent-text);
}
.nav-item.active .nav-icon {
  color: var(--accent);
}
.nav-item b {
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--muted);
  display: inline-grid;
  place-items: center;
  font-size: 11.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.nav-item.has-alert b {
  background: var(--red);
  color: #fff;
}
.account-block {
  margin-top: 8px;
  padding: 12px 6px 2px;
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 10px;
}
.avatar {
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-text);
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 650;
}
.account-block strong {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13.5px;
  font-weight: 550;
}
.icon-button svg {
  width: 18px;
  height: 18px;
}

.workspace {
  min-width: 0;
}
.topbar {
  position: sticky;
  top: 0;
  z-index: 4;
  height: var(--topbar-h);
  padding: 0 32px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.88);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.context-label {
  display: none;
}
.topbar h1 {
  margin: 0;
  font-size: 19px;
  font-weight: 650;
  line-height: 1.2;
  letter-spacing: -0.02em;
}
.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.content {
  max-width: 1440px;
  margin: 0 auto;
  padding: 24px 32px 56px;
}

/* ---------- Buttons ---------- */
.button {
  min-height: 36px;
  padding: 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-2);
  box-shadow: var(--shadow-xs);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 13.5px;
  font-weight: 550;
  line-height: 1.2;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s, box-shadow 0.12s;
}
.button:hover {
  background: var(--surface-2);
  color: var(--text);
}
.button.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}
.button.primary:hover {
  border-color: var(--accent-hover);
  background: var(--accent-hover);
}
.button.danger {
  border-color: var(--red-line);
  background: var(--surface);
  color: var(--red);
}
.button.danger:hover {
  background: var(--red-soft);
}
.button.ghost {
  border-color: transparent;
  background: transparent;
  box-shadow: none;
  color: var(--muted);
}
.button.ghost:hover {
  background: var(--surface-3);
  color: var(--text);
}
.button.small {
  min-height: 30px;
  padding: 0 10px;
  border-radius: 7px;
  font-size: 12.5px;
}
.button:disabled,
.button[disabled] {
  opacity: 0.45;
  cursor: default;
  pointer-events: none;
}
.button:focus-visible {
  box-shadow: var(--ring);
}
.icon-button {
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--muted);
  display: grid;
  place-items: center;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.icon-button:hover {
  background: var(--surface-3);
  color: var(--text);
}
.icon-button.ghost {
  border-color: transparent;
  background: transparent;
}
.row-button {
  border: 0;
  background: none;
  color: var(--accent-text);
  cursor: pointer;
}

/* ---------- Toolbar, inputs ---------- */
.toolbar {
  margin-bottom: 16px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.toolbar > span,
.toolbar > .muted {
  color: var(--muted);
  font-size: 13px;
}
.filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
input.field,
textarea.field,
select.field,
.select {
  height: 36px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background-color: var(--surface);
  color: var(--text);
  font-size: 14px;
  box-shadow: var(--shadow-xs);
  outline: none;
  transition: border-color 0.12s, box-shadow 0.12s;
}
select.select,
.form select,
select.field {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23667085' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 16px;
  cursor: pointer;
}
input.field:focus,
textarea.field:focus,
select.field:focus,
.select:focus {
  border-color: var(--accent);
  box-shadow: var(--ring);
}
input.field.search {
  min-width: 280px;
  padding-left: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2398a2b3' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: left 12px center;
  background-size: 16px;
}
::placeholder {
  color: var(--muted-2);
}

/* ---------- Panels, tables ---------- */
.stack {
  display: grid;
  gap: 16px;
  align-content: start;
}
.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-xs);
  overflow: hidden;
}
.panel + .panel {
  margin-top: 16px;
}
.stack > .panel + .panel {
  margin-top: 0;
}
.panel-head {
  min-height: 56px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line-soft);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.panel-head > div {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 12px;
}
.panel-head h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 620;
}
.panel-head span {
  color: var(--muted);
  font-size: 13px;
}
.panel > p.muted {
  margin: 0;
  padding: 14px 18px !important;
  font-size: 13px;
}
.panel > video {
  display: block;
}
.panel > p {
  margin: 0;
  padding: 14px 18px 0;
}
.panel > .drawer-actions {
  margin: 0;
  padding: 14px 18px 16px;
}
.panel > .drawer-actions:empty {
  display: none;
}
.panel-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.table-wrap {
  overflow: auto;
}
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}
.data-table th {
  position: sticky;
  top: 0;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
  font-weight: 550;
  text-align: left;
  white-space: nowrap;
}
.data-table td {
  max-width: 460px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line-soft);
  color: var(--text-2);
  font-size: 13.5px;
  vertical-align: middle;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.data-table td strong {
  color: var(--text);
  font-weight: 600;
}
.data-table td small,
.data-table td .muted {
  color: var(--muted);
  font-size: 12.5px;
}
.data-table td .button {
  min-height: 30px;
  padding: 0 10px;
  font-size: 12.5px;
}
.data-table tbody tr {
  cursor: pointer;
  transition: background 0.1s;
}
.data-table tbody tr:hover {
  background: #fafbff;
}
.data-table tr:last-child td {
  border-bottom: 0;
}
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 18px 0 4px;
  color: var(--muted);
  font-size: 13px;
}
.mono {
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--muted);
}
.muted {
  color: var(--muted);
}
.amount {
  color: var(--text);
  font-weight: 600;
}
.amount.positive {
  color: var(--green);
}
.amount.negative {
  color: var(--red);
}

/* ---------- Status pills ---------- */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 22px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--text-2);
  font-size: 12px;
  font-weight: 550;
  line-height: 1;
  white-space: nowrap;
  vertical-align: middle;
}
.pill:before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.8;
}
.pill.completed,
.pill.succeeded,
.pill.active,
.pill.delivered {
  color: var(--green);
  border-color: var(--green-line);
  background: var(--green-soft);
}
.pill.processing,
.pill.sending,
.pill.queued,
.pill.preparing,
.pill.delivering,
.pill.animating {
  color: var(--blue);
  border-color: var(--blue-line);
  background: var(--blue-soft);
}
.pill.pending,
.pill.awaiting_payment,
.pill.awaiting_selection,
.pill.awaiting_confirmation {
  color: var(--yellow);
  border-color: var(--yellow-line);
  background: var(--yellow-soft);
}
.pill.failed,
.pill.refunded,
.pill.dead,
.pill.blocked {
  color: var(--red);
  border-color: var(--red-line);
  background: var(--red-soft);
}

/* ---------- Empty / loading ---------- */
.empty {
  min-height: 160px;
  padding: 24px;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 14px;
  text-align: center;
}
.content > .empty,
.stack > .empty,
.broadcast-list > .empty {
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
}
.broadcast-list > .empty {
  grid-column: 1 / -1;
}
.loading {
  min-height: 260px;
  display: grid;
  place-items: center;
}
.loading:before {
  content: "";
  width: 22px;
  height: 22px;
  border: 2px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
.loading.small {
  min-height: 60px;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ---------- Metrics ---------- */
.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.metric {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-xs);
}
.metric-label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}
.metric-value {
  display: block;
  margin-top: 8px;
  font-size: 28px;
  font-weight: 650;
  line-height: 1.1;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.metric-foot {
  display: block;
  margin-top: 6px;
  color: var(--muted-2);
  font-size: 12px;
}

/* ---------- Drawer ---------- */
.drawer {
  position: sticky;
  top: 0;
  height: 100vh;
  border-left: 1px solid var(--line);
  background: var(--surface);
  display: none;
  overflow: hidden;
  z-index: 8;
}
.drawer.open {
  display: flex;
  flex-direction: column;
  animation: drawer-in 0.18s ease-out;
}
@keyframes drawer-in {
  from {
    opacity: 0;
    transform: translateX(12px);
  }
}
.drawer-head {
  min-height: var(--topbar-h);
  padding: 12px 16px 12px 22px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex: 0 0 auto;
}
.drawer-head > div {
  min-width: 0;
}
.drawer-head span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}
.drawer-head h2 {
  margin: 1px 0 0;
  font-size: 17px;
  font-weight: 650;
  letter-spacing: -0.01em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.drawer-head .icon-button {
  border-color: transparent;
}
.drawer-content {
  flex: 1;
  overflow-y: auto;
  padding: 20px 22px 32px;
}
.drawer-profile {
  display: flex;
  align-items: center;
  gap: 14px;
  padding-bottom: 18px;
}
.drawer-profile > div {
  min-width: 0;
  display: grid;
  gap: 2px;
}
.drawer-profile strong {
  font-size: 16px;
  font-weight: 650;
}
.drawer-profile span {
  color: var(--muted);
  font-size: 13px;
}
.drawer-profile a {
  font-size: 13px;
  text-decoration: none;
}
.drawer-profile a:hover {
  text-decoration: underline;
}
.drawer-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
}
.action-groups {
  display: grid;
  gap: 10px;
  margin: -4px 0 20px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
}
.action-group {
  display: grid;
  gap: 6px;
}
.action-group + .action-group {
  padding-top: 10px;
  border-top: 1px solid var(--line-soft);
}
.action-group > span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 550;
}
.action-group > div {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.action-group .button {
  min-height: 30px;
  padding: 0 10px;
  font-size: 12.5px;
}
.detail-section {
  padding: 18px 0;
  border-top: 1px solid var(--line-soft);
}
.drawer-content > .detail-section:first-child {
  padding-top: 0;
  border-top: 0;
}
.detail-section h3 {
  margin: 0 0 12px;
  font-size: 13px;
  font-weight: 650;
}
.detail-section p {
  margin: 0 0 8px;
  font-size: 13.5px;
}
.detail-section blockquote {
  margin: 8px 0;
  padding: 8px 12px;
  border-left: 3px solid var(--line-strong);
  background: var(--surface-2);
  border-radius: 0 6px 6px 0;
  color: var(--text-2);
  font-size: 13px;
}
.detail-section .drawer-actions {
  margin: 12px 0 0;
}
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px 18px;
}
.detail-item span,
.detail-item strong {
  display: block;
}
.detail-item span {
  color: var(--muted);
  font-size: 12px;
}
.detail-item strong {
  margin-top: 2px;
  font-size: 13.5px;
  font-weight: 550;
  overflow-wrap: anywhere;
}
.message-block {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--line-soft);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 13.5px;
}
.timeline {
  display: grid;
}
.timeline-item {
  position: relative;
  padding: 0 0 14px 20px;
}
.timeline-item:before {
  content: "";
  position: absolute;
  left: 2px;
  top: 6px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--accent);
}
.timeline-item:after {
  content: "";
  position: absolute;
  left: 6px;
  top: 18px;
  bottom: 2px;
  width: 1px;
  background: var(--line);
}
.timeline-item:last-child {
  padding-bottom: 0;
}
.timeline-item:last-child:after {
  display: none;
}
.timeline-item strong {
  display: block;
  font-size: 13.5px;
  font-weight: 550;
}
.timeline-item > span {
  color: var(--muted);
  font-size: 12.5px;
}
.support-mode-notice {
  margin-bottom: 16px;
  padding: 10px 12px;
  border: 1px solid var(--yellow-line);
  border-radius: var(--radius-sm);
  background: var(--yellow-soft);
  color: var(--yellow);
  font-size: 13px;
  font-weight: 550;
}

/* ---------- Modal ---------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: none;
}
.modal.open {
  display: grid;
  place-items: center;
  padding: 20px;
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(16, 24, 40, 0.45);
  animation: fade-in 0.15s ease-out;
}
.modal-card {
  position: relative;
  width: min(560px, calc(100vw - 32px));
  max-height: calc(100vh - 40px);
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow-xl);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: modal-in 0.18s ease-out;
}
@keyframes fade-in {
  from {
    opacity: 0;
  }
}
@keyframes modal-in {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.985);
  }
}
.modal-card .drawer-head {
  padding: 14px 16px 14px 24px;
}
.modal-content {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px 24px;
}
.modal-card:has(.idea-frame-pipeline),
.modal-card:has(.preparation-panel) {
  width: min(820px, calc(100vw - 32px));
}

/* ---------- Forms ---------- */
.form {
  display: grid;
  gap: 16px;
}
.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
}
.form label {
  display: block;
  color: var(--text-2);
  font-size: 13px;
  font-weight: 550;
}
.form label > span {
  display: block;
  margin-bottom: 6px;
}
.form small {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 400;
  line-height: 1.45;
}
.form p {
  margin: 0;
  font-size: 13.5px;
}
.form input:not([type="checkbox"]):not([type="radio"]):not([type="file"]),
.form select,
.form textarea {
  width: 100%;
  min-height: 38px;
  padding: 8px 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background-color: var(--surface);
  color: var(--text);
  font-size: 14px;
  font-weight: 400;
  box-shadow: var(--shadow-xs);
  outline: 0;
  transition: border-color 0.12s, box-shadow 0.12s;
}
.form select {
  padding-right: 34px;
}
.form textarea {
  min-height: 96px;
  line-height: 1.5;
  resize: vertical;
}
.form input:focus,
.form select:focus,
.form textarea:focus {
  border-color: var(--accent);
  box-shadow: var(--ring);
}
.form input:disabled,
.form select:disabled,
.form textarea:disabled {
  background-color: var(--surface-3);
  color: var(--muted);
}
.form input[type="file"],
.scenario-attachment input[type="file"] {
  width: 100%;
  max-width: 100%;
  padding: 6px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 13px;
  font-weight: 400;
  cursor: pointer;
}
input[type="file"]::file-selector-button {
  margin-right: 10px;
  padding: 5px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text-2);
  font: inherit;
  font-weight: 550;
  cursor: pointer;
}
.form input[type="checkbox"],
.check input[type="checkbox"],
input[type="checkbox"] {
  width: 16px;
  height: 16px;
  min-height: 16px;
  margin: 0;
  padding: 0;
  flex: 0 0 16px;
  accent-color: var(--accent);
  vertical-align: middle;
  cursor: pointer;
}
.form label:has(> input[type="checkbox"]),
.check,
.form label.inline-check {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-2);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
}
.form label:has(> input[type="checkbox"]) > span {
  margin-bottom: 0;
}
.form-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
  padding-top: 16px;
  border-top: 1px solid var(--line-soft);
}
.form-actions .button.danger:first-of-type,
.form-actions #archive-idea {
  margin-right: 0;
}
.form-actions #delete-idea {
  margin-right: auto;
}
.secret-box {
  padding: 14px;
  border: 1px solid var(--accent-line);
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent-text);
  font-family: var(--mono);
  overflow-wrap: anywhere;
}
.inline-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 18px;
}
.ai-settings {
  width: 100%;
  max-width: 720px;
}
.ai-settings-form {
  padding: 20px;
}
.ai-settings-form .form-actions {
  margin-top: 0;
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 30;
  min-width: 240px;
  max-width: 440px;
  padding: 12px 16px;
  border-radius: 10px;
  background: #101828;
  color: #fff;
  box-shadow: var(--shadow-xl);
  font-size: 13.5px;
  font-weight: 500;
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.18s ease, transform 0.18s ease;
  pointer-events: none;
}
.toast.show {
  opacity: 1;
  transform: none;
}
.toast.error {
  background: #b42318;
}

/* ---------- Users ---------- */
.user-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 14px;
}
.user-card {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-xs);
  cursor: pointer;
  transition: border-color 0.12s, box-shadow 0.12s, transform 0.12s;
}
.user-card:hover {
  border-color: var(--accent-line);
  box-shadow: var(--shadow-md);
}
.user-card-header {
  display: flex;
  align-items: center;
  gap: 12px;
}
.user-avatar {
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  border-radius: 50%;
  object-fit: cover;
  background: var(--surface-3);
}
.user-avatar.fallback {
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent-text);
  font-size: 17px;
  font-weight: 650;
}
.user-avatar.large {
  width: 56px;
  height: 56px;
}
.user-info {
  min-width: 0;
  display: grid;
  gap: 1px;
}
.user-info a {
  color: var(--text);
  font-size: 15px;
  font-weight: 620;
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.user-info a:hover {
  color: var(--accent-text);
}
.user-info span {
  color: var(--muted);
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
}
.user-balance {
  margin-top: 14px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.user-balance div {
  display: grid;
  gap: 1px;
}
.user-balance span {
  color: var(--muted);
  font-size: 12px;
}
.user-balance strong {
  font-size: 14px;
  font-weight: 620;
  font-variant-numeric: tabular-nums;
}
.user-card-footer {
  margin-top: 12px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 12.5px;
}
.user-card.in-support {
  border-color: var(--yellow-line);
  box-shadow: inset 3px 0 0 #f79009, var(--shadow-xs);
}
.support-mode-label {
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--yellow-soft);
  color: var(--yellow);
  font-size: 12px;
  font-weight: 600;
}
.support-profile .drawer-profile {
  padding-bottom: 10px;
}
.result-gallery {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.result-item {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
}
.result-media {
  display: block;
  aspect-ratio: 1;
  background: var(--surface-3);
}
.result-media img,
.result-media video {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}
.result-item > div {
  padding: 10px;
  display: grid;
  gap: 2px;
}
.result-item strong {
  font-size: 13px;
  font-weight: 600;
}
.result-item span {
  color: var(--muted);
  font-size: 12px;
}
.result-item a {
  font-size: 12.5px;
  text-decoration: none;
}
.result-item .pill {
  justify-self: start;
  margin-top: 4px;
}
.result-item .button {
  margin-top: 8px;
  min-height: 30px;
  font-size: 12.5px;
}
.custom-order-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}
.custom-order-actions .button {
  min-height: 28px;
  padding: 0 10px;
  font-size: 12px;
}

/* ---------- Scenario editor ---------- */
.scenario-editor {
  max-width: 1240px;
  margin: 0 auto;
  display: grid;
  gap: 16px;
}
.scenario-toolbar {
  position: sticky;
  top: calc(var(--topbar-h) + 12px);
  z-index: 3;
  padding: 12px 14px 12px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow-md);
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto auto;
  align-items: center;
  gap: 16px;
}
.scenario-toolbar > div:first-child {
  display: grid;
  gap: 1px;
}
.scenario-toolbar strong {
  font-size: 14.5px;
  font-weight: 620;
}
.scenario-toolbar span {
  color: var(--muted);
  font-size: 12.5px;
}
.scenario-toolbar span.dirty {
  color: var(--yellow);
  font-weight: 550;
}
.scenario-variables {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
}
.scenario-variables code,
.scenario-field code {
  padding: 3px 7px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--text-2);
  font: 12px/1.2 var(--mono);
}
.scenario-save {
  min-width: 170px;
}
.scenario-save:disabled {
  opacity: 1;
  border-color: var(--line);
  background: var(--surface-3);
  color: var(--muted-2);
  box-shadow: none;
}
.scenario-section {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-xs);
  overflow: hidden;
}
.scenario-section-head {
  min-height: 54px;
  padding: 0 18px;
  border-bottom: 1px solid var(--line-soft);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.scenario-section-head h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 620;
}
.scenario-section-head span {
  color: var(--muted);
  font-size: 12.5px;
}
.scenario-grid {
  padding: 18px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}
.scenario-field {
  min-width: 0;
  display: grid;
  gap: 8px;
  align-content: start;
}
.scenario-field-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}
.scenario-field-head strong {
  color: var(--text-2);
  font-size: 13px;
  font-weight: 600;
}
.scenario-field-head small {
  color: var(--muted-2);
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
}
.scenario-field textarea {
  width: 100%;
  height: 140px;
  padding: 11px 13px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 13.5px;
  line-height: 1.55;
  outline: none;
  resize: vertical;
  transition: border-color 0.12s, box-shadow 0.12s;
}
.scenario-field textarea:focus {
  border-color: var(--accent);
  box-shadow: var(--ring);
}
.scenario-button-field textarea {
  height: 64px;
}
.scenario-prompts .scenario-field textarea {
  height: 220px;
  font-family: var(--mono);
  font-size: 12.5px;
}
.scenario-vk-clip {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 12.5px;
}
.scenario-vk-clip input {
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: 13px;
  outline: none;
}
.scenario-vk-clip input:focus {
  border-color: var(--accent);
  box-shadow: var(--ring);
}
.scenario-attachment {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}
.scenario-attachment input[type="file"] {
  flex: 1;
  min-width: 0;
  font-size: 12.5px;
}
.scenario-attachment [data-attachment-preview] {
  width: 56px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
  background: var(--surface-2);
}
.scenario-attachment img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}
.scenario-attachment .button {
  min-height: 30px;
  padding: 0 10px;
  font-size: 12.5px;
}

/* ---------- Broadcasts ---------- */
.broadcast-toolbar > div {
  display: flex;
  align-items: center;
  gap: 12px;
}
.broadcast-toolbar .muted {
  font-size: 13px;
}
.live-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--green);
  font-size: 13px;
  font-weight: 550;
}
.live-indicator:before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  animation: pulse 1.6s ease-in-out infinite;
}
@keyframes pulse {
  50% {
    opacity: 0.35;
  }
}
.broadcast-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 14px;
}
.broadcast-card {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-xs);
  display: flex;
  flex-direction: column;
}
.broadcast-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}
.broadcast-card-head > div {
  min-width: 0;
}
.broadcast-audience {
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 500;
}
.broadcast-message {
  margin-top: 6px;
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-line-clamp: 5;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.broadcast-progress {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  margin-top: auto;
  padding-top: 16px;
}
.broadcast-progress div:first-child {
  display: grid;
}
.broadcast-progress strong {
  font-size: 15px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}
.broadcast-progress span,
.broadcast-progress small {
  color: var(--muted);
  font-size: 12px;
}
.progress-track {
  height: 6px;
  border-radius: 999px;
  background: var(--surface-3);
  overflow: hidden;
}
.progress-track i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
}
.broadcast-card-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line-soft);
  color: var(--muted);
  font-size: 12.5px;
}
.broadcast-card-foot > span {
  margin-right: auto;
}
.broadcast-card-foot .button {
  min-height: 30px;
  padding: 0 10px;
  font-size: 12.5px;
}
.modal-card:has(.broadcast-form) {
  width: min(1080px, calc(100vw - 32px));
}
.broadcast-form {
  gap: 16px;
}
.broadcast-composer,
.broadcast-audience-box,
.broadcast-preview,
.broadcast-trends {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
.composer-head {
  min-height: 46px;
  padding: 0 14px;
  border-bottom: 1px solid var(--line-soft);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 12.5px;
}
.composer-head > span:first-child {
  color: var(--text);
  font-size: 13.5px;
  font-weight: 620;
}
.composer-head select {
  width: auto !important;
  min-height: 32px !important;
  max-width: 240px;
  padding-top: 0 !important;
  padding-bottom: 0 !important;
  font-size: 13px !important;
}
.composer-tools {
  min-height: 44px;
  padding: 6px 10px;
  border-bottom: 1px solid var(--line-soft);
  display: flex;
  align-items: center;
  gap: 4px;
}
.composer-tools .button {
  min-height: 30px;
  min-width: 32px;
  padding: 0 8px;
}
.composer-tools span {
  margin-left: auto;
  color: var(--muted-2);
  font-size: 12px;
  font-weight: 400;
}
.rich-editor {
  min-height: 160px;
  padding: 14px;
  outline: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 14px;
  font-weight: 400;
  line-height: 1.55;
  color: var(--text);
}
.rich-editor:empty:before {
  content: attr(data-placeholder);
  color: var(--muted-2);
  pointer-events: none;
}
.broadcast-attachment {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}
.broadcast-attachment .muted {
  font-size: 12.5px;
}
.broadcast-attachment #attachment-preview {
  display: flex;
  align-items: center;
  gap: 8px;
}
.broadcast-attachment #attachment-preview img {
  width: 52px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 7px;
  object-fit: cover;
}
.broadcast-vk-attachment input {
  margin-top: 0;
}
.broadcast-trends {
  padding: 14px;
}
.broadcast-section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
  font-size: 13.5px;
}
.broadcast-section-heading .muted {
  font-size: 12.5px;
}
.broadcast-trend-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 8px;
  max-height: 172px;
  overflow: auto;
  color: var(--muted);
  font-size: 13px;
}
.broadcast-trend {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 6px 6px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 13px;
}
.broadcast-trend:has(input:checked) {
  border-color: var(--accent-line);
  background: var(--accent-soft);
}
.broadcast-trend label {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}
.broadcast-trend label span {
  display: block;
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.broadcast-trend label small {
  display: none;
}
.broadcast-trend select {
  width: 92px !important;
  min-height: 28px !important;
  padding: 0 26px 0 8px !important;
  font-size: 12px !important;
  background-position: right 6px center !important;
}
.broadcast-action-list {
  max-height: none;
}
.broadcast-action label {
  flex: 0 0 auto;
}
.broadcast-action input[type="text"] {
  flex: 1;
  min-width: 0;
  min-height: 28px;
  padding: 0 8px;
  font-size: 12.5px;
}
.broadcast-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(300px, 0.75fr);
  gap: 16px;
  align-items: start;
}
.broadcast-audience-box {
  padding-bottom: 14px;
}
.broadcast-audience-box label {
  display: block;
  margin: 14px 14px 0;
}
.broadcast-audience-box label > span {
  display: block;
  margin-bottom: 6px;
  color: var(--text-2);
  font-size: 12.5px;
}
.broadcast-audience-box textarea {
  min-height: 60px;
}
.broadcast-filter-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0 12px;
  padding: 0 14px 2px;
}
.broadcast-audience-box .broadcast-filter-grid label {
  min-width: 0;
  margin: 14px 0 0;
}
.broadcast-filter-grid select,
.broadcast-filter-grid input {
  width: 100%;
  min-width: 0;
}
.broadcast-profile-help {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 16px 14px 0;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 400;
}
.broadcast-profile-help .button {
  flex: none;
}
.broadcast-count {
  margin: 16px 14px 0 !important;
  padding: 12px 14px;
  border: 1px solid var(--accent-line);
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  color: var(--accent-text);
  font-size: 14px;
  font-weight: 650;
}
.broadcast-cooldown small {
  display: block;
  margin-top: 6px;
}
.recipient-search {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  margin: 14px;
}
.recipient-search .field {
  min-width: 0;
}
.recipient-result {
  width: calc(100% - 28px);
  min-height: 38px;
  margin: 0 14px 6px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: space-between;
  text-align: left;
  font-size: 13.5px;
  cursor: pointer;
}
.recipient-result:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.recipient-result span {
  color: var(--muted);
  font-size: 12.5px;
}
#recipient-results > .muted {
  display: block;
  margin: 0 14px 6px;
  font-size: 13px;
}
.recipient-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 14px;
}
.recipient-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  max-width: 100%;
  padding: 3px 4px 3px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-text);
  font-size: 12.5px;
  font-weight: 550;
}
.recipient-chip button {
  width: 20px;
  height: 20px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
}
.recipient-chip button:hover {
  background: rgba(91, 79, 233, 0.14);
}
.broadcast-preview {
  position: sticky;
  top: 0;
  overflow: hidden;
}
.broadcast-preview > span {
  display: block;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line-soft);
  color: var(--text);
  font-size: 13.5px;
  font-weight: 620;
}
.vk-message {
  min-height: 260px;
  padding: 16px;
  background: #e8edf3;
  display: grid;
  align-content: start;
  gap: 8px;
}
.vk-bubble {
  max-width: 94%;
  padding: 10px 12px;
  border-radius: 14px 14px 14px 4px;
  background: #fff;
  color: #18212c;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 13.5px;
  line-height: 1.45;
  box-shadow: 0 1px 1px rgba(38, 56, 73, 0.12);
}
.vk-message img {
  max-width: 94%;
  max-height: 220px;
  border-radius: 10px;
  object-fit: cover;
}
.broadcast-preview-buttons {
  display: grid;
  gap: 6px;
  max-width: 94%;
}
.broadcast-preview-buttons span {
  padding: 8px 12px;
  border-radius: 8px;
  background: #fff;
  color: #2a5885;
  text-align: center;
  font-size: 13px;
  font-weight: 550;
}
.broadcast-preview-buttons span.primary {
  background: #5181b8;
  color: #fff;
}
.broadcast-preview-buttons span.secondary {
  background: #fff;
  color: #2a5885;
}
.broadcast-preview-buttons span.positive {
  background: #4bb34b;
  color: #fff;
}
.broadcast-preview-buttons span.negative {
  background: #e64646;
  color: #fff;
}
.broadcast-preview-vk {
  max-width: 94%;
  padding: 10px 12px;
  border-radius: 10px;
  background: #fff;
  color: #2a5885;
  font-size: 13px;
}
.broadcast-recipient-log {
  min-height: 100px;
  color: var(--muted);
  font-size: 13.5px;
}
.broadcast-log-summary {
  padding-bottom: 12px;
  color: var(--muted);
  font-size: 13px;
}
.broadcast-log-table {
  display: grid;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.broadcast-log-table > div {
  display: grid;
  grid-template-columns: 120px 110px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  color: var(--text-2);
  font-size: 13px;
}
.broadcast-log-table > div + div {
  border-top: 1px solid var(--line-soft);
}
.broadcast-log-table a {
  text-decoration: none;
  font-weight: 550;
}
.broadcast-log-table small {
  color: var(--muted);
  overflow-wrap: anywhere;
}
.broadcast-log-pages {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 16px;
  color: var(--muted);
  font-size: 13px;
}

/* ---------- Ideas, regeneration ---------- */
.preparation-panel,
.idea-frame-pipeline {
  margin: 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
}
.preparation-panel {
  display: grid;
  gap: 14px;
}
.preparation-panel h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 650;
}
.idea-frame-pipeline {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 16px;
}
.idea-frame-pipeline > label:has(textarea),
.idea-frame-pipeline > label:has(> input[type="checkbox"]),
.idea-frame-pipeline > small,
.idea-frame-pipeline > div {
  grid-column: 1 / -1;
}
.idea-frame-pipeline figure figcaption {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}
.form section > p {
  margin-bottom: 12px;
  color: var(--text-2);
}
.form section > label + label {
  margin-top: 14px;
}
#preparation-reference-list {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}
.preparation-reference {
  width: 160px;
  margin: 0;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
}
.preparation-reference img {
  width: 100%;
  height: 144px;
  display: block;
  object-fit: contain;
  border-radius: 6px;
  background: var(--surface-3);
}
.preparation-reference figcaption {
  margin-top: 6px;
  font-size: 12.5px;
  font-weight: 550;
}
.preparation-reference label {
  margin: 8px 0;
}
.preparation-reference select {
  width: 100%;
}
#regeneration-upload {
  padding: 16px;
  border: 1.5px dashed var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 13px;
  transition: border-color 0.12s, background 0.12s;
}
#regeneration-upload p {
  margin: 0 0 10px;
}
#regeneration-upload.dragging {
  border-color: var(--accent);
  background: var(--accent-soft);
}
#regeneration-photos {
  display: grid;
  gap: 6px;
  margin-top: 10px;
  color: var(--text-2);
}
#regeneration-photos > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.regeneration-video {
  display: block;
  width: 100%;
  max-height: 480px;
  margin: 0 auto 16px;
  background: #000;
}

/* ---------- Responsive ---------- */
@media (max-width: 1280px) {
  .app-shell.drawer-open {
    grid-template-columns: 68px minmax(0, 1fr) 420px;
  }
  .app-shell.drawer-open .sidebar {
    padding-inline: 10px;
  }
  .app-shell.drawer-open .brand span,
  .app-shell.drawer-open .nav-label,
  .app-shell.drawer-open .nav-item > span,
  .app-shell.drawer-open .account-block strong,
  .app-shell.drawer-open .account-block .icon-button {
    display: none;
  }
  .app-shell.drawer-open .nav-item {
    justify-content: center;
    position: relative;
  }
  .app-shell.drawer-open .nav-item b {
    position: absolute;
    top: 0;
    right: 2px;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    font-size: 10px;
  }
  .app-shell.drawer-open .nav-item:not(.has-alert) b {
    display: none;
  }
  .app-shell.drawer-open .navigation {
    padding-top: 10px;
  }
  .metric-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}
@media (max-width: 1050px) {
  .scenario-toolbar {
    grid-template-columns: 1fr auto;
  }
  .scenario-variables {
    grid-column: 1 / -1;
    grid-row: 2;
  }
  .scenario-grid {
    grid-template-columns: 1fr;
  }
}
@media (max-width: 860px) {
  :root {
    --sidebar-w: 64px;
  }
  .app-shell,
  .app-shell.drawer-open {
    grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  }
  .sidebar {
    padding-inline: 8px;
  }
  .brand span,
  .nav-label,
  .nav-item > span,
  .nav-item b,
  .account-block strong,
  .account-block .icon-button {
    display: none;
  }
  .nav-item {
    justify-content: center;
  }
  .nav-item.has-alert {
    box-shadow: inset 0 0 0 1.5px var(--red-line);
  }
  .navigation {
    padding-top: 10px;
  }
  .account-block {
    justify-content: center;
  }
  .topbar {
    padding: 0 18px;
  }
  .content {
    padding: 18px;
  }
  .drawer {
    position: fixed;
    top: 0;
    right: 0;
    width: min(440px, calc(100vw - var(--sidebar-w)));
    box-shadow: var(--shadow-xl);
  }
  .broadcast-layout {
    grid-template-columns: 1fr;
  }
  .broadcast-filter-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .broadcast-preview {
    position: static;
  }
  .idea-frame-pipeline {
    grid-template-columns: 1fr;
  }
}
@media (max-width: 560px) {
  .metric-grid {
    grid-template-columns: 1fr;
  }
  .topbar h1 {
    font-size: 17px;
  }
  .content {
    padding: 14px;
  }
  .toolbar {
    align-items: stretch;
    flex-direction: column;
  }
  .filters {
    display: grid;
  }
  input.field.search {
    min-width: 0;
  }
  .form-row,
  .detail-grid,
  .broadcast-filter-grid {
    grid-template-columns: 1fr;
  }
  .scenario-toolbar {
    grid-template-columns: 1fr;
  }
  .scenario-variables {
    display: none;
  }
  .scenario-save {
    width: 100%;
  }
  .user-card-grid,
  .broadcast-list {
    grid-template-columns: 1fr;
  }
  .broadcast-log-table > div {
    grid-template-columns: 1fr auto;
  }
  .broadcast-log-table small {
    grid-column: 1 / -1;
  }
  .composer-tools span {
    display: none;
  }
}

/* ---------- Login ---------- */
.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
  background:
    radial-gradient(900px 500px at 50% -10%, #ebe8ff 0, transparent 60%),
    var(--bg);
}
.auth-card {
  width: min(400px, 100%);
  padding: 32px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow-xl);
}
.auth-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 16px;
}
.auth-brand .brand-symbol {
  width: 32px;
  height: 32px;
}
.auth-title {
  margin: 28px 0 22px;
  font-size: 24px;
  font-weight: 680;
  letter-spacing: -0.02em;
}
.auth-submit {
  width: 100%;
  min-height: 42px;
  margin-top: 4px;
  font-size: 14.5px;
}
.auth-error {
  min-height: 20px;
  margin: 0;
  color: var(--red);
  font-size: 13px;
  text-align: center;
}

/* ---------- Bulk result upload ---------- */
.result-upload-zone {
  display: grid;
  gap: 4px;
  justify-items: center;
  padding: 22px 16px;
  border: 1.5px dashed var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 13px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s;
}
.result-upload-zone input {
  display: none;
}
.result-upload-zone strong {
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
}
.result-upload-zone .link {
  color: var(--accent-text);
}
.result-upload-zone:hover,
.result-upload-zone.dragging {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.result-upload-zone.disabled {
  opacity: 0.6;
  pointer-events: none;
}
.result-upload-summary {
  color: var(--text-2);
  font-size: 13px;
}
.result-upload-list {
  display: grid;
  gap: 6px;
  max-height: 320px;
  overflow-y: auto;
}
.result-upload-list:empty {
  display: none;
}
.result-upload-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
.result-upload-name {
  display: grid;
  gap: 3px;
  flex: 1;
  min-width: 0;
}
.result-upload-name strong {
  overflow: hidden;
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.result-upload-name span {
  color: var(--muted);
  font-size: 12px;
}
.result-upload-row.error {
  border-color: var(--red-line);
  background: var(--red-soft);
}
.result-upload-row.error .result-upload-name span {
  color: var(--red);
}
.result-upload-row.done .result-upload-name span {
  color: var(--green);
}
.result-upload-bar {
  height: 3px;
  border-radius: 2px;
  background: var(--line-soft);
  overflow: hidden;
}
.result-upload-bar i {
  display: block;
  height: 100%;
  background: var(--accent);
  transition: width 0.15s;
}
.result-upload-row.done .result-upload-bar i {
  background: var(--green);
}
.result-upload-row.error .result-upload-bar,
.result-upload-row.queued .result-upload-bar {
  visibility: hidden;
}
.result-upload-row .button {
  flex: none;
  padding: 2px 8px;
}

.broadcast-attachment #attachment-preview { flex-wrap:wrap; }
.broadcast-attachment-item { display:flex;align-items:center;gap:6px; }
.broadcast-random-attachment { display:flex;align-items:center;gap:8px; }
.broadcast-random-attachment input { width:auto;min-height:0;margin:0; }
#broadcast-preview-images { display:flex;flex-wrap:wrap;gap:7px; }

/* ---------- Support conversations ---------- */
.content:has(> .support-layout) {
  padding-bottom: 24px;
}
.support-layout {
  height: calc(100vh - var(--topbar-h) - 48px);
  min-height: 520px;
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr) 300px;
  gap: 16px;
}
.support-layout > .panel + .panel {
  margin-top: 0;
}
.support-list,
.support-chat {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.support-list-head {
  padding: 12px;
  border-bottom: 1px solid var(--line-soft);
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
}
.support-list-head input.field.search {
  width: 100%;
  min-width: 0;
}
.support-tabs {
  display: flex;
  gap: 2px;
  padding: 3px;
  border-radius: var(--radius-sm);
  background: var(--surface-3);
}
.support-tab {
  flex: 1 1 auto;
  min-width: 0;
  height: 28px;
  padding: 0 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 550;
  white-space: nowrap;
  cursor: pointer;
}
.support-tab:hover {
  color: var(--text-2);
}
.support-tab.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-xs);
}
.support-items {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}
.support-items .empty {
  min-height: 120px;
}
.support-item {
  width: 100%;
  padding: 11px 14px;
  border: 0;
  border-bottom: 1px solid var(--line-soft);
  background: none;
  display: flex;
  align-items: center;
  gap: 11px;
  text-align: left;
  cursor: pointer;
}
.support-item:hover {
  background: var(--surface-2);
}
.support-item.active {
  background: var(--accent-soft);
}
.support-item .user-avatar {
  width: 40px;
  height: 40px;
}
.support-item-body {
  min-width: 0;
  flex: 1;
  display: grid;
  gap: 2px;
}
.support-item-top,
.support-item-bottom {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.support-item-top strong {
  overflow: hidden;
  color: var(--text);
  font-size: 14px;
  font-weight: 550;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.support-item.unread .support-item-top strong {
  font-weight: 700;
}
.support-item-top time {
  flex: 0 0 auto;
  color: var(--muted-2);
  font-size: 12px;
}
.support-preview {
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.support-item.unread .support-preview {
  color: var(--text-2);
}
.support-preview em {
  color: var(--muted-2);
  font-style: normal;
}
.support-unread {
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--red);
  color: #fff;
  display: inline-grid;
  place-items: center;
  font-size: 11.5px;
  font-weight: 650;
}
.support-state {
  color: var(--muted-2);
  font-size: 12px;
}
.support-list-foot {
  padding: 8px 12px;
  border-top: 1px solid var(--line-soft);
  display: flex;
  justify-content: flex-end;
}
.button.danger-text {
  border-color: transparent;
  box-shadow: none;
  color: var(--red);
}
.support-placeholder {
  flex: 1;
  display: grid;
  place-items: center;
}
.support-chat-head {
  min-height: 64px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line-soft);
  display: flex;
  align-items: center;
  gap: 12px;
}
.support-chat-title {
  min-width: 0;
  flex: 1;
  display: grid;
}
.support-chat-title strong {
  overflow: hidden;
  font-size: 15px;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.support-chat-title span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-size: 12.5px;
}
.support-chat-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}
.support-back {
  display: none;
}
.pill.support-waiting {
  color: var(--yellow);
  border-color: var(--yellow-line);
  background: var(--yellow-soft);
}
.pill.support-answered {
  color: var(--green);
  border-color: var(--green-line);
  background: var(--green-soft);
}
.support-messages {
  flex: 1;
  min-height: 0;
  padding: 16px 20px;
  overflow-y: auto;
  background: var(--surface-2);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.support-day {
  margin: 10px 0 6px;
  display: flex;
  justify-content: center;
}
.support-day span {
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--muted);
  font-size: 12px;
  font-weight: 550;
}
.support-note {
  align-self: center;
  color: var(--muted-2);
  font-size: 12px;
}
.support-message {
  max-width: min(560px, 78%);
  display: grid;
  gap: 2px;
}
.support-message.in {
  align-self: flex-start;
}
.support-message.out {
  align-self: flex-end;
  justify-items: end;
}
.support-bubble {
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 14px 14px 14px 4px;
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.support-message.unread .support-bubble {
  border-color: var(--yellow-line);
  box-shadow: inset 3px 0 0 var(--yellow-line);
}
.support-message.out .support-bubble {
  border-color: var(--accent);
  border-radius: 14px 14px 4px 14px;
  background: var(--accent);
  color: #fff;
}
.support-meta {
  padding: 0 4px;
  color: var(--muted-2);
  font-size: 11.5px;
}
.support-composer {
  padding: 12px 16px;
  border-top: 1px solid var(--line-soft);
  display: flex;
  align-items: flex-end;
  gap: 10px;
}
.support-composer textarea.field {
  min-height: 40px;
  height: 40px;
  flex: 1;
  padding: 9px 12px;
  line-height: 1.45;
  resize: none;
}
.support-composer .button {
  height: 40px;
}
.support-side {
  min-height: 0;
  overflow-y: auto;
  display: grid;
  align-content: start;
  gap: 12px;
}
.support-side .panel + .panel {
  margin-top: 0;
}
.support-side-card {
  padding: 14px 16px;
}
.support-side-card h3 {
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 650;
}
.support-side-card .muted {
  margin: 0;
  font-size: 13px;
}
.support-side-profile {
  display: flex;
  align-items: center;
  gap: 12px;
}
.support-side-profile > div {
  min-width: 0;
  display: grid;
  justify-items: start;
  gap: 2px;
}
.support-side-profile span {
  color: var(--muted);
  font-size: 12.5px;
}
.support-side-balance {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line-soft);
  display: grid;
  gap: 1px;
}
.support-side-balance span,
.support-side-balance em {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
}
.support-side-balance strong {
  font-size: 18px;
  font-weight: 650;
}
.support-side-list {
  margin: 0 -16px -14px;
}
.support-side-row {
  width: 100%;
  padding: 9px 16px;
  border: 0;
  border-top: 1px solid var(--line-soft);
  background: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  text-align: left;
}
button.support-side-row {
  cursor: pointer;
}
button.support-side-row:hover {
  background: var(--surface-2);
}
.support-side-text {
  min-width: 0;
  display: grid;
}
.support-side-row strong {
  font-size: 13px;
  font-weight: 550;
}
.support-side-row em {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
}
.support-side-row em.support-side-error {
  overflow: hidden;
  color: var(--red);
  text-overflow: ellipsis;
  white-space: nowrap;
}
@media (max-width: 1440px) {
  .support-layout {
    grid-template-columns: 300px minmax(0, 1fr) 260px;
  }
}
.app-shell.drawer-open .support-layout {
  grid-template-columns: 300px minmax(0, 1fr);
}
.app-shell.drawer-open .support-side {
  display: none;
}
@media (max-width: 1180px) {
  .support-layout {
    grid-template-columns: 300px minmax(0, 1fr);
  }
  .support-side {
    display: none;
  }
}
@media (max-width: 860px) {
  .support-layout,
  .app-shell.drawer-open .support-layout {
    height: calc(100vh - var(--topbar-h) - 36px);
    grid-template-columns: minmax(0, 1fr);
  }
  .support-layout.has-chat .support-list,
  .support-layout:not(.has-chat) .support-chat {
    display: none;
  }
  .support-back {
    display: inline-grid;
  }
  .support-chat-head {
    flex-wrap: wrap;
  }
}
