:root {
  color: #222222;
  background: #eef2f5;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.72), rgba(238, 242, 245, 0.92)),
    #eef2f5;
}

button,
textarea {
  font: inherit;
}

button {
  border: 0;
}

.app-shell {
  width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  grid-template-columns: 292px minmax(420px, 1fr) minmax(320px, 380px);
  color: #222222;
}

.sidebar,
.workspace,
.video-panel {
  min-height: 100vh;
  min-height: 100dvh;
}

.sidebar {
  padding: 22px 18px;
  border-right: 1px solid #dfe6eb;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(12px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 22px;
}

.brand-mark {
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  border-radius: 8px;
  background:
    linear-gradient(135deg, #222222 0 48%, transparent 48%),
    linear-gradient(135deg, transparent 52%, #2aa786 52%),
    #f3c84b;
  box-shadow: inset 0 0 0 1px rgba(34, 34, 34, 0.08);
}

.brand h1,
.brand p,
.title-group h2,
.title-group p,
.video-panel-head h2,
.video-panel-head p {
  margin: 0;
}

.brand h1 {
  font-size: 17px;
  line-height: 1.25;
}

.brand p {
  margin-top: 4px;
  color: #66727c;
  font-size: 12px;
}

.new-session-button {
  width: 100%;
  height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 8px;
  color: #ffffff;
  background: #222222;
  cursor: pointer;
}

.button-icon {
  width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.16);
  line-height: 18px;
}

.conversation-list {
  height: calc(100vh - 126px);
  height: calc(100dvh - 126px);
  margin-top: 16px;
  overflow: auto;
  padding-right: 3px;
}

.conversation-item {
  width: 100%;
  padding: 12px;
  margin-bottom: 8px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: #f6f8f9;
  color: #26313a;
  cursor: pointer;
  text-align: left;
}

.conversation-item:hover,
.conversation-item.active {
  border-color: #cfdce4;
  background: #ffffff;
}

.conversation-title {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
  font-weight: 650;
}

.conversation-meta {
  display: block;
  margin-top: 5px;
  color: #7b8790;
  font-size: 12px;
}

.workspace {
  position: relative;
  display: grid;
  grid-template-rows: auto 1fr auto;
  background: #f8fafb;
}

.workspace-header {
  height: 82px;
  padding: 18px 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  border-bottom: 1px solid #dfe6eb;
  background: rgba(248, 250, 251, 0.92);
}

.sidebar-toggle {
  display: none;
}

.icon-button {
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #ffffff;
  cursor: pointer;
}

.sidebar-toggle span {
  width: 17px;
  height: 2px;
  display: block;
  border-radius: 2px;
  background: #222222;
}

.sidebar-toggle span + span {
  margin-top: 5px;
  width: 11px;
}

.title-group {
  min-width: 0;
  flex: 1;
}

.title-group p,
.video-panel-head p {
  color: #6d7a84;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0;
}

.title-group h2,
.video-panel-head h2 {
  overflow: hidden;
  margin-top: 4px;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 20px;
  line-height: 1.2;
}

.model-pill {
  min-height: 34px;
  max-width: 210px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  border: 1px solid #dce5ea;
  border-radius: 8px;
  background: #ffffff;
  color: #53616b;
  font-size: 13px;
}

.model-pill span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-dot {
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: #b8c2ca;
}

.model-pill.ready .status-dot {
  background: #2aa786;
}

.model-pill.offline .status-dot {
  background: #d55353;
}

.messages-panel {
  min-height: 0;
  padding: 24px;
  overflow: hidden;
}

.messages {
  height: 100%;
  overflow: auto;
  padding-right: 4px;
}

.empty-state {
  min-height: 100%;
  display: grid;
  place-content: center;
  text-align: center;
  color: #6f7c86;
}

.empty-state h3 {
  margin: 0;
  color: #26313a;
  font-size: 24px;
}

.empty-state p {
  margin: 10px 0 0;
  font-size: 14px;
}

.message-row {
  display: flex;
  margin-bottom: 14px;
}

.message-row.user {
  justify-content: flex-end;
}

.message-row.assistant {
  justify-content: flex-start;
}

.bubble {
  max-width: min(680px, 78%);
  padding: 12px 14px;
  border-radius: 8px;
  font-size: 15px;
  line-height: 1.65;
  word-break: break-word;
  white-space: pre-wrap;
}

.user .bubble {
  color: #ffffff;
  background: #222222;
}

.assistant .bubble {
  color: #26313a;
  border: 1px solid #dfe6eb;
  background: #ffffff;
}

.task-status {
  display: block;
  margin-bottom: 10px;
  color: #677680;
  font-size: 13px;
  white-space: normal;
}

.message-video {
  width: 240px;
  max-width: 100%;
  aspect-ratio: 9 / 16;
  display: block;
  border-radius: 8px;
  background: #101010;
}

.chat-composer {
  min-height: 86px;
  padding: 14px 24px 20px;
  display: flex;
  align-items: flex-end;
  gap: 12px;
  border-top: 1px solid #dfe6eb;
  background: #f8fafb;
}

.chat-composer textarea,
.video-panel textarea {
  width: 100%;
  resize: none;
  border: 1px solid #d8e1e7;
  outline: 0;
  border-radius: 8px;
  background: #ffffff;
  color: #222222;
}

.chat-composer textarea {
  min-height: 48px;
  max-height: 160px;
  padding: 12px 14px;
  line-height: 1.5;
}

.chat-composer textarea:focus,
.video-panel textarea:focus {
  border-color: #92b7c7;
  box-shadow: 0 0 0 3px rgba(80, 153, 185, 0.14);
}

.send-button {
  width: 46px;
  height: 46px;
  flex: 0 0 auto;
  border-radius: 8px;
  color: #ffffff;
  background: #222222;
  cursor: pointer;
  font-size: 22px;
}

.send-button:disabled,
.video-submit:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

.video-panel {
  padding: 22px;
  border-left: 1px solid #dfe6eb;
  background: #ffffff;
}

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

.video-panel-head h2 {
  font-size: 19px;
}

.spec-badge {
  flex: 0 0 auto;
  padding: 7px 9px;
  border-radius: 8px;
  background: #f2f6f7;
  color: #5d6b75;
  font-size: 12px;
}

.duration-control {
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.duration-control > span {
  color: #5f6d76;
  font-size: 13px;
  font-weight: 650;
}

.duration-options {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px;
  border: 1px solid #d8e1e7;
  border-radius: 8px;
  background: #f7fafb;
}

.duration-option {
  min-width: 52px;
  height: 30px;
  padding: 0 10px;
  border-radius: 6px;
  color: #52616b;
  background: transparent;
  cursor: pointer;
  font-size: 13px;
}

.duration-option.active {
  color: #ffffff;
  background: #222222;
}

.video-panel textarea {
  min-height: 226px;
  padding: 14px;
  font-size: 15px;
  line-height: 1.6;
}

.upload-row {
  min-height: 42px;
  margin-top: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.image-upload-button {
  height: 40px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 13px;
  border: 1px solid #d8e1e7;
  border-radius: 8px;
  color: #26313a;
  background: #ffffff;
  cursor: pointer;
}

.image-upload-button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

#imageUploadStatus {
  color: #6a7882;
  font-size: 13px;
}

.image-preview-list {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.image-preview-list:empty {
  display: none;
}

.image-chip {
  position: relative;
  overflow: hidden;
  aspect-ratio: 1;
  border: 1px solid #dfe6eb;
  border-radius: 8px;
  background: #f3f6f8;
}

.image-chip img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.image-chip button {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  color: #ffffff;
  background: rgba(34, 34, 34, 0.78);
  cursor: pointer;
  line-height: 24px;
}

.message-images {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 88px));
  gap: 8px;
  margin-top: 10px;
}

.message-images img {
  width: 88px;
  height: 88px;
  display: block;
  border-radius: 8px;
  object-fit: cover;
  background: #e9eef2;
}

.video-actions {
  margin-top: 14px;
  display: flex;
  justify-content: flex-end;
}

.video-submit {
  min-width: 118px;
  height: 42px;
  border-radius: 8px;
  color: #ffffff;
  background: #222222;
  cursor: pointer;
}

.task-card {
  margin-top: 20px;
  padding: 14px;
  border: 1px solid #dfe6eb;
  border-radius: 8px;
  background: #f8fafb;
}

.task-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  color: #64737d;
  font-size: 13px;
}

