*{box-sizing:border-box;margin:0;padding:0}
:root{
  --bg:#ffffff;--sidebar:#f9f9f9;--text:#0d0d0d;--text-soft:#5d5d5d;--muted:#8e8e8e;
  --border:#e5e5e5;--hover:#ececec;--user-bubble:#f4f4f4;--black:#0d0d0d;--white:#fff;
  --radius:18px;--max:760px;
  --scrollbar:#d0d0d0;--scrollbar-hover:#b5b5b5;--field-bg:#fafafa;--field-focus:#fff;--disabled:#d4d4d4;
}
[data-theme="dark"]{
  --bg:#212121;--sidebar:#171717;--text:#ececec;--text-soft:#c4c4c4;--muted:#9a9a9a;
  --border:#3a3a3a;--hover:#2f2f2f;--user-bubble:#2f2f2f;--black:#ececec;--white:#2a2a2a;
  --scrollbar:#4a4a4a;--scrollbar-hover:#5d5d5d;--field-bg:#1e1e1e;--field-focus:#262626;--disabled:#3a3a3a;
}
html,body{height:100%}
body.sft-body{background:var(--bg);color:var(--text);font-family:var(--sft-font);overflow:hidden;-webkit-font-smoothing:antialiased}
#sft-app{height:100vh;height:100dvh;display:flex;flex-direction:column}
button{font-family:inherit;cursor:pointer}
a{color:inherit}
::-webkit-scrollbar{width:8px;height:8px}
::-webkit-scrollbar-thumb{background:var(--scrollbar);border-radius:8px}
::-webkit-scrollbar-thumb:hover{background:var(--scrollbar-hover)}

.sft-boot{height:100vh;display:flex;align-items:center;justify-content:center}
.sft-spinner{width:34px;height:34px;border:3px solid var(--border);border-top-color:var(--black);border-radius:50%;animation:sftspin .8s linear infinite}
@keyframes sftspin{to{transform:rotate(360deg)}}

.sft-shell{display:flex;height:100vh;height:100dvh;width:100%}

/* Sidebar */
.sft-sidebar{width:270px;background:var(--sidebar);border-left:1px solid var(--border);display:flex;flex-direction:column;flex-shrink:0;transition:margin .25s ease}
.sft-sidebar-top{padding:12px;display:flex;flex-direction:column;gap:8px}
.sft-new-btn{display:flex;align-items:center;justify-content:space-between;gap:8px;background:var(--black);color:var(--white);border:none;padding:12px 14px;border-radius:12px;font-size:14px;font-weight:600;width:100%}
.sft-new-btn:hover{opacity:.88}
.sft-conv-list{flex:1;overflow-y:auto;padding:6px 8px}
.sft-conv-group-label{font-size:11px;color:var(--muted);padding:10px 10px 6px;font-weight:600}
.sft-conv-item{display:flex;align-items:center;justify-content:space-between;gap:6px;padding:10px 12px;border-radius:10px;font-size:13.5px;color:var(--text-soft);cursor:pointer;margin-bottom:2px;position:relative}
.sft-conv-item:hover{background:var(--hover)}
.sft-conv-item.active{background:var(--hover);color:var(--text);font-weight:600}
.sft-conv-title{white-space:nowrap;overflow:hidden;text-overflow:ellipsis;flex:1}
.sft-conv-del{opacity:0;background:none;border:none;color:var(--muted);font-size:16px;padding:2px 4px;border-radius:6px;flex-shrink:0}
.sft-conv-item:hover .sft-conv-del{opacity:1}
.sft-conv-del:hover{background:var(--hover);color:var(--text)}
.sft-sidebar-bottom{padding:10px;border-top:1px solid var(--border)}
.sft-side-link{display:flex;align-items:center;gap:10px;padding:11px 12px;border-radius:10px;font-size:13.5px;color:var(--text-soft);background:none;border:none;width:100%;text-align:right}
.sft-side-link:hover{background:var(--hover);color:var(--text)}
.sft-side-link svg{width:18px;height:18px;flex-shrink:0}

