/* ===== CloudBox - dark matte UI ===== */
@font-face {
	font-family: 'Inter';
	font-style: normal;
	font-weight: 400;
	font-display: swap;
	src: url('fonts/inter-400.woff2') format('woff2');
}
@font-face {
	font-family: 'Inter';
	font-style: normal;
	font-weight: 500;
	font-display: swap;
	src: url('fonts/inter-500.woff2') format('woff2');
}
@font-face {
	font-family: 'Inter';
	font-style: normal;
	font-weight: 600;
	font-display: swap;
	src: url('fonts/inter-600.woff2') format('woff2');
}
@font-face {
	font-family: 'Inter';
	font-style: normal;
	font-weight: 700;
	font-display: swap;
	src: url('fonts/inter-700.woff2') format('woff2');
}

:root {
	--bg: #171b20;
	--surface: #1d232a;
	--surface-2: #222a32;
	--border: #2a333d;
	--text: #dde4ec;
	--muted: #8b97a3;
	--accent: #4fae94;
	--accent-hover: #62bda3;
	--accent-ink: #071a15;
	--danger: #e07a82;
	--radius: 6px;
}

* { box-sizing: border-box; }

html, body {
	margin: 0;
	height: 100%;
	background: var(--bg);
	color: var(--text);
	font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
	-webkit-font-smoothing: antialiased;
	letter-spacing: 0.01em;
}

.hidden { display: none !important; }

/* ---------- buttons ---------- */
.btn {
	background: var(--surface-2);
	color: var(--text);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	padding: 8px 14px;
	font-size: 13.5px;
	font-weight: 500;
	font-family: inherit;
	cursor: pointer;
	transition: background 0.12s ease, border-color 0.12s ease;
}
.btn:hover { background: #2a333d; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.primary:hover { background: var(--accent-hover); }
.btn.danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn.danger:hover { background: rgba(224, 122, 130, 0.12); }
.btn.block { display: block; width: 100%; }
.btn.close-x { padding: 6px 10px; }
.link-btn { background: none; border: none; color: var(--muted); cursor: pointer; padding: 0; font-size: 12px; font-family: inherit; }
.link-btn:hover { color: var(--accent-hover); }

/* ---------- login ---------- */
.login-view {
	height: 100vh;
	display: flex;
	align-items: center;
	justify-content: center;
	background:
		radial-gradient(900px 500px at 20% -10%, rgba(79, 174, 148, 0.08), transparent 60%),
		radial-gradient(700px 420px at 90% 110%, rgba(79, 174, 148, 0.06), transparent 60%),
		var(--bg);
}
.login-card {
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: 14px;
	box-shadow: 0 16px 48px rgba(0, 0, 0, 0.45);
	padding: 40px;
	width: 360px;
	max-width: 92vw;
}
.brand { display: flex; align-items: center; gap: 10px; font-size: 18px; font-weight: 700; margin-bottom: 26px; color: var(--text); }
.brand-icon { flex: none; }
.login-card h1 { font-size: 20px; margin: 0 0 6px; }
.login-card .sub { color: var(--muted); font-size: 13.5px; margin: 0 0 24px; line-height: 1.5; }
.field { display: block; margin-bottom: 16px; }
.field span { display: block; color: var(--muted); font-size: 12.5px; margin-bottom: 6px; }
.field input {
	width: 100%;
	background: #14181d;
	border: 1px solid var(--border);
	border-radius: 8px;
	color: var(--text);
	padding: 11px 13px;
	font-size: 14px;
	font-family: inherit;
	outline: none;
	transition: border-color 0.12s ease, box-shadow 0.12s ease;
}
.field input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(79, 174, 148, 0.22); }
.error { color: var(--danger); font-size: 13px; margin: 0 0 14px; }

