/* ============ 7AIpictools · Linear Aesthetic ============ */
:root {
  --bg: #050506;
  --surface: rgba(255, 255, 255, 0.02);
  --surface-strong: rgba(255, 255, 255, 0.045);
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);
  --text: #EDEDEF;
  --text-2: #A1A1AA;
  --text-3: #6E7076;
  --accent: #6366F1;
  --accent-2: #A855F7;
  --accent-soft: rgba(99, 102, 241, 0.14);
  --danger: #F43F5E;
  --ok: #34D399;
  --radius: 14px;
  --radius-sm: 9px;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { color-scheme: dark; }

body {
  font-family: "Inter", "Geist", "SF Pro Display", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  letter-spacing: -0.01em;
  min-height: 100vh;
  overflow-x: hidden;
}

/* 背景光晕 */
.bg-glow { position: fixed; border-radius: 50%; filter: blur(120px); pointer-events: none; z-index: 0; }
.bg-glow-1 { width: 640px; height: 640px; top: -280px; left: -160px; background: radial-gradient(circle, rgba(99,102,241,0.13), transparent 70%); }
.bg-glow-2 { width: 560px; height: 560px; top: 20%; right: -220px; background: radial-gradient(circle, rgba(168,85,247,0.09), transparent 70%); }

/* ============ 顶栏 ============ */
.topbar {
  position: sticky; top: 0; z-index: 50;
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  background: rgba(5, 5, 6, 0.72);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: 1280px; margin: 0 auto; padding: 0 24px;
  height: 60px; display: flex; align-items: center; justify-content: space-between;
}
.brand { display: flex; align-items: baseline; gap: 8px; }
.brand-mark {
  font-size: 15px; font-weight: 700; color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  width: 26px; height: 26px; border-radius: 7px;
  display: inline-flex; align-items: center; justify-content: center;
  align-self: center;
  box-shadow: 0 0 18px rgba(99, 102, 241, 0.45);
}
.brand-name { font-size: 16px; font-weight: 650; }
.brand-sub { font-size: 12px; color: var(--text-3); }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.dl-format { display: flex; align-items: center; gap: 8px; margin-right: 2px; }
.dl-format-label { font-size: 12px; color: var(--text-3); white-space: nowrap; }
.seg-compact { padding: 2px; background: rgba(255, 255, 255, 0.04); }
.seg-compact .seg-item { flex: none; min-width: auto; padding: 4px 10px; font-size: 11.5px; }

/* ============ 按钮 ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  font-family: inherit; font-size: 13px; font-weight: 550;
  padding: 8px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: transparent; color: var(--text);
  cursor: pointer; transition: all 0.22s var(--ease);
  letter-spacing: -0.01em;
}
.btn:hover { border-color: var(--border-strong); background: var(--surface-strong); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.btn-primary {
  background: linear-gradient(135deg, #5457E8, #6D6FF0);
  border: 1px solid rgba(140, 142, 250, 0.5);
  color: #fff;
  box-shadow: 0 0 22px rgba(99, 102, 241, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.18);
}
.btn-primary:hover:not(:disabled) {
  box-shadow: 0 0 34px rgba(99, 102, 241, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.22);
  transform: translateY(-1px);
}
.btn-primary:disabled { opacity: 0.45; cursor: not-allowed; box-shadow: none; transform: none; }

.btn-generate { width: 100%; padding: 12px; font-size: 14px; margin-top: 4px; position: relative; overflow: hidden; }
.btn-generate.loading .btn-label::after {
  content: ""; display: inline-block; width: 12px; height: 12px; margin-left: 8px;
  border: 2px solid rgba(255, 255, 255, 0.35); border-top-color: #fff;
  border-radius: 50%; animation: spin 0.8s linear infinite; vertical-align: -2px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============ 主体布局 ============ */
.page { position: relative; z-index: 1; max-width: 1280px; margin: 0 auto; padding: 28px 24px 64px; }

.tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 24px; }
.tab {
  display: flex; flex-direction: column; align-items: flex-start; gap: 3px;
  padding: 16px 18px; border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--surface);
  cursor: pointer; font-family: inherit; color: var(--text-2); text-align: left;
  transition: all 0.25s var(--ease); position: relative; overflow: hidden;
}
.tab::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(115deg, transparent 30%, rgba(255,255,255,0.05) 48%, transparent 62%);
  transform: translateX(-100%); transition: none;
}
.tab:hover::after { animation: shimmer 0.9s var(--ease); }
@keyframes shimmer { to { transform: translateX(100%); } }
.tab:hover { border-color: var(--border-strong); color: var(--text); }
.tab.active {
  border-color: rgba(99, 102, 241, 0.55);
  background: linear-gradient(180deg, rgba(99, 102, 241, 0.10), rgba(99, 102, 241, 0.03));
  color: var(--text);
  box-shadow: 0 0 24px rgba(99, 102, 241, 0.16);
}
.tab-icon { font-size: 16px; color: var(--accent); line-height: 1.4; }
.tab.active .tab-icon { text-shadow: 0 0 14px rgba(99, 102, 241, 0.8); }
.tab-title { font-size: 14px; font-weight: 600; color: var(--text); }
.tab-desc { font-size: 12px; color: var(--text-3); }

.panel { display: none; }
.panel.active { display: block; animation: fadeUp 0.35s var(--ease); }
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.panel-grid { display: grid; grid-template-columns: 460px 1fr; gap: 20px; align-items: start; }

.card {
  border: 1px solid var(--border); border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(255,255,255,0.025), rgba(255,255,255,0.008));
  padding: 22px;
}
.control-card { position: sticky; top: 84px; }
.card-title { font-size: 16px; font-weight: 650; margin-bottom: 6px; }
.card-hint { font-size: 12.5px; line-height: 1.7; color: var(--text-2); margin-bottom: 18px; }

/* ============ 提示词行（输入框 + AI 优化按钮） ============ */
.prompt-row { display: flex; align-items: stretch; gap: 8px; }
.prompt-row .textarea { flex: 1; min-width: 0; }
.btn-optimize {
  flex: none; white-space: nowrap; padding: 0 12px; font-size: 12px;
  color: #C7C9F5; border-color: rgba(99, 102, 241, 0.4);
  background: rgba(99, 102, 241, 0.08);
}
.btn-optimize:hover:not(:disabled) { border-color: rgba(99, 102, 241, 0.7); background: rgba(99, 102, 241, 0.16); box-shadow: 0 0 14px rgba(99, 102, 241, 0.2); }
.btn-optimize:disabled { opacity: 0.5; cursor: wait; }

/* ============ 上传组件 ============ */
.upload-row { display: flex; align-items: stretch; gap: 10px; margin-bottom: 18px; }
.upload-row-single { justify-content: center; }
.upload-row-single .upload-box { width: 100%; max-width: 100%; }
.upload-swap-mark {
  align-self: center; font-size: 18px; color: var(--text-3); flex: 0 0 auto;
  width: 30px; height: 30px; border: 1px solid var(--border); border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}
.upload-box {
  position: relative; flex: 1; min-height: 132px;
  border: 1px dashed var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); cursor: pointer;
  transition: all 0.22s var(--ease); overflow: hidden;
}
.upload-box:hover, .upload-box.dragover {
  border-color: rgba(99, 102, 241, 0.6);
  background: var(--accent-soft);
  box-shadow: 0 0 18px rgba(99, 102, 241, 0.15);
}
.upload-tag {
  position: absolute; top: 8px; left: 8px; z-index: 3;
  font-size: 10.5px; font-weight: 600; color: var(--accent);
  background: rgba(99, 102, 241, 0.16); border: 1px solid rgba(99, 102, 241, 0.35);
  padding: 2px 8px; border-radius: 999px; letter-spacing: 0.02em;
}
.upload-placeholder {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 5px;
  color: var(--text-3); font-size: 12.5px; text-align: center; padding: 10px;
}
.upload-placeholder svg { color: var(--text-3); opacity: 0.75; }
.upload-placeholder small { font-size: 11px; color: var(--text-3); opacity: 0.7; }
.upload-preview { position: absolute; inset: 0; z-index: 2; }
.upload-preview img { width: 100%; height: 100%; object-fit: cover; display: block; }
.file-input {
  position: absolute; inset: 0; z-index: 4;
  width: 100%; height: 100%; opacity: 0; cursor: pointer;
}
.upload-remove {
  position: absolute; top: 8px; right: 8px; z-index: 5;
  width: 24px; height: 24px; border-radius: 50%;
  border: 1px solid var(--border-strong); background: rgba(5, 5, 6, 0.75);
  color: var(--text); font-size: 15px; line-height: 1; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.2s var(--ease);
}
.upload-remove:hover { background: var(--danger); border-color: var(--danger); }

