/* ============================================================
   AI 创意工坊 — Stripe Design System
   Light theme · Deep Violet accent · sohne-var typography
   ============================================================ */

/* ---------- Font ---------- */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600&family=JetBrains+Mono:wght@400;500&display=swap');

/* ---------- Design Tokens ---------- */
:root {
  /* Colors — Stripe palette */
  --c-midnight:     #061b31;
  --c-slate:        #50617a;
  --c-ghost:        #64748d;
  --c-white:        #ffffff;
  --c-porcelain:    #f8fafd;
  --c-powder:       #e5edf5;
  --c-stone:        #d8d6df;
  --c-violet:       #533afd;
  --c-washed:       #b9b9f9;
  --c-soft:         #8087ff;
  --c-green:        #81b81a;
  --c-orange:       #ff6118;
  --c-red:          #dc2626;
  --c-success:      #10b981;

  /* Gradient */
  --g-sunburst: linear-gradient(90deg, rgb(114,50,241) 3.13%, rgb(251,118,250) 50%, rgb(255,207,94));
  --g-dreamy: radial-gradient(circle, rgb(127,125,252), rgb(244,75,204) 33%, rgb(229,237,245) 66%);

  /* Typography */
  --font: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', 'Fira Code', monospace;
  --fw-light: 300;
  --fw-regular: 400;
  --fw-medium: 500;
  --fw-semibold: 600;

  /* Spacing (base 4px) */
  --s-2: 2px;
  --s-4: 4px;
  --s-8: 8px;
  --s-12: 12px;
  --s-16: 16px;
  --s-20: 20px;
  --s-24: 24px;
  --s-28: 28px;
  --s-32: 32px;
  --s-40: 40px;
  --s-48: 48px;
  --s-64: 64px;

  /* Border Radius */
  --r-sm: 4px;
  --r-md: 6px;
  --r-lg: 8px;
  --r-full: 9999px;

  /* Shadows */
  --shadow-sm: rgba(23,23,23,0.06) 0px 3px 6px 0px;
  --shadow-md: rgba(0,0,0,0.08) 0px 4px 12px;
  --shadow-lg: rgba(50,50,93,0.12) 0px 16px 32px 0px;
  --shadow-xl: rgba(0,0,0,0.2) 0px 0px 32px 8px;

  /* Surfaces */
  --bg: var(--c-white);
  --surface: var(--c-porcelain);
  --surface-alt: var(--c-powder);
}

/* ---------- Reset ---------- */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html { font-size: 16px; -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font);
  font-weight: var(--fw-regular);
  background: var(--bg);
  color: var(--c-midnight);
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

::selection {
  background: var(--c-violet);
  color: var(--c-white);
}

::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--c-stone); border-radius: 2px; }
::-webkit-scrollbar-thumb:hover { background: var(--c-ghost); }

/* ---------- Layout ---------- */
.app {
  max-width: 768px;
  margin: 0 auto;
  padding: var(--s-32) var(--s-20) var(--s-64);
}

/* ---------- Header ---------- */
.header {
  text-align: left;
  padding: var(--s-48) var(--s-4) var(--s-40);
}

.header-inner {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--s-16);
  flex-wrap: wrap;
}

.header-left {
  display: flex;
  align-items: center;
  gap: var(--s-12);
}

.logo {
  font-size: 34px;
  font-weight: var(--fw-light);
  letter-spacing: -0.025em;
  line-height: 1.1;
  color: var(--c-midnight);
}

.badge {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: var(--fw-medium);
  color: var(--c-ghost);
  background: var(--c-porcelain);
  padding: var(--s-2) var(--s-8);
  border-radius: var(--r-sm);
}

.header-desc {
  font-size: 14px;
  font-weight: var(--fw-regular);
  color: var(--c-slate);
  letter-spacing: 0.003px;
  margin-top: var(--s-8);
  width: 100%;
}

/* ---------- Navigation ---------- */
.nav {
  display: flex;
  gap: var(--s-2);
  background: var(--c-porcelain);
  border-radius: var(--r-md);
  padding: var(--s-4);
  margin-bottom: var(--s-28);
  flex-wrap: wrap;
}

.tab {
  flex: 1;
  min-width: 72px;
  padding: var(--s-8) var(--s-16);
  background: transparent;
  border: none;
  border-radius: var(--r-sm);
  color: var(--c-slate);
  font-family: var(--font);
  font-size: 13px;
  font-weight: var(--fw-medium);
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
  letter-spacing: -0.1px;
}

.tab:hover {
  color: var(--c-midnight);
  background: rgba(0,0,0,0.03);
}

