/* =========================================================
   ComfyUI Portal — Glassmorphism / 玻璃拟态控制台
   ========================================================= */

:root {
  --glass-bg: rgba(255, 255, 255, 0.42);
  --glass-bg-strong: rgba(255, 255, 255, 0.58);
  --glass-bg-weak: rgba(255, 255, 255, 0.22);
  --glass-border: rgba(255, 255, 255, 0.55);
  --glass-border-soft: rgba(255, 255, 255, 0.28);
  --ink: #1c1e2a;
  --ink-soft: #4a4f6a;
  --ink-mute: #7b819a;
  --accent: #6b7cff;
  --accent-2: #9b7bff;
  --danger: #e2556a;
  --ok: #2faf7a;
  --warn: #d4a017;
  --shadow-float: 0 8px 32px rgba(80, 90, 160, 0.14), 0 2px 8px rgba(40, 50, 100, 0.08);
  --shadow-lift: 0 16px 48px rgba(80, 90, 160, 0.2);
  --blur: 18px;
  --radius: 16px;
  --radius-sm: 10px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --dur: 220ms;
  --font: "Inter", "Segoe UI", "PingFang SC", "HarmonyOS Sans SC", "Microsoft YaHei", system-ui, sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  font-family: var(--font);
  font-size: 14px;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

body {
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(155, 123, 255, 0.35), transparent 50%),
    radial-gradient(900px 500px at 90% 10%, rgba(107, 124, 255, 0.28), transparent 45%),
    radial-gradient(800px 600px at 50% 100%, rgba(120, 200, 255, 0.22), transparent 50%),
    linear-gradient(145deg, #e8ecfb 0%, #dfe4f8 40%, #e6e0f6 70%, #dce8f8 100%);
  background-attachment: fixed;
  min-height: 100vh;
}

/* ---------- Links ---------- */
a { color: var(--accent); text-decoration: none; }
a:hover { opacity: 0.85; }
a.ghost, .user-bar a.ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--glass-border);
  background: var(--glass-bg-weak);
  backdrop-filter: blur(var(--blur));
  -webkit-backdrop-filter: blur(var(--blur));
  color: var(--ink);
  font-weight: 500;
  opacity: 1;
  transition: background var(--dur) var(--ease), transform var(--dur) var(--ease);
}
a.ghost:hover { background: var(--glass-bg-strong); opacity: 1; }

/* ---------- Buttons: glass panels, less pill ---------- */
button, .ghost, .btn-like {
  font: inherit;
  font-weight: 500;
  border: 1px solid var(--glass-border);
  cursor: pointer;
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  backdrop-filter: blur(var(--blur));
  -webkit-backdrop-filter: blur(var(--blur));
  transition:
    transform var(--dur) var(--ease),
    background var(--dur) var(--ease),
    box-shadow var(--dur) var(--ease),
    border-color var(--dur) var(--ease),
    opacity var(--dur) var(--ease);
  user-select: none;
}

button {
  background: var(--glass-bg-strong);
  color: var(--ink);
  box-shadow: var(--shadow-float);
}
button:hover {
  background: rgba(255, 255, 255, 0.72);
  box-shadow: var(--shadow-lift);
  transform: translateY(-1px);
}
button:active {
  transform: translateY(0) scale(0.98);
  box-shadow: var(--shadow-float);
}
button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

button.ghost, .ghost {
  background: var(--glass-bg-weak);
  color: var(--ink);
  box-shadow: none;
}
button.ghost:hover, .ghost:hover {
  background: var(--glass-bg-strong);
}

button.danger {
  background: rgba(226, 85, 106, 0.12);
  color: var(--danger);
  border-color: rgba(226, 85, 106, 0.35);
  box-shadow: none;
}
button.danger:hover { background: rgba(226, 85, 106, 0.2); }

button.ok {
  background: rgba(47, 175, 122, 0.18);
  color: var(--ok);
  border-color: rgba(47, 175, 122, 0.35);
}