/* ---------- layout ---------- */
.app { display: flex; height: 100vh; }
.sidebar {
	width: 240px;
	flex: none;
	display: flex;
	flex-direction: column;
	background: #1a1f25;
	border-right: 1px solid var(--border);
}
.sidebar .brand { margin: 20px 22px 12px; font-size: 16px; }
.side-nav { padding: 10px 12px; flex: 1; overflow-y: auto; }
.side-section-title { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin: 16px 10px 6px; }
.side-link {
	display: flex; align-items: center; gap: 10px;
	color: var(--muted); text-decoration: none;
	font-size: 14px; padding: 8px 10px; border-radius: var(--radius);
	border-left: 3px solid transparent;
}
.side-link:hover { background: var(--surface-2); color: var(--text); }
.side-link.active { background: #223630; color: var(--text); border-left-color: var(--accent); }
.side-link .ic { width: 16px; text-align: center; font-size: 13px; opacity: 0.85; }
.share-list .share-item {
	display: flex; align-items: center; justify-content: space-between; gap: 6px;
	font-size: 12.5px; padding: 7px 10px 7px 16px; border-radius: var(--radius); color: var(--muted);
	overflow: hidden; white-space: nowrap;
}
.share-item:hover { background: var(--surface-2); }
.share-item .si-path { overflow: hidden; text-overflow: ellipsis; }
.share-item .si-x { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 13px; padding: 0; }
.share-item .si-x:hover { color: var(--danger); }
.share-list .none { font-size: 12.5px; color: var(--muted); padding: 4px 10px 4px 16px; }
.side-bottom { padding: 14px; border-top: 1px solid var(--border); }
.user-chip { display: flex; align-items: center; gap: 10px; }
.avatar {
	width: 34px; height: 34px; border-radius: 6px; flex: none;
	background: var(--accent); color: var(--accent-ink);
	display: flex; align-items: center; justify-content: center;
	font-weight: 700; font-size: 14px;
}
.user-meta { display: flex; flex-direction: column; }
.user-meta span { font-size: 13.5px; font-weight: 500; }
.user-meta .link-btn { text-align: left; margin-top: 2px; }

/* ---------- main ---------- */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; background: var(--bg); }
.topbar {
	display: flex; align-items: center; justify-content: space-between; gap: 12px;
	padding: 12px 20px; border-bottom: 1px solid var(--border); background: var(--bg);
}
.top-actions { display: flex; gap: 8px; flex: none; }
.breadcrumb { display: flex; align-items: center; gap: 2px; font-size: 14px; overflow-x: auto; white-space: nowrap; }
.breadcrumb a, .breadcrumb span {
	color: var(--muted); text-decoration: none; padding: 5px 8px; border-radius: var(--radius); cursor: pointer;
}
.breadcrumb a:hover { color: var(--text); background: var(--surface-2); }
.breadcrumb .sep { color: var(--border); padding: 0 2px; cursor: default; }
.breadcrumb .current { color: var(--text); font-weight: 500; cursor: default; }

.file-area { flex: 1; overflow-y: auto; padding: 8px 20px 40px; }
.file-table { width: 100%; border-collapse: collapse; }
.file-table th {
	text-align: left; color: var(--muted); font-weight: 500; font-size: 12px;
	text-transform: uppercase; letter-spacing: 0.06em;
	padding: 10px 12px; border-bottom: 1px solid var(--border);
	position: sticky; top: 0; background: var(--bg);
}
.file-table td { padding: 0 12px; height: 48px; border-bottom: 1px solid var(--border); font-size: 14px; }
.file-table tbody tr { cursor: default; transition: background 0.1s ease; }
.file-table tbody tr:hover { background: var(--surface); }
.col-name { width: 55%; }
.col-name .wrap { display: flex; align-items: center; gap: 12px; overflow: hidden; }
.col-name .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.col-size, .col-date { width: 15%; color: var(--muted); font-size: 13px; }
.col-actions { width: 130px; text-align: right; }
.icon-col { flex: none; }
.icon-svg { width: 20px; height: 20px; }

.row-actions { display: inline-flex; gap: 2px; opacity: 0; transition: opacity 0.1s ease; }
.file-table tr:hover .row-actions { opacity: 1; }
.row-actions button {
	background: none; border: none; cursor: pointer; font-size: 14px;
	color: var(--muted); padding: 6px; border-radius: 4px;
}
.row-actions button:hover { background: var(--surface-2); color: var(--text); }

