:root {
  --bg: #f6f5f2;
  --surface: #ffffff;
  --surface-2: #efeee9;
  --text: #1a1917;
  --muted: #837f76;
  --border: #e3e0d8;
  --accent: #e5175f;
  --accent-2: #ff5c8a;
  --accent-soft: rgba(229, 23, 95, 0.08);
  --shadow: 0 8px 30px rgba(20, 18, 15, 0.08);
}
.dark {
  --bg: #0e0d0f;
  --surface: #17161a;
  --surface-2: #201e24;
  --text: #f2efec;
  --muted: #8a8690;
  --border: #2a282f;
  --accent: #ff2d76;
  --accent-2: #ff6ea3;
  --accent-soft: rgba(255, 45, 118, 0.12);
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Bricolage Grotesque", sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}
.dark body, body {
  background:
    radial-gradient(circle at 12% -5%, var(--accent-soft), transparent 45%),
    radial-gradient(circle at 95% 8%, rgba(255,110,163,0.06), transparent 40%),
    var(--bg);
  min-height: 100vh;
}

/* shell */
.shell { display: flex; min-height: 100vh; }

/* sidebar */
.sidebar {
  width: 250px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 22px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand { display: flex; align-items: center; gap: 12px; margin-bottom: 34px; padding: 0 6px; }
.brand-mark {
  width: 40px; height: 40px; border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff; font-weight: 800; font-size: 22px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 6px 18px var(--accent-soft);
}
.brand-name { font-weight: 700; font-size: 18px; letter-spacing: -0.5px; }
.brand-tag { font-size: 11px; color: var(--muted); font-family: "JetBrains Mono", monospace; letter-spacing: 1px; text-transform: uppercase; }

.nav { display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px; border-radius: 12px;
  background: none; border: none; cursor: pointer;
  color: var(--muted); font-family: inherit; font-size: 15px; font-weight: 500;
  transition: all .18s ease; text-align: left; width: 100%;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav-new {
  margin-top: 14px;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px; border-radius: 12px; cursor: pointer;
  background: none; border: 1px dashed var(--border); color: var(--muted);
  font-family: inherit; font-size: 14px; font-weight: 500; transition: all .18s;
}
.nav-new:hover { border-color: var(--accent); color: var(--accent); }

.sidebar-foot { margin-top: auto; padding-top: 18px; }
.counter { font-size: 11px; color: var(--muted); font-family: "JetBrains Mono", monospace; margin-bottom: 14px; padding-left: 6px; }
.profile { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 12px; background: var(--surface-2); }
.avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff; font-weight: 700; font-size: 13px;
  display: flex; align-items: center; justify-content: center;
}
.profile span { font-size: 13px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.backdrop { display: none; }

/* main */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  display: flex; align-items: center; gap: 14px;
  padding: 16px 28px; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(12px);
}
.topbar-title { font-weight: 600; font-size: 15px; flex: 1; }
.icon-btn {
  background: none; border: none; cursor: pointer; color: var(--muted);
  padding: 8px; border-radius: 10px; transition: all .18s; display: flex;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.mobile-only { display: none; }

.content { flex: 1; padding: 32px 28px; max-width: 1200px; width: 100%; margin: 0 auto; }

/* studio */
.studio { max-width: 780px; margin: 0 auto; }
.hero-title { font-size: clamp(30px, 5vw, 46px); font-weight: 700; letter-spacing: -1.5px; margin: 12px 0 6px; }
.hero-sub { color: var(--muted); font-size: 16px; margin: 0 0 28px; }

.mode-toggle {
  display: inline-flex; gap: 4px; background: var(--surface-2);
  padding: 4px; border-radius: 14px; margin-bottom: 20px;
}
.pill {
  padding: 9px 20px; border-radius: 10px; border: none; cursor: pointer;
  background: none; color: var(--muted); font-family: inherit; font-weight: 600; font-size: 14px;
  transition: all .2s;
}
.pill-active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

.composer {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 22px; padding: 8px; box-shadow: var(--shadow);
}
.composer-input {
  width: 100%; border: none; outline: none; resize: none;
  background: transparent; color: var(--text);
  font-family: inherit; font-size: 17px; padding: 16px 16px 8px;
  line-height: 1.5;
}
.composer-input::placeholder { color: var(--muted); }
.composer-controls {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  padding: 8px 8px 8px; border-top: 1px solid var(--border);
}
.ctrl-select {
  padding: 8px 12px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text); font-family: inherit;
  font-size: 13px; cursor: pointer; outline: none;
}
.ctrl-select:focus { border-color: var(--accent); }
.gen-btn {
  margin-left: auto; display: flex; align-items: center; gap: 6px;
  padding: 10px 22px; border-radius: 12px; border: none; cursor: pointer;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff; font-family: inherit; font-weight: 700; font-size: 14px;
  transition: transform .15s, box-shadow .2s; box-shadow: 0 6px 20px var(--accent-soft);
}
.gen-btn:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 10px 26px var(--accent-soft); }
.gen-btn:disabled { opacity: .8; cursor: default; }
.gen-busy { background: var(--surface-2); color: var(--accent); animation: pulse 1.4s infinite; }
@keyframes pulse { 0%,100% { opacity: .7; } 50% { opacity: 1; } }

.chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 10px 12px; }
.chip {
  padding: 6px 12px; border-radius: 20px; border: 1px solid var(--border);
  background: none; color: var(--muted); font-family: inherit; font-size: 12px;
  cursor: pointer; transition: all .15s;
}
.chip:hover { border-color: var(--accent); color: var(--accent); }