.result-video {
  width: 100%;
  aspect-ratio: 9 / 16;
  border-radius: 8px;
  background: #101010;
}

.task-error {
  margin: 0;
  color: #b33c3c;
  font-size: 13px;
  line-height: 1.5;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  z-index: 40;
  max-width: min(420px, calc(100vw - 32px));
  padding: 12px 14px;
  border-radius: 8px;
  color: #ffffff;
  background: rgba(34, 34, 34, 0.92);
  transform: translateX(-50%);
  font-size: 14px;
}

.is-hidden {
  display: none !important;
}

.mobile-scrim {
  display: none;
}

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

  .video-panel {
    grid-column: 1 / -1;
    min-height: auto;
    border-left: 0;
    border-top: 1px solid #dfe6eb;
  }

  .video-panel textarea {
    min-height: 150px;
  }
}

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

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 30;
    width: min(300px, 86vw);
    transform: translateX(-102%);
    transition: transform 180ms ease;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .mobile-scrim.open {
    position: fixed;
    inset: 0;
    z-index: 29;
    display: block;
    background: rgba(0, 0, 0, 0.18);
  }

  .workspace,
  .video-panel {
    min-height: auto;
  }

  .workspace {
    min-height: 72vh;
  }

  .workspace-header {
    height: 74px;
    padding: 14px 16px;
  }

  .sidebar-toggle {
    display: grid;
  }

  .title-group h2 {
    font-size: 17px;
  }

  .model-pill {
    max-width: 142px;
  }

  .messages-panel {
    height: calc(72vh - 154px);
    padding: 16px;
  }

  .bubble {
    max-width: 86%;
  }

  .chat-composer {
    padding: 12px 16px 16px;
  }

  .video-panel {
    padding: 18px 16px 24px;
  }

  .image-preview-list {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}