.tab.active {
  background: var(--c-white);
  color: var(--c-midnight);
  box-shadow: var(--shadow-sm);
}

/* ---------- Tab Content ---------- */
.tc {
  display: none;
  animation: fadeUp 0.2s ease;
}

.tc.active {
  display: block;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---------- Card ---------- */
.card {
  background: var(--c-white);
  border: 1px solid var(--c-stone);
  border-radius: var(--r-md);
  padding: var(--s-24);
  margin-bottom: var(--s-16);
  transition: box-shadow 0.15s ease;
}

.card:hover {
  box-shadow: var(--shadow-md);
}

.card-title {
  font-size: 20px;
  font-weight: var(--fw-semibold);
  letter-spacing: -0.01em;
  line-height: 1.25;
  color: var(--c-midnight);
  margin-bottom: var(--s-20);
}

/* ---------- Form Fields ---------- */
.field {
  margin-bottom: var(--s-16);
}

.label {
  display: block;
  font-size: 11px;
  font-weight: var(--fw-medium);
  color: var(--c-ghost);
  margin-bottom: var(--s-6);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.input,
textarea,
select {
  width: 100%;
  padding: var(--s-10) var(--s-12);
  background: var(--c-white);
  border: 1px solid var(--c-stone);
  border-radius: var(--r-sm);
  color: var(--c-midnight);
  font-family: var(--font);
  font-size: 14px;
  font-weight: var(--fw-regular);
  line-height: 1.5;
  transition: all 0.15s ease;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
}

.input:focus,
textarea:focus,
select:focus {
  border-color: var(--c-violet);
  box-shadow: 0 0 0 3px rgba(83,58,253,0.1);
}

textarea {
  resize: vertical;
  min-height: 72px;
}

select {
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L5 5L9 1' stroke='%2364748d' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: var(--s-32);
}

option {
  background: var(--c-white);
  color: var(--c-midnight);
}

.row {
  display: flex;
  flex-wrap: wrap;
}

.g-2 { gap: var(--s-8); }
.g-3 { gap: var(--s-12); }

.flex-1 {
  flex: 1;
  min-width: 100px;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-8);
  width: 100%;
  padding: 10px var(--s-24);
  border: none;
  border-radius: var(--r-sm);
  font-family: var(--font);
  font-size: 14px;
  font-weight: var(--fw-medium);
  cursor: pointer;
  transition: all 0.15s ease;
  letter-spacing: -0.1px;
  line-height: 1.4;
}

.btn:active { transform: scale(0.98); }

.btn-primary {
  background: var(--c-violet);
  color: var(--c-white);
}

.btn-primary:hover {
  background: #4532e8;
  box-shadow: 0 4px 12px rgba(83,58,253,0.25);
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-ghost {
  background: transparent;
  border: 1px solid var(--c-stone);
  color: var(--c-slate);
  width: auto;
}

.btn-ghost:hover {
  border-color: var(--c-ghost);
  color: var(--c-midnight);
}

.btn-sm {
  padding: var(--s-6) var(--s-12);
  font-size: 12px;
}

.btn-danger {
  color: var(--c-red);
  border-color: transparent;
}

.btn-danger:hover {
  background: #fef2f2;
  border-color: rgba(220,38,38,0.25);
  color: #b91c1c;
}

/* ---------- Spinner ---------- */
.spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255,255,255,0.25);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  display: none;
}

.btn-primary:disabled .spinner { display: inline-block; }

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

/* ---------- Upload Zone ---------- */
.upload {
  position: relative;
  border: 1px dashed var(--c-stone);
  border-radius: var(--r-sm);
  padding: var(--s-28) var(--s-20);
  text-align: center;
  cursor: pointer;
  transition: all 0.15s ease;
  background: var(--c-porcelain);
}

.upload:hover {
  border-color: var(--c-violet);
  background: var(--c-powder);
}

.upload.dragover {
  border-color: var(--c-violet);
  background: rgba(83,58,253,0.04);
  box-shadow: 0 0 0 3px rgba(83,58,253,0.1);
}

.upload-placeholder {
  text-align: center;
  color: var(--c-ghost);
}

.upload-placeholder svg { margin-bottom: var(--s-8); }

.upload-placeholder p {
  font-size: 14px;
  font-weight: var(--fw-regular);
  color: var(--c-slate);
  margin-bottom: var(--s-2);
}

.upload-hint {
  font-size: 11px;
  color: var(--c-ghost);
}