/* preview */
.preview {
  margin-top: 24px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 22px; overflow: hidden; box-shadow: var(--shadow);
}
.preview-media { width: 100%; background: var(--surface-2); }
.preview-media img { width: 100%; display: block; }
.preview-media > div { aspect-ratio: 16/9; }
.preview-actions { display: flex; flex-wrap: wrap; gap: 8px; padding: 14px; }

.act {
  display: flex; align-items: center; gap: 6px;
  padding: 9px 16px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text); cursor: pointer;
  font-family: inherit; font-size: 13px; font-weight: 600; transition: all .15s;
}
.act:hover { border-color: var(--accent); color: var(--accent); }
.act.ghost { background: none; }
.act-danger:hover { border-color: #e5484d; color: #e5484d; }

.shimmer { height: 380px; display: flex; align-items: center; justify-content: center; }
.shimmer-inner {
  color: var(--accent); font-family: "JetBrains Mono", monospace; font-size: 14px;
  animation: pulse 1.4s infinite;
}
.shimmer { position: relative; overflow: hidden; }
.shimmer::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(110deg, transparent 20%, var(--accent-soft) 50%, transparent 80%);
  animation: slide 1.6s infinite;
}
@keyframes slide { to { transform: translateX(100%); } }

/* pages */
.page {}
.page-head { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 26px; }
.page-title { font-size: 30px; font-weight: 700; letter-spacing: -1px; margin: 0; }
.filters { display: flex; gap: 8px; margin-left: auto; flex-wrap: wrap; align-items: center; }
.search {
  padding: 9px 14px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font-family: inherit; font-size: 13px;
  outline: none; min-width: 180px;
}
.search:focus { border-color: var(--accent); }
.fbtn {
  padding: 8px 14px; border-radius: 10px; border: 1px solid var(--border);
  background: none; color: var(--muted); font-family: inherit; font-size: 13px;
  font-weight: 600; cursor: pointer; transition: all .15s;
}
.fbtn-active { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.back { background: none; border: none; color: var(--muted); cursor: pointer; font-family: inherit; font-size: 14px; font-weight: 600; }
.back:hover { color: var(--accent); }

/* gallery */
.gallery {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 18px;
}
.gcard {
  background: var(--surface); border: 1px solid var(--border); border-radius: 18px;
  overflow: hidden; cursor: pointer; transition: transform .18s, box-shadow .2s;
}
.gcard:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.gcard-media { position: relative; aspect-ratio: 4/3; background: var(--surface-2); }
.gcard-media img { width: 100%; height: 100%; object-fit: cover; }
.badge {
  position: absolute; top: 8px; left: 8px; padding: 3px 8px; border-radius: 6px;
  background: rgba(0,0,0,.6); color: #fff; font-family: "JetBrains Mono", monospace;
  font-size: 10px; font-weight: 700; letter-spacing: .5px;
}
.gcard-body { padding: 12px 14px; }
.gcard-prompt { font-size: 13px; margin: 0 0 4px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.gcard-meta { font-size: 11px; color: var(--muted); font-family: "JetBrains Mono", monospace; margin: 0; }

/* folders */
.folder-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 18px; }
.folder-card { background: var(--surface); border: 1px solid var(--border); border-radius: 18px; overflow: hidden; }
.folder-cover { aspect-ratio: 16/9; background: var(--surface-2); cursor: pointer; }
.folder-cover img { width: 100%; height: 100%; object-fit: cover; }
.folder-empty { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; }
.folder-info { display: flex; align-items: center; justify-content: space-between; padding: 14px; }
.folder-name { font-weight: 600; font-size: 15px; margin: 0; }
.folder-count { font-size: 12px; color: var(--muted); margin: 2px 0 0; font-family: "JetBrains Mono", monospace; }

/* empty */
.empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 80px 20px; color: var(--text); text-align: center;
}

