/* SiteXplorer interface */
:root {
	--bg: #f6f7f9;
	--surface: #ffffff;
	--surface-2: #eef0f3;
	--border: #dde1e6;
	--text: #1d2128;
	--muted: #646b76;
	--accent: #2f6fdb;
	--accent-soft: #e3ecfb;
	--accent-text: #ffffff;
	--danger: #c43d3d;
	--danger-soft: #fbe9e9;
	--ok-soft: #e6f4ea;
	--ok-text: #1f6b37;
	--shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08);
	--shadow-lg: 0 12px 32px rgba(16,24,40,.18);
	--radius: 10px;
	--tile: 168px;
	color-scheme: light;
}
@media (prefers-color-scheme: dark) {
	:root:not([data-theme="light"]) {
		--bg: #15171b;
		--surface: #1e2126;
		--surface-2: #272b31;
		--border: #343941;
		--text: #e7e9ec;
		--muted: #9aa1ab;
		--accent: #6d9cf0;
		--accent-soft: #24324b;
		--accent-text: #0e1420;
		--danger: #ef7b7b;
		--danger-soft: #3a2424;
		--ok-soft: #1f3326;
		--ok-text: #8fd3a4;
		--shadow: 0 1px 2px rgba(0,0,0,.3);
		--shadow-lg: 0 12px 32px rgba(0,0,0,.5);
		color-scheme: dark;
	}
}
:root[data-theme="dark"] {
	--bg: #15171b; --surface: #1e2126; --surface-2: #272b31; --border: #343941; --text: #e7e9ec; --muted: #9aa1ab;
	--accent: #6d9cf0; --accent-soft: #24324b; --accent-text: #0e1420; --danger: #ef7b7b; --danger-soft: #3a2424;
	--ok-soft: #1f3326; --ok-text: #8fd3a4; --shadow: 0 1px 2px rgba(0,0,0,.3); --shadow-lg: 0 12px 32px rgba(0,0,0,.5);
	color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
	margin: 0; background: var(--bg); color: var(--text);
	font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select { font: inherit; color: inherit; }
.ic { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

/* header */
.top {
	position: sticky; top: 0; z-index: 20; background: var(--surface); border-bottom: 1px solid var(--border);
	box-shadow: var(--shadow);
}
.top-row { display: flex; align-items: center; gap: 8px; padding: 10px 16px; max-width: 1400px; margin: 0 auto; }
.top-row + .top-row { padding-top: 0; }
.crumbs { display: flex; align-items: center; gap: 2px; min-width: 0; flex: 1; overflow-x: auto; scrollbar-width: none; white-space: nowrap; font-weight: 600; }
.crumbs::-webkit-scrollbar { display: none; }
.crumbs a, .crumbs span { padding: 4px 6px; border-radius: 6px; color: var(--text); display: inline-flex; align-items: center; gap: 6px; }
.crumbs a:hover { background: var(--surface-2); text-decoration: none; }
.crumbs .sep { color: var(--muted); padding: 0; font-weight: 400; }
.crumbs .ic { width: 18px; height: 18px; }
.search { position: relative; flex: 0 1 260px; min-width: 120px; }
.search .ic { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--muted); pointer-events: none; }
.search input {
	width: 100%; padding: 7px 10px 7px 32px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg);
}
.search input:focus { outline: 2px solid var(--accent); outline-offset: -1px; background: var(--surface); }

