/* SV Studio 工作台：深色，布局参考主流 AI 出片网站（左侧导航、中间出片记录、底部输入框） */

:root {
  color-scheme: dark;
  --bg: #0b0c10;
  --bg-soft: #0f1116;
  --panel: #14161d;
  --panel-2: #1b1e27;
  --panel-3: #232733;
  --line: #242833;
  --line-2: #313646;
  --text: #eceef4;
  --text-2: #d5d8e1;
  --muted: #9198a8;
  --dim: #646b7b;
  --accent: #8b5cf6;
  --accent-soft: rgb(139 92 246 / 16%);
  --grad: linear-gradient(135deg, #a855f7 0%, #6366f1 52%, #3b82f6 100%);
  --ok: #34d399;
  --warn: #fbbf24;
  --err: #f87171;
  --side: 212px;
  --shadow: 0 12px 40px rgb(0 0 0 / 45%);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.6 -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
}

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

[hidden] {
  display: none !important;
}

fieldset {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.icon {
  flex: none;
}

.spin {
  animation: spin 1s linear infinite;
}

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

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

.hint {
  color: var(--dim);
  font-size: 12px;
}

.err-text {
  color: var(--err);
}

/* ---------- 外框：左侧导航 + 主区域 ---------- */

.shell {
  min-height: 100vh;
}

.side {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: var(--side);
  padding: 18px 12px 14px;
  border-right: 1px solid var(--line);
  background: var(--bg-soft);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 2px 8px 20px;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.3px;
  text-decoration: none;
}

.logo {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: var(--grad);
  box-shadow: 0 4px 16px rgb(124 92 255 / 35%);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.5px;
}

.logo.lg {
  width: 54px;
  height: 54px;
  border-radius: 16px;
  font-size: 19px;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 10px;
  border: 0;
  border-radius: 10px;
  background: none;
  color: var(--muted);
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

.nav-item:hover {
  background: var(--panel);
  color: var(--text);
}

.nav-item.on {
  background: var(--panel-2);
  color: var(--text);
}

.nav-item.on .icon {
  color: #a78bfa;
}

.side-foot {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: auto;
}

.pill {
  align-self: flex-start;
  margin-left: 10px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgb(251 191 36 / 12%);
  color: var(--warn);
  font-size: 12px;
}

.main {
  min-width: 0;
  margin-left: var(--side);
  padding: 22px 32px 0;
}

.banner {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 1120px;
  margin: 0 auto 14px;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 13px;
}

.banner a {
  margin: 0 2px;
  color: inherit;
  font-weight: 600;
}

.banner.warn {
  border: 1px solid rgb(251 191 36 / 25%);
  background: rgb(251 191 36 / 9%);
  color: #fcd34d;
}

.banner.err {
  border: 1px solid rgb(248 113 113 / 25%);
  background: rgb(248 113 113 / 9%);
  color: #fca5a5;
}

/* ---------- 按钮、输入框 ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  padding: 0 14px;
  border: 1px solid var(--line-2);
  border-radius: 10px;
  background: var(--panel-2);
  font-size: 14px;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}

.btn:hover {
  border-color: #474d60;
}

.btn.primary,
.btn.gen {
  border: 0;
  background: var(--grad);
  box-shadow: 0 6px 20px rgb(99 102 241 / 32%);
  color: #fff;
  font-weight: 600;
}

.btn.primary:hover,
.btn.gen:hover {
  filter: brightness(1.08);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  filter: none;
}

.btn.ghost {
  border-color: transparent;
  background: transparent;
  color: var(--muted);
}

.btn.ghost:hover {
  background: var(--panel-2);
  color: var(--text);
}

.btn.sm {
  height: 30px;
  padding: 0 10px;
  border-radius: 8px;
  font-size: 13px;
}

.btn.block {
  width: 100%;
}

.input {
  width: 100%;
  height: 42px;
  padding: 0 14px;
  border: 1px solid var(--line-2);
  border-radius: 11px;
  outline: 0;
  background: var(--bg-soft);
}

.input:focus {
  border-color: var(--accent);
}

/* ---------- 登录 ---------- */

.login-body {
  background: radial-gradient(1100px 560px at 50% -10%, rgb(124 58 237 / 20%), transparent 60%), var(--bg);
}

.login {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 20px;
}

.login-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  width: min(100%, 360px);
  padding: 34px 28px 28px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgb(20 22 29 / 88%);
  box-shadow: var(--shadow);
  text-align: center;
}

.login-card h1 {
  margin: 12px 0 0;
  font-size: 22px;
}

.login-card p {
  margin: 0;
}

.login-card form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  margin-top: 20px;
}

.login-card .banner {
  width: 100%;
  margin: 14px 0 0;
}

/* ---------- 创作页：出片记录 ---------- */

.create {
  display: flex;
  flex-direction: column;
  max-width: 1120px;
  min-height: calc(100vh - 22px);
  margin: 0 auto;
}

.feed {
  flex: 1;
  padding-bottom: 20px;
}

.feed-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.load-more {
  align-self: center;
}

.job {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 20px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
}

.job-info {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag {
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--panel-3);
  color: var(--muted);
  font-size: 12px;
}

.thumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.thumbs img {
  width: 46px;
  height: 46px;
  border: 1px solid var(--line-2);
  border-radius: 8px;
  object-fit: cover;
}

.job-prompt {
  display: -webkit-box;
  margin: 0;
  overflow: hidden;
  color: var(--text-2);
  white-space: pre-wrap;
  word-break: break-word;
  cursor: pointer;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 7;
}

.job-prompt.open {
  display: block;
}

.job-meta {
  color: var(--dim);
  font-size: 12px;
}

.job-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  margin-top: auto;
  margin-left: -8px;
}