/* ---------- Forms ---------- */
input, select, textarea {
  font: inherit;
  color: var(--ink);
  width: 100%;
  background: rgba(255, 255, 255, 0.38);
  border: 1px solid var(--glass-border-soft);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  outline: none;
  backdrop-filter: blur(var(--blur));
  -webkit-backdrop-filter: blur(var(--blur));
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
input:hover, select:hover, textarea:hover { background: rgba(255, 255, 255, 0.5); }
input:focus, select:focus, textarea:focus {
  border-color: rgba(107, 124, 255, 0.55);
  background: rgba(255, 255, 255, 0.62);
  box-shadow: 0 0 0 3px rgba(107, 124, 255, 0.15);
}
input:disabled { opacity: 0.5; }
select {
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--ink-soft) 50%),
    linear-gradient(135deg, var(--ink-soft) 50%, transparent 50%);
  background-position: calc(100% - 16px) 55%, calc(100% - 10px) 55%;
  background-size: 6px 6px;
  background-repeat: no-repeat;
  padding-right: 34px;
}
textarea {
  min-height: 110px;
  resize: vertical;
  line-height: 1.55;
  border-radius: var(--radius);
}
label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-soft);
  margin-bottom: 6px;
}
.field { margin-bottom: 14px; }

/* ---------- Shell ---------- */
.app-shell { display: block; min-height: 100vh; }
.app-body {
  display: grid;
  grid-template-columns: 220px 1fr;
  min-height: calc(100vh - 64px);
  gap: 0;
}

.user-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 64px;
  padding: 0 20px;
  background: rgba(255, 255, 255, 0.38);
  backdrop-filter: blur(22px) saturate(1.4);
  -webkit-backdrop-filter: blur(22px) saturate(1.4);
  border-bottom: 1px solid var(--glass-border-soft);
  position: sticky;
  top: 0;
  z-index: 40;
  box-shadow: 0 4px 24px rgba(80, 90, 160, 0.08);
  animation: slideDown 0.35s var(--ease) both;
}
.user-bar .site { font-weight: 600; font-size: 15px; color: var(--ink); }
.user-bar .right { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.user-bar .uname { font-weight: 500; font-size: 13px; color: var(--ink-soft); }
.user-bar .role {
  font-size: 11px;
  color: var(--ink-soft);
  border: 1px solid var(--glass-border);
  border-radius: 8px;
  padding: 3px 10px;
  background: rgba(255, 255, 255, 0.35);
}
.user-bar .quota {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid var(--glass-border);
  border-radius: 8px;
  padding: 5px 12px;
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow-float);
}
.user-bar .quota.low {
  background: rgba(226, 85, 106, 0.2);
  border-color: rgba(226, 85, 106, 0.4);
  color: var(--danger);
  animation: pulseSoft 1.8s ease-in-out infinite;
}

