:root {
	--bg: #f3f5f8;
	--panel: #ffffff;
	--panel-2: #f1f3f6;
	--text: #1a2330;
	--muted: #5b6776;
	--accent: #2563eb;
	--accent-hover: #1d4ed8;
	--danger: #dc2626;
	--ok: #16a34a;
	--warn: #b45309;
	--border: #d9dee5;
	--radius: 10px;
	--shadow: 0 1px 3px rgba(16, 24, 40, 0.06), 0 1px 2px rgba(16, 24, 40, 0.04);
}

* { box-sizing: border-box; }

body {
	margin: 0;
	font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
	background: var(--bg);
	color: var(--text);
	line-height: 1.5;
}

.topbar {
	background: var(--panel);
	border-bottom: 1px solid var(--border);
	padding: 0.9rem 1.25rem;
}
.brand { color: var(--text); font-weight: 700; text-decoration: none; letter-spacing: 0.2px; }

.container { max-width: 1000px; margin: 0 auto; padding: 1.5rem 1.25rem 3rem; }

.dashboard-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.head-actions { display: flex; align-items: center; gap: 0.5rem; }
/* Both the <a class="button"> and the logout <button> must drop the default
   top margin, otherwise the bare <button> sits ~0.5rem lower than the link. */
.head-actions .button, .head-actions button { margin-top: 0; }
.head-actions form { margin: 0; }

h1 { font-size: 1.5rem; margin: 0.2rem 0 1rem; }
h2 { font-size: 1.1rem; margin: 0 0 0.75rem; }

.card {
	background: var(--panel);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	padding: 1.25rem;
	margin-bottom: 1.25rem;
	box-shadow: var(--shadow);
}

a { color: var(--accent); }
.card.narrow { max-width: 560px; margin: 2rem auto; }

.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; }
@media (max-width: 760px) { .grid { grid-template-columns: 1fr; } }

label { display: block; font-size: 0.85rem; color: var(--muted); margin: 0.75rem 0 0.25rem; }

input, select {
	width: 100%;
	padding: 0.55rem 0.65rem;
	background: var(--panel-2);
	border: 1px solid var(--border);
	border-radius: 8px;
	color: var(--text);
	font-family: inherit;
	font-size: 0.95rem;
}
input:focus, select:focus { outline: 2px solid var(--accent); border-color: var(--accent); }

/* File input: style the wrapper compactly and theme the native button. */
input[type="file"] { padding: 0.4rem; cursor: pointer; }
input[type="file"]::file-selector-button {
	margin-right: 0.8rem;
	padding: 0.45rem 0.9rem;
	border: none;
	border-radius: 6px;
	background: var(--accent);
	color: #fff;
	font-family: inherit;
	font-size: 0.9rem;
	font-weight: 600;
	cursor: pointer;
}
input[type="file"]::file-selector-button:hover { background: var(--accent-hover); }
/* Safari < 16.4 fallback (kept as a separate rule on purpose). */
input[type="file"]::-webkit-file-upload-button {
	margin-right: 0.8rem;
	padding: 0.45rem 0.9rem;
	border: none;
	border-radius: 6px;
	background: var(--accent);
	color: #fff;
	font-family: inherit;
	font-size: 0.9rem;
	font-weight: 600;
	cursor: pointer;
}

button, .button {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	margin-top: 1rem;
	padding: 0.6rem 1.1rem;
	background: var(--accent);
	color: #fff;
	border: 1px solid transparent;
	border-radius: 8px;
	font-family: inherit;
	font-size: 0.95rem;
	font-weight: 600;
	line-height: 1.25;
	cursor: pointer;
	text-decoration: none;
}
button:hover, .button:hover { background: var(--accent-hover); }
button.ghost, .button.ghost { background: transparent; border: 1px solid var(--border); color: var(--text); }
button.danger { background: var(--danger); }
button.small, .button.small { margin-top: 0; padding: 0.35rem 0.7rem; font-size: 0.8rem; }

/* Checkboxes/radios must not inherit the full-width text-field styling above. */
input[type="checkbox"], input[type="radio"] {
	width: auto; height: auto; padding: 0; margin: 0;
	background: none; border: none; accent-color: var(--accent); cursor: pointer;
}

.hint { color: var(--muted); font-size: 0.85rem; }
.empty { color: var(--muted); }

.alert { padding: 0.7rem 0.9rem; border-radius: 8px; margin: 0.5rem 0 1rem; font-size: 0.9rem; }
.alert.error { background: rgba(239,68,68,0.12); border: 1px solid var(--danger); }
.alert.info  { background: rgba(59,130,246,0.12); border: 1px solid var(--accent); }
.alert.warn  { background: rgba(245,158,11,0.12); border: 1px solid var(--warn); }

.meta { display: grid; grid-template-columns: max-content 1fr; gap: 0.3rem 1rem; margin: 1rem 0; }
.meta dt { color: var(--muted); }
.meta dd { margin: 0; word-break: break-all; }
.meta.unavailable { opacity: 0.5; }

.hash { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 0.85rem; }
.selectable { user-select: all; }

