:root {
  --bg: #fff;
  --surface: #fff;
  --sidebar: #ece4ff;
  --sidebar-strong: #dfd2ff;
  --soft: #f7f6f9;
  --text: #24222a;
  --muted: #77727f;
  --line: #e6e3ea;
  --purple: #8247f5;
  --purple-2: #a081f7;
  --purple-soft: #eee6ff;
  --danger: #e95372;
  --success: #2ab673;
  --shadow: 0 18px 55px rgba(38, 25, 65, .18);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-width: 320px;
  color: var(--text);
  background: var(--bg);
  font: 14px/1.45 Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
button, input, textarea, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; }

body.dark {
  --bg: #111015;
  --surface: #19171f;
  --sidebar: #211c31;
  --sidebar-strong: #302641;
  --soft: #211f27;
  --text: #f5f2fa;
  --muted: #ada8b5;
  --line: #312e38;
  --purple-soft: #312452;
  --shadow: 0 18px 60px rgba(0, 0, 0, .4);
}

.app-shell { min-height: 100vh; }
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 30;
  display: flex;
  width: 230px;
  flex-direction: column;
  padding: 12px 12px 10px;
  overflow-y: auto;
  background: var(--sidebar);
  border-right: 1px solid rgba(82, 61, 120, .07);
}
.brand {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  height: 58px;
  color: transparent;
  background: linear-gradient(130deg, #7b45f5, #f06167);
  background-clip: text;
  -webkit-background-clip: text;
  font-size: 28px;
  font-weight: 900;
  letter-spacing: -3px;
  cursor: pointer;
}
.brand b { font-size: 45px; line-height: .9; }
.brand sup { margin: 2px 0 0 3px; font-size: 14px; }
.menu-search {
  display: grid;
  grid-template-columns: 18px 1fr auto;
  align-items: center;
  gap: 5px;
  height: 37px;
  margin-bottom: 9px;
  padding: 0 9px;
  color: #857e91;
  background: rgba(255, 255, 255, .22);
  border: 1px solid rgba(72, 53, 104, .12);
  border-radius: 6px;
  cursor: pointer;
}
.menu-search span:nth-child(2) { text-align: left; font-size: 12px; }
kbd { padding: 1px 5px; color: #8e86a0; border: 1px solid rgba(72, 53, 104, .13); border-radius: 4px; font-size: 10px; }
.nav-list { display: grid; gap: 3px; }
.nav-item, .bottom-item {
  display: grid;
  width: 100%;
  grid-template-columns: 23px 1fr auto;
  align-items: center;
  min-height: 41px;
  padding: 0 10px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  text-align: left;
  cursor: pointer;
}
.nav-item:hover, .nav-item.active, .bottom-item:hover, .bottom-item.active { background: rgba(125, 78, 244, .17); }
.nav-item strong, .bottom-item strong { font-size: 13px; font-weight: 650; }
.nav-icon { width: 18px; text-align: center; font-size: 15px; }
.nav-tail { color: #5f5a68; font-size: 17px; }
.mini-badge { padding: 2px 5px; border-radius: 4px; color: white; background: var(--purple); font-size: 9px; font-weight: 800; }
.sidebar-bottom { margin-top: auto; padding-top: 12px; }
.sidebar-bottom .bottom-item { min-height: 39px; }
.upgrade-row { border-bottom: 1px solid rgba(70, 47, 105, .1); margin-bottom: 5px; }
.legal { display: flex; gap: 10px; padding: 9px 9px 0; color: #716a7c; font-size: 10px; }
.legal a:hover { color: var(--purple); }

.page { min-height: 100vh; margin-left: 230px; }
.topbar {
  position: relative;
  z-index: 11;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 68px;
  padding: 0 16px;
  background: var(--bg);
}
.topbar-title { display: flex; align-items: center; gap: 8px; min-width: 0; }
.topbar h1 { margin: 0; font-size: 21px; font-weight: 500; letter-spacing: -.4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-actions { display: flex; align-items: center; gap: 16px; }
.icon-btn, .mobile-menu {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
}
.icon-btn:hover { background: var(--soft); }
.mobile-menu { display: none; font-size: 20px; }
.primary-btn, .generate-btn {
  border: 0;
  border-radius: 7px;
  color: white;
  background: linear-gradient(130deg, var(--purple), #925cf7);
  box-shadow: 0 7px 18px rgba(130, 71, 245, .2);
  cursor: pointer;
  font-weight: 650;
}
.primary-btn { padding: 8px 17px; }
.primary-btn:hover, .generate-btn:hover { filter: brightness(1.05); transform: translateY(-1px); }
.secondary-btn { padding: 8px 14px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); cursor: pointer; }

/* Home */
.home-content { padding: 0 15px 45px; }
.tool-showcase { position: relative; }
.tool-rail { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(290px, 1fr); gap: 14px; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; }
.tool-rail::-webkit-scrollbar { display: none; }
.tool-card { min-width: 0; scroll-snap-align: start; cursor: pointer; }
.tool-thumb { height: 236px; overflow: hidden; border-radius: 10px; background: var(--soft); }
.tool-thumb img, .tool-thumb video { display: block; width: 100%; height: 100%; object-fit: cover; }
.tool-card h3 { margin: 11px 13px 4px; font-size: 15px; }
.tool-card p { margin: 0 13px; color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rail-arrow { position: absolute; z-index: 2; top: 104px; width: 39px; height: 39px; border: 0; border-radius: 50%; color: white; background: rgba(27, 24, 33, .68); cursor: pointer; font-size: 23px; }
.rail-arrow.left { left: 8px; }
.rail-arrow.right { right: 8px; }
.feed-head { display: flex; align-items: flex-end; justify-content: space-between; padding: 34px 0 15px; }
.feed-head h2 { margin: 0; font-size: 20px; font-weight: 600; }
.filter-group { display: flex; padding: 3px; background: var(--soft); border-radius: 8px; }
.filter-btn { padding: 6px 14px; border: 0; border-radius: 6px; color: var(--muted); background: transparent; cursor: pointer; font-size: 12px; }
.filter-btn.active { color: white; background: var(--purple); }
.masonry { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; margin-top: 30px; }
.masonry-column { display: flex; min-width: 0; flex-direction: column; gap: 8px; }
.feed-card { position: relative; overflow: hidden; border-radius: 9px; background: var(--soft); cursor: pointer; }
.feed-card img, .feed-card video { display: block; width: 100%; aspect-ratio: var(--ratio); object-fit: cover; }
.feed-card::after { content: ""; position: absolute; inset: 55% 0 0; background: linear-gradient(transparent, rgba(7, 6, 10, .76)); }
.feed-hover { position: absolute; z-index: 2; inset: 0; display: grid; place-items: center; visibility: hidden; opacity: 0; background: rgba(12, 9, 18, .32); transition: opacity .16s ease, visibility .16s ease; }
.feed-hover button { padding: 7px 13px; color: white; background: var(--purple); border: 0; border-radius: 6px; cursor: pointer; font-size: 12px; font-weight: 650; box-shadow: 0 7px 18px rgba(0,0,0,.22); }
.feed-card:hover .feed-hover { visibility: visible; opacity: 1; }
.feed-label { position: absolute; z-index: 3; inset: auto 10px 10px; color: white; font-size: 12px; font-weight: 700; }
.empty { display: none; padding: 80px 0; color: var(--muted); text-align: center; }

/* Mega navigation */
.mega-menu {
  position: fixed;
  z-index: 25;
  top: 20px;
  left: 230px;
  width: min(780px, calc(100vw - 250px));
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  padding: 12px;
  visibility: hidden;
  opacity: 0;
  transform: translateX(-8px);
  color: var(--text);
  background: var(--sidebar);
  border: 1px solid rgba(102, 76, 145, .1);
  border-radius: 0 10px 10px 0;
  box-shadow: var(--shadow);
  transition: .17s ease;
}
.mega-menu.open { visibility: visible; opacity: 1; transform: translateX(0); }
.mega-head { display: flex; align-items: center; justify-content: space-between; padding: 5px 8px 11px; }
.mega-head h3 { margin: 0; font-size: 14px; }
.mega-close { border: 0; background: transparent; cursor: pointer; font-size: 20px; }
.mega-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px 12px; }
.mega-card { display: grid; grid-template-columns: 39px 1fr; gap: 7px; align-items: center; min-height: 58px; padding: 8px; border-radius: 7px; }
.mega-card:hover { background: rgba(255, 255, 255, .42); }
.mega-card-icon { display: grid; width: 39px; height: 39px; place-items: center; border-radius: 7px; background: rgba(255, 255, 255, .55); font-size: 19px; }
.mega-card b { display: block; margin-bottom: 1px; font-size: 12px; }
.mega-card small { display: block; color: var(--muted); font-size: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Workbench */
.workbench { display: grid; grid-template-columns: minmax(510px, 38%) 1fr; min-height: calc(100vh - 68px); border-top: 1px solid transparent; }
.builder-panel { position: relative; display: flex; min-width: 0; flex-direction: column; padding: 5px 18px 86px 16px; border-right: 1px solid var(--line); }
.result-panel { min-width: 0; padding: 4px 20px 50px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 14px; }
.field { min-width: 0; }
.field label { display: block; margin-bottom: 6px; font-size: 13px; }
.control, select, input[type="text"], input[type="email"], input[type="password"], input[type="number"] {
  width: 100%;
  height: 38px;
  padding: 0 12px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 5px;
  outline: 0;
}
.segmented { display: grid; grid-template-columns: repeat(var(--segments, 3), 1fr); gap: 7px; margin: 4px 0 16px; }
.segment { min-height: 45px; padding: 7px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--soft); cursor: pointer; font-size: 12px; }
.segment.active { color: white; background: var(--purple); border-color: var(--purple); }
.upload-zone {
  display: grid;
  min-height: 205px;
  place-items: center;
  padding: 20px;
  color: var(--muted);
  background: var(--surface);
  border: 1px dashed #cbc6d1;
  border-radius: 6px;
  text-align: center;
  cursor: pointer;
}
.upload-zone.compact { min-height: 145px; }
.upload-zone:hover { color: var(--purple); border-color: var(--purple); background: var(--purple-soft); }
.upload-icon { display: block; margin-bottom: 4px; color: var(--text); font-size: 31px; font-weight: 300; }
.upload-zone small { display: block; font-size: 11px; }
.upload-preview { width: 100%; height: 160px; object-fit: contain; border-radius: 6px; }
.examples { display: flex; align-items: center; gap: 7px; margin: 10px 0 15px; }
.examples span { margin-right: 5px; }
.examples img { width: 41px; height: 41px; object-fit: cover; border-radius: 4px; cursor: pointer; }
.textarea-wrap { position: relative; margin-bottom: 13px; }
.textarea-wrap label { display: block; margin: 0 0 -19px 12px; color: var(--muted); font-size: 11px; transform: translateY(8px); pointer-events: none; }
textarea { width: 100%; min-height: 142px; padding: 25px 12px 12px; resize: vertical; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: 6px; outline: 0; }
textarea:focus, input:focus, select:focus { border-color: var(--purple); box-shadow: 0 0 0 2px rgba(130, 71, 245, .08); }
.duration-row { margin: 2px 0 16px; }
.duration-row input { width: 100%; accent-color: var(--purple); }
.duration-labels { display: flex; justify-content: space-between; color: var(--muted); font-size: 11px; }
.option-row { display: flex; align-items: center; justify-content: space-between; min-height: 48px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 6px; }
.switch { position: relative; width: 40px; height: 22px; border: 0; border-radius: 999px; background: #c9c5ce; cursor: pointer; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: white; transition: .2s; }
.switch.on { background: var(--purple); }
.switch.on::after { transform: translateX(18px); }
.checkbox-row { display: flex; align-items: center; gap: 8px; margin: 12px 0; color: var(--muted); }
.checkbox-row input { accent-color: var(--purple); }
.generate-wrap { position: absolute; inset: auto 18px 16px 16px; }
.plan-nudge { display: flex; justify-content: space-between; margin-bottom: 7px; padding: 10px 12px; color: #7d55d7; background: var(--purple-soft); border: 1px solid #d8c7ff; border-radius: 6px; font-size: 11px; }
.generate-btn { width: 100%; min-height: 48px; font-size: 17px; }
.generate-btn:disabled { opacity: .58; cursor: default; transform: none; }
.tabs { display: flex; height: 42px; gap: 32px; border-bottom: 1px solid var(--line); }
.tab { position: relative; padding: 0 0 9px; border: 0; color: var(--text); background: transparent; cursor: pointer; font-size: 13px; }
.tab.active { color: var(--purple); }
.tab.active::after { content: ""; position: absolute; inset: auto 0 -1px; height: 2px; background: var(--purple); }
.tab-pane { padding: 28px 0; }
.guide-title { margin: 8px 0 27px; text-align: center; font-size: 18px; }
.guide-visual { display: block; width: min(800px, 76%); max-height: 450px; margin: 0 auto 28px; object-fit: cover; border-radius: 7px; }
.guide-section h3 { margin: 20px 0 12px; padding-bottom: 7px; color: var(--purple); border-bottom: 2px solid var(--purple); font-size: 14px; }
.guide-step { display: grid; grid-template-columns: 28px 1fr; gap: 8px; margin-bottom: 14px; padding: 14px; background: var(--soft); border: 1px solid var(--line); border-radius: 7px; }
.guide-step b:first-child { display: grid; width: 24px; height: 24px; place-items: center; color: white; background: var(--purple); border-radius: 50%; font-size: 11px; }
.guide-step strong { display: block; margin-bottom: 5px; }
.guide-step p { margin: 0; color: var(--muted); font-size: 12px; }
.result-empty { display: grid; min-height: 55vh; place-items: center; color: var(--muted); text-align: center; }
.empty-illustration { width: 96px; height: 76px; margin: auto; border: 2px solid var(--line); border-radius: 12px; transform: rotate(-4deg); }
.api-box { padding: 20px; background: #191621; color: #ece7f6; border-radius: 8px; overflow-x: auto; white-space: pre; font: 12px/1.7 ui-monospace, SFMono-Regular, Consolas, monospace; }

/* Upgrade & documents */
.pricing-page { padding: 20px 6vw 70px; }
.pricing-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; max-width: 1210px; margin: 5px auto 38px; }
.price-card { display: flex; min-height: 530px; flex-direction: column; padding: 18px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; }
.price-card.featured { border-color: var(--purple); box-shadow: 0 12px 35px rgba(130, 71, 245, .12); }
.price-card h2 { margin: 0 0 8px; font-weight: 500; }
.price { margin-bottom: 14px; font-size: 26px; }
.price small { font-size: 12px; }
.price-card p, .price-card li { color: var(--muted); font-size: 12px; }
.price-card ul { flex: 1; padding-left: 17px; line-height: 2; }
.price-card .primary-btn { width: 100%; margin: 8px 0 10px; }
.compare { max-width: 1210px; margin: auto; }
.compare h2 { text-align: center; }
.compare table { width: 100%; border-collapse: collapse; background: var(--surface); }
.compare th, .compare td { padding: 15px; border: 1px solid var(--line); text-align: center; }
.doc-page { max-width: 980px; margin: auto; padding: 28px 30px 80px; }
.doc-page h1 { font-size: 30px; }
.doc-page h2 { margin-top: 32px; }
.doc-page p, .doc-page li { color: var(--muted); line-height: 1.8; }

/* Modals */
.modal-layer { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; padding: 18px; visibility: hidden; opacity: 0; background: rgba(18, 15, 24, .58); transition: .18s; }
.modal-layer.open { visibility: visible; opacity: 1; }
.dialog { position: relative; width: min(450px, 100%); max-height: calc(100vh - 36px); overflow-y: auto; padding: 24px; background: var(--surface); border-radius: 10px; box-shadow: var(--shadow); transform: translateY(8px) scale(.98); transition: .18s; }
.modal-layer.open .dialog { transform: translateY(0) scale(1); }
.dialog.wide { width: min(850px, 100%); }
.dialog-close { position: absolute; top: 9px; right: 10px; width: 31px; height: 31px; border: 0; border-radius: 50%; background: transparent; cursor: pointer; font-size: 22px; }
.dialog-close:hover { background: var(--soft); }
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; margin: -8px 0 17px; border-bottom: 1px solid var(--line); }
.auth-tab { padding: 12px; border: 0; border-bottom: 2px solid transparent; background: transparent; cursor: pointer; }
.auth-tab.active { color: var(--purple); border-bottom-color: var(--purple); }
.dialog h2 { margin: 0 0 14px; text-align: center; font-size: 18px; }
.social-btn { display: flex; width: 100%; justify-content: center; gap: 10px; margin: 10px 0; padding: 10px; border: 1px solid var(--line); border-radius: 5px; background: var(--surface); cursor: pointer; }
.or { display: flex; align-items: center; gap: 12px; margin: 17px 0; color: var(--muted); font-size: 11px; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.auth-form { display: grid; gap: 12px; }
.auth-form .primary-btn { width: 100%; margin-top: 4px; }
.text-link { border: 0; color: var(--purple); background: transparent; cursor: pointer; text-align: right; font-size: 12px; }
.agree { display: flex; gap: 8px; align-items: flex-start; color: var(--muted); font-size: 11px; }
.language-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.language-btn { padding: 11px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); cursor: pointer; text-align: left; }
.language-btn.active, .language-btn:hover { color: var(--purple); border-color: var(--purple); background: var(--purple-soft); }
.search-dialog input { height: 46px; margin-bottom: 12px; }
.search-results { display: grid; max-height: 54vh; overflow-y: auto; gap: 5px; }
.search-result { display: grid; grid-template-columns: 33px 1fr auto; align-items: center; gap: 8px; padding: 9px; border: 0; border-radius: 7px; background: transparent; cursor: pointer; text-align: left; }
.search-result:hover { background: var(--soft); }
.search-result small { color: var(--muted); }
.support-menu { display: grid; gap: 8px; }
.support-choice { padding: 15px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); text-align: left; cursor: pointer; }
.support-choice:hover { border-color: var(--purple); }
.preview-dialog { display: grid; grid-template-columns: 1fr .82fr; width: min(820px, 100%); padding: 0; overflow: hidden; }
.preview-image { min-height: 470px; background-size: cover; background-position: center; }
.preview-copy { display: flex; flex-direction: column; justify-content: center; padding: 35px; }
.preview-copy h2 { text-align: left; font-size: 24px; }
.preview-copy p { color: var(--muted); }
.toast { position: fixed; z-index: 100; left: 50%; bottom: 24px; padding: 10px 16px; color: white; background: #211b2c; border-radius: 7px; box-shadow: var(--shadow); opacity: 0; transform: translate(-50%, 15px); pointer-events: none; transition: .2s; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.scrim { display: none; }

@media (min-width: 1500px) {
  .tool-rail { grid-auto-columns: calc((100vw - 230px - 88px) / 5); }
}
@media (max-width: 1180px) {
  .masonry { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .workbench { grid-template-columns: minmax(460px, 44%) 1fr; }
  .pricing-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 880px) {
  .sidebar { transform: translateX(-102%); transition: transform .22s; box-shadow: var(--shadow); }
  .sidebar.open { transform: translateX(0); }
  .page { margin-left: 0; }
  .mobile-menu { display: grid; }
  .scrim { position: fixed; inset: 0; z-index: 28; background: rgba(11, 8, 17, .42); }
  .scrim.show { display: block; }
  .mega-menu { z-index: 35; left: 230px; width: min(650px, calc(100vw - 245px)); }
  .workbench { grid-template-columns: 1fr; }
  .builder-panel { min-height: calc(100vh - 68px); border-right: 0; }
  .result-panel { border-top: 1px solid var(--line); }
  .guide-visual { width: 90%; }
}
@media (max-width: 620px) {
  .topbar { height: 61px; padding: 0 11px; }
  .topbar h1 { font-size: 17px; }
  .top-actions { gap: 3px; }
  .primary-btn { padding: 7px 10px; font-size: 12px; }
  .home-content { padding: 0 10px 35px; }
  .tool-rail { grid-auto-columns: 82vw; }
  .tool-thumb { height: 205px; }
  .rail-arrow { display: none; }
  .feed-head { align-items: flex-start; gap: 12px; }
  .masonry { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; }
  .mega-menu { inset: 64px 8px auto; width: auto; max-height: calc(100vh - 76px); border-radius: 10px; }
  .mega-grid { grid-template-columns: 1fr; }
  .workbench { min-height: calc(100vh - 61px); }
  .builder-panel { padding: 4px 11px 88px; }
  .result-panel { padding: 4px 11px 35px; }
  .field-row { grid-template-columns: 1fr; gap: 10px; }
  .segmented { grid-template-columns: repeat(2, 1fr); }
  .upload-zone { min-height: 180px; }
  .generate-wrap { inset: auto 11px 13px; }
  .tabs { gap: 24px; }
  .guide-visual { width: 100%; }
  .pricing-page { padding: 10px 12px 55px; }
  .pricing-grid { grid-template-columns: 1fr; }
  .price-card { min-height: auto; }
  .compare { overflow-x: auto; }
  .compare table { min-width: 650px; }
  .preview-dialog { grid-template-columns: 1fr; }
  .preview-image { min-height: 310px; }
  .preview-copy { padding: 24px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
