/* =========================================================
   AiDrama – USER: header, auth, account, modal
   ========================================================= */
.btn-red { background: var(--accent); color: #fff; box-shadow: 0 8px 26px rgba(var(--c-accent) / .45); }
.btn-red:hover { background: var(--accent-hi); box-shadow: 0 8px 30px rgba(var(--c-accent) / .6); }
.btn-block { width: 100%; }
.btn-outline { background: transparent; border: 1px solid var(--line-2); color: var(--fg-0); font-size: 14px; }
.btn-outline:hover { background: var(--bg-2); }
.btn-danger:hover { background: rgba(var(--c-accent) / .18); color: var(--accent-hi); }
.link-sm { font-size: 13px; font-weight: 600; color: var(--fg-1); display: inline-flex; align-items: center; gap: 4px; }
.link-sm:hover { color: var(--fg-0); text-decoration: underline; }

/* ---------- Header user ---------- */
.signin-btn {
    display: inline-flex; align-items: center; height: 36px; padding: 0 16px; border-radius: var(--r-pill);
    background: var(--bg-2); font-size: 13px; font-weight: 700; white-space: nowrap;
}
.signin-btn:hover { background: var(--bg-3); }
.user-btn { display: inline-flex; align-items: center; gap: 6px; height: 40px; padding: 0 10px 0 4px; border-radius: var(--r-pill); background: var(--bg-2); }
.user-btn:hover { background: var(--bg-3); }
.user-caret { color: var(--fg-2); }
.avatar { display: inline-block; border-radius: 50%; object-fit: cover; flex-shrink: 0; background: var(--bg-3); }
.avatar-letter { display: inline-grid; place-items: center; color: #fff; font-family: var(--font-display); font-weight: 800; line-height: 1; }
.user-menu { min-width: 260px; padding: 10px; }
.um-head { display: flex; align-items: center; gap: 12px; padding: 8px 8px 12px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.um-head b { display: block; font-size: 15px; }
.um-head small { display: block; font-size: 12px; color: var(--fg-2); }
.user-menu a, .um-logout button {
    display: flex; align-items: center; justify-content: flex-start; gap: 12px; width: 100%; padding: 10px;
    border-radius: var(--r-chip); font-size: 14px; font-weight: 600; color: var(--fg-1); text-align: left;
}
.user-menu a:hover, .um-logout button:hover { background: var(--bg-2); color: var(--fg-0); }
.um-i { display: inline-grid; place-items: center; color: var(--fg-2); }
.um-logout { margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--line); }

/* ---------- Toast ---------- */
.toast-stack { position: fixed; top: calc(var(--header-h) + 10px); right: 16px; z-index: 90; display: grid; gap: 8px; max-width: min(420px, calc(100vw - 32px)); }
.toast {
    display: flex; align-items: flex-start; gap: 10px; padding: 12px 16px; border-radius: var(--r-card);
    background: rgba(var(--c-bg-1) / .97); border: 1px solid var(--line-2); box-shadow: var(--shadow-float);
    font-size: 14px; font-weight: 600; animation: toastIn .35s var(--ease-out-expo); backdrop-filter: blur(12px);
}
.toast .icon { margin-top: 1px; }
.toast-ok .icon { color: rgb(var(--c-ok)); }
.toast-err .icon { color: var(--accent-hi); }
.toast-dev { font-weight: 500; word-break: break-all; }
.toast-dev a { color: rgb(var(--c-vip)); text-decoration: underline; }
.toast.is-leaving { opacity: 0; transform: translateY(-8px); transition: opacity .3s, transform .3s; }
@keyframes toastIn { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: none; } }

/* ---------- Auth pages ---------- */
.auth-wrap { display: grid; place-items: center; min-height: calc(100vh - var(--header-h) - 120px); padding: 40px 16px; }
.auth-card {
    width: 100%; max-width: 440px; padding: 32px 28px; border-radius: var(--r-panel);
    background: var(--bg-1); border: 1px solid var(--line); box-shadow: var(--shadow-float);
}
.auth-icon { display: grid; place-items: center; width: 52px; height: 52px; border-radius: 16px; background: rgba(var(--c-accent) / .15); color: var(--accent-hi); margin-bottom: 18px; }
.auth-title { font-family: var(--font-display); font-weight: 800; font-size: 28px; letter-spacing: -.025em; }
.auth-intro { margin-top: 6px; color: var(--fg-1); font-size: 14px; line-height: 1.55; }
.auth-switch { margin-top: 20px; text-align: center; font-size: 14px; color: var(--fg-2); }
.auth-switch a { display: inline-flex; align-items: center; gap: 4px; color: var(--fg-0); font-weight: 700; }
.auth-switch a:hover { text-decoration: underline; }

/* ---------- Forms ---------- */
.form { display: grid; gap: 16px; margin-top: 22px; }
.field { display: grid; gap: 6px; }
.field-label { font-size: 13px; font-weight: 700; color: var(--fg-1); }
.input-wrap {
    display: flex; align-items: center; gap: 10px; height: 48px; padding: 0 14px; border-radius: 12px;
    background: var(--bg-2); border: 1px solid var(--line); color: var(--fg-2); transition: border-color .14s, box-shadow .14s;
}
.input-wrap:focus-within { border-color: rgba(var(--c-accent) / .7); box-shadow: 0 0 0 3px rgba(var(--c-accent) / .18); }
.input-wrap input { flex: 1; min-width: 0; height: 100%; background: transparent; border: 0; outline: 0; color: var(--fg-0); font-size: 15px; }
.input-wrap.is-disabled { opacity: .7; }
.field.has-error .input-wrap { border-color: rgba(var(--c-accent) / .8); }
.field-error { font-size: 12.5px; color: #ff6b6b; font-weight: 600; }
.field-hint { font-size: 12.5px; color: var(--fg-2); }
.pw-toggle { display: grid; place-items: center; color: var(--fg-2); }
.pw-toggle:hover { color: var(--fg-0); }
.form-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; color: var(--fg-1); cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); }
.input {
    width: 100%; height: 46px; padding: 0 16px; border-radius: 12px; background: var(--bg-2); border: 1px solid var(--line);
    color: var(--fg-0); font-size: 15px; outline: 0;
}
.input:focus { border-color: rgba(var(--c-accent) / .7); }

