:root {
  --bg: #f5f6f8;
  --panel: #ffffff;
  --panel-soft: #f7f8fa;
  --line: #e9edf2;
  --line-strong: #dfe5eb;
  --text: #171b22;
  --muted: #667385;
  --muted-soft: #94a0ae;
  --accent: #12b9d8;
  --accent-dark: #0799b6;
  --orange: #ff7a22;
  --ok: #21b47b;
  --warn: #e4a02f;
  --danger: #ef5a5a;
  --shadow: 0 20px 52px rgba(30, 40, 55, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: "Manrope", "Noto Sans SC", sans-serif;
  color: var(--text);
  background: var(--bg);
}

button,
textarea,
input {
  font: inherit;
}

button {
  border: 0;
}

.app-shell {
  width: min(1280px, calc(100% - 24px));
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr;
  gap: 0;
  padding: 22px 0 320px;
}

.sidebar {
  display: none;
}

.sidebar-title {
  display: none;
}

.sidebar-dock {
  position: static;
  height: 100%;
  max-height: none;
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr);
  gap: 14px;
  opacity: 1;
  pointer-events: auto;
  transform: none;
  transition: 180ms ease;
}

.sidebar:hover .sidebar-dock,
.sidebar:focus-within .sidebar-dock {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.sidebar-status {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid var(--line);
  box-shadow: 0 12px 32px rgba(20, 30, 45, 0.08);
}

.sidebar-status strong {
  display: block;
  font-size: 14px;
}

.sidebar-status p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.status-dot {
  width: 10px;
  height: 10px;
  margin-top: 4px;
  border-radius: 999px;
  background: var(--warn);
  box-shadow: 0 0 0 6px rgba(228, 160, 47, 0.16);
  flex: 0 0 auto;
}

.status-dot.is-online {
  background: var(--ok);
  box-shadow: 0 0 0 6px rgba(33, 180, 123, 0.14);
}

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

.mini-metric {
  min-width: 0;
  padding: 10px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid var(--line);
}

.mini-metric span {
  display: block;
  color: var(--muted-soft);
  font-size: 11px;
}

.mini-metric strong {
  display: block;
  margin-top: 6px;
  font-size: 17px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-toolbar,
.result-actions,
.feed-title-row,
.feed-card-actions,
.selected-meta,
.composer-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.soft-button,
.ghost-button,
.topbar-button,
.card-mini-button,
.mode-chip,
.control-chip,
.link-button {
  cursor: pointer;
  color: var(--text);
  background: #eef0f2;
  border-radius: 8px;
  min-height: 38px;
  padding: 0 14px;
  transition: background 160ms ease, transform 160ms ease, border-color 160ms ease;
}

.ghost-button,
.topbar-button,
.mode-chip,
.control-chip {
  background: #fff;
  border: 1px solid var(--line);
}

.soft-button:hover,
.ghost-button:hover,
.topbar-button:hover,
.card-mini-button:hover,
.mode-chip:hover,
.control-chip:hover,
.link-button:hover {
  transform: translateY(-1px);
  background: #e9ecef;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
  transform: none;
}

button:disabled:hover {
  background: transparent;
  transform: none;
}

.danger,
.card-mini-button.danger {
  color: var(--danger);
}

.sidebar-list {
  overflow: visible;
  display: grid;
  gap: 10px;
  align-content: start;
  padding-right: 0;
}

.sidebar-item {
  padding: 13px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.95);
  cursor: pointer;
}

.sidebar-item.is-active {
  border-color: rgba(18, 185, 216, 0.55);
  background: #edfaff;
}

.sidebar-item-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}