/* Main */
.sft-main{flex:1;display:flex;flex-direction:column;min-width:0;position:relative}
.sft-topbar{height:54px;display:flex;align-items:center;gap:10px;padding:0 14px;border-bottom:1px solid transparent;flex-shrink:0}
.sft-icon-btn{background:none;border:none;width:38px;height:38px;border-radius:10px;display:flex;align-items:center;justify-content:center;color:var(--text)}
.sft-icon-btn:hover{background:var(--hover)}
.sft-icon-btn svg{width:21px;height:21px}
.sft-model-select{position:relative}
.sft-model-btn{display:flex;align-items:center;gap:6px;background:none;border:none;font-size:16px;font-weight:600;color:var(--text);padding:8px 12px;border-radius:10px}
.sft-model-btn:hover{background:var(--hover)}
.sft-model-btn .chev{width:14px;height:14px;color:var(--muted)}
.sft-model-menu{position:absolute;top:46px;right:0;background:var(--white);border:1px solid var(--border);border-radius:14px;box-shadow:0 12px 36px rgba(0,0,0,.14);min-width:240px;padding:6px;z-index:40}
.sft-model-opt{display:flex;align-items:center;justify-content:space-between;gap:8px;padding:11px 12px;border-radius:10px;font-size:14px;cursor:pointer}
.sft-model-opt:hover{background:var(--hover)}
.sft-model-opt .free-tag{font-size:11px;border:1px solid var(--border);padding:1px 7px;border-radius:20px;color:var(--muted)}
.sft-model-opt.locked{opacity:.5}
.sft-model-opt.locked:hover{opacity:.7;background:var(--hover)}
.sft-lock-tag{font-size:10.5px;border:1px solid var(--border);padding:1px 8px;border-radius:20px;color:var(--muted);white-space:nowrap;flex-shrink:0}
.sft-topbar-spacer{flex:1}
.sft-login-btn{background:var(--black);color:var(--white);border:none;padding:9px 18px;border-radius:20px;font-size:13.5px;font-weight:600}

/* Messages */
.sft-messages{flex:1;overflow-y:auto;padding:20px 0 10px}
.sft-thread{max-width:var(--max);margin:0 auto;padding:0 18px}
.sft-msg{display:flex;gap:14px;margin-bottom:26px;animation:sftmsg .25s ease}
@keyframes sftmsg{from{opacity:0;transform:translateY(6px)}to{opacity:1;transform:none}}
.sft-msg.user{flex-direction:row-reverse}
.sft-avatar{width:30px;height:30px;border-radius:50%;flex-shrink:0;display:flex;align-items:center;justify-content:center;font-size:13px;font-weight:700;background:var(--black);color:var(--white)}
.sft-msg.user .sft-avatar{background:var(--user-bubble);color:var(--text)}
.sft-msg-col{min-width:0;max-width:100%}
.sft-msg.user .sft-msg-col{display:flex;flex-direction:column;align-items:flex-start}
.sft-bubble{font-size:15.5px;line-height:2;word-wrap:break-word;overflow-wrap:break-word}
.sft-msg.user .sft-bubble{background:var(--user-bubble);padding:11px 16px;border-radius:var(--radius);display:inline-block}
.sft-msg-actions{display:flex;gap:4px;margin-top:8px;opacity:0;transition:.15s}
.sft-msg:hover .sft-msg-actions{opacity:1}
.sft-copy-btn{background:none;border:none;color:var(--muted);font-size:12px;display:flex;align-items:center;gap:5px;padding:5px 8px;border-radius:8px}
.sft-copy-btn:hover{background:var(--hover);color:var(--text)}
.sft-copy-btn svg{width:15px;height:15px}
.sft-attach-preview{display:flex;flex-wrap:wrap;gap:8px;margin-bottom:8px}
.sft-attach-preview img{max-width:200px;max-height:200px;border-radius:12px;border:1px solid var(--border)}
.sft-attach-file{display:flex;align-items:center;gap:8px;background:var(--user-bubble);padding:8px 12px;border-radius:10px;font-size:13px}