.job-media {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 10px;
  min-width: 0;
}

.media {
  position: relative;
  max-width: 100%;
  overflow: hidden;
  border-radius: 12px;
  background: #000;
}

.media video,
.media img {
  display: block;
  max-width: 100%;
  max-height: 460px;
}

.media .dl {
  position: absolute;
  top: 8px;
  right: 8px;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: rgb(0 0 0 / 60%);
  color: #fff;
  opacity: 0;
  transition: opacity 0.15s;
}

.media:hover .dl,
.media .dl:focus-visible {
  opacity: 1;
}

.placeholder {
  position: relative;
  display: grid;
  place-items: center;
  height: 300px;
  max-width: 100%;
  overflow: hidden;
  border-radius: 12px;
  background: var(--panel-2);
  color: var(--muted);
}

.placeholder.small {
  height: auto;
  padding: 18px 22px;
}

.placeholder.err {
  border: 1px solid rgb(248 113 113 / 20%);
  background: rgb(248 113 113 / 7%);
  color: #fca5a5;
}

.ph-text {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 18px;
  font-size: 13px;
  text-align: center;
}

.elapsed {
  color: var(--dim);
  font-variant-numeric: tabular-nums;
}

.shimmer {
  position: absolute;
  inset: 0;
  background: linear-gradient(110deg, transparent 30%, rgb(255 255 255 / 5%) 50%, transparent 70%);
  background-size: 200% 100%;
  animation: shimmer 1.6s linear infinite;
}

@keyframes shimmer {
  from {
    background-position: 150% 0;
  }
  to {
    background-position: -50% 0;
  }
}

/* 还没有记录时 */
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 13vh 0 40px;
  text-align: center;
}

.feed-list:has(.job) .empty {
  display: none;
}

.empty h1 {
  margin: 0;
  font-size: 30px;
  letter-spacing: 0.5px;
}

.empty p {
  margin: 0 0 18px;
}

.empty.small {
  padding: 10vh 0;
}

.shortcuts {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 190px));
  gap: 12px;
}