/* ============ 参数控件 ============ */
.param-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 14px; }
.param-item { margin-bottom: 14px; }
.param-label { display: block; font-size: 12px; font-weight: 550; color: var(--text-2); margin-bottom: 8px; }
.optional { color: var(--text-3); font-weight: 400; }

.seg { display: flex; gap: 4px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 3px; }
.seg-wrap { flex-wrap: wrap; }
.seg-item {
  flex: 1; min-width: 40px; padding: 6px 4px;
  font-family: inherit; font-size: 12px; font-weight: 550; color: var(--text-2);
  background: transparent; border: none; border-radius: 6px; cursor: pointer;
  transition: all 0.2s var(--ease); white-space: nowrap;
}
.seg-item:hover { color: var(--text); background: var(--surface-strong); }
.seg-item.active { background: var(--accent-soft); color: #C7C9F5; box-shadow: inset 0 0 0 1px rgba(99, 102, 241, 0.4); }

.textarea, .input {
  width: 100%; font-family: inherit; font-size: 13px; color: var(--text);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 10px 12px; resize: vertical;
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}
.textarea:focus, .input:focus { outline: none; border-color: rgba(99, 102, 241, 0.6); box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12); }
.textarea::placeholder, .input::placeholder { color: var(--text-3); }

/* 详情图类型多选 */
.type-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.type-check { position: relative; display: block; cursor: pointer; }
.type-check input { position: absolute; opacity: 0; pointer-events: none; }
.type-check span {
  display: block; text-align: center; padding: 9px 6px;
  font-size: 12.5px; font-weight: 550; color: var(--text-2);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); transition: all 0.2s var(--ease);
}
.type-check span:hover { border-color: var(--border-strong); color: var(--text); }
.type-check input:checked + span {
  color: #C7C9F5; border-color: rgba(99, 102, 241, 0.55);
  background: var(--accent-soft);
  box-shadow: 0 0 12px rgba(99, 102, 241, 0.14);
}
.type-check input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ============ 结果区 ============ */
.result-card { min-height: 420px; display: flex; flex-direction: column; }
.result-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.result-title { font-size: 14px; font-weight: 650; color: var(--text-2); }
.result-actions { display: flex; gap: 8px; }
.result-progress { font-size: 12.5px; color: var(--accent); font-weight: 550; }
.result-body { flex: 1; display: flex; align-items: center; justify-content: center; }
.result-body-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; align-items: stretch; align-content: start; }

.result-empty {
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  color: var(--text-3); font-size: 13px; text-align: center;
  border: 1px dashed var(--border); border-radius: var(--radius);
  padding: 48px 24px; width: 100%;
  grid-column: 1 / -1;
}
.result-empty svg { opacity: 0.5; }

.result-img-wrap { position: relative; border-radius: var(--radius-sm); overflow: hidden; border: 1px solid var(--border); background: #0A0A0C; }
.result-img-wrap img { width: 100%; display: block; height: auto; max-height: 640px; object-fit: contain; }
.result-img-wrap .img-overlay {
  position: absolute; inset: auto 0 0 0; padding: 24px 12px 10px;
  background: linear-gradient(transparent, rgba(5,5,6,0.85));
  display: flex; justify-content: flex-end; gap: 8px;
  opacity: 0; transition: opacity 0.25s var(--ease);
}
.result-img-wrap:hover .img-overlay { opacity: 1; }
.result-img-wrap .img-overlay .btn { padding: 5px 10px; font-size: 12px; background: rgba(5,5,6,0.7); backdrop-filter: blur(8px); }
.result-caption { font-size: 11.5px; color: var(--text-3); margin-top: 7px; text-align: center; }

/* 骨架屏 */
.skeleton {
  border-radius: var(--radius-sm); overflow: hidden;
  background: var(--surface-strong); border: 1px solid var(--border);
  position: relative; min-height: 220px;
}
.skeleton::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(115deg, transparent 30%, rgba(255,255,255,0.06) 48%, transparent 62%);
  transform: translateX(-100%);
  animation: shimmer 1.6s ease-in-out infinite;
}
.result-body-grid .skeleton { min-height: 220px; }