.sidebar {
  margin: 12px 0 12px 12px;
  padding: 14px 10px;
  background: rgba(255, 255, 255, 0.28);
  backdrop-filter: blur(var(--blur));
  -webkit-backdrop-filter: blur(var(--blur));
  border: 1px solid var(--glass-border-soft);
  border-radius: var(--radius);
  box-shadow: var(--shadow-float);
  display: flex;
  flex-direction: column;
  gap: 4px;
  height: fit-content;
  position: sticky;
  top: 76px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px 14px;
  font-weight: 600;
  font-size: 12px;
  color: var(--ink-mute);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.brand .dot {
  width: 8px;
  height: 8px;
  border-radius: 4px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
}
.nav-btn {
  text-align: left;
  background: transparent !important;
  color: var(--ink-soft) !important;
  border: 1px solid transparent !important;
  border-radius: var(--radius-sm) !important;
  padding: 11px 14px !important;
  box-shadow: none !important;
  font-weight: 500;
}
.nav-btn:hover {
  background: rgba(255, 255, 255, 0.4) !important;
  color: var(--ink) !important;
  transform: none !important;
}
.nav-btn.active {
  background: rgba(255, 255, 255, 0.65) !important;
  color: var(--ink) !important;
  border-color: var(--glass-border) !important;
  box-shadow: var(--shadow-float) !important;
  font-weight: 600;
}

.main {
  padding: 20px 24px 48px;
  max-width: 1280px;
  animation: fadeIn 0.35s var(--ease) both;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.topbar h1 { margin: 0; font-size: 24px; font-weight: 600; letter-spacing: -0.02em; }
.topbar .sub { color: var(--ink-mute); font-size: 13px; margin-top: 4px; }

/* ---------- Glass panels ---------- */
.panel, .card {
  background: rgba(255, 255, 255, 0.4);
  backdrop-filter: blur(var(--blur)) saturate(1.3);
  -webkit-backdrop-filter: blur(var(--blur)) saturate(1.3);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-float);
  transition: box-shadow var(--dur) var(--ease), transform var(--dur) var(--ease), background var(--dur) var(--ease);
  animation: riseIn 0.4s var(--ease) both;
}
.panel:hover, .card:hover {
  background: rgba(255, 255, 255, 0.5);
  box-shadow: var(--shadow-lift);
  transform: translateY(-2px);
}
.panel h2, .panel h3 { margin: 0 0 14px; font-size: 15px; font-weight: 600; }

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}
.card .k { color: var(--ink-mute); font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; }
.card .v {
  font-size: 28px;
  font-weight: 600;
  margin-top: 6px;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  background: linear-gradient(135deg, var(--ink), var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.grid-2 { display: grid; grid-template-columns: 1.05fr 0.95fr; gap: 16px; }

/* ---------- Table ---------- */
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th {
  color: var(--ink-mute);
  font-weight: 500;
  font-size: 11px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  text-align: left;
  padding: 10px 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.5);
}
.table td {
  padding: 12px 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.35);
  vertical-align: middle;
  color: var(--ink-soft);
}
.table tr:last-child td { border-bottom: none; }
.table tbody tr {
  transition: background var(--dur) var(--ease);
  border-radius: 8px;
}
.table tbody tr:hover td {
  background: rgba(255, 255, 255, 0.28);
  color: var(--ink);
}

/* ---------- Badges ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid var(--glass-border-soft);
  color: var(--ink-soft);
  background: rgba(255, 255, 255, 0.4);
}
.badge.ok { color: var(--ok); border-color: rgba(47, 175, 122, 0.4); background: rgba(47, 175, 122, 0.12); }
.badge.err { color: var(--danger); border-color: rgba(226, 85, 106, 0.4); background: rgba(226, 85, 106, 0.12); }
.badge.run { color: var(--warn); border-color: rgba(212, 160, 23, 0.4); background: rgba(212, 160, 23, 0.12); }

/* ---------- Gallery ---------- */
.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
}
.gallery .item {
  position: relative;
  background: rgba(255, 255, 255, 0.35);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-float);
  transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
  animation: riseIn 0.35s var(--ease) both;
}
.gallery .item:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lift);
}
.gallery img, .gallery video {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  display: block;
  background: rgba(0, 0, 0, 0.06);
  cursor: pointer;
}
.gallery .meta { padding: 10px 12px; font-size: 12px; color: var(--ink-mute); }
.gallery .meta .p {
  color: var(--ink-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 4px;
}

/* ---------- Auth ---------- */
.auth-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  animation: fadeIn 0.35s var(--ease) both;
}
.auth-card {
  width: min(400px, 100%);
  background: rgba(255, 255, 255, 0.45);
  backdrop-filter: blur(24px) saturate(1.4);
  -webkit-backdrop-filter: blur(24px) saturate(1.4);
  border: 1px solid var(--glass-border);
  border-radius: 24px;
  padding: 32px 28px;
  box-shadow: var(--shadow-lift);
  animation: riseIn 0.45s var(--ease) both;
}
.auth-card h1 { margin: 0 0 8px; font-size: 22px; font-weight: 600; }
.auth-card .desc { color: var(--ink-mute); font-size: 13px; margin-bottom: 22px; }
.tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 18px;
  padding: 4px;
  background: rgba(255, 255, 255, 0.28);
  border: 1px solid var(--glass-border-soft);
  border-radius: var(--radius-sm);
}
.tabs button {
  flex: 1;
  background: transparent !important;
  color: var(--ink-mute) !important;
  box-shadow: none !important;
  border: none !important;
  border-radius: 8px !important;
  padding: 10px !important;
}
.tabs button.active {
  background: rgba(255, 255, 255, 0.65) !important;
  color: var(--ink) !important;
  box-shadow: var(--shadow-float) !important;
}