.empty { text-align: center; padding: 90px 20px; color: var(--muted); }
.empty-icon { font-size: 46px; opacity: 0.3; margin-bottom: 14px; }
.empty h3 { color: var(--text); font-weight: 600; margin: 0 0 8px; }
.empty p { font-size: 13.5px; margin: 0; line-height: 1.5; }

/* ---------- drop zone ---------- */
.drop-zone {
	position: absolute; inset: 0; margin: 70px 16px 16px; z-index: 20;
	background: rgba(79, 174, 148, 0.08);
	border: 2px dashed var(--accent); border-radius: 14px;
	display: flex; align-items: center; justify-content: center;
	pointer-events: none;
}
.drop-zone p { font-weight: 600; font-size: 16px; color: var(--accent); }

/* ---------- modals ---------- */
.modal {
	position: fixed; inset: 0; z-index: 50;
	background: rgba(0, 0, 0, 0.6);
	display: flex; align-items: center; justify-content: center;
}
.modal-card {
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: 14px;
	box-shadow: 0 24px 64px rgba(0, 0, 0, 0.5);
	width: 480px; max-width: 94vw; max-height: 86vh;
	display: flex; flex-direction: column;
	overflow: hidden;
}
.modal-head {
	display: flex; align-items: center; justify-content: space-between; gap: 10px;
	padding: 16px 18px; border-bottom: 1px solid var(--border);
}
.modal-title { font-weight: 600; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.modal-actions { display: flex; gap: 8px; }
.modal-card .sub { margin: 16px 18px 0; color: var(--muted); font-size: 13px; line-height: 1.5; }
.share-row { display: flex; gap: 8px; padding: 14px 18px; }
.share-row input {
	flex: 1; background: #14181d; border: 1px solid var(--border); border-radius: var(--radius);
	color: var(--text); padding: 9px 11px; font-size: 13px; font-family: inherit; outline: none;
}
.copied { margin: 0 18px 16px; color: var(--accent); font-size: 13px; }
.confirm-text { margin: 18px; color: var(--text); font-size: 14px; line-height: 1.5; word-break: break-word; }
.confirm-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 0 18px 18px; }

