:root{
  --bg:#f7f8fb;
  --panel:#ffffff;
  --panel2:#f3f4f6;
  --text:#0f172a;
  --muted:#6b7280;
  --border:#e5e7eb;
  --accent:#111827;
  --accent2:#0f172a;
  --danger:#dc2626;
  --radius:12px;
  --shadow:0 12px 40px rgba(15,23,42,.08);
  color-scheme: light;
}

*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji","Segoe UI Emoji";
  background:var(--bg);
  color:var(--text);
}

a{color:inherit;text-decoration:none}

.hidden{display:none!important}

.app{
  display:grid;
  grid-template-columns:260px 1fr;
  min-height:100vh;
}

.sidebar{
  background:linear-gradient(180deg,var(--panel),var(--panel2));
  border-right:1px solid var(--border);
  padding:14px;
  display:flex;
  flex-direction:column;
  gap:12px;
  position:sticky;
  top:0;
  height:100vh;
  align-self:start;
}

.brand{display:flex;align-items:center;gap:10px;padding:10px 12px;border:1px solid var(--border);border-radius:var(--radius);background:var(--panel2)}
.brand__dot{width:12px;height:12px;border-radius:50%;background:linear-gradient(135deg,var(--accent),#334155)}
.brand__name{font-weight:700;letter-spacing:.2px}

.nav{display:flex;flex-direction:column;gap:6px}
.nav__item{
  display:flex;
  align-items:center;
  gap:10px;
  padding:9px 10px;
  border-radius:10px;
  border:1px solid transparent;
  color:var(--muted);
  transition:all .12s ease;
  font-weight:600;
  line-height:1.2;
  background:transparent;
}
.nav__item:hover{background:var(--panel2);color:var(--text);border-color:var(--border)}
.nav__item.is-active{background:#eef2f7;color:var(--text);border-color:var(--border)}
.nav__icon svg{width:17px;height:17px;stroke:currentColor}
.nav__label{flex:1;min-width:0}

.sidebar__new{
  width:100%;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:8px;
  border:1px solid var(--border);
  background:var(--panel);
  color:var(--text);
  padding:10px 12px;
  border-radius:10px;
  cursor:pointer;
  font-weight:650;
  transition:all .12s ease;
  box-shadow:0 6px 18px rgba(15,23,42,.06);
}
.sidebar__new:hover{background:var(--panel2);border-color:#d1d5db}

.sidebar__section{display:flex;flex-direction:column;gap:8px;min-height:0}
.sidebar__sectionTitle{color:var(--muted);font-size:12px;padding:0 4px;font-weight:600;letter-spacing:.2px}
.convos{display:flex;flex-direction:column;gap:6px;overflow:auto;min-height:0}
.convo{
  width:100%;
  font: inherit;
  text-align:left;
  border:1px solid var(--border);
  background:var(--panel);
  display:flex;
  gap:8px;
  align-items:center;
  padding:9px 10px;
  border-radius:10px;
  color:var(--muted);
  cursor:pointer;
  transition:all .12s ease;
}
.convo:hover{background:var(--panel2);color:var(--text)}
.convo.is-active{background:#eef2f7;border-color:#d0d7e2;color:var(--text)}
.convo__title{flex:1;min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.convo__model{font-size:11px;color:var(--muted);border:1px solid var(--border);padding:2px 8px;border-radius:999px;background:var(--panel2)}

.sidebar__footer{margin-top:auto}
.user{display:flex;align-items:center;justify-content:space-between;gap:10px;padding:8px 10px;border:1px solid var(--border);border-radius:12px;background:var(--panel2);margin-bottom:10px}
.user__name{min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;font-size:12px;color:var(--text)}
.user__link{font-size:12px;color:var(--muted)}
.user__link:hover{color:var(--text)}
.muted{color:var(--muted);font-size:12px}

.main{
  display:flex;
  flex-direction:column;
  padding:20px 22px 26px;
  background:var(--bg);
}

.page{max-width:1100px;width:100%;margin:0 auto;display:flex;flex-direction:column;gap:14px}
.page--wide{max-width:1200px}
.page__header{display:flex;flex-direction:column;gap:6px}
.page__headerRow{display:flex;align-items:center;justify-content:space-between;gap:10px;flex-wrap:wrap}
.page__title{margin:0;font-size:24px;font-weight:700;letter-spacing:-.2px}
.page__subtitle{color:var(--muted);font-size:13px;margin:0}
.page__subtitle a{
  color:inherit;
  text-decoration:underline;
  text-decoration-color:var(--muted);
  text-decoration-thickness:1px;
  transition:color .12s ease,text-decoration-color .12s ease;
}
.page__subtitle a:hover{
  color:#4b5563;
  text-decoration-color:#4b5563;
}
.page__body{display:flex;flex-direction:column;gap:12px}

.card{
  border:1px solid var(--border);
  border-radius:var(--radius);
  background:var(--panel);
  box-shadow:var(--shadow);
  padding:14px;
  display:flex;
  flex-direction:column;
  gap:12px;
  max-width:420px;
}

.loginOption{display:flex;align-items:center;justify-content:center;gap:10px;font-weight:600}
.loginOption__icon{width:20px;height:20px;display:block}

.model{display:flex;align-items:center;gap:8px}
.model__label{color:var(--muted);font-size:12px}
.model__select{
  border:1px solid var(--border);
  background:var(--panel);
  color:var(--text);
  padding:8px 10px;
  border-radius:10px;
  outline:none;
}

.chat{
  border:1px solid var(--border);
  border-radius:var(--radius);
  background:var(--panel);
  box-shadow:var(--shadow);
  display:flex;
  flex-direction:column;
  min-height:68vh;
}
.chat--home{min-height:auto}
.chat--home .chat__messages{
  flex:0 1 auto;
  min-height:160px;
  max-height:60vh;
}

.chat__messages{
  padding:16px 16px 10px;
  display:flex;
  flex-direction:column;
  gap:12px;
  overflow:auto;
  flex:1;
}

.chat__composer{
  padding:12px;
  border-top:1px solid var(--border);
  background:var(--panel2);
  border-bottom-left-radius:var(--radius);
  border-bottom-right-radius:var(--radius);
}

.attachments{display:flex;flex-wrap:wrap;gap:8px;margin-bottom:10px}
.chip{display:inline-flex;align-items:center;gap:8px;border:1px solid var(--border);background:var(--panel);padding:7px 10px;border-radius:999px;color:var(--text);max-width:100%}
.chip__name{max-width:340px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.chip__x{border:none;background:transparent;color:var(--muted);cursor:pointer;padding:0 2px;font-size:14px}
.chip__x:hover{color:var(--text)}

.composer{display:flex;gap:10px;align-items:flex-end}

.composer__input{
  flex:1;
  resize:none;
  border:1px solid var(--border);
  border-radius:10px;
  padding:10px 12px;
  background:var(--panel);
  color:var(--text);
  outline:none;
  line-height:1.35;
  min-height:44px;
}

.composer__btn{
  display:inline-flex;
  align-items:center;
  gap:8px;
  border:1px solid var(--border);
  background:var(--panel);
  color:var(--text);
  padding:9px 12px;
  border-radius:10px;
  cursor:pointer;
  transition:all .12s ease;
}
.composer__btn:hover{background:var(--panel2);border-color:#d1d5db}
.composer__btn--primary{border-color:var(--accent);background:var(--accent);color:#f8fafc}
.composer__btn--primary:hover{filter:brightness(0.98)}
.composer__btn--danger{border-color:rgba(220,38,38,.3);background:#fff1f2;color:#b91c1c}
.composer__btn--danger:hover{background:#ffe4e6}

.btn__icon{display:inline-flex;align-items:center;justify-content:center;width:16px;height:16px;color:inherit}
.btn__icon svg{width:16px;height:16px}
.btn__label{display:inline-flex;align-items:center;gap:4px}

.msg{width:100%;display:flex;flex-direction:column;gap:6px}
.msg__bubble{
  max-width:86%;
  border:1px solid var(--border);
  border-radius:14px;
  padding:12px 12px;
  line-height:1.45;
  white-space:pre-wrap;
  word-break:break-word;
  background:var(--panel2);
}
.msg--user{align-items:flex-end}
.msg--user .msg__bubble{background:#e5e7eb;border-color:#d1d5db}
.msg--assistant{align-items:flex-start}
.msg--assistant .msg__bubble{background:var(--panel)}
.msg--system{align-items:flex-start}
.msg--system .msg__bubble{background:#fff7ed;border-color:rgba(249,115,22,.35)}
.msg__meta{font-size:11px;color:var(--muted)}

.spell{border:1px solid var(--border);border-radius:var(--radius);background:var(--panel);box-shadow:var(--shadow);padding:14px;display:flex;flex-direction:column;gap:10px}

.spell__input{width:100%;border:1px solid var(--border);border-radius:12px;padding:12px;background:var(--panel2);color:var(--text);outline:none;line-height:1.45}

.spell__actions{display:flex;justify-content:flex-end}

.actions{display:flex;justify-content:flex-end;gap:10px;flex-wrap:wrap}

.spell__result{border:1px solid var(--border);border-radius:var(--radius);background:var(--panel2);padding:14px;overflow:auto;min-height:120px}

.subStatus{display:flex;align-items:center;gap:10px;flex-wrap:wrap}
.badge{display:inline-flex;align-items:center;gap:6px;padding:6px 10px;border-radius:999px;font-size:12px;border:1px solid var(--border);background:var(--panel2)}
.badge--success{border-color:rgba(34,197,94,.35);background:#ecfdf3}
.badge--warning{border-color:rgba(234,179,8,.35);background:#fffbeb}
.badge--danger{border-color:rgba(239,68,68,.45);background:#fef2f2}
.badge--muted{color:var(--muted)}
.subHistory{margin-top:12px;display:flex;flex-direction:column;gap:8px}
.subHistory__title{font-weight:600}
.subHistory__list{display:flex;flex-direction:column;gap:8px}
.subHistory__item{border:1px solid var(--border);background:var(--panel);border-radius:12px;padding:10px 12px;display:flex;flex-direction:column;gap:4px}
.subHistory__row{display:flex;justify-content:space-between;gap:10px;flex-wrap:wrap}
.subHistory__primary{font-weight:650}
.subHistory__meta{color:var(--muted);font-size:12px}
.subHistory__link{color:var(--accent);font-size:12px}
.subGrid{display:grid;grid-template-columns: repeat(auto-fit,minmax(220px,1fr));gap:10px;margin-top:6px}
.subCard{border:1px solid var(--border);background:var(--panel);border-radius:12px;padding:10px 12px;display:flex;flex-direction:column;gap:4px}
.subLabel{color:var(--muted);font-size:12px}
.subValue{font-weight:600;word-break:break-word}
.subValue--code{font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono","Courier New", monospace;}

.subPlans{border:1px solid var(--border);border-radius:var(--radius);background:var(--panel2);box-shadow:var(--shadow);padding:12px;display:flex;flex-direction:column;gap:10px}
.subPlans__header{display:flex;align-items:flex-start;justify-content:space-between;gap:12px;flex-wrap:wrap}
.subPlans__title{margin:0;font-size:18px;font-weight:700}
.subPlans__hint{margin:0;color:var(--muted);font-size:13px;max-width:520px}
.planGrid{display:grid;grid-template-columns:repeat(auto-fit,minmax(240px,1fr));gap:12px}
.planCard{border:1px solid var(--border);border-radius:12px;background:var(--panel);padding:12px;display:flex;flex-direction:column;gap:10px;box-shadow:var(--shadow)}
.planCard.is-current{border-color:rgba(34,197,94,.35);box-shadow:0 10px 26px rgba(16,185,129,.16)}
.planCard__header{display:flex;align-items:flex-start;justify-content:space-between;gap:10px}
.planCard__name{margin:0;font-weight:700;font-size:15px}
.planCard__price{font-weight:650;font-size:15px}
.planCard__period{margin:0;color:var(--muted);font-size:12px}
.planCard__limit{margin:0;font-weight:600}
.planCard__features{margin:0;padding-left:18px;display:flex;flex-direction:column;gap:6px;color:var(--muted);font-size:13px}
.planCard__badge{font-size:11px}
.planCard__footer{display:flex;flex-direction:column;gap:8px}
.planCard__actions{display:flex;flex-wrap:wrap;gap:8px}
.planCard__note{margin:0;color:var(--muted);font-size:12px}

.imageCard{border:1px solid var(--border);border-radius:var(--radius);background:var(--panel);box-shadow:var(--shadow);padding:14px}
.imageForm{display:flex;flex-direction:column;gap:12px}
.imageForm__grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(260px,1fr));gap:12px}
.imageForm__col{display:flex;flex-direction:column;gap:6px}
.imageForm__label{color:var(--muted);font-size:12px}
.imageForm__input,.imageForm__select{border:1px solid var(--border);border-radius:12px;padding:10px 12px;background:var(--panel2);color:var(--text);outline:none}
.imageForm__hint{margin:0;color:var(--muted);font-size:12px}
.imageForm__status{margin:4px 0 0;color:var(--muted);min-height:18px}
.imageForm__status.is-error{color:var(--danger)}
.imageForm__status.is-success{color:var(--accent)}

.segmented{display:flex;flex-wrap:wrap;gap:8px}
.segmented__item{display:inline-flex;align-items:center;gap:6px;padding:8px 10px;border:1px solid var(--border);border-radius:10px;background:var(--panel2);cursor:pointer}
.segmented__item input{margin:0}
.segmented__label{color:var(--muted);font-size:13px}
.segmented__item input:checked + .segmented__label{color:var(--text)}

.imageResults{display:flex;flex-direction:column;gap:12px;margin-top:12px}
.imageResults__list{display:grid;grid-template-columns:repeat(auto-fit,minmax(220px,1fr));gap:12px}
.imageResult{border:1px solid var(--border);background:var(--panel);border-radius:12px;padding:10px;display:flex;flex-direction:column;gap:8px;box-shadow:var(--shadow)}
.imageResult__img{width:100%;border-radius:10px;border:1px solid var(--border);object-fit:cover;background:var(--panel2)}
.imageResult__actions{display:flex;justify-content:flex-end}
.imageResult__link{color:var(--accent);font-size:13px}
.imageTexts{border:1px solid var(--border);border-radius:12px;padding:12px;background:var(--panel2);line-height:1.45}
.imageHistory{margin-top:16px;display:flex;flex-direction:column;gap:10px}
.imageHistory__header{display:flex;align-items:center;justify-content:space-between;gap:10px;flex-wrap:wrap}
.imageHistory__status{margin:0;color:var(--muted);min-height:18px}
.imageHistory__list{display:grid;grid-template-columns:repeat(auto-fit,minmax(180px,1fr));gap:12px}
.historyItem__image{position:relative;border:1px solid var(--border);border-radius:12px;overflow:hidden;background:var(--panel2);cursor:zoom-in;box-shadow:var(--shadow)}
.historyItem__image img{width:100%;height:100%;display:block;object-fit:cover;aspect-ratio:1/1;transition:transform .16s ease}
.historyItem__image:hover img{transform:scale(1.03)}
.historyItem__actions{position:absolute;top:8px;right:8px;z-index:2;display:flex;gap:6px}
.historyItem__link,.historyItem__btn{color:#f8fafc;font-size:12px;background:rgba(15,23,42,.75);border:1px solid rgba(255,255,255,.14);padding:6px 8px;border-radius:8px;backdrop-filter:blur(6px);text-decoration:none;display:inline-flex;align-items:center;gap:4px;cursor:pointer;appearance:none}
.historyItem__iconBtn{width:32px;height:32px;justify-content:center;padding:6px}
.historyItem__iconBtn svg{width:16px;height:16px;display:block;fill:currentColor}
.historyItem__overlay{position:absolute;left:0;right:0;bottom:0;padding:10px 12px;display:flex;flex-direction:column;gap:6px;background:linear-gradient(180deg,rgba(0,0,0,0) 0%,rgba(0,0,0,0.55) 40%,rgba(0,0,0,0.78) 100%);color:#f8fafc}
.historyItem__overlayTitle{font-weight:700;font-size:13px}
.historyItem__overlayMeta{display:flex;flex-wrap:wrap;gap:6px;font-size:12px}
.historyItem__overlayMeta span{background:rgba(255,255,255,.14);padding:4px 8px;border-radius:8px}
.historyItem__overlayActions{display:flex;flex-wrap:wrap;gap:6px;margin-top:2px}
.historyItem__placeholder{display:flex;align-items:center;justify-content:center;aspect-ratio:1/1;background:linear-gradient(135deg,rgba(148,163,184,.15),rgba(148,163,184,.06));color:var(--muted);font-weight:650;cursor:default;pointer-events:none}
.historyItem__placeholderText{display:flex;align-items:center;gap:6px;letter-spacing:.02em}
.historyItem__placeholderText::after{content:'';width:10px;height:10px;border:2px solid rgba(15,23,42,.35);border-top-color:rgba(15,23,42,.75);border-radius:999px;animation:historySpinner .9s linear infinite}
@keyframes historySpinner{to{transform:rotate(360deg)}}

.imagePreview{position:fixed;inset:0;z-index:9999;display:flex;align-items:center;justify-content:center;padding:20px;background:rgba(0,0,0,.72);opacity:0;pointer-events:none;transition:opacity .16s ease}
.imagePreview.is-visible{opacity:1;pointer-events:auto}
.imagePreview__img{max-width:92vw;max-height:92vh;border-radius:12px;box-shadow:0 14px 38px rgba(0,0,0,.45);background:#0f172a}

@media (min-width: 1200px){
  .imageHistory__list{grid-template-columns:repeat(4,minmax(0,1fr))}
}

.hero{display:grid;grid-template-columns:minmax(0,1.1fr) 0.9fr;gap:18px;padding:18px;border:1px solid var(--border);border-radius:var(--radius);background:var(--panel);box-shadow:var(--shadow);align-items:center}
.hero__content{display:flex;flex-direction:column;gap:10px}
.pill{display:inline-flex;align-items:center;gap:8px;padding:6px 12px;border-radius:999px;border:1px solid var(--border);background:var(--panel2);font-size:12px;font-weight:650;color:var(--text)}
.pill__dot{width:8px;height:8px;border-radius:50%;background:var(--accent)}
.hero__title{margin:0;font-size:28px;line-height:1.15;letter-spacing:-.3px}
.hero__text{margin:0;color:var(--muted);line-height:1.5}
.hero__actions{display:flex;flex-wrap:wrap;gap:10px}
.hero__meta{display:flex;flex-wrap:wrap;gap:8px}
.tag{display:inline-flex;align-items:center;padding:6px 10px;border:1px solid var(--border);border-radius:999px;font-size:12px;background:var(--panel2);color:var(--text)}
.hero__panel{background:var(--panel2);border:1px solid var(--border);border-radius:var(--radius);padding:14px;box-shadow:0 6px 16px rgba(15,23,42,.05)}
.panelCard{display:flex;flex-direction:column;gap:10px}
.panelCard__title{font-weight:700;margin:0}
.panelCard__list{margin:0 0 4px 16px;padding:0;display:flex;flex-direction:column;gap:6px;color:var(--muted)}
.panelCard__list li{margin-left:4px}
.panelCard__note{font-size:12px;color:var(--muted);margin:0}

.featureGrid{display:grid;grid-template-columns:repeat(auto-fit,minmax(220px,1fr));gap:12px}
.featureCard{border:1px solid var(--border);background:var(--panel);border-radius:var(--radius);padding:12px;box-shadow:0 6px 16px rgba(15,23,42,.05);display:flex;flex-direction:column;gap:6px}
.featureCard__title{margin:0;font-weight:700;font-size:15px}
.featureCard__text{margin:0;color:var(--muted);line-height:1.45;font-size:13px}

.button{display:inline-flex;align-items:center;gap:8px;padding:10px 14px;border-radius:10px;border:1px solid var(--border);background:var(--panel);color:var(--text);font-weight:650;cursor:pointer;transition:all .12s ease}
.button:hover{background:var(--panel2);border-color:#d1d5db}
.button--primary{background:var(--accent);color:#f8fafc;border-color:var(--accent)}
.button--primary:hover{
  background:#1f2937;
  border-color:#1f2937;
  color:#f8fafc;
  box-shadow:0 8px 18px rgba(17,24,39,.22);
}
.button--ghost{background:transparent}

@media (max-width: 920px){
  .app{grid-template-columns: 1fr}
  .sidebar{display:none}
  .main{padding:16px}
  .hero{grid-template-columns:1fr}
}

.modal{position:fixed;inset:0;z-index:2000;display:flex;align-items:center;justify-content:center;padding:16px}
.modal[hidden]{display:none!important}
.modal__backdrop{position:absolute;inset:0;background:rgba(15,23,42,.55);backdrop-filter:blur(3px)}
.modal__dialog{position:relative;z-index:1;max-width:420px;width:100%;background:var(--panel);border-radius:var(--radius);box-shadow:0 16px 46px rgba(15,23,42,.22);padding:18px 18px 16px;border:1px solid var(--border);display:flex;flex-direction:column;gap:10px}
.modal__title{margin:0;font-size:18px;font-weight:700}
.modal__text{margin:0;color:var(--muted);line-height:1.45}
.modal__actions{display:flex;gap:8px;flex-wrap:wrap;justify-content:flex-end}
.modal__close{position:absolute;top:10px;right:10px;border:none;background:transparent;color:var(--muted);cursor:pointer;padding:6px;border-radius:8px;font-size:16px;line-height:1}
.modal__close:hover{background:var(--panel2);color:var(--text)}