/* ---------- Account: profile card ---------- */
.account { padding-top: 28px; }
.profile-card {
    position: relative; overflow: hidden; padding: 28px; border-radius: var(--r-panel); border: 1px solid var(--line);
    background: radial-gradient(ellipse at 85% 0%, rgba(var(--c-accent) / .22), transparent 55%), var(--bg-1);
}
.profile-top { display: flex; gap: 26px; align-items: flex-start; }
.profile-avatar-col { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.profile-avatar { position: relative; display: inline-block; border-radius: 50%; padding: 3px; background: linear-gradient(135deg, rgba(255, 255, 255, .25), rgba(255, 255, 255, .05)); }
.profile-avatar .avatar { display: block; }
.avatar-cam {
    position: absolute; right: -2px; bottom: 2px; display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%;
    background: var(--accent); color: #fff; border: 3px solid var(--bg-1);
}
.profile-avatar-sm .avatar-cam { width: 24px; height: 24px; border-width: 2px; right: -4px; bottom: -2px; }
.level-badge { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 12px; border-radius: var(--r-pill); background: var(--bg-2); border: 1px solid var(--line); font-size: 12.5px; font-weight: 700; white-space: nowrap; }
.profile-main { min-width: 0; padding-top: 8px; }
.profile-name { font-family: var(--font-display); font-weight: 800; font-size: clamp(28px, 3vw, 38px); letter-spacing: -.03em; line-height: 1.1; word-break: break-word; }
.member-pill { display: inline-flex; align-items: center; height: 30px; padding: 0 14px; margin-top: 10px; border-radius: var(--r-pill); background: var(--bg-2); border: 1px solid var(--line); font-size: 13px; font-weight: 700; color: var(--fg-1); }
.profile-meta { display: flex; flex-wrap: wrap; gap: 8px 22px; margin-top: 14px; font-size: 14px; color: var(--fg-1); }
.profile-meta span { display: inline-flex; align-items: center; gap: 8px; }
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-top: 26px; }
.stat-card {
    display: grid; grid-template-columns: auto 1fr; align-items: center; column-gap: 10px; row-gap: 12px;
    padding: 16px; border-radius: var(--r-card); background: rgba(var(--c-bg-0) / .35); border: 1px solid var(--line); transition: border-color .14s;
}
a.stat-card:hover { border-color: var(--line-2); }
.stat-icon { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; }
.si-red { background: rgba(var(--c-accent) / .16); color: var(--accent-hi); }
.si-gray { background: var(--bg-3); color: var(--fg-1); }
.si-green { background: rgba(var(--c-ok) / .14); color: rgb(var(--c-ok)); }
.si-gold { background: rgba(var(--c-vip) / .14); color: rgb(var(--c-vip)); }
.stat-label { font-size: 14px; color: var(--fg-1); font-weight: 600; }
.stat-num { grid-column: 1 / -1; font-family: var(--font-display); font-size: 30px; font-weight: 800; line-height: 1; }