.upload-preview {
  max-width: 100%;
  max-height: 180px;
  border-radius: var(--r-sm);
  display: none;
  margin-top: var(--s-8);
  box-shadow: var(--shadow-sm);
}

.upload-preview[src] { display: block; }

.upload.has-image .upload-placeholder { display: none; }

.upload-remove {
  position: absolute;
  top: var(--s-8);
  right: var(--s-8);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: rgba(0,0,0,0.5);
  color: #fff;
  font-size: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease;
}

.upload-remove:hover {
  background: rgba(0,0,0,0.7);
}

/* ---------- Result Gallery ---------- */
.result-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: var(--s-12);
}

.result-item {
  background: var(--c-white);
  border: 1px solid var(--c-stone);
  border-radius: var(--r-sm);
  overflow: hidden;
  transition: box-shadow 0.15s ease;
}

.result-item:hover {
  box-shadow: var(--shadow-md);
}

.result-item img,
.result-item video {
  width: 100%;
  display: block;
  max-height: 300px;
  object-fit: contain;
  background: var(--c-porcelain);
}

.result-actions {
  display: flex;
  gap: var(--s-2);
  padding: var(--s-8) var(--s-10);
  border-top: 1px solid var(--c-stone);
}

.result-actions button {
  flex: 1;
  padding: var(--s-4) var(--s-8);
  border: 1px solid var(--c-stone);
  border-radius: var(--r-sm);
  background: var(--c-white);
  color: var(--c-slate);
  font-family: var(--font);
  font-size: 11px;
  font-weight: var(--fw-medium);
  cursor: pointer;
  transition: all 0.15s ease;
}

.result-actions button:hover {
  background: var(--c-porcelain);
  border-color: var(--c-ghost);
  color: var(--c-midnight);
}

/* Empty state */
.empty {
  text-align: center;
  padding: var(--s-48) var(--s-16);
  color: var(--c-ghost);
  font-size: 13px;
  font-weight: var(--fw-regular);
}

/* ---------- Progress ---------- */
.progress-card {
  padding: var(--s-24);
  text-align: center;
}

.progress-msg {
  margin-bottom: var(--s-16);
  color: var(--c-midnight);
  font-size: 14px;
  font-weight: var(--fw-medium);
}

.progress-bar {
  height: 4px;
  background: var(--c-powder);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: var(--s-16);
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: var(--c-violet);
  border-radius: 2px;
  transition: width 0.5s ease;
}

.progress-tips {
  font-size: 11px;
  font-weight: var(--fw-regular);
  color: var(--c-ghost);
  line-height: 1.6;
}

.progress-tips p { margin: var(--s-2) 0; }

/* ---------- History ---------- */
.hi {
  background: var(--c-white);
  border: 1px solid var(--c-stone);
  border-radius: var(--r-sm);
  padding: var(--s-16);
  margin-bottom: var(--s-8);
  transition: box-shadow 0.15s ease;
}

.hi:hover {
  box-shadow: var(--shadow-sm);
}

.hi-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--s-8);
  flex-wrap: wrap;
  gap: var(--s-4);
}

.hi-badge {
  font-size: 10px;
  font-weight: var(--fw-medium);
  padding: var(--s-2) var(--s-8);
  border-radius: var(--r-sm);
  background: rgba(83,58,253,0.08);
  color: var(--c-violet);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.hi-time {
  font-size: 11px;
  font-weight: var(--fw-regular);
  color: var(--c-ghost);
}

.hi-prompt {
  font-size: 14px;
  font-weight: var(--fw-regular);
  color: var(--c-midnight);
  margin-bottom: var(--s-6);
  word-break: break-word;
  cursor: pointer;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.5;
}

.hi-prompt.expanded {
  -webkit-line-clamp: unset;
  display: block;
}

.hi-prompt::after {
  content: ' ▼';
  font-size: 9px;
  color: var(--c-ghost);
  opacity: 0.5;
}

.hi-prompt.expanded::after {
  content: ' ▲';
}

.hi-meta {
  font-size: 11px;
  font-weight: var(--fw-regular);
  color: var(--c-ghost);
  margin-bottom: var(--s-8);
}

/* Thumbnail grid */
.hi-thumbs {
  margin-bottom: var(--s-8);
}

.thumb-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: var(--s-4);
}

.thumb {
  position: relative;
  border-radius: var(--r-sm);
  overflow: hidden;
  cursor: pointer;
  border: 1px solid var(--c-stone);
  transition: box-shadow 0.15s ease;
  aspect-ratio: 1;
  background: var(--c-porcelain);
}

.thumb:hover {
  box-shadow: 0 0 0 2px var(--c-violet);
}

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