.preview-body { flex: 1; overflow: auto; background: #14181d; display: flex; align-items: center; justify-content: center; min-height: 240px; }
.preview-body img { max-width: 100%; max-height: 70vh; object-fit: contain; }
.preview-body video, .preview-body audio { max-width: 100%; max-height: 70vh; }
.preview-body embed { width: 100%; height: 70vh; border: none; }
.preview-text { padding: 24px; white-space: pre-wrap; font-family: ui-monospace, 'Cascadia Code', Consolas, monospace; font-size: 13px; color: var(--text); max-width: 100%; max-height: 70vh; overflow: auto; }
.preview-fallback { color: var(--muted); font-size: 14px; padding: 30px; }

/* move modal */
.move-list { flex: 1; overflow-y: auto; padding: 8px 0; max-height: 40vh; }
.move-item { display: flex; align-items: center; gap: 10px; padding: 9px 18px; font-size: 14px; cursor: default; }
.move-item:hover { background: var(--surface-2); }
.move-item .mi-ic { width: 18px; text-align: center; color: var(--muted); }
.move-item .mi-name { color: var(--muted); }
.move-item.selected { background: #223630; }
.move-item.selected .mi-name { color: var(--text); }
.move-item.back { color: var(--muted); }
#move-path { padding: 10px 14px 0; }

/* ---------- toast ---------- */
.toast {
	position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
	background: var(--surface-2); color: var(--text);
	border: 1px solid var(--border); border-radius: 10px;
	padding: 11px 18px; font-size: 13.5px; z-index: 80;
	box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
}

/* ---------- scrollbars ---------- */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background-color: #39424c; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background-color: #4a5560; }

::selection { background: rgba(79, 174, 148, 0.35); }

/* ---------- touch + tap helpers ---------- */
button, input { -webkit-tap-highlight-color: transparent; }
button { touch-action: manipulation; }

/* ---------- mobile drawer scrim ---------- */
.scrim {
	position: fixed; inset: 0; z-index: 55;
	background: rgba(0, 0, 0, 0.55);
	opacity: 0; visibility: hidden; transition: opacity 0.2s ease, visibility 0.2s ease;
}
.scrim.open { opacity: 1; visibility: visible; }

/* ---------- name stack & mobile-only bits ---------- */
.name-stack { flex: 1; min-width: 0; display: block; }
.name-stack .name { display: block; }
.m-menu-btn { display: none; }
.m-meta, .more-btn { display: none; }

/* ---------- mobile action sheet ---------- */
.sheet { position: fixed; inset: 0; z-index: 70; display: flex; align-items: flex-end; justify-content: center; }
.sheet-scrim { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.55); }
.sheet-card {
	position: relative; width: 100%; max-width: 560px;
	background: var(--surface); border: 1px solid var(--border);
	border-top-left-radius: 18px; border-top-right-radius: 18px;
	padding: 14px 16px 22px; box-shadow: 0 -8px 40px rgba(0, 0, 0, 0.5);
}
.sheet-title { font-size: 13.5px; color: var(--muted); margin: 4px 4px 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sheet-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 12px; }
.sheet-item {
	display: flex; align-items: center; gap: 10px;
	background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px;
	color: var(--text); padding: 14px; font-size: 14.5px; font-family: inherit; cursor: pointer;
}
.sheet-item .si-i { font-size: 16px; opacity: 0.9; }
.sheet-item.danger { color: var(--danger); border-color: rgba(224, 122, 130, 0.4); }

/* ---------- mobile (≤ 720px) ---------- */
@media (max-width: 720px) {
	#menu-btn { display: inline-flex; align-items: center; justify-content: center; font-size: 17px; }

	.sidebar {
		position: fixed; top: 0; left: 0; bottom: 0; width: 264px; z-index: 60;
		transform: translateX(-100%); transition: transform 0.22s ease;
		box-shadow: 0 0 40px rgba(0, 0, 0, 0.5);
	}
	.app.sidebar-open .sidebar { transform: none; }

	.scrim { display: block; }

	.topbar { gap: 8px; padding: 10px 12px; }
	.top-actions { gap: 6px; }
	#refresh-btn { display: none; }
	.breadcrumb { font-size: 13.5px; min-width: 0; }
	.btn { padding: 10px 13px; }

	.file-area { padding: 10px 10px 100px; }
	.file-table thead { display: none; }
	.file-table, .file-table tbody, .file-table tr, .file-table td { display: block; width: 100%; }
	.file-table tr {
		display: flex; align-items: center; gap: 10px;
		background: var(--surface); border: 1px solid var(--border);
		border-radius: 10px; padding: 12px; margin-bottom: 8px; height: auto;
	}
	.file-table td { border: 0; padding: 0; height: auto; }
	.col-name { flex: 1; min-width: 0; }
	.col-name .wrap { gap: 14px; }
	.name-stack { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
	.name-stack .name { font-size: 14.5px; }
	.m-meta { display: block; font-size: 11.5px; color: var(--muted); }
	.col-size, .col-date { display: none !important; }
	.col-actions { width: auto; }
	.row-actions { opacity: 1; }
	.row-actions button:not(.more-btn) { display: none; }
	.more-btn { display: inline-flex !important; align-items: center; justify-content: center; font-size: 22px; padding: 6px 14px; }

	.modal { align-items: flex-end; }
	.modal-card { width: 100%; max-width: 100%; max-height: 88vh; border-radius: 18px 18px 0 0; animation: sheet-up 0.22s ease; }
	@keyframes sheet-up {
		from { transform: translateY(40%); opacity: 0.6; }
		to { transform: none; opacity: 1; }
	}
	.drop-zone { margin: 60px 8px 8px; }
	.preview-body { min-height: 40vh; }
	.preview-body img, .preview-body video { max-height: 56vh; }
	.preview-body embed { height: 56vh; }
	.preview-text { max-height: 56vh; font-size: 12.5px; }

	.login-card { padding: 30px 22px; width: 92vw; }
	.field input { font-size: 16px; padding: 13px 14px; }
	.empty { padding: 60px 16px; }
	.toast { bottom: 16px; max-width: 92vw; }
}