/* Tabs */
.tabbar {
    display: flex; gap: 4px; width: max-content; max-width: 100%; margin: 26px 0 24px; padding: 5px; overflow-x: auto; scrollbar-width: none;
    border-radius: var(--r-pill); background: var(--bg-1); border: 1px solid var(--line);
}
.tabbar::-webkit-scrollbar { display: none; }
.tab { display: inline-flex; align-items: center; gap: 8px; height: 38px; padding: 0 16px; border-radius: var(--r-pill); font-size: 14px; font-weight: 600; color: var(--fg-1); white-space: nowrap; }
.tab:hover { color: var(--fg-0); }
.tab.is-active { background: #fff; color: var(--bg-0); font-weight: 700; }

/* Panels */
.acc-grid { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); gap: 20px; }
.panel { padding: 24px; border-radius: var(--r-panel); background: var(--bg-1); border: 1px solid var(--line); }
.panel-narrow { max-width: 760px; margin: 0 auto 20px; }
.panel-title, .acc-title { display: flex; align-items: center; gap: 12px; font-family: var(--font-display); font-weight: 800; font-size: 21px; letter-spacing: -.02em; min-width: 0; }
.panel-icon { display: grid; place-items: center; flex-shrink: 0; width: 42px; height: 42px; border-radius: 12px; border: 1px solid var(--line); }
.pi-red { background: rgba(var(--c-accent) / .16); color: var(--accent-hi); border-color: rgba(var(--c-accent) / .25); }
.pi-gold { background: rgba(var(--c-vip) / .12); color: rgb(var(--c-vip)); border-color: rgba(var(--c-vip) / .25); }
.count-pill { display: inline-grid; place-items: center; min-width: 30px; height: 30px; padding: 0 8px; border-radius: var(--r-pill); background: var(--bg-2); font-family: var(--font-sans); font-size: 13px; font-weight: 700; }
.acc-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.acc-actions { display: flex; gap: 8px; align-items: flex-start; }
.summary-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 20px 0 0; }
.summary-grid > div { padding: 12px 16px; border-radius: 12px; background: var(--bg-2); min-width: 0; }
.summary-grid dt { font-size: 13px; color: var(--fg-2); }
.summary-grid dd { margin: 3px 0 0; font-weight: 700; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.summary-grid dd.ok { color: rgb(var(--c-ok)); }
.quick-list { display: grid; gap: 10px; margin-top: 20px; }
.quick-list a {
    display: flex; align-items: center; gap: 12px; height: 52px; padding: 0 16px; border-radius: var(--r-card);
    border: 1px solid var(--line-2); font-weight: 700; font-size: 15px; transition: background-color .14s;
}
.quick-list a span { flex: 1; }
.quick-list a .icon:last-child { color: var(--fg-2); }
.quick-list a:hover { background: var(--bg-2); }

/* Empty states */
.empty-panel {
    display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px; padding: 60px 24px;
    border-radius: var(--r-panel); background: var(--bg-1); border: 1px solid var(--line);
}
.empty-panel h3 { font-size: 20px; font-weight: 800; margin-top: 8px; }
.empty-panel p { max-width: 440px; color: var(--fg-1); font-size: 14.5px; line-height: 1.6; }
.empty-panel .btn { margin-top: 14px; }
.empty-icon { display: grid; place-items: center; width: 58px; height: 58px; border-radius: 50%; background: var(--bg-3); color: var(--fg-1); }
.ei-red { background: rgba(var(--c-accent) / .16); color: var(--accent-hi); }

/* Cards with remove button / progress */
.card-wrap { position: relative; }
.card-x {
    position: absolute; top: 8px; right: 8px; z-index: 2; display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%;
    background: rgba(8, 8, 10, .75); border: 1px solid var(--line-2); color: var(--fg-0); backdrop-filter: blur(6px);
}
.card-x:hover { background: var(--accent); }
.card-x.is-on { color: var(--accent-hi); }
.card-x.is-on:hover { color: #fff; }
.progress { position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: rgba(255, 255, 255, .2); }
.progress > span { display: block; height: 100%; background: var(--accent); }
.card-history .card-eps { bottom: 12px; }

/* Lists */
.inline-create { display: flex; gap: 10px; margin-top: 20px; }
.inline-create .input { flex: 1; min-width: 0; }
.dashed-empty { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-top: 18px; padding: 36px 16px; border: 1px dashed var(--line-2); border-radius: var(--r-card); color: var(--fg-2); font-size: 14px; text-align: center; }
.list-rows { display: grid; gap: 8px; margin-top: 18px; }
.list-row { display: flex; align-items: center; gap: 14px; padding: 10px 14px 10px 10px; border-radius: var(--r-card); background: var(--bg-2); transition: background-color .14s; }
.list-row:hover { background: var(--bg-3); }
.list-cover { display: grid; place-items: center; flex-shrink: 0; width: 48px; height: 64px; border-radius: 8px; overflow: hidden; background: var(--bg-3); color: var(--fg-2); }
.list-cover img { width: 100%; height: 100%; object-fit: cover; }
.list-text { flex: 1; min-width: 0; }
.list-text b { display: block; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-text small { font-size: 13px; color: var(--fg-2); }
.back-link { display: inline-flex; align-items: center; gap: 6px; margin-bottom: 14px; font-size: 14px; font-weight: 600; color: var(--fg-1); }
.back-link:hover { color: var(--fg-0); }
.pop { position: relative; }
.pop summary { list-style: none; cursor: pointer; }
.pop summary::-webkit-details-marker { display: none; }
.pop-body { position: absolute; right: 0; top: calc(100% + 8px); z-index: 10; width: min(360px, 80vw); margin: 0; padding: 12px; border-radius: var(--r-card); background: var(--bg-1); border: 1px solid var(--line-2); box-shadow: var(--shadow-float); }

/* Settings */
.avatar-box { display: flex; align-items: center; gap: 16px; padding: 14px 16px; border-radius: var(--r-card); background: var(--bg-2); border: 1px solid var(--line); }
.avatar-text { flex: 1; min-width: 0; }
.avatar-text b { display: block; font-size: 15px; }
.avatar-text small { display: block; font-size: 13px; color: var(--fg-2); }
.avatar-gallery { padding: 14px; border-radius: var(--r-card); background: var(--bg-2); }
.avatar-gallery[hidden] { display: none; }
.gallery-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(56px, 1fr)); gap: 10px; margin-top: 8px; }
.gallery-item { border-radius: 50%; padding: 3px; border: 2px solid transparent; transition: border-color .14s, transform .14s; }
.gallery-item img { border-radius: 50%; width: 100%; height: auto; }
.gallery-item:hover { transform: scale(1.06); }
.gallery-item.is-selected { border-color: var(--accent); }
.panel-narrow + .panel-narrow { margin-top: 20px; }

/* Favorite button */
.btn-fav .fav-on, .btn-fav .fav-off { display: inline-flex; }
.btn-fav .fav-on { display: none; color: var(--accent-hi); }
.btn-fav.is-on .fav-on { display: inline-flex; }
.btn-fav.is-on .fav-off { display: none; }
.btn-fav.is-pop .fav-on { animation: favPop .4s var(--ease-out-expo); }
@keyframes favPop { 0% { transform: scale(.5); } 60% { transform: scale(1.25); } 100% { transform: scale(1); } }

/* Modal */
.modal { position: fixed; inset: 0; z-index: 85; display: grid; place-items: center; padding: 16px; background: rgba(0, 0, 0, .7); backdrop-filter: blur(6px); }
.modal[hidden] { display: none; }
.modal-panel { width: 100%; max-width: 440px; padding: 20px; border-radius: var(--r-panel); background: var(--bg-1); border: 1px solid var(--line-2); box-shadow: var(--shadow-float); animation: toastIn .3s var(--ease-out-expo); }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.modal-head h2 { font-family: var(--font-display); font-size: 20px; font-weight: 800; }
.modal-lists { display: grid; gap: 6px; max-height: 46vh; overflow-y: auto; }
.modal-lists .ml-empty { padding: 18px; text-align: center; color: var(--fg-2); font-size: 14px; border: 1px dashed var(--line-2); border-radius: var(--r-card); }
.modal-lists label { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 12px; background: var(--bg-2); cursor: pointer; font-weight: 600; }
.modal-lists label:hover { background: var(--bg-3); }
.modal-lists input { width: 18px; height: 18px; accent-color: var(--accent); flex-shrink: 0; }
.modal-lists span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.modal-lists small { color: var(--fg-2); font-size: 12px; font-weight: 500; }
.modal .inline-create { margin-top: 14px; }
.modal-foot { margin-top: 14px; }

@media (max-width: 1023px) {
    .signin-btn { height: 34px; padding: 0 12px; }
    .acc-grid { grid-template-columns: 1fr; }
    .stat-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 767px) {
    .profile-card { padding: 20px; }
    .profile-top { flex-direction: column; align-items: center; text-align: center; gap: 14px; }
    .profile-meta { justify-content: center; }
    .summary-grid { grid-template-columns: 1fr; }
    .avatar-box { flex-wrap: wrap; }
    .inline-create { flex-direction: column; }
    .auth-card { padding: 26px 20px; }
    .header-actions .lang-dd { display: none; }
    .hero-actions .btn-fav [data-fav-label] { display: none; }
}

/* ---------- Comments ---------- */
.comments { margin-top: 44px; padding: 24px; border-radius: var(--r-panel); background: var(--bg-1); border: 1px solid var(--line); }
.cmt-top { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.cmt-title { font-family: var(--font-display); font-weight: 800; font-size: 21px; letter-spacing: -.02em; }
.cmt-count { font-size: 15px; color: var(--fg-2); }
.cmt-form { display: flex; gap: 12px; align-items: flex-start; }
.cmt-form-main { flex: 1; min-width: 0; }
.cmt-form textarea {
    display: block; width: 100%; min-height: 66px; padding: 12px 14px; resize: vertical; border-radius: 12px;
    background: var(--bg-2); border: 1px solid var(--line); color: var(--fg-0); font: inherit; font-size: 15px; line-height: 1.5; outline: 0;
    transition: border-color .14s, box-shadow .14s;
}
.cmt-form textarea::placeholder { color: var(--fg-2); }
.cmt-form textarea:focus { border-color: rgba(var(--c-accent) / .7); box-shadow: 0 0 0 3px rgba(var(--c-accent) / .18); }
.cmt-actions { display: flex; align-items: center; gap: 12px; margin-top: 10px; }
.cmt-status { flex: 1; min-width: 0; font-size: 13px; font-weight: 600; color: var(--fg-1); }
.cmt-status.is-ok { color: rgb(var(--c-ok)); }
.cmt-status.is-err { color: #ff6b6b; }
.cmt-chars { font-size: 12px; color: var(--fg-2); font-variant-numeric: tabular-nums; }
.cmt-submit { height: 40px; }
.cmt-submit:disabled { opacity: .45; box-shadow: none; cursor: not-allowed; }
.cmt-form.is-busy .cmt-submit { opacity: .6; }
.cmt-login {
    display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
    padding: 14px 16px; border-radius: 12px; background: rgba(var(--c-bg-2) / .7); color: var(--fg-1); font-size: 14px;
}
.cmt-list { display: grid; gap: 18px; margin-top: 24px; }
.cmt { display: flex; gap: 12px; align-items: flex-start; }
.cmt.is-new { animation: toastIn .4s var(--ease-out-expo); }
.cmt-avatar { box-shadow: 0 0 0 2px rgba(255, 255, 255, .06); }
.avatar.cmt-avatar { width: 36px; height: 36px; }
.cmt-body { flex: 1; min-width: 0; }
.cmt-head { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 10px; }
.cmt-user { font-size: 14px; font-weight: 700; }
.cmt-ep { padding: 1px 8px; border-radius: var(--r-pill); background: var(--bg-2); font-size: 11px; font-weight: 700; color: var(--fg-1); }
.cmt-time { font-size: 13px; color: var(--fg-2); }
.cmt-del { display: grid; place-items: center; width: 26px; height: 26px; margin-left: auto; border-radius: 8px; color: var(--fg-2); opacity: 0; transition: opacity .14s, background-color .14s, color .14s; }
.cmt:hover .cmt-del, .cmt-del:focus-visible { opacity: 1; }
.cmt-del:hover { background: rgba(var(--c-accent) / .16); color: var(--accent-hi); }
.cmt-text { margin-top: 4px; font-size: 15px; line-height: 1.55; color: var(--fg-0); white-space: normal; overflow-wrap: anywhere; }
.cmt-empty { margin-top: 18px; padding: 22px; text-align: center; font-size: 14px; color: var(--fg-2); border: 1px dashed var(--line-2); border-radius: var(--r-card); }
.cmt-empty[hidden] { display: none; }
.cmt-more { margin: 22px auto 0; display: flex; }
@media (max-width: 767px) {
    .comments { padding: 18px; }
    .cmt-form > .avatar { display: none; }
    .cmt-del { opacity: 1; }
}
@media (hover: none) { .cmt-del { opacity: 1; } }
