/* ==========================================================================
   S3Update - Login + File Manager theme (layered on Bootstrap 3.4.1)
   ========================================================================== */
:root {
    --c-bg: #f4f6fb;
    --c-surface: #ffffff;
    --c-surface-2: #f8f9fc;
    --c-border: #e6e9f2;
    --c-text: #1d2333;
    --c-muted: #6b7489;
    --c-primary: #5b5bf7;
    --c-primary-2: #8b5cf6;
    --c-primary-soft: rgba(91, 91, 247, .1);
    --c-success: #12b981;
    --c-warning: #f59e0b;
    --c-danger: #ef4444;
    --c-info: #0ea5e9;
    --c-folder: #f6b73c;
    --radius: 14px;
    --radius-sm: 10px;
    --shadow-sm: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
    --shadow: 0 10px 30px -12px rgba(30, 41, 80, .18), 0 4px 10px -6px rgba(30, 41, 80, .1);
    --shadow-lg: 0 30px 70px -20px rgba(30, 30, 90, .35);
    --ease: cubic-bezier(.22, .8, .3, 1);
    --font: "Inter", "Segoe UI Variable", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
    --mono: "Cascadia Code", "JetBrains Mono", Consolas, "Courier New", monospace;
}

html, body.s3u { height: 100%; }
body.s3u {
    margin: 0; padding: 0;
    font-family: var(--font); font-size: 14px; line-height: 1.5;
    color: var(--c-text); background: var(--c-bg);
    -webkit-font-smoothing: antialiased;
}
.s3u svg { display: inline-block; vertical-align: middle; }
.s3u *:focus-visible { outline: 3px solid rgba(91, 91, 247, .45); outline-offset: 2px; }
.s3u button { font-family: inherit; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); border: 0; }