.result-error {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  color: var(--danger); font-size: 13px; text-align: center;
  border: 1px solid rgba(244, 63, 94, 0.3); border-radius: var(--radius);
  background: rgba(244, 63, 94, 0.06); padding: 32px 24px; width: 100%;
}

/* ============ 弹窗 ============ */
.modal-mask {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(3, 3, 4, 0.7); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
.modal-mask.hidden, .hidden { display: none !important; }
.modal {
  width: 100%; max-width: 420px;
  background: #0B0B0E; border: 1px solid var(--border-strong);
  border-radius: 16px; box-shadow: 0 24px 80px rgba(0,0,0,0.6), 0 0 40px rgba(99,102,241,0.08);
  animation: fadeUp 0.3s var(--ease);
}
.modal-lg { max-width: 760px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px 0; }
.modal-head h3 { font-size: 15px; font-weight: 650; }
.modal-close {
  width: 28px; height: 28px; border-radius: 8px; border: 1px solid var(--border);
  background: transparent; color: var(--text-2); font-size: 17px; cursor: pointer;
  transition: all 0.2s var(--ease);
}
.modal-close:hover { color: var(--text); background: var(--surface-strong); }
.modal-body { padding: 14px 20px 4px; }
.modal-body-scroll { max-height: 60vh; overflow-y: auto; }
.modal-hint { font-size: 12px; line-height: 1.7; color: var(--text-3); margin-bottom: 12px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px 18px; }

.history-item { display: flex; gap: 12px; align-items: center; padding: 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); margin-bottom: 10px; background: var(--surface); }
.history-item img { width: 76px; height: 76px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); flex: 0 0 auto; }
.history-info { flex: 1; min-width: 0; }
.history-info .h-mode { font-size: 13px; font-weight: 600; }
.history-info .h-meta { font-size: 11.5px; color: var(--text-3); margin-top: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ============ 继续编辑弹窗 ============ */
.refine-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.refine-preview img {
  width: 100%; max-height: 320px; object-fit: contain;
  border: 1px solid var(--border); border-radius: var(--radius-sm); background: #0A0A0C;
}
.refine-controls .btn-primary { width: 100%; margin-top: 6px; }
.refine-result { margin-top: 16px; border-top: 1px solid var(--border); padding-top: 14px; }
.refine-result-imgbox img {
  width: 100%; max-height: 360px; object-fit: contain;
  border: 1px solid var(--border); border-radius: var(--radius-sm); background: #0A0A0C;
}
.refine-result-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 10px; }
@media (max-width: 640px) {
  .refine-grid { grid-template-columns: 1fr; }
}

/* ============ Toast ============ */
.toast-wrap { position: fixed; top: 72px; right: 24px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast {
  padding: 11px 16px; border-radius: 10px; font-size: 13px; max-width: 340px;
  border: 1px solid var(--border-strong); background: rgba(12, 12, 15, 0.92);
  backdrop-filter: blur(12px); box-shadow: 0 8px 30px rgba(0,0,0,0.5);
  animation: toastIn 0.3s var(--ease);
}
.toast-ok { border-color: rgba(52, 211, 153, 0.4); color: #A7F3D0; }
.toast-err { border-color: rgba(244, 63, 94, 0.45); color: #FDA4AF; }
.toast-info { color: var(--text-2); }
.toast.fade-out { animation: toastOut 0.3s var(--ease) forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateX(16px); } }

/* ============ 响应式 ============ */
@media (max-width: 1080px) {
  .panel-grid { grid-template-columns: 1fr; }
  .control-card { position: static; }
}
@media (max-width: 640px) {
  .page { padding: 18px 14px 48px; }
  .tabs { grid-template-columns: 1fr; }
  .upload-row { flex-direction: column; }
  .upload-swap-mark { align-self: center; }
  .param-grid { grid-template-columns: 1fr; }
  .type-grid { grid-template-columns: repeat(2, 1fr); }
  .result-body-grid { grid-template-columns: 1fr 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}