.thumb.single {
  aspect-ratio: 16/9;
  max-width: 240px;
}

.thumb-num {
  position: absolute;
  bottom: 2px;
  right: 2px;
  background: var(--c-white);
  color: var(--c-ghost);
  padding: 1px 4px;
  border-radius: var(--r-sm);
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: var(--fw-medium);
  border: 1px solid var(--c-stone);
}

.thumb-play {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 16px;
  color: var(--c-white);
  text-shadow: 0 2px 8px rgba(0,0,0,0.5);
  pointer-events: none;
  opacity: 0.85;
}

/* History action buttons */
.hi-actions {
  display: flex;
  gap: var(--s-4);
  flex-wrap: wrap;
}

.hi-actions button {
  padding: var(--s-4) var(--s-10);
  border: 1px solid var(--c-stone);
  border-radius: var(--r-sm);
  background: var(--c-white);
  color: var(--c-slate);
  font-family: var(--font);
  font-size: 11px;
  font-weight: var(--fw-medium);
  cursor: pointer;
  transition: all 0.15s ease;
}

.hi-actions button:hover {
  background: var(--c-porcelain);
  border-color: var(--c-ghost);
  color: var(--c-midnight);
}

.history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--s-16);
  flex-wrap: wrap;
  gap: var(--s-8);
}

.history-actions {
  display: flex;
  gap: var(--s-6);
}

.history-count {
  font-size: 11px;
  font-weight: var(--fw-regular);
  color: var(--c-ghost);
  margin-bottom: var(--s-12);
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: var(--s-28);
  left: 50%;
  transform: translateX(-50%);
  padding: var(--s-10) var(--s-20);
  border-radius: var(--r-sm);
  background: var(--c-midnight);
  color: var(--c-white);
  font-family: var(--font);
  font-size: 12px;
  font-weight: var(--fw-medium);
  z-index: 9999;
  animation: toastUp 0.2s ease;
  box-shadow: var(--shadow-lg);
  white-space: nowrap;
}

.toast.error {
  background: var(--c-red);
}

.toast.warning {
  background: var(--c-orange);
}

@keyframes toastUp {
  from { opacity: 0; transform: translateX(-50%) translateY(10px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ---------- Preview Overlay ---------- */
.preview-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.8);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  z-index: 9998;
  display: none;
  align-items: center;
  justify-content: center;
  padding: var(--s-20);
  animation: fadeIn 0.15s ease;
}

.preview-modal {
  max-width: 90vw;
  max-height: 85vh;
  background: rgba(0,0,0,0.2);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: var(--r-lg);
  overflow: hidden;
}

.preview-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--s-8) var(--s-12);
  color: rgba(255,255,255,0.8);
}

.preview-top span {
  font-size: 13px;
  font-weight: var(--fw-medium);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 80%;
}

.preview-close-btn {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,0.1);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease;
}

.preview-close-btn:hover {
  background: rgba(255,255,255,0.2);
}

.preview-body {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--s-4);
}