@keyframes fadeUp { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { 0% { opacity: 0; transform: scale(.96) translateY(8px); } 100% { opacity: 1; transform: none; } }
@keyframes shake { 10%, 90% { transform: translateX(-1px); } 20%, 80% { transform: translateX(3px); } 30%, 50%, 70% { transform: translateX(-5px); } 40%, 60% { transform: translateX(5px); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes float { 0%, 100% { transform: translate(0, 0) scale(1); } 50% { transform: translate(30px, -25px) scale(1.06); } }
@keyframes shimmer { 0% { background-position: -400px 0; } 100% { background-position: 400px 0; } }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(18, 185, 129, .5); } 50% { box-shadow: 0 0 0 5px rgba(18, 185, 129, 0); } }

/* ---------- Buttons ---------- */
.btn-primary-x, .btn-ghost-x, .btn-link-x {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    border: 0; cursor: pointer; text-decoration: none !important; font-weight: 600; font-size: 14px;
    transition: transform .18s var(--ease), box-shadow .18s var(--ease), background .18s, color .18s, opacity .18s;
    -webkit-appearance: none; appearance: none;
}
.btn-primary-x {
    position: relative; overflow: hidden;
    height: 44px; padding: 0 20px; border-radius: 12px; color: #fff !important;
    background: linear-gradient(135deg, var(--c-primary), var(--c-primary-2));
    box-shadow: 0 8px 20px -8px rgba(91, 91, 247, .7);
}
.btn-primary-x:hover { transform: translateY(-1px); box-shadow: 0 12px 26px -10px rgba(91, 91, 247, .85); }
.btn-primary-x:active { transform: translateY(0) scale(.99); }
.btn-primary-x::after {
    content: ""; position: absolute; inset: 0;
    background: linear-gradient(120deg, transparent 30%, rgba(255, 255, 255, .25) 50%, transparent 70%);
    transform: translateX(-100%); transition: transform .6s var(--ease);
}
.btn-primary-x:hover::after { transform: translateX(100%); }
.btn-ghost-x {
    height: 40px; padding: 0 16px; border-radius: 10px;
    background: var(--c-surface); color: var(--c-text) !important; border: 1px solid var(--c-border);
}
.btn-ghost-x:hover { background: var(--c-surface-2); border-color: #d5d9e6; transform: translateY(-1px); }
.btn-link-x { background: none; color: var(--c-primary); padding: 6px 4px; font-size: 13.5px; }
.btn-link-x:hover { text-decoration: underline !important; }
.btn-link-x.muted { color: var(--c-muted); font-weight: 500; }
.btn-link-x[disabled], .btn-link-x.is-disabled { color: #a3a9b9; cursor: not-allowed; text-decoration: none !important; }
.btn-block-x { width: 100%; }
.is-loading { pointer-events: none; opacity: .85; }
.btn-primary-x.is-loading::before, .btn-ghost-x.is-loading::before {
    content: ""; width: 16px; height: 16px; border-radius: 50%;
    border: 2px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite;
}
.btn-primary-x[disabled] { opacity: .6; cursor: not-allowed; transform: none; }

.icon-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 38px; height: 38px; flex: 0 0 38px; border-radius: 10px;
    border: 1px solid var(--c-border); background: var(--c-surface); color: var(--c-muted); cursor: pointer;
    transition: all .18s var(--ease);
}
.icon-btn svg { width: 19px; height: 19px; }
.icon-btn:hover { color: var(--c-primary); border-color: rgba(91, 91, 247, .35); background: var(--c-primary-soft); transform: translateY(-1px); }
.icon-btn[disabled] { opacity: .45; cursor: not-allowed; transform: none; background: var(--c-surface); color: var(--c-muted); border-color: var(--c-border); }
.icon-btn.spinning svg { animation: spin .7s linear infinite; }

.spinner-x {
    display: inline-block; width: 22px; height: 22px; border-radius: 50%;
    border: 3px solid var(--c-primary-soft); border-top-color: var(--c-primary); animation: spin .75s linear infinite;
}

/* ---------- Alerts ---------- */
.alert-x {
    display: flex; align-items: flex-start; gap: 10px;
    padding: 11px 14px; border-radius: 12px; font-size: 13.5px; margin-bottom: 16px;
    border: 1px solid transparent; animation: fadeUp .35s var(--ease);
}
.alert-x .alert-dot { width: 8px; height: 8px; flex: 0 0 8px; border-radius: 50%; margin-top: 6px; background: currentColor; }
.alert-error { background: #fef2f2; color: #b42318; border-color: #fecdca; animation: fadeUp .35s var(--ease), shake .45s .1s; }
.alert-success { background: #ecfdf3; color: #067647; border-color: #abefc6; }
.alert-warning { background: #fffaeb; color: #b54708; border-color: #fedf89; }
.alert-info { background: #f0f9ff; color: #026aa2; border-color: #b9e6fe; }

/* ==========================================================================
   LOGIN
   ========================================================================== */
.auth-body { background: radial-gradient(1200px 600px at 10% -10%, #e0e3ff 0%, transparent 60%), radial-gradient(900px 600px at 110% 110%, #f3e8ff 0%, transparent 55%), #eef1f8; overflow-x: hidden; }
.bg-orbs { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.orb { position: absolute; border-radius: 50%; filter: blur(60px); opacity: .55; animation: float 14s ease-in-out infinite; }
.orb-1 { width: 380px; height: 380px; left: -80px; top: -60px; background: #a5b4fc; }
.orb-2 { width: 320px; height: 320px; right: -60px; bottom: -40px; background: #d8b4fe; animation-delay: -5s; }
.orb-3 { width: 220px; height: 220px; right: 22%; top: 12%; background: #7dd3fc; opacity: .35; animation-delay: -9s; }
.bg-grid {
    position: absolute; inset: 0;
    background-image: linear-gradient(rgba(91, 91, 247, .06) 1px, transparent 1px), linear-gradient(90deg, rgba(91, 91, 247, .06) 1px, transparent 1px);
    background-size: 36px 36px;
    -webkit-mask-image: radial-gradient(ellipse at center, #000 30%, transparent 75%); mask-image: radial-gradient(ellipse at center, #000 30%, transparent 75%);
}
.auth-wrap { position: relative; z-index: 1; min-height: 100%; display: flex; align-items: center; justify-content: center; padding: 32px 16px; }
.auth-card {
    width: 100%; max-width: 420px; padding: 34px 32px 24px;
    background: rgba(255, 255, 255, .86); border: 1px solid rgba(255, 255, 255, .9); border-radius: 22px;
    box-shadow: var(--shadow-lg);
    -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
    animation: pop .55s var(--ease);
}
.brand { display: flex; align-items: center; gap: 12px; margin-bottom: 26px; }
.brand-mark {
    display: inline-flex; align-items: center; justify-content: center;
    width: 46px; height: 46px; border-radius: 14px; color: #fff;
    background: linear-gradient(135deg, var(--c-primary), var(--c-primary-2));
    box-shadow: 0 10px 22px -10px rgba(91, 91, 247, .9);
}
.brand-mark.sm { width: 36px; height: 36px; border-radius: 11px; }
.brand-name { font-weight: 700; font-size: 16px; letter-spacing: -.01em; }
.brand-sub { font-size: 12.5px; color: var(--c-muted); }
.auth-title { font-size: 24px; font-weight: 750; letter-spacing: -.02em; margin: 0 0 6px; }
.auth-lead { color: var(--c-muted); margin: 0 0 22px; font-size: 13.5px; }
.step { animation: fadeUp .45s var(--ease); }
.text-center { text-align: center; }

.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: #39405a; }
.input-icon { position: relative; }
.input-icon > svg { position: absolute; left: 14px; top: 50%; width: 18px; height: 18px; margin-top: -9px; color: #9aa2b6; transition: color .18s; pointer-events: none; }
.input-icon input {
    width: 100%; height: 46px; padding: 0 44px 0 42px; font-size: 14.5px;
    border: 1.5px solid var(--c-border); border-radius: 12px; background: #fff; color: var(--c-text);
    transition: border-color .18s, box-shadow .18s; outline: none;
}
.input-icon input:focus { border-color: var(--c-primary); box-shadow: 0 0 0 4px var(--c-primary-soft); }
.input-icon:focus-within > svg { color: var(--c-primary); }
.pw-toggle { position: absolute; right: 6px; top: 50%; margin-top: -17px; width: 34px; height: 34px; border: 0; border-radius: 9px; background: none; color: #9aa2b6; cursor: pointer; }
.pw-toggle:hover, .pw-toggle.on { color: var(--c-primary); background: var(--c-primary-soft); }
.pw-toggle svg { width: 18px; height: 18px; }

.otp-icon {
    width: 62px; height: 62px; margin: 0 auto 14px; border-radius: 18px; display: flex; align-items: center; justify-content: center;
    color: var(--c-primary); background: var(--c-primary-soft); animation: pop .5s var(--ease);
}
.masked-numbers { color: var(--c-text); font-weight: 600; white-space: normal; word-break: break-word; }
.otp-real {
    width: 100%; height: 50px; text-align: center; font-size: 22px; letter-spacing: 8px; font-family: var(--mono);
    border: 1.5px solid var(--c-border); border-radius: 12px; outline: none;
}
.otp-real:focus { border-color: var(--c-primary); box-shadow: 0 0 0 4px var(--c-primary-soft); }
.js .otp-real.enhanced { position: absolute; opacity: 0; pointer-events: none; height: 1px; width: 1px; }
.otp-boxes { display: none; gap: 8px; justify-content: center; }
.otp-boxes.ready { display: flex; }
.otp-box {
    width: 46px; height: 54px; flex: 0 1 46px; min-width: 0; text-align: center; font-size: 22px; font-weight: 700; font-family: var(--mono);
    border: 1.5px solid var(--c-border); border-radius: 12px; background: #fff; color: var(--c-text); outline: none;
    transition: border-color .18s, box-shadow .18s, transform .18s;
}
.otp-box:focus { border-color: var(--c-primary); box-shadow: 0 0 0 4px var(--c-primary-soft); transform: translateY(-2px); }
.otp-box.filled { border-color: rgba(91, 91, 247, .55); background: #fbfbff; }
.otp-meta { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin: 4px 0 18px; font-size: 12.5px; color: var(--c-muted); }
.otp-expiry { display: inline-flex; align-items: center; gap: 6px; }
.otp-expiry svg { width: 15px; height: 15px; }
.otp-expiry.low { color: var(--c-warning); }
.otp-expiry.expired { color: var(--c-danger); font-weight: 600; }
.otp-actions { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 6px; margin-top: 14px; }
.auth-foot { display: flex; align-items: center; justify-content: center; gap: 6px; margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--c-border); font-size: 12px; color: var(--c-muted); }
.auth-foot svg { width: 14px; height: 14px; color: var(--c-success); }

/* ==========================================================================
   FILE MANAGER
   ========================================================================== */
.app-body { background: radial-gradient(900px 400px at 100% -10%, #ebe9ff 0%, transparent 60%), var(--c-bg); }
.app-header {
    position: sticky; top: 0; z-index: 50;
    background: rgba(255, 255, 255, .82); border-bottom: 1px solid var(--c-border);
    -webkit-backdrop-filter: saturate(180%) blur(14px); backdrop-filter: saturate(180%) blur(14px);
    animation: fadeIn .4s;
}
.app-header-inner { max-width: 1320px; margin: 0 auto; padding: 10px 20px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.app-brand { display: flex; align-items: center; gap: 10px; min-width: 0; color: var(--c-text) !important; text-decoration: none !important; }
.app-brand-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.app-name { font-weight: 700; font-size: 15px; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.app-context { font-size: 12px; color: var(--c-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 40vw; }
.app-header-actions { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.admin-chip { display: flex; align-items: center; gap: 9px; padding: 4px 12px 4px 4px; border-radius: 999px; background: var(--c-surface-2); border: 1px solid var(--c-border); }
.admin-avatar { width: 30px; height: 30px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; color: #fff; background: linear-gradient(135deg, var(--c-primary), var(--c-primary-2)); }
.admin-meta { display: flex; flex-direction: column; line-height: 1.15; }
.admin-name { font-weight: 600; font-size: 13px; max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.admin-role { font-size: 11px; color: var(--c-muted); display: flex; align-items: center; gap: 5px; }
.dot-online { width: 7px; height: 7px; border-radius: 50%; background: var(--c-success); animation: pulse 2.4s infinite; }
.logout-btn:hover { color: var(--c-danger) !important; border-color: #fecdca; background: #fef2f2; }

.app-main { max-width: 1320px; margin: 0 auto; padding: 20px 20px 48px; }
.card-x { background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }

.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 10px; animation: fadeUp .4s var(--ease); }
.toolbar-nav { display: flex; align-items: center; gap: 6px; min-width: 0; flex: 1 1 420px; }
.toolbar-tools { display: flex; align-items: center; gap: 8px; flex: 0 1 auto; }
.crumbs { display: flex; align-items: center; gap: 2px; min-width: 0; overflow-x: auto; padding: 0 6px; scrollbar-width: none; white-space: nowrap; }
.crumbs::-webkit-scrollbar { display: none; }
.crumb { border: 0; background: none; color: var(--c-muted); padding: 6px 8px; border-radius: 8px; cursor: pointer; font-weight: 500; font-size: 13.5px; max-width: 220px; overflow: hidden; text-overflow: ellipsis; flex-shrink: 0; transition: background .15s, color .15s; }
.crumb:hover { background: var(--c-primary-soft); color: var(--c-primary); }
.crumb.current { color: var(--c-text); font-weight: 650; cursor: default; background: none; }
.crumb-sep { color: #c3c8d6; flex-shrink: 0; }
.crumb-sep svg { width: 16px; height: 16px; }
.crumb-home svg { width: 16px; height: 16px; margin: -2px 4px 0 0; }

.search-box { position: relative; width: 300px; max-width: 100%; }
.search-box > svg { position: absolute; left: 12px; top: 50%; margin-top: -9px; width: 18px; height: 18px; color: #9aa2b6; pointer-events: none; }
.search-box input {
    width: 100%; height: 38px; padding: 0 34px 0 38px; border-radius: 10px; border: 1px solid var(--c-border); background: var(--c-surface-2);
    font-size: 13.5px; outline: none; transition: all .18s;
}
.search-box input:focus { background: #fff; border-color: var(--c-primary); box-shadow: 0 0 0 4px var(--c-primary-soft); }
.kbd-hint { position: absolute; right: 9px; top: 50%; transform: translateY(-50%); font-size: 11px; padding: 1px 6px; border-radius: 5px; background: #fff; border: 1px solid var(--c-border); color: var(--c-muted); box-shadow: none; font-family: var(--font); }
.search-box input:focus ~ .kbd-hint, .search-box input:not(:placeholder-shown) ~ .kbd-hint { display: none; }
.seg { display: inline-flex; background: var(--c-surface-2); border: 1px solid var(--c-border); border-radius: 10px; padding: 3px; }
.seg-btn { width: 32px; height: 30px; border: 0; background: none; border-radius: 7px; color: var(--c-muted); cursor: pointer; transition: all .15s; }
.seg-btn svg { width: 17px; height: 17px; }
.seg-btn.active { background: #fff; color: var(--c-primary); box-shadow: var(--shadow-sm); }

.stats-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 2px 12px; min-height: 28px; }
.stat-pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 11px; border-radius: 999px; background: var(--c-surface); border: 1px solid var(--c-border); font-size: 12.5px; color: var(--c-muted); animation: fadeIn .3s; }
.stat-pill b { color: var(--c-text); font-weight: 650; }
.stat-pill.warn { color: #b54708; background: #fffaeb; border-color: #fedf89; }

.section-title { display: flex; align-items: center; gap: 8px; margin: 18px 2px 10px; font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--c-muted); }
.section-title .count { background: var(--c-surface); border: 1px solid var(--c-border); border-radius: 999px; padding: 0 8px; font-size: 11px; letter-spacing: 0; }
.fm-content { min-height: 280px; transition: opacity .2s; }
.fm-content.leaving { opacity: .35; }

/* grid view */
.items { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.item {
    position: relative; display: flex; align-items: center; gap: 12px; padding: 14px; text-align: left; width: 100%;
    background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--radius); box-shadow: var(--shadow-sm);
    color: inherit; transition: transform .2s var(--ease), box-shadow .2s var(--ease), border-color .2s;
    animation: fadeUp .4s var(--ease) both; animation-delay: calc(var(--i, 0) * 18ms);
}
.item:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: rgba(91, 91, 247, .3); }
.item.folder { cursor: pointer; }
.item.folder:active { transform: translateY(-1px) scale(.995); }
.item-icon { width: 44px; height: 44px; flex: 0 0 44px; border-radius: 12px; display: flex; align-items: center; justify-content: center; transition: transform .2s var(--ease); }
.item:hover .item-icon { transform: scale(1.06) rotate(-3deg); }
.item-icon svg { width: 26px; height: 26px; }
.folder .item-icon { background: #fff6e0; color: var(--c-folder); }
.folder.locked .item-icon { background: #f1f2f6; color: #9aa2b6; }
.file .item-icon { background: #eef2ff; color: var(--c-primary); position: relative; }
.file .item-icon::after { content: attr(data-ext); position: absolute; bottom: 5px; font-size: 7.5px; font-weight: 800; letter-spacing: .04em; color: var(--c-primary); }
.item-body { min-width: 0; flex: 1; }
.item-name { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-name mark { padding: 0 1px; background: #fde68a; border-radius: 3px; color: inherit; }
.item-sub { font-size: 12px; color: var(--c-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.item-sub .sep { margin: 0 5px; color: #c3c8d6; }
.item-chev { color: #c3c8d6; transition: transform .2s var(--ease), color .2s; }
.item-chev svg { width: 18px; height: 18px; }
.item.folder:hover .item-chev { color: var(--c-primary); transform: translateX(3px); }
.item-actions { display: flex; gap: 6px; flex-shrink: 0; }
.item-actions .icon-btn { width: 34px; height: 34px; flex-basis: 34px; }
.item-actions .icon-btn svg { width: 17px; height: 17px; }
.item-actions .act-edit:hover { color: var(--c-primary); }
.item-actions .act-dl:hover { color: var(--c-success); border-color: rgba(18, 185, 129, .35); background: rgba(18, 185, 129, .08); }
.file.flash { animation: flashRow 1.4s var(--ease); }
@keyframes flashRow { 0% { box-shadow: 0 0 0 0 rgba(18, 185, 129, .55); border-color: var(--c-success); } 100% { box-shadow: var(--shadow-sm); } }

/* list view */
.view-list .items { grid-template-columns: 1fr; gap: 0; background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-sm); }
.view-list .item { border: 0; border-radius: 0; box-shadow: none; border-bottom: 1px solid var(--c-border); padding: 10px 14px; }
.view-list .item:last-child { border-bottom: 0; }
.view-list .item:hover { transform: none; background: #fafbff; box-shadow: none; }
.view-list .item-icon { width: 36px; height: 36px; flex-basis: 36px; border-radius: 10px; }
.view-list .item-icon svg { width: 21px; height: 21px; }
.view-list .file .item-icon::after { bottom: 3px; font-size: 6.5px; }

/* skeleton */
.skeleton .item { pointer-events: none; }
.sk { border-radius: 8px; background: linear-gradient(90deg, #eef0f5 0, #f7f8fb 40px, #eef0f5 80px); background-size: 800px 100%; animation: shimmer 1.3s infinite linear; }
.sk-icon { width: 44px; height: 44px; border-radius: 12px; flex: 0 0 44px; }
.sk-line { height: 11px; margin: 4px 0; }

/* empty / error states */
.state {
    text-align: center; padding: 56px 20px; margin-top: 8px;
    background: var(--c-surface); border: 1px dashed #d7dbe7; border-radius: var(--radius); animation: fadeUp .4s var(--ease);
}
.state-icon { width: 72px; height: 72px; margin: 0 auto 14px; border-radius: 22px; display: flex; align-items: center; justify-content: center; background: var(--c-primary-soft); color: var(--c-primary); }
.state-icon svg { width: 34px; height: 34px; }
.state.error .state-icon { background: #fef2f2; color: var(--c-danger); }
.state.warn .state-icon { background: #fffaeb; color: var(--c-warning); }
.state h3 { font-size: 17px; font-weight: 700; margin: 0 0 6px; }
.state p { color: var(--c-muted); margin: 0 auto 18px; max-width: 420px; }
.state .state-actions { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; }

/* ---------- Modals ---------- */
.modal-x { position: fixed; inset: 0; z-index: 1000; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal-x[hidden] { display: none; }
.modal-x-backdrop { position: absolute; inset: 0; background: rgba(15, 18, 35, .48); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); animation: fadeIn .2s; }
.modal-x-dialog { position: relative; background: var(--c-surface); border-radius: 18px; box-shadow: var(--shadow-lg); animation: pop .3s var(--ease); max-height: 100%; display: flex; flex-direction: column; }
.modal-x.closing .modal-x-dialog { animation: pop .18s var(--ease) reverse forwards; }
.modal-x.closing .modal-x-backdrop { animation: fadeIn .18s reverse forwards; }
.modal-x-head { display: flex; align-items: center; gap: 12px; padding: 14px 16px 14px 20px; border-bottom: 1px solid var(--c-border); }
.modal-x-title { margin: 0; font-size: 16px; font-weight: 700; letter-spacing: -.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.modal-x-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 12px 16px 12px 20px; border-top: 1px solid var(--c-border); background: var(--c-surface-2); border-radius: 0 0 18px 18px; }

.editor-dialog { width: 100%; max-width: 1080px; height: min(86vh, 900px); }
.file-badge { flex: 0 0 auto; font-size: 10.5px; font-weight: 800; letter-spacing: .05em; padding: 6px 8px; border-radius: 8px; color: var(--c-primary); background: var(--c-primary-soft); }
.editor-head-text { min-width: 0; flex: 1; }
.editor-meta { font-size: 12px; color: var(--c-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dirty-pill { font-size: 11.5px; font-weight: 600; padding: 3px 10px; border-radius: 999px; color: #b54708; background: #fffaeb; border: 1px solid #fedf89; animation: fadeIn .2s; white-space: nowrap; }
.dirty-pill[hidden] { display: none; }
.editor-body { position: relative; flex: 1; min-height: 0; background: #fbfcfe; }
.editor-text {
    display: block; width: 100%; height: 100%; resize: none; border: 0; outline: none; padding: 16px 20px;
    font-family: var(--mono); font-size: 13.5px; line-height: 1.65; color: #1e2436; background: transparent; tab-size: 4;
    white-space: pre; overflow: auto;
}
.editor-text.wrap { white-space: pre-wrap; word-break: break-word; }
.editor-loading { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; gap: 10px; color: var(--c-muted); background: rgba(251, 252, 254, .9); z-index: 2; }
.editor-loading[hidden] { display: none; }
.editor-status { display: flex; align-items: center; gap: 16px; font-size: 12px; color: var(--c-muted); flex-wrap: wrap; }
.wrap-toggle { display: inline-flex; align-items: center; gap: 6px; margin: 0; font-weight: 500; cursor: pointer; }
.wrap-toggle input { margin: 0; }
.editor-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.editor-actions .btn-primary-x { height: 40px; }

.confirm-dialog { width: 100%; max-width: 400px; padding: 26px 24px 20px; text-align: center; }
.confirm-icon { width: 56px; height: 56px; margin: 0 auto 12px; border-radius: 16px; display: flex; align-items: center; justify-content: center; background: #fffaeb; color: var(--c-warning); }
.confirm-text { color: var(--c-muted); margin: 8px 0 20px; }
.confirm-actions { display: flex; gap: 10px; justify-content: center; }
.confirm-actions > * { flex: 1; }

/* ---------- Create folder / file ---------- */
.create-group { display: flex; gap: 8px; }
.create-btn { height: 38px; padding: 0 14px; border-radius: 10px; font-size: 13.5px; white-space: nowrap; }
.create-btn svg { width: 18px; height: 18px; }
.btn-ghost-x.create-btn svg { color: var(--c-folder); }
.create-btn[disabled] { opacity: .5; cursor: not-allowed; transform: none; box-shadow: none; }
.create-dialog { width: 100%; max-width: 440px; padding: 24px; }
.create-head { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.create-icon { width: 48px; height: 48px; flex: 0 0 48px; border-radius: 14px; display: flex; align-items: center; justify-content: center; animation: pop .4s var(--ease); }
.create-icon svg { width: 26px; height: 26px; }
.create-icon.folder { background: #fff6e0; color: var(--c-folder); }
.create-icon.file { background: #eef2ff; color: var(--c-primary); }
.create-where { font-size: 12.5px; color: var(--c-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 300px; }
.create-field-label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: #39405a; }
.create-input-wrap { position: relative; display: flex; align-items: center; }
.create-input-wrap input {
    width: 100%; height: 46px; padding: 0 14px; font-size: 14.5px; border: 1.5px solid var(--c-border); border-radius: 12px;
    outline: none; transition: border-color .18s, box-shadow .18s;
}
.create-input-wrap input:focus { border-color: var(--c-primary); box-shadow: 0 0 0 4px var(--c-primary-soft); }
.create-input-wrap.has-suffix input { padding-right: 52px; }
.create-input-wrap.invalid input { border-color: var(--c-danger); box-shadow: 0 0 0 4px rgba(239, 68, 68, .12); animation: shake .4s; }
.create-suffix { position: absolute; right: 12px; font-family: var(--mono); font-size: 13px; color: var(--c-muted); background: var(--c-surface-2); border: 1px solid var(--c-border); border-radius: 6px; padding: 1px 6px; pointer-events: none; }
.create-suffix[hidden] { display: none; }
.create-hint { font-size: 12px; color: var(--c-muted); margin: 8px 0 0; }
.create-error { font-size: 12.5px; color: var(--c-danger); margin-top: 6px; font-weight: 500; animation: fadeIn .2s; }
.create-error[hidden] { display: none; }
.create-dialog .confirm-actions { margin-top: 20px; }
.item.created { animation: flashRow 1.6s var(--ease); }

/* ---------- Upload ---------- */
/* Bootstrap 3 sets input[type=file]{display:block}, which overrides [hidden]; keep the pickers off-screen instead. */
.s3u input[type="file"].picker-hidden { position: fixed !important; left: -9999px; top: 0; width: 1px; height: 1px; opacity: 0; pointer-events: none; display: block; }

.btn-ghost-x.upload-btn svg { color: var(--c-primary); transition: transform .25s var(--ease); }
.btn-ghost-x.upload-btn:hover svg { transform: translateY(-2px); animation: nudgeUp .9s var(--ease) infinite; }
@keyframes nudgeUp { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-3px); } }

/* upload dialog */
.upload-dialog { width: 100%; max-width: 620px; padding: 22px 22px 18px; overflow: hidden; }
.upload-dialog::before {
    content: ""; position: absolute; left: 0; right: 0; top: 0; height: 120px; pointer-events: none;
    background: radial-gradient(420px 120px at 20% 0%, rgba(91, 91, 247, .14), transparent 70%), radial-gradient(360px 120px at 90% 0%, rgba(139, 92, 246, .14), transparent 70%);
}
.ud-head { position: relative; display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.ud-badge {
    width: 50px; height: 50px; flex: 0 0 50px; border-radius: 15px; display: flex; align-items: center; justify-content: center; color: #fff;
    background: linear-gradient(135deg, var(--c-primary), var(--c-primary-2)); box-shadow: 0 12px 24px -10px rgba(91, 91, 247, .8);
    animation: pop .45s var(--ease), floatY 3.2s ease-in-out .5s infinite;
}
.ud-badge svg { width: 27px; height: 27px; }
@keyframes floatY { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }
.ud-head-text { flex: 1; min-width: 0; }
.ud-where { font-size: 12.5px; color: var(--c-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.ud-tiles { position: relative; display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.ud-tile {
    position: relative; overflow: hidden; display: flex; flex-direction: column; align-items: flex-start; gap: 4px; text-align: left;
    padding: 20px 18px 16px; border-radius: 16px; cursor: pointer; color: var(--c-text);
    background: var(--c-surface); border: 1.5px solid var(--c-border);
    transition: transform .25s var(--ease), box-shadow .25s var(--ease), border-color .25s;
    animation: fadeUp .45s var(--ease) both;
}
.ud-tile.tile-folder { animation-delay: .08s; }
.ud-tile::before { /* soft gradient glow that slides in on hover */
    content: ""; position: absolute; inset: 0; opacity: 0; transition: opacity .3s;
    background: linear-gradient(135deg, rgba(91, 91, 247, .08), rgba(139, 92, 246, .1));
}
.ud-tile.tile-folder::before { background: linear-gradient(135deg, rgba(246, 183, 60, .1), rgba(245, 158, 11, .12)); }
.ud-tile::after { /* shine sweep */
    content: ""; position: absolute; top: 0; bottom: 0; width: 60%; left: -80%;
    background: linear-gradient(110deg, transparent, rgba(255, 255, 255, .7), transparent); transform: skewX(-18deg);
}
.ud-tile:hover, .ud-tile:focus-visible { transform: translateY(-4px); box-shadow: var(--shadow); border-color: rgba(91, 91, 247, .45); }
.ud-tile.tile-folder:hover, .ud-tile.tile-folder:focus-visible { border-color: rgba(246, 183, 60, .6); }
.ud-tile:hover::before, .ud-tile:focus-visible::before { opacity: 1; }
.ud-tile:hover::after { left: 130%; transition: left .8s var(--ease); }
.ud-tile:active { transform: translateY(-1px) scale(.99); }
.ud-tile > * { position: relative; z-index: 1; }
.ud-tile-icon {
    width: 54px; height: 54px; border-radius: 16px; display: flex; align-items: center; justify-content: center; margin-bottom: 10px;
    background: #eef2ff; color: var(--c-primary); transition: transform .35s var(--ease);
}
.tile-folder .ud-tile-icon { background: #fff6e0; color: var(--c-folder); }
.ud-tile-icon svg { width: 30px; height: 30px; }
.ud-tile:hover .ud-tile-icon { transform: translateY(-3px) rotate(-6deg) scale(1.08); }
.ud-tile-title { font-size: 16px; font-weight: 750; letter-spacing: -.01em; }
.ud-tile-sub { font-size: 12.5px; color: var(--c-muted); line-height: 1.4; }
.ud-tile-cta { display: inline-flex; align-items: center; gap: 2px; margin-top: 10px; font-size: 12.5px; font-weight: 650; color: var(--c-primary); }
.tile-folder .ud-tile-cta { color: #c27c0e; }
.ud-tile-cta svg { width: 16px; height: 16px; transition: transform .25s var(--ease); }
.ud-tile:hover .ud-tile-cta svg { transform: translateX(4px); }

.ud-drop {
    position: relative; display: flex; align-items: center; justify-content: center; gap: 10px; margin-top: 14px; padding: 18px;
    border-radius: 14px; color: var(--c-muted); font-size: 13px; background: var(--c-surface-2);
    /* animated dashed border ("marching ants") */
    background-image:
        repeating-linear-gradient(90deg, #c7cbe0 0 8px, transparent 8px 14px), repeating-linear-gradient(90deg, #c7cbe0 0 8px, transparent 8px 14px),
        repeating-linear-gradient(0deg, #c7cbe0 0 8px, transparent 8px 14px), repeating-linear-gradient(0deg, #c7cbe0 0 8px, transparent 8px 14px);
    background-size: 100% 1.5px, 100% 1.5px, 1.5px 100%, 1.5px 100%;
    background-position: 0 0, 0 100%, 0 0, 100% 0;
    background-repeat: no-repeat;
    animation: fadeUp .45s .16s var(--ease) both, ants 1.4s linear infinite;
    transition: color .2s, background-color .2s, transform .2s var(--ease);
}
@keyframes ants {
    to { background-position: 14px 0, -14px 100%, 0 -14px, 100% 14px; }
}
.ud-drop b { color: var(--c-text); }
.ud-drop-icon { width: 22px; height: 22px; color: var(--c-primary); animation: nudgeUp 1.6s var(--ease) infinite; }
.ud-drop.over { color: var(--c-primary); background-color: var(--c-primary-soft); transform: scale(1.01); }
.ud-rules { margin-top: 12px; font-size: 12px; color: var(--c-muted); text-align: center; }
.ud-rules b { color: var(--c-text); font-weight: 600; }

/* file cards: in grid view, actions get their own row so long names stay readable */
.view-grid .item.file { flex-wrap: wrap; row-gap: 10px; }
.view-grid .item.file .item-body { flex: 1 1 calc(100% - 60px); }
.view-grid .item.file .item-actions { flex: 1 1 100%; justify-content: flex-end; padding-top: 10px; border-top: 1px dashed var(--c-border); }
.item-actions .act-copy:hover { color: var(--c-info); border-color: rgba(14, 165, 233, .35); background: rgba(14, 165, 233, .08); }
.item-actions .act-copy.copied { color: #fff; background: var(--c-success); border-color: var(--c-success); animation: pop .3s var(--ease); }

.drop-overlay {
    position: fixed; inset: 0; z-index: 900; display: flex; align-items: center; justify-content: center; padding: 24px;
    background: rgba(91, 91, 247, .12); -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px); animation: fadeIn .15s; pointer-events: none;
}
.drop-overlay[hidden] { display: none; }
.drop-card {
    display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 34px 48px; border-radius: 22px;
    background: var(--c-surface); border: 2px dashed var(--c-primary); box-shadow: var(--shadow-lg); animation: pop .25s var(--ease); text-align: center;
}
.drop-card svg { width: 46px; height: 46px; color: var(--c-primary); }
.drop-card b { font-size: 16px; }
.drop-card span { font-size: 13px; color: var(--c-muted); }

.upload-panel {
    position: fixed; z-index: 1500; left: 20px; bottom: 20px; width: 380px; max-width: calc(100vw - 40px);
    background: var(--c-surface); border: 1px solid var(--c-border); border-radius: 16px; box-shadow: var(--shadow-lg);
    overflow: hidden; animation: toastIn .3s var(--ease);
}
.upload-panel[hidden] { display: none; }
.up-head { display: flex; align-items: center; gap: 6px; padding: 12px 10px 10px 16px; }
.up-head .icon-btn { width: 32px; height: 32px; flex-basis: 32px; border: 0; }
.up-title-wrap { flex: 1; min-width: 0; }
.up-title { display: block; font-weight: 700; font-size: 14px; }
.up-sub { display: block; font-size: 12px; color: var(--c-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.up-bar { height: 4px; background: var(--c-surface-2); }
.up-bar span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--c-primary), var(--c-primary-2)); transition: width .25s var(--ease); }
.upload-panel.done .up-bar span { background: var(--c-success); }
.upload-panel.has-errors .up-bar span { background: var(--c-warning); }
.up-list { list-style: none; margin: 0; padding: 4px 0; max-height: 260px; overflow-y: auto; }
.upload-panel.collapsed .up-list { display: none; }
.upload-panel.collapsed #upToggle svg { transform: rotate(180deg); }
.up-list li { display: flex; align-items: center; gap: 10px; padding: 6px 16px; font-size: 12.5px; }
.up-list .up-name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.up-list .up-state { flex: 0 0 auto; font-size: 11.5px; color: var(--c-muted); max-width: 46%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.up-list .up-dot { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 8px; background: #d5d9e6; }
.up-list li.uploading .up-dot { background: var(--c-primary); animation: pulse 1.2s infinite; }
.up-list li.done .up-dot { background: var(--c-success); }
.up-list li.done.sync-fail .up-dot { background: var(--c-warning); }
.up-list li.error .up-dot, .up-list li.skipped .up-dot { background: var(--c-danger); }
.up-list li.error .up-state, .up-list li.skipped .up-state { color: var(--c-danger); }
.up-list li.skipped { opacity: .75; }

/* folder card is a div[role=button] so it can host action buttons */
.item.folder:focus-visible { outline: 3px solid rgba(91, 91, 247, .45); outline-offset: 2px; }
.item .item-actions .act-rename:hover { color: var(--c-warning); border-color: rgba(245, 158, 11, .35); background: rgba(245, 158, 11, .08); }
.item.folder .item-actions { opacity: 0; transition: opacity .15s; }
.item.folder:hover .item-actions, .item.folder:focus-within .item-actions { opacity: 1; }
@media (hover: none) { .item.folder .item-actions { opacity: 1; } }

/* ---------- Toasts ---------- */
.toast-host { position: fixed; z-index: 2000; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 10px; align-items: flex-end; pointer-events: none; }
.toast-x {
    pointer-events: auto; display: flex; align-items: flex-start; gap: 10px; min-width: 260px; max-width: 380px;
    padding: 12px 14px; border-radius: 14px; background: #1d2333; color: #fff; box-shadow: var(--shadow-lg);
    font-size: 13.5px; animation: toastIn .35s var(--ease); border-left: 4px solid var(--c-info);
}
.toast-x.out { animation: toastOut .3s var(--ease) forwards; }
.toast-x.success { border-left-color: var(--c-success); }
.toast-x.error { border-left-color: var(--c-danger); }
.toast-x.warning { border-left-color: var(--c-warning); }
.toast-x .toast-ic { flex: 0 0 18px; margin-top: 1px; }
.toast-x .toast-ic svg { width: 18px; height: 18px; }
.toast-x.success .toast-ic { color: var(--c-success); }
.toast-x.error .toast-ic { color: #f87171; }
.toast-x.warning .toast-ic { color: var(--c-warning); }
.toast-x.info .toast-ic { color: var(--c-info); }
.toast-x .toast-msg { flex: 1; }
.toast-x .toast-close { background: none; border: 0; color: #9aa2b6; cursor: pointer; padding: 0 2px; font-size: 18px; line-height: 1; }
@keyframes toastIn { from { opacity: 0; transform: translateY(12px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateX(30px); } }

/* ---------- Responsive ---------- */
@media (max-width: 991px) {
    .admin-meta { display: none; }
    .admin-chip { padding: 3px; }
    .toolbar-tools { flex: 1 1 100%; }
    .search-box { flex: 1; width: auto; }
}
@media (max-width: 640px) {
    body.s3u { font-size: 14px; }
    .auth-card { padding: 26px 20px 18px; border-radius: 18px; }
    .auth-title { font-size: 21px; }
    .otp-box { height: 50px; font-size: 20px; }
    .app-header-inner { padding: 8px 12px; }
    .app-context { max-width: 46vw; }
    #btnHeaderRefresh { display: none; }
    .logout-btn { padding: 0 12px; height: 36px; }
    .app-main { padding: 12px 12px 40px; }
    .toolbar { padding: 8px; }
    .toolbar-nav { flex-basis: 100%; }
    .toolbar-tools { flex-wrap: wrap; }
    .create-group { flex: 1 1 100%; order: 3; }
    .create-btn { flex: 1; }
    .create-dialog { margin: auto 16px; padding: 20px; }
    .upload-dialog { margin: auto 12px; padding: 18px 16px 14px; }
    .ud-tiles { grid-template-columns: 1fr; gap: 10px; }
    .ud-tile { flex-direction: row; flex-wrap: wrap; align-items: center; column-gap: 12px; padding: 14px; }
    .ud-tile-icon { margin: 0; width: 46px; height: 46px; }
    .ud-tile-title { flex: 1; }
    .ud-tile-sub { flex: 1 1 100%; }
    .ud-tile-cta { display: none; }
    .upload-panel { left: 12px; right: 12px; bottom: 12px; width: auto; max-width: none; }
    .items { grid-template-columns: 1fr; gap: 8px; }
    .item { padding: 12px; }
    .kbd-hint { display: none; }
    .modal-x { padding: 0; align-items: stretch; }
    .editor-dialog { height: 100%; max-height: none; border-radius: 0; }
    .modal-x-foot { border-radius: 0; padding: 10px 12px; }
    .editor-actions { width: 100%; }
    .editor-actions > * { flex: 1; }
    .confirm-dialog { margin: auto 16px; }
    .toast-host { left: 12px; right: 12px; bottom: 12px; align-items: stretch; }
    .toast-x { max-width: none; min-width: 0; }
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