/* buttons */
.btn {
	display: inline-flex; align-items: center; gap: 6px; padding: 7px 10px; border: 1px solid transparent; border-radius: 8px;
	background: transparent; cursor: pointer; white-space: nowrap; line-height: 20px;
}
.btn:hover:not(:disabled) { background: var(--surface-2); }
.btn:disabled { opacity: .4; cursor: default; }
.btn:focus-visible, .item:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn.primary { background: var(--accent); color: var(--accent-text); }
.btn.primary:hover:not(:disabled) { background: var(--accent); filter: brightness(1.08); }
.btn.outline { border-color: var(--border); background: var(--surface); }
.btn.danger { color: var(--danger); }
.btn.on { background: var(--accent-soft); color: var(--accent); }
.btn-group { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.btn-group .btn { border-radius: 0; padding: 6px 8px; }
.toolbar { display: flex; align-items: center; gap: 2px; flex-wrap: wrap; flex: 1; }
.toolbar .grow { flex: 1; }
.selinfo { color: var(--muted); padding: 0 6px; font-size: 14px; }
select.sort { padding: 6px 8px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }

/* messages */
.msg { max-width: 1400px; margin: 12px auto 0; padding: 0 16px; }
.msg div { padding: 10px 14px; border-radius: 8px; background: var(--danger-soft); color: var(--danger); }
.msg div.ok { background: var(--ok-soft); color: var(--ok-text); }

/* content */
main { max-width: 1400px; margin: 0 auto; padding: 16px; }
.empty { text-align: center; color: var(--muted); padding: 48px 16px; }

/* grid view */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(var(--tile), 1fr)); gap: 12px; }
.grid .item {
	position: relative; display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border);
	border-radius: var(--radius); overflow: hidden; cursor: pointer; box-shadow: var(--shadow); color: var(--text);
	transition: border-color .1s, box-shadow .1s;
}
.grid .item:hover { border-color: var(--accent); text-decoration: none; }
.grid .thumb { aspect-ratio: 1; display: flex; align-items: center; justify-content: center; background: var(--surface-2); color: var(--muted); }
.grid .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.grid .thumb .ic { width: 44px; height: 44px; stroke-width: 1.5; }
.grid .item[data-k="folder"] .thumb { color: var(--accent); }
.grid .name { padding: 8px 10px; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.grid .meta { padding: 0 10px 8px; margin-top: -6px; font-size: 12px; color: var(--muted); }

/* list view */
.list { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.list .item, .list .head {
	display: grid; grid-template-columns: 34px minmax(0,1fr) 90px 150px 170px; align-items: center; gap: 8px;
	padding: 6px 12px; border-bottom: 1px solid var(--border); color: var(--text); cursor: pointer;
}
.list .item:last-child { border-bottom: 0; }
.list .head { font-size: 13px; color: var(--muted); cursor: default; background: var(--surface-2); }
.list .head button { all: unset; cursor: pointer; }
.list .head button:hover { color: var(--text); }
.list .item:hover { background: var(--surface-2); text-decoration: none; }
.list .nm { display: flex; align-items: center; gap: 10px; min-width: 0; }
.list .nm span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list .nm .ic { color: var(--muted); }
.list .item[data-k="folder"] .nm .ic { color: var(--accent); }
.list .num { text-align: right; font-variant-numeric: tabular-nums; }
.list .dim { color: var(--muted); font-size: 13.5px; }
.list .perm { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }
.list .thumbmini { width: 28px; height: 28px; border-radius: 4px; object-fit: cover; flex: none; }

/* selection */
.check {
	width: 22px; height: 22px; border-radius: 6px; border: 2px solid var(--border); background: var(--surface);
	display: flex; align-items: center; justify-content: center; color: transparent; flex: none; cursor: pointer;
}
.check .ic { width: 14px; height: 14px; stroke-width: 3; }
.grid .check { position: absolute; top: 8px; left: 8px; opacity: 0; box-shadow: var(--shadow); transition: opacity .1s; }
.grid .item:hover .check, .selecting .grid .check { opacity: 1; }
@media (hover: none) { .grid .check { opacity: .9; } }
.item.sel { border-color: var(--accent); background: var(--accent-soft); }
.grid .item.sel { box-shadow: 0 0 0 2px var(--accent); }
.item.sel .check { background: var(--accent); border-color: var(--accent); color: var(--accent-text); opacity: 1; }
.item.cut { opacity: .5; }
.item.cursor { outline: 2px solid var(--accent); outline-offset: -2px; }

footer { max-width: 1400px; margin: 0 auto; padding: 0 16px 24px; color: var(--muted); font-size: 13px; display: flex; gap: 16px; flex-wrap: wrap; }

/* dialogs */
dialog {
	border: 1px solid var(--border); border-radius: 14px; background: var(--surface); color: var(--text); padding: 0;
	width: min(520px, calc(100vw - 32px)); box-shadow: var(--shadow-lg);
}
dialog::backdrop { background: rgba(10,14,20,.45); }
dialog form { margin: 0; }
.dlg-head { display: flex; align-items: center; gap: 8px; padding: 14px 16px 6px 20px; }
.dlg-head h2 { font-size: 17px; margin: 0; flex: 1; }
.dlg-body { padding: 6px 20px 8px; max-height: min(70vh, 640px); overflow: auto; }
.dlg-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 16px 16px; }
.field { display: block; margin: 10px 0; }
.field > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.field input[type=text], .field input[type=password], .field select, .field input[type=file] {
	width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg);
}
.field input:focus, .field select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.opt { display: flex; gap: 8px; align-items: flex-start; margin: 6px 0; }
.opt input { margin-top: 3px; }
.hint { color: var(--muted); font-size: 13px; }
fieldset { border: 1px solid var(--border); border-radius: 10px; margin: 12px 0; padding: 8px 14px 10px; }
legend { font-weight: 600; padding: 0 6px; font-size: 14px; }
.shares { list-style: none; margin: 0; padding: 0; }
.shares li { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; margin: 8px 0; }
.shares .row { display: flex; gap: 8px; align-items: center; }
.shares .row input { flex: 1; min-width: 0; padding: 6px 8px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg); font-size: 13px; }
.shares .what { font-weight: 600; margin-bottom: 4px; display: flex; gap: 8px; align-items: center; }
.shares .when { color: var(--muted); font-size: 13px; margin-top: 4px; }
.keys { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 14px; }
kbd { font: 12px ui-monospace, Menlo, Consolas, monospace; background: var(--surface-2); border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 5px; padding: 1px 6px; white-space: nowrap; }