/* ---------- Toast / Modal ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%) translateY(12px);
  background: rgba(255, 255, 255, 0.55);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  color: var(--ink);
  border: 1px solid var(--glass-border);
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lift);
  z-index: 1000;
  max-width: min(420px, calc(100vw - 32px));
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease);
  font-size: 13px;
  font-weight: 500;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(40, 45, 80, 0.28);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: none;
  place-items: center;
  z-index: 900;
  padding: 20px;
}
.modal-backdrop.show { display: grid; animation: fadeIn 0.2s var(--ease) both; }
.modal {
  width: min(860px, 100%);
  max-height: 90vh;
  overflow: auto;
  background: rgba(255, 255, 255, 0.55);
  backdrop-filter: blur(24px) saturate(1.4);
  -webkit-backdrop-filter: blur(24px) saturate(1.4);
  border: 1px solid var(--glass-border);
  border-radius: 20px;
  padding: 22px;
  box-shadow: var(--shadow-lift);
  animation: riseIn 0.3s var(--ease) both;
}
.modal img { max-width: 100%; border-radius: var(--radius-sm); }

/* ---------- Misc ---------- */
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.muted { color: var(--ink-mute); font-size: 13px; }
.mono { font-family: ui-monospace, Consolas, monospace; font-size: 12px; }
.hr { border: none; border-top: 1px solid var(--glass-border-soft); margin: 16px 0; }
.empty {
  text-align: center;
  color: var(--ink-mute);
  padding: 40px 16px;
  border: 1px dashed var(--glass-border);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.15);
}
.file-drop {
  border: 1px dashed var(--glass-border);
  border-radius: var(--radius-sm);
  padding: 20px;
  text-align: center;
  color: var(--ink-mute);
  background: rgba(255, 255, 255, 0.2);
  cursor: pointer;
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.file-drop:hover { border-color: var(--accent); background: rgba(255, 255, 255, 0.4); color: var(--ink); }
.copy-btn { padding: 4px 10px !important; font-size: 12px !important; margin-left: 6px; vertical-align: middle; }
.schema-row {
  display: grid;
  grid-template-columns: 1.1fr 1fr 0.8fr 0.8fr 0.8fr 0.8fr auto;
  gap: 8px;
  margin-bottom: 8px;
  align-items: center;
}
.share-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 2;
  width: 14px;
  height: 14px;
  border-radius: 4px;
  background: linear-gradient(135deg, #3ddc84, #2faf7a);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  animation: popIn 0.25s var(--ease) both;
}
.insp-like {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid var(--glass-border);
  background: rgba(255, 255, 255, 0.35);
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.insp-like:hover { background: rgba(255, 255, 255, 0.6); }
.insp-like.liked {
  background: linear-gradient(135deg, rgba(107, 124, 255, 0.25), rgba(155, 123, 255, 0.25));
  border-color: rgba(107, 124, 255, 0.4);
  color: var(--ink);
}
.insp-like:disabled { opacity: 0.45; cursor: not-allowed; }
.insp-meta {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--glass-border-soft);
  font-size: 13px;
  color: var(--ink-soft);
}
.insp-meta .label {
  color: var(--ink-mute);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin-bottom: 4px;
}
.insp-meta .prompt-block {
  white-space: pre-wrap;
  word-break: break-word;
  background: rgba(255, 255, 255, 0.35);
  border: 1px solid var(--glass-border-soft);
  border-radius: var(--radius-sm);
  padding: 12px;
  margin-top: 6px;
  color: var(--ink);
}
.insp-like-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--glass-border-soft);
}
.md-switch { position: relative; display: inline-flex; cursor: pointer; }
.md-switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.md-switch-track {
  width: 48px;
  height: 26px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.35);
  border: 1px solid var(--glass-border);
  position: relative;
  transition: background var(--dur) var(--ease);
}
.md-switch-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  border-radius: 6px;
  background: var(--ink-soft);
  transition: transform var(--dur) var(--ease), background var(--dur) var(--ease);
}
.md-switch input:checked + .md-switch-track {
  background: linear-gradient(135deg, rgba(107, 124, 255, 0.45), rgba(155, 123, 255, 0.45));
}
.md-switch input:checked + .md-switch-track .md-switch-thumb {
  transform: translateX(22px);
  background: white;
}
.spin {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid rgba(0, 0, 0, 0.12);
  border-top-color: var(--accent);
  display: inline-block;
  animation: rot 0.7s linear infinite;
  vertical-align: -2px;
}