.sidebar-item-id {
  min-width: 0;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 12px;
  color: #5d6978;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-item-prompt {
  margin: 9px 0;
  color: #343b46;
  font-size: 13px;
  line-height: 1.55;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.sidebar-item-meta {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.content {
  min-width: 0;
  padding-right: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 9;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  padding: 10px 0 24px;
  background: linear-gradient(180deg, var(--bg) 70%, rgba(245, 246, 248, 0));
}

.topbar-search {
  width: 210px;
  min-height: 38px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.topbar-search span {
  color: #20242b;
  font-size: 20px;
}

.topbar-search input {
  min-width: 0;
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
}

.current-strip {
  display: none;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  margin-bottom: 18px;
}

.selected-thumbs {
  display: flex;
  align-items: center;
  min-width: 156px;
  padding-top: 2px;
}

.selected-thumb {
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 4px;
  background: #eceff3;
  border: 1px solid var(--line);
  color: var(--muted-soft);
  font-size: 12px;
  box-shadow: 0 6px 16px rgba(20, 30, 45, 0.08);
}

.selected-thumb + .selected-thumb {
  margin-left: -14px;
  transform: rotate(5deg);
}

.selected-thumb:nth-child(2) {
  transform: rotate(-7deg);
}

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

.current-copy {
  min-width: 0;
}

.current-line {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  color: #303744;
  line-height: 1.65;
}

.current-line strong {
  font-weight: 600;
}

.current-line span {
  color: #536070;
  font-size: 15px;
  white-space: nowrap;
}

.meta-pill,
.mini-pill,
.status-badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 12px;
  line-height: 1;
  white-space: nowrap;
}

.meta-pill,
.mini-pill {
  background: #eef1f4;
  color: #596677;
}

.status-pending {
  background: rgba(228, 160, 47, 0.14);
  color: #a36d0d;
}

.status-running {
  background: rgba(18, 185, 216, 0.13);
  color: #087f98;
}

.status-success {
  background: rgba(33, 180, 123, 0.13);
  color: #187f59;
}

.status-unknown {
  background: #eef1f4;
  color: #667385;
}

.result-panel {
  display: none;
}

.result-media {
  width: 100%;
}

.video-frame,
video {
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 4px;
  background: #101114;
}

.video-frame {
  display: grid;
  place-items: center;
  color: rgba(255, 255, 255, 0.68);
}

.video-frame p {
  margin: 0;
}

.task-loading {
  position: relative;
  overflow: hidden;
  align-content: center;
  gap: 12px;
  color: #eef6ff;
  background:
    radial-gradient(circle at 24% 18%, rgba(18, 185, 216, 0.28), transparent 34%),
    radial-gradient(circle at 76% 78%, rgba(33, 180, 123, 0.18), transparent 30%),
    linear-gradient(135deg, #111827 0%, #182233 52%, #0f1722 100%);
}

.task-loading::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(110deg, transparent 0%, rgba(255, 255, 255, 0.12) 45%, transparent 70%);
  transform: translateX(-120%);
  animation: loading-sheen 2.4s ease-in-out infinite;
}

.task-loading strong,
.task-loading span,
.task-loading .loading-track,
.task-loading .loading-orb {
  position: relative;
  z-index: 1;
}

.task-loading strong {
  font-size: 18px;
  font-weight: 700;
}

.task-loading span {
  color: rgba(238, 246, 255, 0.68);
}

.loading-orb {
  width: 54px;
  height: 54px;
  border-radius: 999px;
  background: conic-gradient(from 0deg, var(--accent), rgba(255, 255, 255, 0.16), var(--ok), var(--accent));
  -webkit-mask: radial-gradient(circle, transparent 47%, #000 49%);
  mask: radial-gradient(circle, transparent 47%, #000 49%);
  animation: loading-spin 1.1s linear infinite;
}

.loading-track {
  width: min(280px, 70%);
  height: 6px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.14);
}

.loading-track i {
  display: block;
  width: 42%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), #fff, var(--ok));
  animation: loading-track 1.45s ease-in-out infinite;
}

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

@keyframes loading-sheen {
  55%,
  100% {
    transform: translateX(120%);
  }
}

@keyframes loading-track {
  0% {
    transform: translateX(-110%);
  }
  100% {
    transform: translateX(250%);
  }
}

.hidden {
  display: none;
}

.result-actions {
  margin-top: 14px;
}

.result-text {
  margin: 14px 0 0;
  padding: 14px 16px;
  min-height: 70px;
  white-space: pre-wrap;
  word-break: break-word;
  color: #596677;
  line-height: 1.7;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
}

.feed-history {
  width: min(760px, 100%);
  display: block;
  margin: 34px auto 0;
}

.feed-title-row {
  justify-content: space-between;
  margin: 0 0 28px;
}

.feed-title-row h2 {
  margin: 0;
  font-size: 28px;
}

.feed-count {
  color: var(--muted);
}

.task-feed {
  display: grid;
  gap: 54px;
}

.feed-card {
  background: transparent;
}

.feed-card-head {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}

.feed-card-thumb {
  width: 162px;
  min-height: 54px;
  display: flex;
  align-items: center;
}

.feed-card-thumb .selected-thumb {
  width: 56px;
  height: 56px;
}

.feed-card-copy {
  min-width: 0;
  padding-top: 2px;
}

.feed-card-text {
  margin: 0;
  color: #303744;
  line-height: 1.7;
  font-weight: 500;
}

.feed-card-model {
  margin-top: 4px;
  color: var(--muted);
  font-size: 14px;
}

.feed-card-media {
  margin-top: 12px;
  margin-left: 0;
}

.feed-card-media video,
.feed-card-media .image-preview {
  width: min(640px, 100%);
  display: block;
  border-radius: 4px;
  background: #e9edf2;
}

.image-preview {
  aspect-ratio: 16 / 9;
  object-fit: cover;
}

.feed-card-actions {
  margin-top: 12px;
  margin-left: 0;
}

.load-more-wrap {
  position: sticky;
  top: 76px;
  z-index: 14;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  margin: -8px 0 14px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-8px);
  transition: opacity 160ms ease, transform 160ms ease;
}

.feed-history:hover .load-more-wrap,
.load-more-wrap:focus-within {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.load-more-wrap.is-hidden {
  display: none;
}

.card-mini-button {
  min-height: 34px;
  padding: 0 13px;
  font-size: 14px;
  background: #e9ecef;
}

.empty-row {
  padding: 18px;
  color: var(--muted);
  background: #fff;
  border: 1px dashed var(--line-strong);
  border-radius: 14px;
}

.composer-shell {
  position: fixed;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  width: min(900px, calc(100vw - 36px));
  z-index: 20;
}

.composer-form {
  min-height: 206px;
  padding: 26px;
  border-radius: 32px;
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.composer-top {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  gap: 22px;
}

.composer-uploads {
  position: relative;
  z-index: 4;
  display: flex;
  align-items: center;
  min-height: 92px;
  width: 150px;
  max-width: calc(100vw - 80px);
  overflow: visible;
  transition: width 180ms ease;
}

.composer-uploads.has-images:hover {
  z-index: 12;
  width: min(520px, calc(100vw - 80px));
}

.composer-uploads.has-images:hover::before {
  content: none;
}

.composer-uploads > * {
  position: relative;
  z-index: 1;
}

.upload-avatar {
  width: 78px;
  height: 78px;
  position: relative;
  z-index: 5;
  flex: 0 0 78px;
  display: grid;
  place-items: center;
  border-radius: 4px;
  background: #eef1f5;
  border: 1px solid var(--line);
  cursor: pointer;
  transition: width 180ms ease, height 180ms ease, margin 180ms ease, border-radius 180ms ease, background 180ms ease;
}

.upload-avatar input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.upload-plus {
  position: absolute;
  right: -14px;
  bottom: -12px;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: #eef0f2;
  color: #15191f;
  border: 1px solid var(--line);
  font-size: 26px;
  line-height: 1;
}

.composer-uploads.has-images .upload-avatar {
  width: 48px;
  height: 48px;
  flex-basis: 48px;
  margin-left: -58px;
  border-radius: 999px;
  background: #293140;
  border-color: #293140;
  box-shadow: 0 10px 24px rgba(22, 29, 41, 0.18);
}

.composer-uploads.has-images:hover .upload-avatar {
  margin-left: 12px;
}

.composer-uploads.has-images .upload-plus {
  position: static;
  width: 100%;
  height: 100%;
  background: transparent;
  border: 0;
  color: #fff;
  font-size: 34px;
}

.composer-main {
  min-width: 0;
}

.composer-main textarea {
  width: 100%;
  min-height: 88px;
  resize: none;
  border: 0;
  outline: 0;
  color: var(--text);
  background: transparent;
  font-size: 18px;
  line-height: 1.7;
}

.composer-main textarea::placeholder {
  color: #8b95a2;
}

.image-strip {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 0;
  max-height: none;
  overflow: visible;
  perspective: 600px;
}

.image-item {
  position: relative;
  display: block;
  flex: 0 0 78px;
  width: 78px;
  height: 78px;
  margin-left: -66px;
  padding: 0;
  border-radius: 10px;
  background: #f7f8fa;
  border: 2px solid #fff;
  box-shadow: 0 10px 24px rgba(20, 28, 40, 0.18);
  overflow: visible;
  transform: rotate(-7deg);
  transition: margin 180ms ease, transform 180ms ease, box-shadow 180ms ease;
}

.image-item:first-child {
  margin-left: 0;
}

.image-item:nth-child(2n) {
  transform: rotate(5deg);
}

.composer-uploads.has-images:hover .image-item {
  margin-left: 8px;
  transform: rotate(0);
  box-shadow: 0 14px 30px rgba(20, 28, 40, 0.14);
}

.composer-uploads.has-images:hover .image-item:first-child {
  margin-left: 0;
}

.image-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 8px;
  display: block;
}

.image-meta {
  display: none;
}

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

.image-meta strong {
  font-size: 12px;
}

.image-meta span {
  color: var(--muted);
  font-size: 11px;
}

.remove-button {
  position: absolute;
  top: -12px;
  right: -12px;
  z-index: 2;
  cursor: pointer;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  padding: 0;
  border-radius: 999px;
  color: #fff;
  background: #293140;
  border: 1px solid rgba(255, 255, 255, 0.5);
  font-size: 22px;
  line-height: 1;
  opacity: 0;
  transform: scale(0.92);
  transition: opacity 160ms ease, transform 160ms ease;
}

.composer-uploads.has-images:hover .remove-button,
.image-item:focus-within .remove-button {
  opacity: 1;
  transform: scale(1);
}

.composer-controls {
  margin-top: 20px;
  gap: 16px;
}

.mode-chip {
  min-height: 44px;
  padding: 0 16px;
  font-size: 15px;
}

.mode-chip.is-active {
  color: var(--accent-dark);
}

.control-group {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  min-width: 72px;
  padding: 5px;
  gap: 3px;
  border-radius: 12px;
  background: #f8fafc;
  border: 1px solid #dfe6ee;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.72);
  overflow: visible;
  transition: min-width 160ms ease, box-shadow 160ms ease;
}

#durationGroup {
  margin-left: 2px;
}

.control-chip {
  display: none;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  min-width: 48px;
  padding: 0 12px;
  border: 0;
  background: transparent;
  border-radius: 9px;
  color: #1c2530;
}

.control-group:hover,
.control-group:focus-within {
  min-width: max-content;
  box-shadow: 0 12px 26px rgba(24, 34, 48, 0.1), inset 0 0 0 1px rgba(255, 255, 255, 0.72);
}

.control-group:hover .control-chip,
.control-group:focus-within .control-chip,
.control-chip.is-active {
  display: inline-flex;
}

.control-chip.is-active {
  background: #111827;
  color: #fff;
  box-shadow: 0 8px 18px rgba(17, 24, 39, 0.18);
}

.composer-spacer {
  flex: 1 1 auto;
}

.counter-text,
.submit-hint {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.link-button {
  color: #4c5665;
  background: transparent;
  min-height: 34px;
  padding: 0 8px;
}

.send-button {
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 999px;
  color: #fff;
  background: #090b0f;
  cursor: pointer;
  font-size: 30px;
  line-height: 1;
  transition: transform 160ms ease, opacity 160ms ease;
}

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

.toast-stack {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 40;
  display: grid;
  gap: 10px;
}

.toast {
  max-width: 360px;
  padding: 12px 14px;
  border-radius: 12px;
  background: #10141a;
  color: #fff;
  box-shadow: 0 12px 30px rgba(10, 14, 20, 0.18);
}

.toast.error {
  background: #b52929;
}

@media (max-width: 1180px) {
  .app-shell {
    grid-template-columns: 1fr;
    gap: 24px;
    padding-bottom: 280px;
  }

  .sidebar {
    position: relative;
    top: auto;
    height: 220px;
    min-height: 0;
  }

  .sidebar-dock {
    display: none;
  }

  .composer-shell {
    left: 50%;
    width: min(1040px, calc(100vw - 24px));
  }

}

@media (max-width: 760px) {
  .app-shell {
    width: calc(100% - 16px);
    padding-top: 8px;
    padding-bottom: 24px;
  }

  .content {
    padding-right: 0;
  }

  .topbar {
    justify-content: flex-start;
    flex-wrap: wrap;
    overflow: visible;
  }

  .topbar-search {
    width: 100%;
  }

  .current-strip,
  .feed-card-head,
  .composer-top {
    grid-template-columns: 1fr;
  }

  .feed-card-thumb,
  .selected-thumbs {
    min-width: 0;
  }

  .feed-card-media,
  .feed-card-actions {
    margin-left: 0;
  }

  .composer-form {
    padding: 18px;
    border-radius: 24px;
  }

  .composer-shell {
    position: static;
    transform: none;
    width: 100%;
    margin-top: 18px;
    padding: 0 8px 16px;
  }

  .mode-chip,
  .control-group {
    flex: 1 1 auto;
  }

  .control-group {
    overflow-x: auto;
    justify-content: flex-start;
  }

  .send-button {
    width: 48px;
    height: 48px;
  }
}