/* photo viewer */
.viewer { position: fixed; inset: 0; z-index: 50; background: #0b0c0e; color: #f1f2f4; display: flex; flex-direction: column; touch-action: none; }
.viewer .vbar { display: flex; align-items: center; gap: 4px; padding: 8px 10px; background: linear-gradient(rgba(0,0,0,.6), rgba(0,0,0,0)); position: absolute; inset: 0 0 auto 0; z-index: 2; }
.viewer .vtitle { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 0 8px; font-size: 14px; }
.viewer .vtitle small { color: #aab0b9; margin-left: 8px; }
.viewer .btn { color: #f1f2f4; }
.viewer .btn:hover:not(:disabled) { background: rgba(255,255,255,.12); }
.viewer .stage { flex: 1; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.viewer .stage img { max-width: 100%; max-height: 100%; object-fit: contain; user-select: none; -webkit-user-drag: none; transition: opacity .15s; }
.viewer .stage img.loading { opacity: .35; }
.viewer .nav { position: absolute; top: 50%; transform: translateY(-50%); z-index: 2; width: 48px; height: 64px; border: 0; border-radius: 10px; background: rgba(0,0,0,.35); color: #fff; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.viewer .nav:hover { background: rgba(0,0,0,.6); }
.viewer .nav .ic { width: 28px; height: 28px; }
.viewer .prev { left: 10px; } .viewer .next { right: 10px; }
.viewer .nofile { text-align: center; color: #aab0b9; }
.viewer .nofile .ic { width: 64px; height: 64px; stroke-width: 1.2; display: block; margin: 0 auto 12px; }
@media (hover: none) { .viewer .nav { display: none; } }

/* login and share pages */
.center-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-lg); padding: 28px; width: min(380px, 100%); }
.card h1 { font-size: 20px; margin: 0 0 4px; display: flex; align-items: center; gap: 10px; }
.card p { color: var(--muted); margin: 0 0 18px; }
.card .btn.primary { width: 100%; justify-content: center; padding: 10px; margin-top: 8px; }
.err { background: var(--danger-soft); color: var(--danger); border-radius: 8px; padding: 8px 12px; margin-bottom: 12px; }
.badge { font-size: 12px; font-weight: 500; color: var(--muted); border: 1px solid var(--border); border-radius: 99px; padding: 1px 8px; }

/* share page for a single file */
.single { display: flex; flex-direction: column; align-items: center; gap: 20px; padding-top: 28px; }
.single-img { display: block; max-width: 100%; max-height: calc(100vh - 280px); border-radius: var(--radius); box-shadow: var(--shadow-lg); object-fit: contain; background: var(--surface-2); }
.single-icon { width: 160px; height: 160px; border-radius: 24px; background: var(--surface); border: 1px solid var(--border); display: flex; align-items: center; justify-content: center; color: var(--muted); box-shadow: var(--shadow); }
.single-icon .ic { width: 72px; height: 72px; stroke-width: 1.3; }
.single-info { text-align: center; max-width: 640px; }
.single-info h1 { font-size: 20px; margin: 0 0 4px; overflow-wrap: anywhere; }
.single-info p { color: var(--muted); margin: 0 0 16px; }
.single .actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.single .btn.primary:hover { text-decoration: none; }

/* layout with the spaces sidebar */
.layout { display: grid; grid-template-columns: 250px minmax(0,1fr); min-height: 100vh; }
.side {
	position: sticky; top: 0; height: 100vh; overflow-y: auto; background: var(--surface); border-right: 1px solid var(--border);
	display: flex; flex-direction: column; padding: 10px 10px 14px; z-index: 30;
}
.side-head { display: flex; align-items: center; gap: 10px; padding: 6px 8px 14px; font-size: 16px; }
.side-head b { flex: 1; }
.side-head > .ic { color: var(--accent); }
.side-label { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 14px 10px 4px; }
.side-item {
	display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border-radius: 8px; color: var(--text); text-align: left;
	border: 0; background: none; cursor: pointer; font-size: 14.5px;
}
.side-item:hover { background: var(--surface-2); text-decoration: none; }
.side-item.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.side-item span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-item small { color: var(--muted); font-size: 11.5px; font-weight: 400; }
.side-hint { padding: 2px 10px; margin: 0; }
.side-foot { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--border); }
.side-backdrop { display: none; }
.content { min-width: 0; }
.drop-hint {
	position: fixed; inset: 12px; z-index: 40; border: 3px dashed var(--accent); border-radius: 18px; background: rgba(47,111,219,.08);
	display: flex; align-items: center; justify-content: center; gap: 12px; font-size: 20px; font-weight: 600; color: var(--accent); pointer-events: none;
}
.drop-hint .ic { width: 32px; height: 32px; }

/* toasts */
.toasts { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 60; display: flex; flex-direction: column; gap: 8px; width: min(520px, calc(100vw - 32px)); }
.toast { background: var(--text); color: var(--bg); padding: 10px 14px; border-radius: 10px; box-shadow: var(--shadow-lg); font-size: 14px; animation: toast-in .15s ease-out; }
.toast.bad { background: var(--danger); color: #fff; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* upload progress */
.progress { position: relative; height: 26px; border-radius: 8px; background: var(--surface-2); overflow: hidden; margin-top: 12px; }
.progress div { position: absolute; inset: 0 auto 0 0; width: 0; background: var(--accent); transition: width .2s; }
.progress span { position: relative; display: block; text-align: center; line-height: 26px; font-size: 13px; font-weight: 600; mix-blend-mode: difference; color: #fff; }

/* lists in dialogs (members, users) */
dialog.wide { width: min(760px, calc(100vw - 32px)); }
.rows { list-style: none; margin: 0 0 8px; padding: 0; }
.rows li { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.rows .who { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 200px; }
.rows .who > .ic { color: var(--muted); }
.rows .acts { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.rows select, .row2 select, .row2 input { padding: 7px 8px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); }
.row2 { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 6px 0; }
.row2 input, .row2 select:first-child { flex: 1; min-width: 140px; }
.dim { color: var(--muted); }
.badge.bad { color: var(--danger); border-color: var(--danger); }
.invite { border: 1px solid var(--accent); background: var(--accent-soft); border-radius: 10px; padding: 10px 12px; margin-top: 8px; }
.invite p { margin: 0 0 8px; }
.invite .row { display: flex; gap: 8px; }
.invite .row input { flex: 1; min-width: 0; padding: 6px 8px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); font-size: 13px; }
.card .btn.primary { text-decoration: none; }

/* sidebar becomes a drawer on small screens */
@media (max-width: 900px) {
	.layout { grid-template-columns: minmax(0,1fr); }
	.side { position: fixed; inset: 0 auto 0 0; width: min(300px, 85vw); transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow-lg); }
	.menu-open .side { transform: none; }
	.menu-open .side-backdrop { display: block; position: fixed; inset: 0; background: rgba(10,14,20,.45); z-index: 25; }
}
@media (min-width: 901px) { .hide-lg { display: none !important; } }

/* small screens */
@media (max-width: 760px) {
	:root { --tile: 120px; }
	body { font-size: 15px; }
	.top-row { padding: 8px 12px; flex-wrap: wrap; }
	.search { order: 3; flex: 1 1 100%; }
	.toolbar .lbl { display: none; }
	.btn { padding: 8px; }
	main { padding: 12px; }
	.grid { gap: 8px; }
	.grid .name { padding: 6px 8px; font-size: 13px; }
	.grid .meta { display: none; }
	.list .item, .list .head { grid-template-columns: 30px minmax(0,1fr) 76px; }
	.list .col-t, .list .col-m { display: none; }
	footer { padding: 0 12px 20px; }
	.hide-sm { display: none; }
}
