/* Compact, modern, single-screen UI. Light/dark aware. */
:root {
	--bg: #f4f6fb;
	--card: #ffffff;
	--ink: #1f2430;
	--ink-dim: #6b7280;
	--line: #e5e8ef;
	--brand: #2f6bff;
	--brand-ink: #ffffff;
	--accent: #0a9b78;
	--warn: #e2622a;
	--danger: #d23b3b;
	--soft: #eef2fb;
	--radius: 12px;
	--shadow: 0 6px 24px rgba(20, 30, 60, .08);
}
@media (prefers-color-scheme: dark) {
	:root {
		--bg: #0f131a;
		--card: #171c26;
		--ink: #e7ebf3;
		--ink-dim: #9aa3b2;
		--line: #262d3a;
		--brand: #5b8bff;
		--soft: #1d2430;
		--shadow: 0 6px 24px rgba(0, 0, 0, .35);
	}
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
	margin: 0;
	background: var(--bg);
	color: var(--ink);
	font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
		"PingFang SC", "Microsoft YaHei", sans-serif;
	-webkit-text-size-adjust: 100%;
}
.hidden { display: none !important; }

/* ---- Buttons & inputs ---- */
.btn {
	appearance: none;
	border: 1px solid transparent;
	border-radius: 10px;
	padding: 9px 14px;
	font-size: 14px;
	font-weight: 600;
	cursor: pointer;
	background: var(--soft);
	color: var(--ink);
	transition: filter .15s, background .15s, border-color .15s;
	white-space: nowrap;
}
.btn:hover { filter: brightness(1.03); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--brand); color: var(--brand-ink); }
.btn-accent { background: var(--accent); color: #fff; }
.btn-warn { background: var(--warn); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-soft { background: var(--soft); color: var(--ink); }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--ink-dim); }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 10px; font-size: 13px; }
.btn-lg { padding: 14px 22px; font-size: 16px; }

.input {
	width: 100%;
	border: 1px solid var(--line);
	background: var(--card);
	color: var(--ink);
	border-radius: 10px;
	padding: 10px 12px;
	font-size: 15px;
	outline: none;
}
.input:focus { border-color: var(--brand); }
.input-sm { font-size: 14px; padding: 8px 10px; }
.linklike { background: none; border: none; color: var(--brand); cursor: pointer; font-size: 13px; padding: 0; }

/* ---- Login overlay ---- */
.overlay {
	position: fixed; inset: 0; z-index: 50;
	display: grid; place-items: center;
	background: rgba(10, 14, 22, .55);
	backdrop-filter: blur(3px);
	padding: 20px;
}
.login-card {
	width: 100%; max-width: 340px;
	background: var(--card); border-radius: var(--radius);
	box-shadow: var(--shadow); padding: 26px 22px;
	display: flex; flex-direction: column; gap: 12px;
}
.login-title { margin: 0; font-size: 20px; }
.login-sub { margin: 0 0 4px; color: var(--ink-dim); font-size: 13px; }
.login-error { color: var(--danger); font-size: 13px; }

/* ---- App shell ---- */
.app { min-height: 100%; display: flex; flex-direction: column; }
.topbar {
	display: flex; align-items: center; justify-content: space-between;
	padding: 12px 16px; padding-top: calc(12px + env(safe-area-inset-top));
	border-bottom: 1px solid var(--line);
	position: sticky; top: 0; background: var(--bg); z-index: 10;
}
.brand { font-weight: 800; font-size: 17px; letter-spacing: .3px; display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-dim { color: var(--ink-dim); font-weight: 600; font-size: 13px; }
.ch-title { font-weight: 700; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-actions { display: flex; gap: 8px; }

.grid {
	width: 100%; max-width: 760px; margin: 0 auto;
	padding: 14px 16px 24px; display: flex; flex-direction: column; gap: 12px; flex: 1;
}
.card {
	background: var(--card); border: 1px solid var(--line);
	border-radius: var(--radius); box-shadow: var(--shadow);
	padding: 14px;
}

/* ---- Compose ---- */
.dropzone { position: relative; border-radius: 10px; }
.dropzone.drag { outline: 2px dashed var(--brand); outline-offset: 3px; }
.textarea {
	width: 100%; resize: vertical; min-height: 110px; max-height: 46vh;
	border: 1px solid var(--line); background: var(--card); color: var(--ink);
	border-radius: 10px; padding: 12px; font-size: 15px; outline: none;
	font-family: inherit;
}
.textarea:focus { border-color: var(--brand); }
.drop-hint {
	position: absolute; inset: 0; display: grid; place-items: center;
	background: rgba(47, 107, 255, .08); color: var(--brand); font-weight: 700;
	border-radius: 10px; pointer-events: none;
}
.attach-row { display: flex; align-items: center; gap: 10px; margin-top: 10px; flex-wrap: wrap; }
.attach-info { color: var(--ink-dim); font-size: 13px; }
.attach-list { display: flex; flex-wrap: wrap; gap: 6px; flex: 1 1 100%; }
.attach-chip {
	display: inline-flex; align-items: center; gap: 6px;
	background: var(--soft); border: 1px solid var(--line);
	border-radius: 8px; padding: 4px 8px; font-size: 13px; color: var(--ink-dim);
	max-width: 100%;
}
.attach-chip-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 200px; }
.attach-chip-remove {
	background: none; border: none; color: var(--ink-dim); cursor: pointer;
	padding: 0 2px; font-size: 14px; line-height: 1;
}
.attach-chip-remove:hover { color: var(--warn); }
.preview-gallery {
	display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
	gap: 10px; margin-bottom: 10px;
}
.preview-gallery .preview-img { width: 100%; height: auto; object-fit: cover; }
.file-row {
	display: flex; align-items: center; gap: 8px; padding: 8px 10px;
	background: var(--soft); border-radius: 8px; margin-bottom: 6px;
}
.pw-row { display: flex; align-items: center; gap: 10px; margin-top: 10px; flex-wrap: wrap; }
.id-row { display: flex; gap: 8px; margin-top: 10px; flex-wrap: nowrap; align-items: center; }
.id-row .input { flex: 1 1 0; min-width: 0; }
.id-row .btn { flex: 0 0 auto; }
.pw-label { color: var(--ink-dim); font-size: 14px; min-width: 36px; }
.check { display: inline-flex; align-items: center; gap: 6px; color: var(--ink-dim); font-size: 14px; cursor: pointer; }
.pw-row .input-sm { flex: 1 1 240px; max-width: 420px; }
.actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }

/* ---- Receive ---- */
.receive-row { display: flex; gap: 8px; flex-wrap: wrap; }
.receive-row .input { flex: 1 1 180px; }
.receive-row .input-sm { flex: 0 1 140px; }

/* ---- Output / results ---- */
.output { display: flex; flex-direction: column; gap: 12px; }
.result-card, .panel {
	background: var(--card); border: 1px solid var(--line);
	border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px;
}
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.panel-title { font-weight: 700; }
.muted { color: var(--ink-dim); font-size: 13px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.share-id {
	font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
	font-size: 22px; font-weight: 800; letter-spacing: 2px;
	background: var(--soft); border-radius: 10px; padding: 12px 14px; text-align: center;
	user-select: all;
}
.qr { display: block; width: 180px; height: 180px; background: #fff; border-radius: 10px; padding: 8px; }
.content-box {
	white-space: pre-wrap; word-break: break-word; background: var(--soft);
	border-radius: 10px; padding: 12px; max-height: 40vh; overflow: auto;
	font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 14px;
}
.preview-img { max-width: 100%; max-height: 40vh; border-radius: 10px; display: block; }
.badge { display: inline-block; font-size: 13px; font-weight: 600; padding: 6px 10px; border-radius: 8px; margin-bottom: 10px; }
.badge-burn { background: rgba(226, 98, 42, .14); color: var(--warn); }
.badge-once { background: rgba(10, 155, 120, .16); color: var(--accent); }

/* ---- Channel ---- */
.msg-list { display: flex; flex-direction: column; gap: 8px; max-height: 46vh; overflow: auto; padding-right: 4px; }
.msg { border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; background: var(--bg); }
.msg-meta { color: var(--ink-dim); font-size: 12px; margin-bottom: 4px; display: flex; gap: 8px; align-items: center; }
.msg-copy { margin-left: auto; }
.msg-body { white-space: pre-wrap; word-break: break-word; }
.msg-img, .preview-img { cursor: zoom-in; }
.msg-img { max-width: 220px; max-height: 220px; border-radius: 8px; display: block; }
.channel-controls { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); display: inline-block; }

/* ---- Views & channel full-screen ---- */
#main-view, .channel-view { display: flex; flex-direction: column; min-height: 100vh; }
.channel-main {
	width: 100%; max-width: 760px; margin: 0 auto;
	padding: 14px 16px 24px; display: flex; flex-direction: column; gap: 12px; flex: 1;
}
.ch-input-row { display: flex; gap: 10px; align-items: stretch; }
.ch-textarea { flex: 1; min-height: 92px; }
.ch-send-col { display: flex; flex-direction: column; gap: 8px; width: 120px; flex: 0 0 auto; }
.ch-send-col .btn { flex: 1; }
.ch-auto-label { margin-left: auto; }
.ch-pw-line { margin-bottom: 10px; font-size: 14px; }
.ch-shortcut-hint { margin-top: 6px; font-size: 12px; }
.channel-msgs-card .msg-list { max-height: 52vh; }
.channel-qr-card { display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.qr-row { display: flex; gap: 12px; align-items: flex-start; flex-wrap: wrap; }
.qr-actions { display: flex; flex-direction: column; gap: 8px; }

/* ---- Toast ---- */
.toast {
	position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%);
	background: #111826; color: #fff; padding: 10px 16px; border-radius: 10px;
	box-shadow: var(--shadow); font-size: 14px; z-index: 60; max-width: 90vw;
}
.toast.err { background: var(--danger); }
.toast.ok { background: var(--accent); }

/* ---- Lightbox ---- */
.lightbox {
	position: fixed; inset: 0; z-index: 1000; display: flex; align-items: center;
	justify-content: center; background: rgba(0, 0, 0, .85); padding: 16px; cursor: zoom-out;
}
.lightbox-img { max-width: 100%; max-height: 100%; border-radius: 8px; }

/* ---- Footer ---- */
.footer { text-align: center; color: var(--ink-dim); font-size: 12px; padding: 14px; }

@media (max-width: 520px) {
	.share-id { font-size: 18px; }
	.actions .btn { flex: 1 1 auto; }
	.id-row .btn { padding: 6px 8px; font-size: 12px; }
	.ch-input-row { flex-direction: column; }
	.ch-send-col { width: 100%; flex-direction: row; }
	.ch-auto-label { margin-left: 0; }
	.topbar-actions { flex-wrap: wrap; justify-content: flex-end; }
}