/* modal */
.overlay {
  position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,.6); backdrop-filter: blur(6px); padding: 20px;
  animation: fade .2s ease;
}
@keyframes fade { from { opacity: 0; } }
.modal {
  background: var(--surface); border: 1px solid var(--border); border-radius: 22px;
  max-width: 760px; width: 100%; max-height: 90vh; overflow: auto; position: relative;
  box-shadow: var(--shadow);
}
.modal-close {
  position: absolute; top: 14px; right: 14px; z-index: 2;
  background: rgba(0,0,0,.5); color: #fff; border: none; border-radius: 10px;
  padding: 8px; cursor: pointer; display: flex;
}
.modal-media { background: var(--surface-2); }
.modal-media img { width: 100%; display: block; }
.modal-media > div { aspect-ratio: 16/9; }
.modal-info { padding: 20px; }
.badge-inline {
  display: inline-block; padding: 4px 10px; border-radius: 6px;
  background: var(--accent-soft); color: var(--accent);
  font-family: "JetBrains Mono", monospace; font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .5px;
}
.modal-prompt { font-size: 18px; margin: 12px 0 6px; line-height: 1.4; }
.modal-meta { font-size: 12px; color: var(--muted); font-family: "JetBrains Mono", monospace; margin: 0 0 18px; }
.modal-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.mini-modal {
  background: var(--surface); border: 1px solid var(--border); border-radius: 20px;
  padding: 24px; max-width: 360px; width: 100%; box-shadow: var(--shadow);
}
.mini-title { margin: 0 0 16px; font-size: 20px; font-weight: 700; }
.mini-input {
  width: 100%; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text); font-family: inherit; font-size: 15px;
  outline: none; margin-bottom: 16px;
}
.mini-input:focus { border-color: var(--accent); }
.mini-actions { display: flex; justify-content: flex-end; gap: 8px; }

/* scrub */
.scrub { transition: background .15s; }

/* toast */
.toast {
  position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 12px 22px; border-radius: 12px;
  font-size: 14px; font-weight: 600; z-index: 200; box-shadow: var(--shadow);
  animation: toastin .3s ease;
}
@keyframes toastin { from { opacity: 0; transform: translate(-50%, 12px); } }

/* footer */
.foot {
  display: flex; justify-content: space-between; align-items: center;
  padding: 20px 28px; border-top: 1px solid var(--border);
  font-size: 13px; color: var(--muted); max-width: 1200px; width: 100%; margin: 0 auto;
}
.foot a { color: var(--accent); text-decoration: none; font-weight: 600; }
.foot a:hover { text-decoration: underline; }

/* stagger entrance */
.stagger { animation: rise .5s ease both; animation-delay: var(--d, 0ms); }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } }

/* responsive */
@media (max-width: 820px) {
  .sidebar {
    position: fixed; left: 0; top: 0; z-index: 90;
    transform: translateX(-100%); transition: transform .25s ease;
    box-shadow: var(--shadow);
  }
  .sidebar.open { transform: translateX(0); }
  .backdrop { display: block; position: fixed; inset: 0; z-index: 80; background: rgba(0,0,0,.4); }
  .mobile-only { display: flex; }
  .content { padding: 22px 16px; }
  .topbar { padding: 14px 16px; }
  .gen-btn { margin-left: 0; flex: 1; justify-content: center; }
  .composer-controls .ctrl-select { flex: 1; }
  .foot { padding: 18px 16px; }
}