.preview-body img,
.preview-body video {
  max-width: 100%;
  max-height: 70vh;
  border-radius: var(--r-sm);
  object-fit: contain;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* ---------- Chat ---------- */
.chat-card {
  padding: var(--s-12);
}

.chat-msgs {
  display: flex;
  flex-direction: column;
  height: 420px;
  overflow-y: auto;
  background: var(--c-porcelain);
  border-radius: var(--r-sm);
  padding: var(--s-16);
  margin-bottom: var(--s-12);
  border: 1px solid var(--c-stone);
}

.chat-welcome {
  text-align: center;
  padding: var(--s-48) var(--s-16);
}

.chat-welcome-icon {
  margin-bottom: var(--s-12);
  color: var(--c-ghost);
}

.chat-welcome p {
  font-size: 15px;
  font-weight: var(--fw-regular);
  color: var(--c-slate);
}

.chat-welcome-hint {
  font-size: 12px;
  font-weight: var(--fw-regular);
  color: var(--c-ghost);
  margin-top: var(--s-4);
}

/* Messages */
.msg {
  margin-bottom: var(--s-10);
  display: flex;
}

.msg-user { justify-content: flex-end; }
.msg-ai   { justify-content: flex-start; }

.msg-bubble {
  max-width: 80%;
  padding: var(--s-10) var(--s-16);
  border-radius: 12px;
  font-size: 14px;
  font-weight: var(--fw-regular);
  line-height: 1.5;
  word-break: break-word;
}

.user-bubble {
  background: var(--c-violet);
  color: var(--c-white);
  border-bottom-right-radius: var(--s-4);
}

.ai-bubble {
  background: var(--c-white);
  border: 1px solid var(--c-stone);
  color: var(--c-midnight);
  border-bottom-left-radius: var(--s-4);
}

.ai-bubble.thinking {
  color: var(--c-ghost);
  font-style: italic;
}

/* Chat input */
.chat-input-row {
  display: flex;
  gap: var(--s-8);
  align-items: flex-end;
}

.chat-input-field {
  flex: 1;
  min-height: 40px;
  max-height: 100px;
}

.chat-tools {
  display: flex;
  gap: var(--s-4);
}

.chat-tool {
  cursor: pointer;
  padding: var(--s-8);
  border-radius: var(--r-sm);
  color: var(--c-ghost);
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  line-height: 1;
}

.chat-tool:hover {
  color: var(--c-violet);
  background: rgba(83,58,253,0.06);
}

.chat-send {
  width: auto;
  padding: var(--s-8) var(--s-14);
  white-space: nowrap;
  border-radius: var(--r-sm);
}

.chat-preview-bar {
  display: flex;
  align-items: center;
  gap: var(--s-6);
  margin-top: var(--s-8);
  padding: var(--s-6) var(--s-10);
  background: var(--c-porcelain);
  border: 1px solid var(--c-stone);
  border-radius: var(--r-sm);
}

.chat-preview-bar img {
  max-height: 48px;
  border-radius: var(--r-sm);
}

.chat-preview-remove {
  background: none;
  border: none;
  color: var(--c-red);
  cursor: pointer;
  font-size: 14px;
  font-family: var(--font);
  padding: var(--s-2) var(--s-4);
}

/* ---------- Footer ---------- */
.footer {
  text-align: center;
  padding: var(--s-40) var(--s-16) var(--s-24);
  color: var(--c-ghost);
  font-size: 12px;
  font-weight: var(--fw-regular);
  display: flex;
  justify-content: center;
  gap: var(--s-10);
  align-items: center;
}

/* ---------- Responsive ---------- */
@media (max-width: 768px) {
  .app {
    padding: var(--s-20) var(--s-12) var(--s-48);
  }

  .header {
    padding: var(--s-36) var(--s-4) var(--s-28);
  }

  .logo {
    font-size: 26px;
    letter-spacing: -0.02em;
  }

  .header-desc {
    font-size: 13px;
    letter-spacing: 0;
  }

  .nav {
    gap: var(--s-2);
    padding: var(--s-3);
    margin-bottom: var(--s-20);
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .tab {
    flex: 0 0 auto;
    min-width: 0;
    padding: var(--s-6) var(--s-12);
    font-size: 12px;
  }

  .card {
    padding: var(--s-16);
    margin-bottom: var(--s-12);
  }

  .card-title {
    font-size: 17px;
    margin-bottom: var(--s-16);
  }

  .row { flex-direction: column; gap: var(--s-8); }

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

  .input, textarea, select {
    font-size: 13px;
    padding: var(--s-8) var(--s-10);
  }

  .upload {
    padding: var(--s-20) var(--s-16);
  }

  .btn {
    padding: 9px var(--s-20);
    font-size: 13px;
  }

  .result-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: var(--s-8);
  }

  .result-item img,
  .result-item video {
    max-height: 220px;
  }

  .chat-msgs {
    height: 340px;
    padding: var(--s-12);
  }

  .chat-welcome {
    padding: var(--s-36) var(--s-12);
  }

  .msg-bubble {
    max-width: 88%;
    font-size: 13px;
    padding: var(--s-8) var(--s-12);
    border-radius: 10px;
  }

  .hi {
    padding: var(--s-12);
  }

  .thumb-grid {
    grid-template-columns: repeat(auto-fill, minmax(56px, 1fr));
  }

  .hi-actions {
    flex-wrap: wrap;
  }

  .hi-actions button {
    font-size: 10px;
    padding: var(--s-3) var(--s-8);
  }

  .toast {
    font-size: 11px;
    padding: var(--s-8) var(--s-16);
    max-width: 90vw;
    white-space: normal;
  }

  .preview-modal {
    max-width: 96vw;
    max-height: 80vh;
  }

  .preview-top span { font-size: 12px; }
}

@media (max-width: 400px) {
  .logo { font-size: 22px; }
  .tab { padding: var(--s-5) var(--s-10); font-size: 11px; }
  .card { padding: var(--s-12); }
  .result-grid { grid-template-columns: 1fr; }
  .result-item img,
  .result-item video { max-height: 200px; }
}