.table-actions { margin-bottom: 0.75rem; }
.col-select { width: 1%; text-align: center; white-space: nowrap; }
.table-wrap { overflow-x: auto; }

/* Filename column: fixed width, overflow faded out, instant hover tooltip. */
.filename-cell { position: relative; }
.filename-cell .fname {
	display: block;
	max-width: 240px;
	white-space: nowrap;
	overflow: hidden;
	-webkit-mask-image: linear-gradient(to right, #000 80%, transparent 100%);
	mask-image: linear-gradient(to right, #000 80%, transparent 100%);
}
/* Pure-CSS tooltip: shows the full name immediately on hover (no title delay). */
.filename-cell:hover::after {
	content: attr(data-full);
	position: absolute;
	left: 0;
	top: calc(100% - 2px);
	z-index: 30;
	background: var(--text);
	color: var(--panel);
	padding: 0.4rem 0.6rem;
	border-radius: 6px;
	font-size: 0.8rem;
	line-height: 1.35;
	white-space: normal;
	width: max-content;
	max-width: 360px;
	word-break: break-all;
	box-shadow: var(--shadow);
	pointer-events: none;
}

/* Clickable, cycling column-header filter (invitations status). */
.th-filter { cursor: pointer; user-select: none; white-space: nowrap; }
.th-filter:hover { color: var(--text); }
.th-filter::after { content: " ⇅"; color: var(--muted); }
table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
th, td { text-align: left; padding: 0.55rem 0.6rem; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--muted); font-weight: 600; }
.filename { word-break: break-all; }
.link a { color: var(--accent); word-break: break-all; }

.badge { padding: 0.1rem 0.5rem; border-radius: 999px; font-size: 0.72rem; font-weight: 600; }
.badge.public { background: rgba(34,197,94,0.15); color: var(--ok); }
.badge.admin { background: rgba(245,158,11,0.15); color: var(--warn); }

.progress { height: 10px; background: var(--panel-2); border-radius: 999px; margin-top: 1rem; overflow: hidden; }
.progress-bar { height: 100%; width: 0; background: var(--accent); transition: width 0.2s ease; }
.progress-text { margin: 0.45rem 0 0; font-size: 0.82rem; color: var(--muted); font-variant-numeric: tabular-nums; }

/* Drag-and-drop upload zone (guest upload). */
.hidden-input { display: none !important; }
.js-only { display: none; } /* revealed by app.js once JS is active */
.dropzone {
	margin-top: 0.5rem;
	padding: 1.75rem 1rem;
	border: 2px dashed var(--border);
	border-radius: var(--radius);
	background: var(--panel-2);
	text-align: center;
	cursor: pointer;
	transition: border-color 0.15s ease, background 0.15s ease;
}
.dropzone:hover, .dropzone:focus { border-color: var(--accent); outline: none; }
.dropzone.drag { border-color: var(--accent); background: rgba(37, 99, 235, 0.08); }
.dropzone-text { margin: 0; font-weight: 600; }
.dropzone-link { color: var(--accent); text-decoration: underline; }
.dropzone-sub { margin: 0.35rem 0 0; font-size: 0.82rem; color: var(--muted); }

.file-list { list-style: none; margin: 0.75rem 0 0; padding: 0; }
.file-list li {
	display: flex; align-items: center; justify-content: space-between; gap: 0.75rem;
	padding: 0.4rem 0.6rem; border: 1px solid var(--border); border-radius: 8px; margin-bottom: 0.4rem;
	background: var(--panel-2); font-size: 0.85rem;
}
.file-list .file-name { word-break: break-all; }
.file-remove {
	margin: 0; padding: 0.1rem 0.5rem; background: transparent; color: var(--muted);
	border: 1px solid var(--border); border-radius: 6px; font-size: 0.8rem; line-height: 1; cursor: pointer;
}
.file-remove:hover { color: var(--danger); border-color: var(--danger); background: transparent; }

.quota-msg { margin: 0.6rem 0 0; font-size: 0.85rem; }
.quota-msg.ok { color: var(--muted); }
.quota-msg.over { color: var(--danger); font-weight: 600; }

.message-body { white-space: pre-wrap; word-break: break-word; background: var(--panel-2); padding: 0.9rem; border-radius: 8px; font-size: 0.9rem; }

/* Collection download list. */
.dl-list { list-style: none; margin: 1rem 0 0; padding: 0; }
.dl-item {
	display: flex; align-items: center; justify-content: space-between; gap: 1rem;
	padding: 0.75rem 0.85rem; border: 1px solid var(--border); border-radius: 8px;
	margin-bottom: 0.6rem; background: var(--panel-2);
}
.dl-item.unavailable { opacity: 0.5; }
.dl-meta { display: flex; flex-direction: column; gap: 0.15rem; min-width: 0; }
.dl-meta .filename { font-weight: 600; }
.dl-sub { font-size: 0.8rem; color: var(--muted); }
.dl-meta .hash { font-size: 0.72rem; color: var(--muted); word-break: break-all; }
.dl-item .button.small { flex-shrink: 0; }

.footer { text-align: center; color: var(--muted); font-size: 0.8rem; padding: 1.5rem; }
