:root {
  color-scheme: dark;
  --bg: #0a1020;
  --panel: rgba(19, 29, 55, .82);
  --panel-strong: #172342;
  --line: rgba(181, 198, 242, .15);
  --text: #f3f6ff;
  --muted: #9ba9c8;
  --accent: #86a6ff;
  --accent-strong: #6288ff;
  --danger: #ff8291;
  --shadow: 0 18px 70px rgba(0, 0, 0, .28);
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--bg); }
body { margin: 0; min-height: 100vh; font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; color: var(--text); background: radial-gradient(circle at top right, #1d2d60 0, transparent 40%), var(--bg); }
button, input, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
[hidden] { display: none !important; }
.shell { width: min(1120px, 100%); margin: 0 auto; padding: max(28px, env(safe-area-inset-top)) 22px 56px; }
.topbar { display: flex; justify-content: space-between; align-items: flex-start; gap: 24px; padding: 30px 0 28px; }
.eyebrow { margin: 0 0 8px; color: var(--accent); font-size: 11px; font-weight: 800; letter-spacing: .16em; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 8px; font-size: clamp(30px, 5vw, 54px); line-height: 1; letter-spacing: -.045em; }
h2 { margin-bottom: 0; font-size: 24px; letter-spacing: -.03em; }
h3 { margin-bottom: 8px; }
.subtitle, .muted { color: var(--muted); }
.subtitle { margin-bottom: 0; font-size: 15px; }
.session-controls { display: flex; align-items: center; gap: 9px; }
.session-pill { border: 1px solid var(--line); border-radius: 999px; padding: 10px 14px; color: var(--muted); font-size: 12px; white-space: nowrap; background: rgba(17, 27, 51, .7); }
.install-button { min-height: 38px; padding: 0 12px; border: 1px solid rgba(134, 166, 255, .35); border-radius: 11px; color: var(--accent); font-size: 12px; background: rgba(134, 166, 255, .08); }
.setup-shortcut { color: var(--accent); font-size: 12px; white-space: nowrap; }
.logout-button { min-height: 38px; padding: 0 12px; border: 1px solid var(--line); border-radius: 11px; color: var(--muted); background: transparent; }
.logout-button:hover { border-color: rgba(134, 166, 255, .6); color: var(--text); }
.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 22px; }
.stat-card { min-height: 112px; padding: 18px; border: 1px solid var(--line); border-radius: 20px; background: var(--panel); box-shadow: var(--shadow); }
.stat-card span { display: block; margin-bottom: 22px; color: var(--muted); font-size: 13px; }
.stat-card strong { display: block; font-size: 28px; letter-spacing: -.035em; }
.stat-card.accent { background: linear-gradient(145deg, rgba(89, 117, 224, .34), rgba(25, 37, 76, .78)); }
.toolbar { display: flex; gap: 12px; margin-bottom: 16px; }
.search-box { display: flex; align-items: center; flex: 1; gap: 10px; min-height: 52px; padding: 0 16px; border: 1px solid var(--line); border-radius: 15px; background: rgba(10, 17, 34, .66); }
.search-box span { color: var(--muted); font-size: 27px; line-height: 0; transform: rotate(-15deg); }
.search-box input { width: 100%; border: 0; outline: 0; color: var(--text); background: transparent; }
.search-box input::placeholder, textarea::placeholder { color: #6e7c9d; }
.search-all-control { display: flex; align-items: center; gap: 8px; min-height: 52px; padding: 0 12px; border: 1px solid var(--line); border-radius: 13px; color: var(--muted); font-size: 12px; white-space: nowrap; background: rgba(10, 17, 34, .45); }
.search-all-control input { width: 16px; height: 16px; margin: 0; accent-color: var(--accent-strong); }
.view-controls { display: flex; gap: 8px; }
.compact-control { display: grid; align-content: center; gap: 4px; min-width: 142px; color: var(--muted); font-size: 11px; font-weight: 700; }
.compact-control .select-input { min-height: 42px; padding-right: 30px; font-size: 12px; }
.primary-button, .secondary-button, .ghost-button, .danger-button { display: inline-flex; justify-content: center; align-items: center; gap: 8px; min-height: 48px; padding: 0 17px; border: 1px solid transparent; border-radius: 13px; color: var(--text); font-weight: 750; text-decoration: none; transition: transform .15s ease, background .15s ease, border-color .15s ease; }
.primary-button { background: linear-gradient(135deg, var(--accent-strong), #8a72f4); box-shadow: 0 10px 26px rgba(99, 126, 255, .23); }
.primary-button:hover, .secondary-button:hover, .ghost-button:hover, .danger-button:hover { transform: translateY(-1px); }
.primary-button:disabled { cursor: not-allowed; opacity: .42; transform: none; }
.secondary-button { border-color: var(--line); background: rgba(255, 255, 255, .06); }
.ghost-button { min-height: 38px; border-color: var(--line); background: transparent; color: var(--muted); font-size: 13px; }
.danger-button { border-color: rgba(255, 130, 145, .28); color: var(--danger); background: rgba(255, 130, 145, .08); }
.notice { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 24px; padding: 14px 16px; border: 1px solid rgba(255, 211, 118, .23); border-radius: 15px; color: #f8d98f; background: rgba(121, 91, 22, .16); }
.notice p { margin: 0; font-size: 13px; line-height: 1.5; }
.section-heading { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin: 30px 0 16px; }
.folder-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 14px; min-height: 42px; margin: 4px 0 16px; }
.breadcrumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; min-width: 0; color: var(--muted); font-size: 13px; }
.breadcrumb-button { padding: 5px 7px; border: 0; border-radius: 8px; color: var(--accent); background: transparent; }
.breadcrumb-button:hover { background: rgba(134, 166, 255, .1); }
.breadcrumb-button.current { color: var(--text); font-weight: 700; }
.breadcrumb-separator { color: #627195; }
.folder-actions { display: flex; flex: 0 0 auto; gap: 8px; }
.selection-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 14px; margin: 4px 0 16px; padding: 11px 13px; border: 1px solid rgba(134, 166, 255, .28); border-radius: 14px; color: var(--muted); background: rgba(134, 166, 255, .08); font-size: 13px; }
.selection-toolbar strong { color: var(--text); }
.selection-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.selection-actions .secondary-button, .selection-actions .danger-button, .selection-actions .ghost-button { min-height: 38px; padding: 0 12px; font-size: 12px; }
.section-actions { display: flex; gap: 8px; }
.folder-list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-bottom: 12px; }
.folder-card { display: flex; align-items: center; gap: 12px; min-width: 0; padding: 13px 14px; border: 1px solid rgba(134, 166, 255, .24); border-radius: 16px; color: var(--text); text-align: left; background: rgba(134, 166, 255, .08); transition: border-color .15s ease, transform .15s ease, background .15s ease; }
.folder-card:hover { border-color: rgba(134, 166, 255, .65); transform: translateY(-2px); background: rgba(134, 166, 255, .14); }
.folder-icon { display: grid; flex: 0 0 38px; place-items: center; width: 38px; height: 34px; border-radius: 9px; color: #a8bcff; font-size: 22px; transform: scaleX(1.15); background: rgba(134, 166, 255, .14); }
.folder-main { display: grid; min-width: 0; gap: 3px; flex: 1; }
.folder-main strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.folder-main small { color: var(--muted); font-size: 11px; }
.folder-arrow { color: var(--muted); font-size: 25px; line-height: 1; }
.documents-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.document-card { display: flex; align-items: center; gap: 14px; min-width: 0; padding: 16px; border: 1px solid var(--line); border-radius: 18px; background: var(--panel); box-shadow: 0 8px 35px rgba(0, 0, 0, .12); transition: border-color .15s ease, transform .15s ease, background .15s ease; }
.document-card:hover { border-color: rgba(134, 166, 255, .46); transform: translateY(-2px); background: var(--panel-strong); }
.document-card.selected { border-color: var(--accent); background: var(--panel-strong); box-shadow: 0 0 0 1px rgba(134, 166, 255, .22), 0 8px 35px rgba(0, 0, 0, .12); }
.document-select { display: grid; flex: 0 0 22px; place-items: center; width: 22px; height: 32px; cursor: pointer; }
.document-select input { width: 17px; height: 17px; margin: 0; accent-color: var(--accent-strong); }
.file-icon { display: grid; flex: 0 0 48px; place-items: center; width: 48px; height: 48px; border-radius: 14px; color: var(--accent); font-size: 21px; font-weight: 800; background: rgba(134, 166, 255, .13); }
.document-main { min-width: 0; flex: 1; }
.document-name { overflow: hidden; margin-bottom: 6px; color: var(--text); font-weight: 760; text-overflow: ellipsis; white-space: nowrap; }
.document-meta { display: flex; flex-wrap: wrap; gap: 6px 12px; color: var(--muted); font-size: 12px; }
.document-path { display: flex; align-items: center; gap: 8px; min-width: 0; margin-top: 7px; color: var(--accent); font-size: 11px; }
.document-path span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.document-location { flex: 0 0 auto; padding: 0; border: 0; color: var(--accent); font-size: 11px; text-decoration: underline; background: transparent; }
.document-open { display: grid; flex: 0 0 36px; place-items: center; width: 36px; height: 36px; border: 1px solid var(--line); border-radius: 10px; color: var(--text); background: transparent; }
.empty-state { grid-column: 1 / -1; padding: 64px 20px; border: 1px dashed var(--line); border-radius: 20px; text-align: center; color: var(--muted); }
.empty-state h3 { color: var(--text); }
.empty-state p { margin-bottom: 0; }
.empty-icon { margin-bottom: 12px; color: var(--accent); font-size: 42px; }
.auth-gate { display: grid; place-items: center; min-height: 100vh; padding: 24px 16px; background: radial-gradient(circle at top right, #1d2d60 0, transparent 42%), var(--bg); }
.auth-card, .setup-card { width: min(500px, 100%); padding: 28px; border: 1px solid var(--line); border-radius: 24px; background: var(--panel); box-shadow: var(--shadow); }
.auth-card h1 { margin-bottom: 12px; font-size: clamp(30px, 8vw, 46px); }
.auth-description { margin-bottom: 22px; color: var(--muted); line-height: 1.55; }
.auth-form, .setup-form { display: grid; gap: 9px; }
.text-input, .select-input { width: 100%; min-height: 48px; padding: 0 13px; border: 1px solid var(--line); border-radius: 12px; outline: 0; color: var(--text); background: rgba(8, 14, 29, .6); }
.text-input:focus, .select-input:focus { border-color: rgba(134, 166, 255, .7); }
.auth-form .primary-button { width: 100%; margin-top: 8px; }
.auth-error, .setup-status { margin: 12px 0 0; padding: 11px 12px; border: 1px solid rgba(255, 130, 145, .28); border-radius: 12px; color: var(--danger); background: rgba(255, 130, 145, .08); font-size: 13px; line-height: 1.45; }
.auth-error { text-align: center; }
.setup-link { display: block; margin-top: 20px; color: var(--accent); font-size: 13px; text-align: center; }
.setup-shell { max-width: 900px; }
.setup-topbar { align-items: center; }
.setup-topbar .ghost-button { flex: 0 0 auto; }
.setup-card { margin: 22px auto 0; }
.setup-card h2 { margin-bottom: 10px; }
.setup-card > .muted { margin-bottom: 24px; line-height: 1.55; }
.setup-form .field-label { margin-top: 8px; }
.setup-options { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 8px; }
.setup-status.success { border-color: rgba(126, 224, 178, .3); color: #a3f1c8; background: rgba(44, 140, 96, .12); }
.modal { width: min(620px, calc(100% - 28px)); padding: 0; border: 0; border-radius: 22px; color: var(--text); background: transparent; box-shadow: var(--shadow); }
.modal::backdrop { background: rgba(2, 5, 15, .78); backdrop-filter: blur(8px); }
.modal-card { padding: 24px; border: 1px solid var(--line); border-radius: 22px; background: #111b35; }
.modal-heading { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; margin-bottom: 20px; }
.modal-heading h2 { font-size: 26px; }
.icon-button { width: 38px; height: 38px; border: 1px solid var(--line); border-radius: 11px; color: var(--muted); font-size: 25px; line-height: 1; background: transparent; }
.file-picker { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; min-height: 160px; margin: 18px 0; border: 1px dashed rgba(134, 166, 255, .55); border-radius: 17px; text-align: center; background: rgba(134, 166, 255, .06); }
.file-picker input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.file-picker-icon { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 13px; color: var(--accent); font-size: 26px; background: rgba(134, 166, 255, .16); }
.file-picker small { color: var(--muted); }
.field-label { display: block; margin-bottom: 7px; color: var(--muted); font-size: 13px; }
textarea { width: 100%; resize: vertical; padding: 12px 13px; border: 1px solid var(--line); border-radius: 12px; outline: 0; color: var(--text); background: rgba(8, 14, 29, .6); }
textarea:focus, .search-box:focus-within { border-color: rgba(134, 166, 255, .7); }
.upload-queue { display: grid; gap: 8px; max-height: 230px; margin-top: 16px; overflow: auto; }
.upload-item { padding: 11px 12px; border: 1px solid var(--line); border-radius: 12px; background: rgba(255, 255, 255, .035); }
.upload-item-top { display: flex; justify-content: space-between; gap: 12px; color: var(--muted); font-size: 12px; }
.upload-item-name { overflow: hidden; color: var(--text); font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }
.upload-item-status { margin-top: 7px; color: var(--muted); font-size: 12px; }
.current-folder { margin: 2px 0 14px; padding: 10px 12px; border: 1px solid rgba(134, 166, 255, .2); border-radius: 11px; color: var(--accent); background: rgba(134, 166, 255, .08); font-size: 13px; }
.progress-track { height: 6px; margin-top: 9px; overflow: hidden; border-radius: 999px; background: rgba(255, 255, 255, .1); }
.progress-bar { width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--accent-strong), #b07dff); transition: width .2s ease; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }
.viewer-modal { width: min(1060px, calc(100% - 20px)); }
.viewer-card { min-height: min(760px, calc(100vh - 24px)); }
.viewer-stage { position: relative; }
.viewer-body { position: relative; display: grid; place-items: center; min-height: min(63vh, 620px); overflow: hidden; border: 1px solid var(--line); border-radius: 15px; background: #080d1b; }
.viewer-body iframe, .viewer-body video { width: 100%; height: min(63vh, 620px); border: 0; }
.viewer-body.video-viewer { min-height: 0; height: auto; max-height: min(63vh, 620px); }
.viewer-body.video-viewer video { display: block; width: auto; height: auto; max-width: 100%; max-height: min(63vh, 620px); object-fit: contain; background: #080d1b; }
.viewer-body.video-buffering::after { position: absolute; right: 14px; bottom: 14px; padding: 7px 10px; border: 1px solid rgba(255, 255, 255, .16); border-radius: 9px; color: var(--text); content: "Đang nạp video…"; font-size: 12px; background: rgba(8, 13, 27, .78); }
.viewer-body img { display: block; max-width: 100%; max-height: min(63vh, 620px); object-fit: contain; }
.viewer-body audio { width: min(100%, 520px); }
.viewer-arrow { position: absolute; z-index: 2; top: 50%; display: grid; place-items: center; width: 48px; height: 68px; padding: 0 0 5px; border: 1px solid rgba(255, 255, 255, .2); border-radius: 15px; color: var(--text); font-size: 47px; font-weight: 300; line-height: 1; background: rgba(9, 14, 30, .7); box-shadow: 0 8px 26px rgba(0, 0, 0, .25); transform: translateY(-50%); transition: background .15s ease, border-color .15s ease, opacity .15s ease; }
.viewer-arrow:hover:not(:disabled) { border-color: rgba(134, 166, 255, .7); background: rgba(44, 61, 113, .9); }
.viewer-arrow:disabled { cursor: default; opacity: .25; }
.viewer-arrow-prev { left: 14px; }
.viewer-arrow-next { right: 14px; }
.viewer-counter { display: block; margin-top: 7px; color: var(--muted); font-size: 12px; }
.viewer-gallery { display: flex; gap: 9px; min-height: 78px; margin-top: 12px; padding: 0 2px 5px; overflow-x: auto; overscroll-behavior-x: contain; scrollbar-color: rgba(134, 166, 255, .55) transparent; }
.viewer-thumb { flex: 0 0 86px; width: 86px; height: 66px; padding: 3px; border: 1px solid var(--line); border-radius: 11px; background: rgba(255, 255, 255, .05); transition: border-color .15s ease, transform .15s ease, opacity .15s ease; }
.viewer-thumb:hover { border-color: rgba(134, 166, 255, .65); transform: translateY(-2px); }
.viewer-thumb.active { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(134, 166, 255, .2); }
.viewer-thumb img, .viewer-thumb video { display: block; width: 100%; height: 100%; border-radius: 7px; object-fit: cover; background: #080d1b; }
.viewer-thumb { position: relative; overflow: hidden; }
.viewer-thumb-badge { position: absolute; right: 7px; bottom: 7px; display: grid; place-items: center; width: 19px; height: 19px; border: 1px solid rgba(255, 255, 255, .32); border-radius: 50%; color: #fff; font-size: 9px; line-height: 1; background: rgba(8, 13, 27, .78); pointer-events: none; }
.viewer-thumb:focus-visible, .viewer-arrow:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.viewer-fallback { max-width: 420px; padding: 40px 20px; text-align: center; color: var(--muted); }
.viewer-fallback strong { display: block; margin-bottom: 8px; color: var(--text); }
.trash-dialog { width: min(760px, calc(100% - 28px)); }
.trash-list { display: grid; gap: 9px; max-height: min(52vh, 520px); overflow: auto; }
.trash-item { display: flex; align-items: center; gap: 11px; padding: 12px; border: 1px solid var(--line); border-radius: 13px; background: rgba(255, 255, 255, .035); }
.trash-item input { flex: 0 0 auto; width: 17px; height: 17px; accent-color: var(--accent-strong); }
.trash-item-main { min-width: 0; flex: 1; }
.trash-item-name { overflow: hidden; margin-bottom: 4px; color: var(--text); font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.trash-item-meta { color: var(--muted); font-size: 12px; }
.trash-item-actions { display: flex; gap: 7px; }
.trash-item-actions button { min-height: 35px; padding: 0 10px; border: 1px solid var(--line); border-radius: 9px; color: var(--muted); font-size: 12px; background: transparent; }
.trash-item-actions button:hover { border-color: rgba(134, 166, 255, .65); color: var(--text); }
.trash-item-actions .trash-permanent-button { border-color: rgba(255, 130, 145, .28); color: var(--danger); }

@media (max-width: 720px) {
  .shell { padding-right: 16px; padding-left: 16px; }
  .topbar { flex-direction: column; gap: 16px; padding-top: 18px; }
  .session-pill { align-self: flex-start; }
  .session-controls { align-items: flex-start; }
  .stats-grid { gap: 8px; }
  .stat-card { min-height: 94px; padding: 13px; border-radius: 15px; }
  .stat-card span { margin-bottom: 15px; font-size: 11px; }
  .stat-card strong { font-size: 21px; }
  .toolbar { flex-direction: column; }
  .search-all-control { justify-content: center; }
  .view-controls { width: 100%; }
  .compact-control { flex: 1; }
  .primary-button { width: 100%; }
  .folder-toolbar { align-items: flex-start; flex-direction: column; }
  .folder-actions { width: 100%; }
  .folder-actions > * { flex: 1; }
  .section-actions { width: 100%; }
  .section-actions > * { flex: 1; }
  .selection-toolbar { align-items: stretch; flex-direction: column; }
  .selection-actions > * { flex: 1; }
  .folder-list { grid-template-columns: 1fr; }
  .documents-list { grid-template-columns: 1fr; }
  .document-card { padding: 13px; }
  .modal-card { padding: 18px; border-radius: 18px; }
  .modal-actions { flex-direction: column-reverse; }
  .modal-actions > * { width: 100%; }
  .viewer-modal { width: calc(100% - 12px); }
  .viewer-card { min-height: calc(100vh - 14px); }
  .viewer-body { min-height: min(58vh, 500px); }
  .viewer-body.video-viewer { min-height: 0; max-height: calc(100svh - 230px); }
  .viewer-body.video-viewer video { max-height: calc(100svh - 230px); }
  .viewer-body img { max-height: min(58vh, 500px); }
  .viewer-arrow { width: 39px; height: 56px; font-size: 38px; }
  .viewer-arrow-prev { left: 8px; }
  .viewer-arrow-next { right: 8px; }
  .viewer-thumb { flex-basis: 72px; width: 72px; height: 56px; }
  .trash-item { align-items: flex-start; flex-wrap: wrap; }
  .trash-item-main { flex-basis: calc(100% - 40px); }
  .trash-item-actions { width: 100%; margin-left: 28px; }
  .trash-item-actions > * { flex: 1; }
  .auth-card, .setup-card { padding: 21px; border-radius: 19px; }
  .setup-topbar { align-items: flex-start; }
  .setup-options { grid-template-columns: 1fr; gap: 2px; }
}