.shortcut {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: linear-gradient(160deg, var(--panel-2), var(--panel));
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.15s;
}

.shortcut:hover {
  border-color: #424859;
  transform: translateY(-1px);
}

.shortcut .icon {
  margin-bottom: 4px;
  color: #a78bfa;
}

.shortcut b {
  font-size: 15px;
}

.shortcut small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

/* ---------- 创作页：底部输入框 ---------- */

.composer-dock {
  position: sticky;
  bottom: 0;
  z-index: 10;
  padding: 10px 0 18px;
  background: linear-gradient(to bottom, transparent, var(--bg) 26px);
}

.composer {
  max-width: 920px;
  margin: 0 auto;
  padding: 12px 12px 10px;
  border: 1px solid var(--line-2);
  border-radius: 20px;
  background: rgb(22 24 32 / 92%);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.composer:focus-within {
  border-color: #474c61;
}

.composer.dragging {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgb(139 92 246 / 25%), var(--shadow);
}

.composer-main {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.prompt {
  flex: 1;
  min-height: 56px;
  max-height: 240px;
  padding: 6px 4px;
  border: 0;
  outline: 0;
  resize: none;
  background: transparent;
  line-height: 1.6;
}

.prompt::placeholder {
  color: var(--dim);
}

.uploads {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  max-width: 290px;
}

.tiles {
  display: contents;
}

.tile {
  position: relative;
  flex: none;
  width: 64px;
  height: 64px;
  overflow: hidden;
  border: 1px solid var(--line-2);
  border-radius: 11px;
  background: var(--panel-2);
}

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

.tile.add {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  border-style: dashed;
  color: var(--muted);
  font-size: 11px;
  cursor: pointer;
}

.tile.add:hover {
  border-color: var(--accent);
  color: var(--text);
}

.tile.add .count {
  color: var(--dim);
  font-size: 10px;
}

.tile-x {
  position: absolute;
  top: 3px;
  right: 3px;
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgb(0 0 0 / 70%);
  color: #fff;
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
}

.file {
  display: none;
}

.composer-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
}

.spacer {
  flex: 1;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 11px;
  border: 1px solid var(--line-2);
  border-radius: 999px;
  background: var(--panel-2);
  color: var(--text-2);
  font-size: 13px;
  white-space: nowrap;
  list-style: none;
  cursor: pointer;
  user-select: none;
}

.chip::-webkit-details-marker {
  display: none;
}

.chip:hover {
  border-color: #474d60;
}

.chip .icon {
  color: var(--muted);
}

.chip.strong {
  color: var(--text);
  font-weight: 600;
}

.model-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--grad);
}

details.pop {
  position: relative;
}

details.pop[open] > .chip {
  border-color: var(--accent);
}

.pop-panel {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  z-index: 30;
  min-width: 230px;
  padding: 6px;
  border: 1px solid var(--line-2);
  border-radius: 14px;
  background: #191c25;
  box-shadow: var(--shadow);
}

.menu-group {
  padding: 6px 10px 4px;
  color: var(--dim);
  font-size: 12px;
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: 9px;
  background: none;
  text-align: left;
  cursor: pointer;
}

.menu-item:hover:not(:disabled),
.menu-item.on {
  background: var(--panel-3);
}

.menu-item:disabled {
  color: var(--dim);
  cursor: not-allowed;
}

.menu-item .mi-icon {
  display: inline-flex;
  color: var(--muted);
}

.menu-item.on .mi-icon {
  color: #a78bfa;
}

.menu-item.model {
  flex-direction: column;
  align-items: flex-start;
  gap: 0;
}

.menu-item.model small {
  color: var(--muted);
  font-size: 12px;
}

.menu-item.model:disabled small {
  color: var(--dim);
}

.soon {
  margin-left: auto;
  padding: 1px 6px;
  border-radius: 6px;
  background: var(--panel-3);
  color: var(--muted);
  font-size: 11px;
}

