.ai-page { max-width: 1440px; margin: auto; padding-bottom: 40px; }
.ai-toolbar,.ai-tabs,.ai-actions,.ai-dialog-head,.ai-result-meta { display:flex; align-items:center; gap:10px; flex-wrap:wrap; }
.ai-toolbar,.ai-dialog-head { justify-content:space-between; margin-bottom:18px; }
.ai-tabs { background:#eaf0f6; border-radius:12px; padding:4px; gap:2px; }
.ai-tabs button { border:0; background:transparent; color:#52647c; }
.ai-tabs button.on { background:white; color:#245da0; box-shadow:0 1px 4px #19365126; }
.ai-layout { display:grid; grid-template-columns:minmax(280px, .83fr) minmax(0,1.17fr); align-items:start; gap:20px; }
.ai-panel { min-width:0; background:white; border:1px solid #dce5ed; border-radius:16px; padding:clamp(16px,2vw,26px); box-shadow:0 4px 16px #2b496208; }
.ai-panel .panel-heading { display:flex; justify-content:space-between; align-items:center; gap:8px; margin-bottom:18px; }
.ai-panel h2,#aiDialog h2 { margin:0; font-size:19px; }
.ai-panel label,#aiDialog label { display:grid; min-width:0; gap:7px; font-weight:600; margin:12px 0; }
.ai-panel small { font-size:12px; color:#60738a; }
.ai-panel :is(textarea,input,select),#aiDialog :is(textarea,input,select) { width:100%; min-width:0; max-width:100%; box-sizing:border-box; font:inherit; border:1px solid #ccdae7; background:#fcfdff; color:#223951; border-radius:9px; padding:10px; }
.ai-panel select,#aiDialog select { min-height:42px; padding:0 38px 0 12px; border-color:#dfe5ee; border-radius:8px; background-color:#fff; background-image:linear-gradient(45deg,transparent 50%,#8291a5 50%),linear-gradient(135deg,#8291a5 50%,transparent 50%); background-position:calc(100% - 17px) 18px,calc(100% - 12px) 18px; background-size:5px 5px,5px 5px; background-repeat:no-repeat; appearance:none; box-shadow:0 1px 2px #1d35500d; cursor:pointer; }
.ai-panel select:focus,#aiDialog select:focus { outline:none; border-color:#7fa5e8; box-shadow:0 0 0 3px #3269d51a; }
.ai-panel textarea,#aiDialog textarea { resize:vertical; }
.ai-field-grid,.ai-results-grid { display:grid; grid-template-columns:repeat(auto-fit,minmax(140px,1fr)); gap:10px; }
.ai-results-grid { grid-template-columns:repeat(auto-fit,minmax(min(190px,100%),1fr)); gap:14px; }
.ai-field-grid:has(>label:only-child) { grid-template-columns:1fr; }
.ai-submit { width:100%; margin-top:10px; }
.ai-price-note { display:flex; align-items:center; flex-wrap:wrap; gap:8px; margin-top:12px; color:#64778c; font-size:12px; }
.ai-price-note b { padding:5px 9px; border-radius:7px; background:#edf6ff; color:#245b91; font-variant-numeric:tabular-nums; }
.ai-output-note { margin:12px 0 6px; color:#6c7f94; font-size:12px; line-height:1.7; }
.ai-output-note:empty { display:none; }
.ai-revision-context { padding:12px; border-radius:9px; background:#f2f6fc; color:#385777; line-height:1.7; overflow-wrap:anywhere; }
.ai-empty { grid-column:1/-1; padding:40px 12px; text-align:center; border:1px dashed #cadae7; border-radius:12px; color:#63768a; }
.ai-records { margin-top:26px; padding-top:22px; border-top:1px solid #e5ecf3; }
.ai-history-heading { display:flex; align-items:center; justify-content:space-between; gap:12px; margin-bottom:14px; }
.ai-history-heading h3 { margin:0; font-size:16px; color:#263e59; }
.ai-history-heading > span { color:#7a8b9d; font-size:12px; }
.ai-history-scope { margin-bottom:12px; max-width:100%; overflow-wrap:anywhere; font-size:12px; color:#386b9f; background:#edf5ff; }
.ai-history-scope[hidden] { display:none; }
.ai-history-filters { padding:12px; border:1px solid #e2eaf2; border-radius:10px; background:#f8fafc; }
.ai-history-search { display:grid; grid-template-columns:minmax(0,1fr); gap:8px; }
.ai-history-dates { display:grid; grid-template-columns:auto minmax(0,1fr) auto minmax(0,1fr); align-items:end; gap:8px; margin-top:10px; }
.ai-history-dates > span { align-self:center; color:#6c7f94; font-size:12px; }
.ai-history-dates > label { margin:0; gap:4px; font-size:11px; color:#6c7f94; font-weight:400; }
.ai-history-dates input { padding:7px 8px; font-size:12px; background:#fff; }
.ai-history-list[aria-busy=true] { opacity:.55; pointer-events:none; }
.ai-history-item { display:grid; grid-template-columns:minmax(0,1fr) auto; align-items:center; gap:0 14px; padding:18px 0; border-bottom:1px solid #e8eef4; }
.ai-record-main { grid-column:1; grid-row:1; display:flex; gap:13px; align-items:flex-start; }
.ai-record-thumb,.ai-record-placeholder { flex:none; width:76px; height:76px; border:1px solid #e0e8f0; border-radius:10px; overflow:hidden; background:#f3f6fa; }
.ai-record-thumb { padding:0; cursor:zoom-in; }
.ai-record-thumb img { display:block; width:100%; height:100%; object-fit:cover; }
.ai-record-placeholder { display:grid; place-items:center; color:#8b9aae; font-size:12px; }
.ai-record-info { flex:1; min-width:0; }
.ai-record-title { display:flex; align-items:flex-start; gap:10px; }
.ai-record-title h3 { flex:1; min-width:0; margin:1px 0 0; font-size:14px; font-weight:600; line-height:1.5; overflow-wrap:anywhere; display:-webkit-box; -webkit-box-orient:vertical; -webkit-line-clamp:2; overflow:hidden; }
.ai-status { flex:none; display:inline-flex; align-items:center; gap:5px; padding:3px 7px; border-radius:6px; font-size:11px; line-height:1.5; background:#edf2f8; color:#718198; white-space:nowrap; }
.ai-status:before { content:""; width:5px; height:5px; border-radius:50%; background:currentColor; }
.ai-status.is-done { color:#2e7c60; background:#edf8f2; }
.ai-status.is-failed { color:#b2574a; background:#fff1ee; }
.ai-status.is-working { color:#326ab1; background:#edf4ff; }
.ai-record-time { margin:7px 0 0; color:#74869b; font-size:12px; line-height:1.6; }
.ai-record-meta { display:flex; flex-wrap:wrap; gap:5px; margin:4px 0 0; color:#8a98aa; font-size:12px; }
.ai-record-actions { grid-column:2; grid-row:1; display:flex; flex-direction:column; justify-content:flex-end; gap:8px; }
.ai-record-actions:empty { display:none; }
.ai-record-actions button { padding:6px 11px; font-size:12px; }
.ai-job-error { grid-column:1/-1; grid-row:2; margin:12px 0 0; padding:9px 11px; border-radius:7px; background:#fff7f5; font-size:12px; line-height:1.6; }
.ai-history-pager { display:flex; align-items:center; justify-content:space-between; flex-wrap:wrap; gap:10px; padding-top:16px; }
.ai-history-pager > span { color:#7a8b9d; font-size:12px; }
.ai-history-pager > div { display:flex; gap:8px; }
.ai-history-pager button { padding:7px 12px; font-size:12px; }
.ai-history-pager button:disabled { opacity:.45; cursor:default; }
.ai-history-empty { margin-top:14px; padding:28px 12px; line-height:1.9; }
.ai-latest-heading time { color:#778ba1; font-size:12px; }
.ai-latest-all { margin-top:12px; }
.ai-detail-description { margin:0; color:#304860; line-height:1.7; overflow-wrap:anywhere; }
#aiRecordResults { margin-top:18px; }
.ai-generation-card { position:relative; overflow:hidden; min-height:260px; padding:26px; border:1px solid #ceddf0; border-radius:14px; background:linear-gradient(145deg,#f4f9ff,#e8f2ff); box-shadow:inset 0 0 40px #6ca6e51a; }
.ai-generation-card:before,.ai-generation-card:after { content:""; position:absolute; border-radius:50%; pointer-events:none; }
.ai-generation-card:before { width:260px; height:260px; top:-130px; right:-80px; background:#78aef84d; filter:blur(3px); animation:aiGlow 3s ease-in-out infinite alternate; }
.ai-generation-card:after { width:180px; height:180px; bottom:-100px; left:-60px; background:#b28cff26; filter:blur(2px); animation:aiGlow 2.4s ease-in-out infinite alternate-reverse; }
.ai-generation-visual { position:relative; width:92px; height:92px; margin:4px auto 20px; display:grid; place-items:center; }
.ai-generation-icon { position:relative; z-index:2; width:54px; height:54px; display:grid; place-items:center; border-radius:18px; background:#256fd7; color:white; font-size:30px; box-shadow:0 8px 24px #256fd766; animation:aiPulse 1.5s ease-in-out infinite; }
.ai-orbit { position:absolute; inset:0; border:2px solid #72a8ed99; border-top-color:#256fd7; border-radius:50%; animation:aiSpin 1.8s linear infinite; }
.ai-orbit-two { inset:10px; border-color:#b28cff88; border-left-color:#8059db; animation-duration:1.25s; animation-direction:reverse; }
.ai-generation-copy { position:relative; z-index:1; text-align:center; }
.ai-generation-copy strong,.ai-generation-copy span { display:block; }
.ai-generation-copy strong { color:#1e4f87; font-size:17px; }
.ai-generation-copy span { margin-top:7px; color:#6d8198; font-size:13px; }
.ai-generation-card progress { position:relative; z-index:1; width:100%; height:10px; margin-top:25px; accent-color:#2c75dc; }
.ai-generation-foot { position:relative; z-index:1; display:flex; justify-content:space-between; gap:12px; margin-top:8px; color:#627892; font-size:12px; }
.ai-generation-foot b { color:#2b65a3; font-weight:600; }
@keyframes aiSpin { to { transform:rotate(360deg); } }
@keyframes aiPulse { 50% { transform:scale(1.07); box-shadow:0 10px 30px #256fd799; } }
@keyframes aiGlow { to { transform:scale(1.18); opacity:.65; } }
.ai-latest { margin:4px 0 18px; padding:12px; border:1px solid #d8e5f0; border-radius:12px; background:#f7fbff; }
.ai-latest:empty { display:none; }
.ai-latest-heading { display:flex; align-items:center; justify-content:space-between; gap:8px; margin-bottom:10px; color:#254d78; }
.ai-latest-heading small { color:#71849a; font-weight:400; }
.ai-image-result,.ai-text-result { min-width:0; align-self:start; border:1px solid #dce5eb; border-radius:12px; overflow:hidden; background:#fcfdff; }
.ai-text-result { grid-column:1/-1; padding:16px; overflow-wrap:anywhere; }
.ai-text-result h3 { margin:8px 0; font-size:18px; }
.ai-text-result details { margin:12px 0; }
.ai-tag-list { display:flex; flex-wrap:wrap; gap:6px; }
.ai-tag-list span { background:#eaf2fc; color:#295884; border-radius:6px; padding:3px 8px; }
.ai-result-meta,.ai-image-result .ai-actions { padding:8px 10px; }
.ai-result-meta { color:#526783; font-size:13px; }
.ai-image-result button.ai-preview { width:100%; height:auto; display:block; border:0; padding:0; border-radius:0; background:#eff3f6; }
.ai-preview img { width:100%; height:148px; object-fit:contain; display:block; }
.ai-latest .ai-image-result { display:grid; grid-template-columns:minmax(120px,220px) 1fr; align-items:center; }
.ai-latest .ai-image-result .ai-preview { grid-row:span 2; }
.ai-latest .ai-image-result .ai-preview img { height:180px; }
.ai-latest .ai-image-result .ai-result-meta { padding:0 14px; }
.ai-latest .ai-image-result .ai-actions { padding:8px 14px 12px; }
.ai-composer { min-width:0; margin-top:4px; padding:14px; border:1px solid #ccdae7; border-radius:14px; background:#fff; transition:border-color .15s,box-shadow .15s; }
.ai-composer:focus-within { border-color:#76aaf0; box-shadow:0 0 0 3px rgb(59 142 234 / .1); }
.ai-composer [hidden] { display:none!important; }
.ai-composer .ai-composer-body textarea,#aiDialog .ai-composer .ai-composer-body textarea { display:block; width:100%; min-height:94px; margin:0; padding:8px 0; border:0; border-radius:0; background:transparent; outline:none; box-shadow:none; line-height:1.6; font-weight:400; }
.ai-composer textarea::placeholder { color:#9aa5b3; }
.ai-composer-toolbar { display:flex; align-items:center; justify-content:space-between; gap:10px; margin-top:6px; }
.ai-composer .ai-upload { display:inline-flex; align-items:center; gap:5px; min-height:36px; padding:5px 8px; border:0; background:#f2f6fa; color:#526881; font-size:13px; font-weight:500; }
.ai-upload span { font-size:20px; line-height:1; }
.ai-reference-count { color:#8592a2; font-size:12px; white-space:nowrap; font-variant-numeric:tabular-nums; }
.ai-upload-hint { margin:9px 0 0; color:#8592a2; font-size:11px; line-height:1.7; font-weight:400; }
.ai-paste-hint { padding:8px 0 18px; color:#8c99aa; font-size:13px; outline:none; }
.ai-thumbs { display:flex; flex-wrap:wrap; gap:14px; padding:4px 4px 10px 0; }
.ai-thumb { flex:none; width:112px; height:112px; position:relative; border:1px solid #dce5ed; border-radius:11px; background:#f3f6fa; }
.ai-thumb img { display:block; width:100%; height:100%; border-radius:10px; object-fit:cover; }
.ai-composer .ai-thumb-preview,#aiDialog .ai-composer .ai-thumb-preview { display:block; width:100%; height:100%; min-height:0; padding:0; border:0; border-radius:10px; background:transparent; cursor:zoom-in; }
.ai-thumb-number { position:absolute; bottom:5px; right:5px; min-width:18px; padding:0 4px; border-radius:5px; background:#ffffffdf; color:#5d6d80; text-align:center; font-size:11px; pointer-events:none; }
.ai-composer .ai-thumb-remove { position:absolute; top:-7px; right:-7px; display:grid; place-items:center; width:26px; height:26px; min-height:26px; padding:0; border:2px solid #fff; border-radius:50%; background:#27303c; color:#fff; font:20px/1 Arial,sans-serif; box-shadow:0 1px 4px #17253626; }
.ai-composer .ai-thumb-remove:hover { background:#101823; }
.ai-composer .ai-thumb-move { position:absolute; bottom:5px; left:5px; display:grid; place-items:center; width:26px; height:26px; min-height:26px; padding:0; border:0; border-radius:6px; background:#ffffffeb; font-size:16px; color:#42556c; }
.ai-composer button:focus-visible { outline:2px solid #3778c8; outline-offset:2px; }
.ai-error { color:#ad3333; overflow-wrap:anywhere; }
.ai-error:empty { display:none; }
#aiDialog { box-sizing:border-box; width:min(620px,calc(100vw - 24px)); max-height:calc(100dvh - 32px); overflow:auto; overscroll-behavior:contain; }
.ai-dialog-head { position:sticky; top:0; background:white; z-index:1; }
#aiDialog progress { width:100%; height:12px; accent-color:#316caa; }
.ai-full-image { width:100%; max-height:65dvh; object-fit:contain; }
.ai-reference-preview { box-sizing:border-box; width:min(1100px,calc(100vw - 24px)); max-width:none; max-height:calc(100dvh - 24px); padding:16px; border:1px solid #dce5ed; border-radius:14px; background:#fff; box-shadow:0 16px 60px #17253633; }
.ai-reference-preview::backdrop { background:#172536b3; }
.ai-reference-preview .ai-dialog-head { position:static; flex-wrap:nowrap; margin-bottom:12px; }
.ai-reference-preview h2 { margin:0; font-size:17px; }
.ai-reference-preview .ai-dialog-head button { flex:none; min-width:44px; min-height:44px; font-size:22px; line-height:1; }
.ai-reference-preview > img { display:block; width:100%; height:min(72dvh,760px); object-fit:contain; background:#f3f6fa; border-radius:8px; }
.ai-accounts { display:flex; gap:8px; flex-wrap:wrap; margin:10px 0; }
.ai-account { background:#eef4fa; border-radius:8px; padding:8px 12px; }
.ai-ledger details { margin:10px 0; overflow-wrap:anywhere; }
.ai-ledger summary { cursor:pointer; padding:8px 0; }
.ai-ledger .ai-event { padding:10px; margin:6px 0; border-left:2px solid #cbdbea; }
@media(max-width:980px) { .ai-layout { grid-template-columns:1fr; } }
@media(max-width:600px) { .ai-page button,.ai-page select,.ai-page a,#aiDialog button { min-height:44px; } .ai-page a { display:inline-flex; align-items:center; }
 .ai-toolbar { display:grid; } .ai-panel { padding:14px; } .ai-tabs button { flex:1; } .ai-results-grid { grid-template-columns:1fr; } .ai-field-grid { gap:6px; }
 .ai-panel :is(input,textarea,select),#aiDialog :is(input,textarea,select) { font-size:16px; }
 .ai-composer { padding:12px; } .ai-thumb { width:92px; height:92px; }
 .ai-page .ai-composer .ai-thumb-remove,#aiDialog .ai-composer .ai-thumb-remove { width:32px; height:32px; min-height:32px; top:-8px; right:-8px; }
 .ai-page .ai-composer .ai-thumb-move,#aiDialog .ai-composer .ai-thumb-move { width:28px; height:28px; min-height:28px; }
 .ai-generation-card { min-height:220px; padding:20px 14px; }
.ai-latest .ai-image-result { grid-template-columns:110px 1fr; } .ai-latest .ai-image-result .ai-preview img { height:110px; }
 .ai-history-search { grid-template-columns:minmax(0,1fr); gap:5px; }
 .ai-history-dates { grid-template-columns:minmax(0,1fr) minmax(0,1fr); }
 .ai-history-dates > span { grid-column:1/-1; }
 .ai-history-dates .ai-date-separator { display:none; }
 .ai-record-thumb,.ai-record-placeholder { width:60px; height:60px; }
 .ai-record-main { gap:10px; }
 .ai-history-item { grid-template-columns:minmax(0,1fr); }
 .ai-record-actions { grid-column:1; grid-row:3; flex-direction:row; flex-wrap:wrap; margin-top:10px; }
 .ai-record-title { flex-wrap:wrap; gap:5px; }
 .ai-record-title h3 { flex-basis:100%; }
 .ai-record-time time { display:block; }
 .ai-history-pager > div { margin-left:auto; }
}
@media(max-width:360px) { .ai-history-dates { grid-template-columns:minmax(0,1fr); } }