/* ---------- Animations ---------- */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes riseIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes slideDown { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }
@keyframes rot { to { transform: rotate(360deg); } }
@keyframes pulseSoft { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.04); } }
@keyframes popIn { from { transform: scale(0); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.gallery .item:nth-child(1) { animation-delay: 0ms; }
.gallery .item:nth-child(2) { animation-delay: 30ms; }
.gallery .item:nth-child(3) { animation-delay: 60ms; }
.gallery .item:nth-child(4) { animation-delay: 90ms; }
.gallery .item:nth-child(5) { animation-delay: 120ms; }
.gallery .item:nth-child(6) { animation-delay: 150ms; }

/* ---------- Responsive ---------- */
@media (max-width: 960px) {
  .app-body { grid-template-columns: 1fr; }
  .sidebar {
    margin: 10px 12px 0;
    flex-direction: row;
    overflow-x: auto;
    position: sticky;
    top: 64px;
    z-index: 30;
  }
  .brand { display: none; }
  .nav-btn { flex: 0 0 auto; white-space: nowrap; }
  .grid-2 { grid-template-columns: 1fr; }
  .main { padding: 14px 14px 40px; }
  .user-bar { padding: 0 12px; }
  .user-bar .uname, .user-bar .role { display: none; }
  .schema-row { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 480px) {
  .cards { grid-template-columns: 1fr 1fr; }
  .card .v { font-size: 22px; }
}

/* =========================================================
   Chat shell / 对话式生成 + 可收起侧栏
   ========================================================= */

.chat-shell {
  display: flex;
  min-height: 100vh;
  height: 100vh;
  overflow: hidden;
}

.rail {
  width: 240px;
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  padding: 12px 10px;
  background: rgba(255, 255, 255, 0.35);
  backdrop-filter: blur(20px) saturate(1.35);
  -webkit-backdrop-filter: blur(20px) saturate(1.35);
  border-right: 1px solid var(--glass-border-soft);
  transition: width var(--dur) var(--ease);
  z-index: 30;
}
.rail.collapsed { width: 68px; }
.rail.collapsed .rail-brand,
.rail.collapsed .rail-label,
.rail.collapsed .user-meta,
.rail.collapsed .rail-foot-actions { display: none; }
.rail.collapsed .user-card { justify-content: center; }

.rail-top {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  min-height: 40px;
}
.rail-toggle {
  width: 36px;
  height: 36px;
  padding: 0 !important;
  display: grid;
  place-items: center;
  border-radius: 10px !important;
  flex: 0 0 auto;
}
.rail-brand {
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
}
.rail-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  overflow: auto;
}
.rail-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
  background: transparent !important;
  color: var(--ink-soft) !important;
  border: 1px solid transparent !important;
  border-radius: 12px !important;
  padding: 11px 12px !important;
  box-shadow: none !important;
}
.rail-btn:hover {
  background: rgba(255, 255, 255, 0.45) !important;
  transform: none !important;
}
.rail-btn.active {
  background: rgba(255, 255, 255, 0.65) !important;
  border-color: var(--glass-border) !important;
  box-shadow: var(--shadow-float) !important;
  color: var(--ink) !important;
  font-weight: 600;
}
.rail-ico {
  width: 22px;
  text-align: center;
  font-size: 15px;
  flex: 0 0 auto;
}
.rail-label { white-space: nowrap; }
.rail.collapsed .rail-btn { justify-content: center; padding: 11px 0 !important; }

.rail-foot {
  margin-top: auto;
  padding-top: 10px;
  border-top: 1px solid var(--glass-border-soft);
}
.user-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  margin-bottom: 8px;
}
.avatar {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-weight: 700;
  background: linear-gradient(135deg, rgba(107,124,255,.85), rgba(155,123,255,.85));
  color: white;
  flex: 0 0 auto;
}
.user-meta { min-width: 0; }
.user-meta .uname {
  font-weight: 600;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-sub {
  font-size: 11px;
  color: var(--ink-mute);
  line-height: 1.4;
}
.sub-exp { opacity: .9; }
.rail-foot-actions {
  display: flex;
  gap: 6px;
}
.rail-foot-actions .ghost,
.rail-foot-actions button { flex: 1; padding: 8px 10px !important; font-size: 12px; }

.workspace {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 12px 14px 14px;
  gap: 12px;
}
.page-pane {
  overflow: auto;
  height: 100%;
  padding-bottom: 20px;
  animation: fadeIn .3s var(--ease) both;
}

/* chat layout */
.chat-layout {
  display: flex;
  gap: 12px;
  height: 100%;
  min-height: 0;
  flex: 1;
}
.chat-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.glass-surface {
  background: rgba(255, 255, 255, 0.4);
  backdrop-filter: blur(var(--blur)) saturate(1.3);
  -webkit-backdrop-filter: blur(var(--blur)) saturate(1.3);
  border: 1px solid var(--glass-border);
  border-radius: 20px;
  box-shadow: var(--shadow-float);
}

.chat-scroll {
  flex: 1;
  overflow: auto;
  padding: 18px 16px 8px;
  min-height: 0;
}
.chat-welcome {
  text-align: center;
  padding: 48px 16px 24px;
  color: var(--ink-soft);
}
.chat-welcome h2 {
  margin: 0 0 8px;
  background: linear-gradient(135deg, var(--ink), var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.msg {
  display: flex;
  margin-bottom: 14px;
  animation: riseIn .28s var(--ease) both;
}
.msg-user { justify-content: flex-end; }
.msg-bot { justify-content: flex-start; }
.msg-bubble {
  max-width: min(720px, 92%);
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  padding: 12px 14px;
  box-shadow: var(--shadow-float);
}
.msg-user .msg-bubble {
  background: linear-gradient(135deg, rgba(107,124,255,.28), rgba(155,123,255,.28));
  border-color: rgba(107,124,255,.3);
}
.msg-error .msg-bubble,
.msg-bubble.msg-error {
  background: rgba(226, 85, 106, 0.14);
  border-color: rgba(226, 85, 106, 0.3);
}
.msg-text {
  color: var(--ink);
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}
.msg-time {
  margin-top: 6px;
  font-size: 11px;
  color: var(--ink-mute);
}
.msg-thumbs {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}
.msg-thumb {
  width: 56px;
  height: 56px;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid var(--glass-border-soft);
}
.msg-result .asset-card {
  margin-bottom: 10px;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--glass-border-soft);
  background: rgba(0,0,0,.03);
}
.msg-result .asset-card img,
.msg-result .asset-card video {
  width: 100%;
  max-height: 420px;
  object-fit: contain;
  display: block;
  background: #111;
}
.asset-actions {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 8px 12px;
  font-size: 13px;
}

/* composer */
.composer {
  padding: 10px 12px 12px;
  border-top: 1px solid var(--glass-border-soft);
  background: rgba(255,255,255,.25);
}
.composer-attach {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.attach-slot {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 96px;
  padding: 8px;
  border: 1px dashed var(--glass-border);
  border-radius: 12px;
  background: rgba(255,255,255,.3);
}
.attach-slot img {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: 8px;
}
.attach-label {
  font-size: 11px;
  color: var(--ink-mute);
}
.attach-clear {
  position: absolute;
  top: 4px;
  right: 4px;
  padding: 2px 8px !important;
  font-size: 14px !important;
  line-height: 1;
}
.composer-box {
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid var(--glass-border);
  border-radius: 18px;
  padding: 10px 12px;
  box-shadow: var(--shadow-float);
}
.composer-box textarea {
  width: 100%;
  min-height: 44px;
  max-height: 160px;
  resize: none;
  border: none !important;
  background: transparent !important;
  box-shadow: none !important;
  padding: 4px 4px 8px;
  font-size: 15px;
}
.composer-box textarea:focus {
  outline: none;
  box-shadow: none !important;
}
.composer-bar {
  display: flex;
  align-items: center;
  gap: 8px;
}
.composer-bar select {
  width: auto;
  min-width: 160px;
  max-width: 240px;
  padding: 8px 28px 8px 10px;
  font-size: 13px;
}
.composer-actions {
  margin-left: auto;
  display: flex;
  gap: 8px;
}
.composer-actions button { padding: 9px 16px !important; border-radius: 12px !important; }

/* guide dock */
.guide-dock {
  width: 300px;
  flex: 0 0 auto;
  max-height: 100%;
  overflow: auto;
  background: rgba(255, 255, 255, 0.4);
  backdrop-filter: blur(var(--blur));
  -webkit-backdrop-filter: blur(var(--blur));
  border: 1px solid var(--glass-border);
  border-radius: 18px;
  padding: 14px;
  box-shadow: var(--shadow-float);
  animation: fadeIn .25s var(--ease) both;
}
.guide-dock-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
.guide-dock img {
  width: 100%;
  border-radius: 12px;
  border: 1px solid var(--glass-border-soft);
  display: block;
}
.guide-fab {
  position: fixed;
  right: 18px;
  bottom: 110px;
  width: 42px;
  height: 42px;
  border-radius: 14px !important;
  padding: 0 !important;
  font-weight: 700;
  z-index: 20;
}

@media (max-width: 1100px) {
  .guide-dock { width: 240px; }
}
@media (max-width: 900px) {
  .rail {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    transform: translateX(0);
  }
  .rail.collapsed {
    width: 68px;
  }
  .workspace { padding-left: 80px; }
  .rail:not(.collapsed) ~ .workspace {
    /* sidebar overlays when expanded on small screens */
  }
  .guide-dock {
    position: fixed;
    right: 10px;
    top: 10px;
    bottom: 10px;
    width: min(300px, 85vw);
    z-index: 25;
  }
  .chat-layout { flex-direction: column; }
}

@media (max-width: 640px) {
  .workspace { padding-left: 76px; padding-right: 8px; }
  .composer-bar { flex-wrap: wrap; }
  .composer-bar select { max-width: 100%; flex: 1; }
}

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(107, 124, 255, 0.3); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: rgba(107, 124, 255, 0.5); }