.settings-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 352px;
  padding: 14px;
}

.plabel {
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 12px;
}

.opts {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.opt {
  position: relative;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-width: 48px;
  padding: 6px 10px;
  border: 1px solid var(--line-2);
  border-radius: 9px;
  background: var(--panel-2);
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
}

.opt:hover {
  color: var(--text);
}

.opt input {
  position: absolute;
  width: 0;
  height: 0;
  opacity: 0;
}

.opt:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--text);
}

.opt:has(input:focus-visible) {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.ratios .opt {
  min-width: 54px;
  padding-top: 8px;
}

.ratio-box {
  display: block;
  border: 1.5px solid currentColor;
  border-radius: 3px;
}

.ratio-box.auto {
  width: 16px;
  height: 16px;
  border-style: dashed;
}

.btn.gen {
  height: 38px;
  padding: 0 18px;
  border-radius: 12px;
}

.composer.htmx-request .gen {
  opacity: 0.6;
}

/* ---------- 提示条 ---------- */

.toast {
  position: fixed;
  top: 18px;
  left: 50%;
  z-index: 100;
  max-width: min(90vw, 520px);
  padding: 10px 16px;
  border: 1px solid var(--line-2);
  border-radius: 12px;
  background: #20232d;
  box-shadow: var(--shadow);
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -10px);
  transition: opacity 0.2s, transform 0.2s;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.toast.err {
  border-color: rgb(248 113 113 / 40%);
  color: #fecaca;
}

/* ---------- 作品页、后台 ---------- */

.page {
  max-width: 1240px;
  margin: 0 auto;
  padding-bottom: 40px;
}

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

.page-head h1 {
  margin: 0;
  font-size: 22px;
}

.seg {
  display: inline-flex;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--panel);
}

.seg a {
  padding: 5px 14px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 13px;
  text-decoration: none;
}

.seg a.on {
  background: var(--panel-3);
  color: var(--text);
}

.gallery {
  column-gap: 14px;
  columns: 4 250px;
}

.tile-card {
  margin: 0 0 14px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  break-inside: avoid;
}

.tile-card .media {
  border-radius: 0;
}

.tile-card .media video,
.tile-card .media img {
  width: 100%;
  max-height: none;
}

.tile-card figcaption {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 12px 12px;
}

.tile-card figcaption p {
  display: -webkit-box;
  margin: 0;
  overflow: hidden;
  color: var(--text-2);
  font-size: 13px;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.foot-note {
  margin-top: 18px;
}

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

.card {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
}

.card h2 {
  margin: 0 0 12px;
  font-size: 15px;
}

.card p {
  margin: 0 0 12px;
}

.kv {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px 20px;
  font-size: 13px;
}

.kv > :nth-child(odd) {
  color: var(--muted);
}

.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 8px;
  border-radius: 50%;
  background: var(--ok);
  vertical-align: 1px;
}

.status-dot.off {
  background: var(--warn);
}

/* ---------- 窄屏（手机）：导航挪到顶上，记录改成上下排 ---------- */

@media (max-width: 900px) {
  .side {
    position: sticky;
    top: 0;
    flex-direction: row;
    align-items: center;
    width: auto;
    padding: 8px 12px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .brand {
    padding: 0 8px 0 0;
  }

  .brand-name {
    display: none;
  }

  .nav {
    flex-direction: row;
  }

  .side-foot {
    flex-direction: row;
    align-items: center;
    margin: 0 0 0 auto;
  }

  .nav-item {
    padding: 7px 9px;
    white-space: nowrap;
  }

  .side-foot .pill,
  .side-foot .nav-item span {
    display: none;
  }

  .main {
    margin-left: 0;
    padding: 14px 12px 0;
  }

  .create {
    min-height: calc(100vh - 64px);
  }

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

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

  .settings-panel {
    width: min(352px, calc(100vw - 40px));
  }

  .uploads {
    max-width: 140px;
  }
}
