:root {
	--bg: light-dark(#fffdfb, #181818);
	--surface: light-dark(#f8f6f4, #202020);
	--surface-2: light-dark(#efedeb, #282828);
	--surface-3: light-dark(#e8e6e4, #303030);
	--border: light-dark(#bfbdbb, #383838);
	--border-strong: light-dark(#9f9d9b, #4a4a4a);
	--text: light-dark(#181818, #efefef);
	--muted: light-dark(#484848, #bfbfbf);
	--faint: light-dark(#707070, #808080);
	--accent-soft: light-dark(#8f4f000f, #8f4f000f);
	--selection-bg: light-dark(#bf6f004f, #8f4f004f);
	--accent: #8f4f00;
	--accent-hover: #cf6f00;
	--on-accent: #ffffff;
	--link: light-dark(#8f4f00, #ffaf4f);
	--green: light-dark(#2f6f2f, #4f8f4f);
	--amber: light-dark(#8f4f00, #8f4f00);
	--red: light-dark(#8f2f2f, #cf4f4f);
	--brand: #8f4f00;
	--on-brand: #ffffff;
	--radius: 12px;
	--radius-md: 12px;
	--radius-sm: 12px;
	--radius-xs: 4px;
	--font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
	--text-large: 18px;
	--text-body: 16px;
	--text-small: 14px;
	--text-tiny: 12px;
	--mono: ui-monospace, "SFMono-Regular", "JetBrains Mono", "Cascadia Code", Consolas, monospace;
	color-scheme: light dark;
}

[data-theme="light"] {
	color-scheme: light;
}

[data-theme="dark"] {
	color-scheme: dark;
}

* {
	box-sizing: border-box;
}

html {
	height: 100%;
}

body {
	margin: 0;
	min-height: 100%;
	min-width: 320px;
	background: var(--bg);
	color: var(--text);
	font-family: var(--font);
	font-size: var(--text-body);
	line-height: 1.5;
	text-rendering: optimizeLegibility;
}

.app {
	display: flex;
	flex-direction: column;
	min-height: 100vh;
}

body.modal-open {
	overflow: hidden;
}

a {
	color: inherit;
}

button {
	font-family: inherit;
}

::selection {
	background: var(--selection-bg);
}

::-webkit-scrollbar {
	width: 10px;
	height: 10px;
}

::-webkit-scrollbar-thumb {
	background: var(--surface-3);
	border-radius: 108px;
	border: 2px solid transparent;
	background-clip: padding-box;
}

::-webkit-scrollbar-thumb:hover {
	background: var(--border-strong);
	background-clip: padding-box;
}

:focus-visible {
	outline: 2px solid var(--accent);
	outline-offset: 2px;
}
/* top bar */

.topbar {
	background: var(--bg);
	border-bottom: 1px solid var(--border);
}

.topbar-inner {
	display: flex;
	align-items: center;
	gap: 16px;
	max-width: 960px;
	min-height: 48px;
	margin: 0 auto;
	padding: 0px 24px;
}

.brand {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	min-width: 0;
	color: var(--text);
	text-decoration: none;
}

.brand-mark {
	display: grid;
	place-items: center;
	flex: 0 0 auto;
	width: 24px;
	height: 24px;
	border-radius: var(--radius-sm);
	background: var(--brand);
	color: var(--on-brand);
}

.brand-mark svg,
.btn svg,
.icon-btn svg,
.icon-btn.sm svg,
.row-action svg,
.menu button svg,
.input-reveal svg {
	width: 18px;
	height: 18px;
}

.entry-icon svg {
	width: 24px;
	height: 24px;
}

.brand-name {
	overflow: hidden;
	font-size: var(--text-body);
	font-weight: 600;
	white-space: nowrap;
	text-overflow: ellipsis;
}

.brand-version {
	flex: 0 0 auto;
	color: var(--faint);
	font-family: var(--mono);
	font-size: var(--text-tiny);
	white-space: nowrap;
}

.crumbs {
	display: flex;
	align-items: center;
	flex: 1 1 200px;
	gap: 1px;
	min-width: 0;
	padding: 4px 6px;
	border: 1px solid var(--border);
	border-radius: var(--radius-sm);
	background: var(--surface);
	overflow-x: auto;
	scrollbar-color: var(--border-strong) transparent;
}

.crumb {
	display: inline-flex;
	align-items: center;
	flex: 0 0 auto;
	gap: 6px;
	padding: 4px 6px;
	border-radius: var(--radius-sm);
	color: var(--muted);
	font-size: var(--text-body);
	text-decoration: none;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.crumb.current {
	max-width: 316px;
	color: var(--text);
	font-weight: 500;
}

.crumb svg {
	width: 18px;
	height: 18px;
	flex: 0 0 auto;
	color: var(--faint);
}

.crumb-sep {
	display: grid;
	place-items: center;
	flex: 0 0 auto;
	color: var(--faint);
}

.crumb-sep svg {
	display: block;
	width: 12px;
	height: 12px;
}

.topbar-actions {
	display: flex;
	align-items: center;
	gap: 0px 8px;
	flex: 0 0 auto;
	margin-left: auto;
}

.topbar-actions > .btn {
	margin-left: 4px;
}

/* buttons */

.btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 4px;
	height: 36px;
	min-width: 36px;
	padding: 0px 10px;
	border: 1px solid var(--border);
	border-radius: var(--radius-sm);
	background: var(--surface);
	color: var(--text);
	font-family: inherit;
	font-size: var(--text-body);
	font-weight: 500;
	line-height: 1.2;
	text-decoration: none;
	cursor: pointer;
}

.btn:hover {
	border-color: var(--border-strong);
	background: var(--surface-2);
}

.btn-primary {
	border-color: var(--accent);
	background: var(--accent);
	color: var(--on-accent);
}

.btn-primary:hover {
	border-color: var(--accent-hover);
	background: var(--accent-hover);
}

.btn-danger {
	border-color: var(--red);
	background: transparent;
	color: var(--red);
}

.btn-danger:hover {
	border-color: var(--red);
	background: var(--surface-2);
}

.btn:disabled {
	opacity: 0.5;
	cursor: not-allowed;
}

.btn-sm {
	height: 32px;
	padding: 0 8px;
	font-size: var(--text-tiny);
}

#logout-btn {
	height: 36px;
}

.icon-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 32px;
	height: 32px;
	padding: 0;
	border: 1px solid transparent;
	border-radius: var(--radius-sm);
	background: transparent;
	color: var(--muted);
	cursor: pointer;
}

.crumb:hover,
.icon-btn:hover {
	background: var(--surface-2);
	color: var(--text);
}

.row-action {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	padding: 0;
	border: 0;
	background: transparent;
	color: var(--muted);
	cursor: pointer;
	text-decoration: none;
}

.row-action:hover {
	color: var(--text);
}

.icon-btn.sm {
	width: 24px;
	height: 24px;
	border-radius: var(--radius-xs);
}

.empty .btn{
	margin: 0px 4px;
}

/* main */

.main {
	flex: 1;
	width: 100%;
	max-width: 960px;
	margin: 0 auto;
	padding: 20px 24px 48px;
}

.bar {
	display: flex;
	align-items: center;
	flex-wrap: wrap;
	gap: 8px;
	margin-bottom: 8px;
}

.summary {
	display: flex;
	justify-content: flex-end;
	margin-left: auto;
	min-width: 0;
	overflow: hidden;
}

.summary:empty {
	display: none;
}

.summary-actions {
	display: flex;
	min-height: 40px;
	align-items: center;
	gap: 8px;
	flex: 0 0 auto;
	flex-wrap: nowrap;
	white-space: nowrap;
}

.summary-actions:empty {
	display: none;
}

.summary-actions .icon-btn {
	width: 48px;
	border-color: var(--border);
}

.bar.selecting .summary-actions {
	display: none;
}

.summary .batch {
	flex: 0 1 auto;
	min-width: 0;
}

/* card + table */

.card {
	overflow: hidden;
	border: 1px solid var(--border);
	border-radius: var(--radius);
	background: var(--surface);
}

.table {
	width: 100%;
	border-collapse: collapse;
	table-layout: fixed;
}

.table thead th {
	padding: 8px 10px;
	border-bottom: 1px solid var(--border);
	color: var(--faint);
	font-size: var(--text-body);
	font-weight: 500;
	text-align: left;
	user-select: none;
}

.table th.col-size,
.table td.col-size {
	width: 20%;
	text-align: right;
}

.table th.col-time,
.table td.col-time {
	text-align: center;
	width: 20%;
}

.table th.col-actions,
.table td.col-actions {
	position: relative;
	width: 48px;
	padding: 0;
	text-align: center;
}

.table td.col-actions .row-action {
	position: absolute;
	inset: 0;
	width: auto;
	height: auto;
	border-radius: 0;
}

.table td.col-actions .row-action:hover {
	background: var(--surface-3);
}

.sort-btn {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	padding: 0;
	border: 0;
	background: none;
	color: inherit;
	font: inherit;
	cursor: pointer;
}

.sort-btn:hover,
th.sorted .sort-btn {
	color: var(--text);
}

.sort-btn .arrow {
	width: 12px;
	height: 12px;
	opacity: 0;
}

th.sorted .arrow {
	opacity: 1;
}

th.sorted.desc .arrow {
	transform: rotate(180deg);
}

.table tbody tr {
	height: 48px;
	border-bottom: 1px solid var(--border);
}

.table tbody tr:last-child {
	border-bottom: 0;
}

.table tbody tr:not(.selected):has(td:not(.col-actions):hover) {
	background: var(--surface-2);
}

.table tbody tr[data-href] {
	cursor: pointer;
}

.table tbody td {
	padding: 0 10px;
	font-size: var(--text-body);
	vertical-align: middle;
}

.entry {
	display: flex;
	align-items: center;
	gap: 8px;
	min-width: 0;
	color: var(--text);
	text-decoration: none;
}

.entry-icon {
	display: grid;
	place-items: center;
	flex: 0 0 auto;
	width: 24px;
	height: 24px;
	color: var(--muted);
}

.icon-dir {
	color: var(--link);
}

.name-wrap {
	display: flex;
	align-items: center;
	gap: 6px;
	min-width: 0;
}

.entry-name {
	overflow: hidden;
	font-weight: 400;
	white-space: nowrap;
	text-overflow: ellipsis;
}

.badge {
	flex: 0 0 auto;
	padding: 0 4px;
	border: 1px solid var(--border-strong);
	border-radius: var(--radius-xs);
	color: var(--faint);
	font-size: var(--text-tiny);
	letter-spacing: 0.03em;
	text-transform: uppercase;
}

.size {
	color: var(--muted);
	font-family: var(--mono);
	font-size: var(--text-tiny);
	white-space: nowrap;
}

.time {
	color: var(--muted);
	font-family: var(--mono);
	white-space: nowrap;
}

.table th.col-select,
.table td.col-select {
	width: 26px;
	padding-right: 0;
	padding-left: 10px;
}

.col-select input {
	display: block;
	width: 16px;
	height: 16px;
	margin: 0;
	accent-color: var(--accent);
	cursor: pointer;
}

.table tbody tr.selected {
	background: var(--surface-3);
}

.selecting tbody tr {
	cursor: pointer;
}

.icon-btn.active {
	background: var(--surface-3);
	color: var(--text);
}

.menu {
	position: absolute;
	z-index: 60;
	display: flex;
	flex-direction: column;
	min-width: 136px;
	max-height: calc(100vh - 16px);
	max-height: calc(100dvh - 16px);
	overflow-y: auto;
	padding: 6px;
	border: 1px solid var(--border-strong);
	border-radius: var(--radius-md);
	background: var(--surface-2);
}

.menu button {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 8px 8px;
	border: 0;
	border-radius: 6px;
	background: none;
	color: var(--text);
	font: inherit;
	font-size: var(--text-body);
	text-align: left;
	cursor: pointer;
}

.menu button:hover {
	background: var(--surface-3);
}

.menu button.danger {
	color: var(--red);
}

.batch {
	display: flex;
	align-items: center;
	gap: 6px;
	min-height: 40px;
	padding: 2px 4px 2px 10px;
	border: 1px solid var(--border);
	border-radius: var(--radius-md);
	background: var(--surface-2);
	color: var(--muted);
	font-size: var(--text-tiny);
	overflow-x: auto;
	scrollbar-width: none;
}

.batch::-webkit-scrollbar {
	display: none;
}

.batch > * {
	flex: 0 0 auto;
}

.batch .btn-sm {
	padding: 0 4px;
}

.batch .icon-btn {
	width: 28px;
	height: 28px;
	padding: 0;
}

.empty {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 10px;
	padding: 56px 24px;
	color: var(--muted);
	text-align: center;
}

.empty-icon {
	display: grid;
	place-items: center;
	width: 40px;
	height: 40px;
	color: var(--faint);
}

.empty-icon svg {
	width: 28px;
	height: 28px;
}

.empty h2 {
	margin: 0;
	color: var(--text);
	font-size: var(--text-body);
	font-weight: 500;
}

.empty p {
	max-width: 336px;
	margin: 0;
	font-size: var(--text-body);
}

/* footer */

.footer {
	display: flex;
	justify-content: space-between;
	gap: 16px;
	flex-wrap: wrap;
	width: 100%;
	max-width: 1168px;
	margin: 0 auto;
	padding: 0 24px 20px;
	color: var(--faint);
	font-size: var(--text-tiny);
}

.footer-side {
	display: flex;
	align-items: center;
	gap: 8px;
	min-width: 0;
}

.footer .mono {
	overflow: hidden;
	font-family: var(--mono);
	white-space: nowrap;
	text-overflow: ellipsis;
}

.status-dot {
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background: var(--green);
}

.status-dot.locked {
	background: var(--amber);
}
/* modal */

.overlay {
	position: fixed;
	inset: 0;
	z-index: 80;
	display: grid;
	place-items: center;
	padding: 16px;
	background: rgba(0, 0, 0, 0.6);
}

.login-page .app {
	justify-content: center;
	align-items: center;
	padding: 24px 16px;
}

.login-page .topbar,
.login-page .footer {
	display: none;
}

.login-page .main {
	flex: 0 0 auto;
	width: min(416px, 100%);
	padding: 0;
}

.login-card {
	position: relative;
	width: min(400px, 100%);
	--text-small: 16px;
	--text-tiny: 16px;
}

.login-theme {
	position: absolute;
	top: 6px;
	right: 6px;
}

.input-wrap {
	position: relative;
}

.input-reveal {
	position: absolute;
	top: 50%;
	right: 6px;
	display: grid;
	place-items: center;
	width: 24px;
	height: 24px;
	padding: 0;
	border: 0;
	border-radius: 6px;
	background: none;
	color: var(--faint);
	cursor: pointer;
	transform: translateY(-50%);
}

.input-reveal:hover {
	color: var(--text);
}

.input-reveal.on {
	color: var(--accent);
}

.input-wrap .input {
	padding-right: 32px;
}

.login-mark {
	width: 28px;
	height: 28px;
	border-radius: 8px;
}

.login-brand {
	display: flex;
	align-items: center;
	gap: 12px;
	margin-bottom: 24px;
	font-size: var(--text-large);
	font-weight: 600;
	letter-spacing: 0.02em;
}

.login-brand svg {
	width: 18px;
	height: 18px;
	color: var(--accent);
}

.dialog {
	width: min(416px, 100%);
	max-height: 90vh;
	overflow: auto;
	padding: 16px;
	border: 1px solid var(--border-strong);
	border-radius: var(--radius);
	background: var(--surface);
}

.dialog.wide {
	width: min(532px, 100%);
}

.dialog-head {
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	gap: 10px;
}

.dialog h2 {
	margin: 0px 0px 16px 0px;
	font-size: var(--text-large);
	font-weight: 600;
}

.dialog .sub {
	margin: 6px 0 0;
	color: var(--muted);
	font-size: var(--text-small);
	line-height: 1.55;
}

.dialog .sub b {
	color: var(--text);
	font-weight: 500;
}

.field {
	display: flex;
	flex-direction: column;
	gap: 6px;
	margin-top: 10px;
}

.field label {
	color: var(--muted);
	font-size: var(--text-tiny);
}

.input {
	width: 100%;
	padding: 8px 10px;
	border: 1px solid var(--border);
	border-radius: var(--radius-sm);
	background: var(--surface-2);
	color: var(--text);
	font-family: inherit;
	font-size: var(--text-body);
	outline: none;
}

.input:focus {
	border-color: var(--accent);
	box-shadow: 0 0 0 2px var(--accent-soft);
}

.form-error {
	color: var(--red);
	font-size: var(--text-small);
}

.form-error p {
	margin: 0;
	padding: 4px 0;
}

.dialog-actions {
	display: flex;
	flex-wrap: wrap;
	justify-content: flex-end;
	gap: 8px;
	margin-top: 32px;
}

.dialog-actions .btn {
	flex: 1;
	height: 44px;
	min-width: 92px;
}

.detail-list {
	display: flex;
	flex-direction: column;
	gap: 8px;
	margin: 16px 0 0;
}

.detail-list > div {
	display: flex;
	gap: 10px;
	line-height: 1.5;
}

.detail-list dt {
	flex: 0 0 72px;
	color: var(--muted);
}

.detail-list dd {
	margin: 0;
	min-width: 0;
	word-break: break-all;
}

.detail-list .muted {
	color: var(--muted);
}

.delete-target {
	max-height: 160px;
	margin: 10px 0 0px;
	padding: 8px 10px;
	overflow-y: auto;
	overscroll-behavior: contain;
	border: 1px solid var(--border);
	border-radius: var(--radius-sm);
	background: var(--surface-2);
	font-family: var(--mono);
	font-size: var(--text-tiny);
}

.delete-name {
	overflow: hidden;
	white-space: nowrap;
	text-overflow: ellipsis;
	line-height: 1.75;
}

/* upload */

.dropzone {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 6px;
	margin-top: 16px;
	padding: 20px 16px;
	border: 1px dashed var(--border-strong);
	border-radius: var(--radius-sm);
	background: var(--surface-2);
	color: var(--muted);
	font-size: var(--text-small);
	text-align: center;
	cursor: pointer;
}

.dropzone:hover {
	border-color: var(--accent);
}

.dropzone svg {
	width: 20px;
	height: 20px;
	margin-bottom: 2px;
	color: var(--muted);
}

.dropzone b {
	color: var(--text);
	font-weight: 500;
}

.dropzone span {
	color: var(--faint);
	font-size: var(--text-tiny);
}

.file-list {
	display: flex;
	flex-direction: column;
	gap: 6px;
	max-height: 216px;
	margin-top: 10px;
	overflow: auto;
}

.file-row {
	display: flex;
	align-items: center;
	min-height: 36px;
	gap: 8px;
	padding: 0px 8px;
	border: 1px solid var(--border);
	border-radius: var(--radius-sm);
	background: var(--surface-2);
	overflow: hidden;
}

.file-row .fname {
	flex: 1;
	min-width: 0;
	overflow: hidden;
	font-size: var(--text-small);
	white-space: nowrap;
	text-overflow: ellipsis;
}

.file-row .fsize {
	flex: 0 1 auto;
	min-width: 0;
	max-width: 50%;
	overflow: hidden;
	text-align: right;
	text-overflow: ellipsis;
	color: var(--faint);
	font-family: var(--mono);
	font-size: var(--text-tiny);
	font-variant-numeric: tabular-nums;
	white-space: nowrap;
}

.file-row .row-action {
	width: 24px;
	height: 24px;
}

.file-row .row-action svg {
	width: 12px;
	height: 12px;
}

.file-progress {
	flex: 0 0 64px;
	height: 4px;
	overflow: hidden;
	border-radius: 108px;
	background: var(--surface-3);
}

.file-progress span {
	display: block;
	width: 0;
	height: 100%;
	background: #006fcf;
}

.file-row.done .file-progress span {
	background: var(--green);
}

.file-row.failed .file-progress span {
	background: var(--red);
}

.upload-meta {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
	margin-top: 10px;
	color: var(--faint);
	font-size: var(--text-tiny);
}

.checkbox {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	color: var(--muted);
	font-size: var(--text-tiny);
	cursor: pointer;
	user-select: none;
}

.checkbox input {
	width: 16px;
	height: 16px;
	accent-color: var(--accent);
}

/* toasts */

.toast-root {
	position: fixed;
	right: 16px;
	bottom: 16px;
	z-index: 90;
	display: flex;
	flex-direction: column;
	gap: 6px;
	width: min(336px, calc(100vw - 32px));
}

.toast {
	display: flex;
	align-items: flex-start;
	gap: 8px;
	padding: 8px 10px;
	border: 1px solid var(--border-strong);
	border-radius: var(--radius-sm);
	background: var(--surface);
	font-size: var(--text-small);
	transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.leaving {
	opacity: 0;
	transform: translateY(8px);
}

.toast svg {
	flex: 0 0 auto;
	width: 18px;
	height: 18px;
	margin-top: 1px;
}

.toast.success svg {
	color: var(--green);
}

.toast.error svg {
	color: var(--red);
}

.toast.error {
	border-color: var(--red);
}

/* animations */

.spin {
	animation: spin 0.8s linear infinite;
}

@keyframes spin {
	to {
		transform: rotate(360deg);
	}
}
/* responsive */

@media (max-width: 980px) {
	.brand-version {
		display: none;
	}
}

@media (max-width: 720px) {
	.topbar-inner {
		flex-wrap: wrap;
		gap: 0px 8px;
		padding: 0px 16px;
	}

	.table th.col-time,
	.table td.col-time {
		width: 30%;
	}
	.main {
		padding: 16px 16px 36px;
	}

	.footer {
		padding: 0 16px 16px;
	}

	.crumbs {
		flex: 1 0 100%;
	}

	.summary-actions {
		margin-left: auto;
	}
}

@media (max-width: 560px) {
	.topbar-actions #login-btn span,
	.topbar-actions #logout-btn span {
		display: none;
	}

	.topbar-actions #login-btn,
	.topbar-actions #logout-btn {
		padding: 8px;
	}

	.main {
		padding: 16px 0px;
	}

	.summary-actions,
	.summary {
		padding-right: 16px;
	}

	.crumbs,
	.card {
		border-left: none;
		border-right: none;
		border-radius: 0px;
	}

	.table th.col-size,
	.table td.col-size {
		display: none;
	}

	.batch .btn span {
		display: none;
	}
}

@media (max-width: 420px) {
	.brand-name {
		display: none;
	}

	.table th.col-time,
	.table td.col-time {
		width: 35%;
	}
}

@media (prefers-reduced-motion: reduce) {
	.spin {
		animation: none;
	}
}