/* Markdown content */
.sft-bubble h1,.sft-bubble h2,.sft-bubble h3{margin:16px 0 8px;line-height:1.5;font-weight:700}
.sft-bubble h1{font-size:21px}.sft-bubble h2{font-size:18px}.sft-bubble h3{font-size:16px}
.sft-bubble p{margin:0 0 12px}
.sft-bubble p:last-child{margin-bottom:0}
.sft-bubble ul,.sft-bubble ol{margin:0 0 12px;padding-right:24px}
.sft-bubble li{margin-bottom:6px}
.sft-bubble a{text-decoration:underline}
.sft-bubble blockquote{border-right:3px solid var(--border);padding:2px 14px;color:var(--text-soft);margin:0 0 12px}
.sft-bubble table{border-collapse:collapse;width:100%;margin:0 0 14px;font-size:14px;display:block;overflow-x:auto}
.sft-bubble th,.sft-bubble td{border:1px solid var(--border);padding:8px 12px;text-align:right}
.sft-bubble th{background:var(--user-bubble);font-weight:700}
.sft-bubble :not(pre)>code{background:var(--user-bubble);padding:2px 6px;border-radius:6px;font-size:13.5px;font-family:'Courier New',monospace;direction:ltr;display:inline-block}
.sft-code-block{margin:0 0 14px;border-radius:12px;overflow:hidden;border:1px solid var(--border)}
.sft-code-head{display:flex;align-items:center;justify-content:space-between;background:#171717;color:#ccc;padding:7px 14px;font-size:12px;direction:ltr}
.sft-code-head button{background:none;border:none;color:#ccc;font-size:12px;display:flex;align-items:center;gap:5px}
.sft-code-head button:hover{color:#fff}
.sft-code-block pre{margin:0;padding:14px;overflow-x:auto;background:#0d0d0d;direction:ltr}
.sft-code-block code{font-family:'Courier New',monospace;font-size:13.5px;line-height:1.6}
.sft-bubble img.sft-gen-img{max-width:100%;border-radius:14px;border:1px solid var(--border);margin-top:6px}

/* Typing */
.sft-typing{display:flex;gap:5px;padding:6px 0}
.sft-typing span{width:8px;height:8px;background:var(--muted);border-radius:50%;animation:sftblink 1.2s infinite}
.sft-typing span:nth-child(2){animation-delay:.2s}
.sft-typing span:nth-child(3){animation-delay:.4s}
@keyframes sftblink{0%,60%,100%{opacity:.3}30%{opacity:1}}

/* Welcome */
.sft-welcome{flex:1;display:flex;flex-direction:column;align-items:center;justify-content:center;text-align:center;padding:20px}
.sft-welcome h2{font-size:28px;font-weight:700;margin-bottom:8px}
.sft-welcome p{color:var(--text-soft);font-size:15px}

/* Composer */
.sft-composer-wrap{padding:0 18px 18px;flex-shrink:0}
.sft-composer{max-width:var(--max);margin:0 auto;background:var(--white);border:1px solid var(--border);border-radius:26px;box-shadow:0 2px 14px rgba(0,0,0,.06);padding:8px 8px 8px 8px}
.sft-composer:focus-within{border-color:#bdbdbd}
.sft-attach-bar{display:flex;flex-wrap:wrap;gap:8px;padding:6px 8px 0}
.sft-attach-chip{display:flex;align-items:center;gap:6px;background:var(--user-bubble);border-radius:10px;padding:6px 10px;font-size:12.5px;max-width:200px}
.sft-attach-chip img{width:32px;height:32px;border-radius:6px;object-fit:cover}
.sft-attach-chip .x{background:none;border:none;color:var(--muted);font-size:15px}
.sft-composer-row{display:flex;align-items:flex-end;gap:6px}
.sft-textarea{flex:1;border:none;outline:none;resize:none;font-family:inherit;font-size:15.5px;line-height:1.6;max-height:200px;padding:10px 8px;background:none;color:var(--text)}
.sft-textarea::placeholder{color:var(--muted)}
.sft-comp-btn{background:none;border:none;width:38px;height:38px;border-radius:50%;display:flex;align-items:center;justify-content:center;color:var(--text-soft);flex-shrink:0}
.sft-comp-btn:hover{background:var(--hover)}
.sft-comp-btn svg{width:21px;height:21px}
.sft-send-btn{background:var(--black);color:var(--white)}
.sft-send-btn:hover{opacity:.85;background:var(--black)}
.sft-send-btn:disabled{background:var(--disabled);cursor:default}
.sft-tools-menu{position:absolute;bottom:64px;background:var(--white);border:1px solid var(--border);border-radius:14px;box-shadow:0 10px 30px rgba(0,0,0,.15);padding:6px;z-index:30}
.sft-tools-menu button{display:flex;align-items:center;gap:10px;width:100%;background:none;border:none;padding:11px 14px;border-radius:10px;font-size:14px;text-align:right;color:var(--text)}
.sft-tools-menu button:hover{background:var(--hover)}
.sft-tools-menu svg{width:18px;height:18px}
.sft-composer-hint{text-align:center;font-size:11.5px;color:var(--muted);margin-top:8px}

/* Modal */
.sft-overlay{position:fixed;inset:0;background:rgba(0,0,0,.45);z-index:100;display:flex;align-items:center;justify-content:center;padding:18px}
.sft-overlay[hidden]{display:none}
.sft-modal{background:var(--white);border-radius:20px;width:100%;max-width:440px;padding:28px;max-height:90vh;overflow-y:auto;animation:sftmodal .2s ease}
@keyframes sftmodal{from{opacity:0;transform:scale(.97)}to{opacity:1;transform:none}}
.sft-modal-wide{max-width:640px}
.sft-modal-head{display:flex;align-items:center;justify-content:space-between;margin-bottom:20px}
.sft-modal-head h2{font-size:20px;font-weight:700}
.sft-modal-close{background:none;border:none;font-size:24px;color:var(--muted);line-height:1}
.sft-modal label{display:block;font-size:13px;font-weight:600;margin-bottom:6px}
.sft-modal input,.sft-modal textarea,.sft-modal select{width:100%;padding:12px 14px;border:1px solid var(--border);border-radius:12px;font-family:inherit;font-size:15px;margin-bottom:16px;background:var(--field-bg);color:var(--text)}
.sft-modal input:focus,.sft-modal textarea:focus{outline:none;border-color:var(--black);background:var(--field-focus)}
.sft-modal-btn{width:100%;background:var(--black);color:var(--white);border:none;padding:13px;border-radius:12px;font-size:15px;font-weight:600}
.sft-modal-btn:hover{opacity:.88}
.sft-modal-btn:disabled{background:#ccc}
.sft-modal-msg{font-size:13px;padding:10px 14px;border-radius:10px;margin-bottom:14px;text-align:center}
.sft-modal-msg.err{background:var(--user-bubble);color:var(--text);border:1px solid var(--border)}
.sft-modal-msg.ok{background:var(--black);color:var(--white)}
.sft-auth-tabs{display:flex;gap:6px;margin-bottom:20px;background:var(--user-bubble);padding:4px;border-radius:12px}
.sft-auth-tab{flex:1;background:none;border:none;padding:10px;border-radius:9px;font-size:13.5px;font-weight:600;color:var(--text-soft)}
.sft-auth-tab.active{background:var(--white);color:var(--text);box-shadow:0 1px 3px rgba(0,0,0,.08)}
.sft-auth-form{display:none}
.sft-auth-form.active{display:block}

/* Plans */
.sft-plans{display:grid;gap:14px}
.sft-plan{border:1px solid var(--border);border-radius:16px;padding:20px}
.sft-plan h3{font-size:17px;margin-bottom:8px}
.sft-plan .price{font-size:24px;font-weight:800;margin-bottom:4px}
.sft-plan .price small{font-size:13px;font-weight:400;color:var(--muted)}
.sft-plan ul{list-style:none;margin:14px 0;font-size:13.5px;color:var(--text-soft)}
.sft-plan li{padding:5px 0;display:flex;align-items:center;gap:8px}
.sft-plan li::before{content:'✓';font-weight:700;color:var(--black)}
.sft-plan-btn{width:100%;background:var(--black);color:var(--white);border:none;padding:12px;border-radius:12px;font-weight:600;font-size:14px}
.sft-plan-btn:hover{opacity:.88}

/* Tickets */
.sft-ticket-list{display:flex;flex-direction:column;gap:10px;margin-bottom:18px}
.sft-ticket-card{border:1px solid var(--border);border-radius:12px;padding:14px;cursor:pointer}
.sft-ticket-card:hover{border-color:#bbb}
.sft-ticket-card .subj{font-weight:600;font-size:14px;margin-bottom:4px}
.sft-ticket-card .st{font-size:12px;color:var(--muted)}
.sft-back-link{background:none;border:none;color:var(--text-soft);font-size:13px;margin-bottom:14px}
.sft-tk-thread{display:flex;flex-direction:column;gap:12px;margin-bottom:16px;max-height:340px;overflow-y:auto}
.sft-tk-msg{padding:12px;border-radius:12px;font-size:13.5px;line-height:1.8;max-width:85%}
.sft-tk-msg.user{background:var(--user-bubble);align-self:flex-start}
.sft-tk-msg.admin{background:var(--black);color:var(--white);align-self:flex-end}
.sft-tk-meta{font-size:11px;opacity:.7;margin-bottom:4px}

/* Toast */
.sft-toast{position:fixed;bottom:24px;left:50%;transform:translateX(-50%);background:var(--black);color:var(--white);padding:12px 22px;border-radius:30px;font-size:13.5px;z-index:200;animation:sfttoast .3s;box-shadow:0 6px 20px rgba(0,0,0,.25)}
@keyframes sfttoast{from{opacity:0;transform:translate(-50%,12px)}to{opacity:1;transform:translate(-50%,0)}}

/* Mobile */
.sft-backdrop{display:none}
@media(max-width:820px){
  .sft-sidebar{position:fixed;top:0;right:0;bottom:0;z-index:60;margin-right:-280px}
  .sft-shell.sidebar-open .sft-sidebar{margin-right:0;box-shadow:-8px 0 30px rgba(0,0,0,.2)}
  .sft-shell.sidebar-open .sft-backdrop{display:block;position:fixed;inset:0;background:rgba(0,0,0,.4);z-index:55}
  .sft-menu-toggle{display:flex}
  :root{--max:100%}
}
@media(min-width:821px){
  .sft-menu-toggle{display:none}
}

/* Model logos, theme toggle, typing cursor */
.sft-avatar img{width:100%;height:100%;object-fit:cover;border-radius:50%}
.sft-avatar.has-logo{background:transparent}
.sft-model-btn-logo{width:20px;height:20px;border-radius:5px;object-fit:cover;flex-shrink:0}
.sft-model-opt-main{display:flex;align-items:center;gap:9px;min-width:0}
.sft-model-opt-logo{width:22px;height:22px;border-radius:6px;object-fit:cover;flex-shrink:0}
.sft-type-cursor{display:inline-block;width:7px;height:1.05em;background:var(--text);margin-right:2px;vertical-align:-2px;border-radius:1px;animation:sftcursor .9s steps(1) infinite}
@keyframes sftcursor{0%,50%{opacity:1}50.01%,100%{opacity:0}}

.sft-image-progress{display:flex;align-items:center;gap:12px;min-height:48px;padding:10px 14px;border:1px solid var(--border);border-radius:16px;background:var(--white);font-size:14px;color:var(--text-soft)}
.sft-image-orbit{position:relative;width:28px;height:28px;flex:0 0 28px;animation:sft-orbit 1.8s linear infinite}
.sft-image-orbit i{position:absolute;width:7px;height:7px;border-radius:50%;background:var(--text);left:10px;top:0;transform-origin:4px 14px;opacity:.9}
.sft-image-orbit i:nth-child(2){transform:rotate(120deg)}
.sft-image-orbit i:nth-child(3){transform:rotate(240deg)}
@keyframes sft-orbit{to{transform:rotate(360deg)}}

@media(max-width:560px){
  .sft-composer-wrap{padding:0 max(10px,env(safe-area-inset-right)) max(12px,env(safe-area-inset-bottom)) max(10px,env(safe-area-inset-left))}
  .sft-composer{border-radius:20px;padding:7px}
  .sft-comp-btn{width:42px;height:42px}
  .sft-modal{width:calc(100% - 24px);padding:20px;border-radius:16px;max-height:calc(100dvh - 24px)}
  .sft-modal input,.sft-modal textarea,.sft-modal select{font-size:16px}
  .sft-toast{width:calc(100% - 28px);max-width:420px;text-align:center;bottom:max(16px,env(safe-area-inset-bottom));padding:12px 16px}
  .sft-image-progress{width:100%;font-size:13px}
}

@media(prefers-reduced-motion:reduce){
  .sft-image-orbit,.sft-spinner,.sft-typing span,.sft-type-cursor{animation:none}
}

.sft-feature-list{display:flex;flex-direction:column;gap:8px;margin-bottom:16px}
.sft-feature-row{width:100%;border:1px solid var(--border);background:var(--white);color:var(--text);padding:12px 14px;border-radius:12px;text-align:right;font:inherit;font-size:14px}
.sft-feature-row:hover,.sft-feature-row.active{background:var(--hover);border-color:var(--text-soft)}
.sft-image-gallery{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:10px;min-height:80px;align-content:start;color:var(--muted)}
.sft-gallery-item{border:0;padding:0;overflow:hidden;border-radius:12px;background:var(--hover);aspect-ratio:1}
.sft-gallery-item img{width:100%;height:100%;display:block;object-fit:cover;transition:transform .2s ease}
.sft-gallery-item:hover img{transform:scale(1.04)}
.sft-table-wrap{width:100%;overflow-x:auto;margin:14px 0;border:1px solid var(--border);border-radius:12px}
.sft-bubble table{width:100%;min-width:460px;border-collapse:collapse;font-size:13px;background:var(--white)}
.sft-bubble th,.sft-bubble td{padding:10px 12px;border-bottom:1px solid var(--border);text-align:right;vertical-align:top;line-height:1.7}
.sft-bubble th{background:var(--hover);font-weight:700;white-space:nowrap}
.sft-bubble tr:last-child td{border-bottom:0}
.sft-code-block{max-width:100%;overflow:hidden;border-radius:12px}
.sft-code-block pre{max-width:100%;overflow:auto;margin:0;direction:ltr;text-align:left}
@media(max-width:560px){.sft-image-gallery{grid-template-columns:repeat(2,minmax(0,1fr))}.sft-feature-row{min-height:44px}.sft-bubble table{font-size:12px}}
