:root {
	--bg: #0f0f14;
	--card: #1a1a22;
	--card2: #23232d;
	--line: #2c2c38;
	--text: #f2f2f7;
	--muted: #8e8e9a;
	--accent: #7b5cf0;
	--accent2: #9a82ff;
	--danger: #ff5c63;
	--ok: #34c77b;
	--safe-t: env(safe-area-inset-top, 0px);
	--safe-b: env(safe-area-inset-bottom, 0px);
	color-scheme: dark;
}
@media (prefers-color-scheme: light) {
	:root {
		--bg: #f2f2f7; --card: #ffffff; --card2: #ececf2; --line: #dcdce4;
		--text: #111118; --muted: #6c6c78; --accent: #6a48e8; --accent2: #6a48e8;
		color-scheme: light;
	}
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font: 16px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif; -webkit-font-smoothing: antialiased; overscroll-behavior-y: contain; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
a { color: var(--accent2); }
[hidden] { display: none !important; }

.loading { padding: 40vh 0 0; text-align: center; color: var(--muted); }

/* Header */
.top { position: sticky; top: 0; z-index: 5; padding: calc(var(--safe-t) + 10px) 16px 8px; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); }
.top-row { display: flex; align-items: center; gap: 8px; }
.top h1 { flex: 1; margin: 0; font-size: 30px; font-weight: 700; letter-spacing: -.5px; }
.top h1 small { font-size: 15px; font-weight: 500; color: var(--muted); margin-left: 6px; }
.icon-btn { width: 38px; height: 38px; border-radius: 19px; display: grid; place-items: center; background: var(--card2); color: var(--accent2); }
.icon-btn svg { width: 20px; height: 20px; }

.chips { display: flex; gap: 8px; overflow-x: auto; padding: 10px 0 2px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; padding: 6px 12px; border-radius: 16px; background: var(--card2); color: var(--muted); font-size: 14px; font-weight: 500; white-space: nowrap; }
.chip.on { background: var(--accent); color: #fff; }
.chip b { font-weight: 600; margin-left: 4px; }

/* Banner */
.banner { margin: 8px 16px; padding: 14px; border-radius: 14px; background: var(--card); display: flex; gap: 12px; align-items: center; }
.banner p { margin: 0; flex: 1; font-size: 14px; color: var(--muted); }
.banner p strong { display: block; color: var(--text); font-size: 15px; }

/* List */
.list { padding: 4px 16px calc(var(--safe-b) + 24px); }
.day { margin: 18px 4px 6px; font-size: 13px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }
.msg { position: relative; display: block; width: 100%; text-align: left; padding: 12px 14px 12px 26px; margin-bottom: 8px; border-radius: 14px; background: var(--card); }
.msg::before { content: ''; position: absolute; left: 10px; top: 18px; width: 8px; height: 8px; border-radius: 4px; background: var(--accent); }
.msg.read::before { background: transparent; }
.msg-head { display: flex; gap: 8px; align-items: baseline; }
.msg-site { flex: 1; min-width: 0; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-time { font-size: 12px; color: var(--muted); flex: none; }
.msg-title { font-weight: 600; margin-top: 2px; }
.msg-body { color: var(--muted); font-size: 15px; margin-top: 2px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; white-space: pre-line; }
.msg.read .msg-title { font-weight: 500; }
.msg.flash { animation: flash 1.2s ease; }
@keyframes flash { 0%, 40% { background: color-mix(in srgb, var(--accent) 35%, var(--card)); } }

.empty { text-align: center; color: var(--muted); padding: 60px 20px; }
.empty svg { width: 54px; height: 54px; opacity: .35; margin-bottom: 10px; }
.more { display: block; margin: 12px auto; padding: 8px 18px; border-radius: 18px; background: var(--card2); color: var(--muted); font-size: 14px; }

/* Buttons + forms */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 11px 18px; border-radius: 12px; background: var(--accent); color: #fff; font-weight: 600; }
.btn.sm { padding: 7px 12px; font-size: 14px; border-radius: 10px; }
.btn.ghost { background: var(--card2); color: var(--text); }
.btn.danger { background: transparent; color: var(--danger); }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .5; }
.field { display: block; margin-bottom: 12px; }
.field span { display: block; font-size: 13px; color: var(--muted); margin: 0 0 5px 2px; }
.field input, .field textarea { width: 100%; padding: 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--card2); outline: none; font-size: 16px; }
.field textarea { min-height: 100px; resize: vertical; }
.field input:focus, .field textarea:focus { border-color: var(--accent); }
.seg { display: flex; padding: 3px; border-radius: 11px; background: var(--card2); margin-bottom: 14px; }
.seg button { flex: 1; padding: 8px 4px; border-radius: 9px; font-size: 14px; font-weight: 600; color: var(--muted); }
.seg button.on { background: var(--accent); color: #fff; }

/* Pair screen */
.pair { max-width: 420px; margin: 0 auto; padding: calc(var(--safe-t) + 40px) 24px calc(var(--safe-b) + 30px); }
.pair .logo { width: 84px; height: 84px; border-radius: 20px; display: block; margin: 0 auto 16px; }
.pair h2 { text-align: center; margin: 0 0 6px; font-size: 26px; }
.pair .lead { text-align: center; color: var(--muted); margin: 0 0 26px; }
.code-input { text-align: center; letter-spacing: 10px; font-size: 28px !important; font-weight: 600; }
.box { padding: 16px; border-radius: 14px; background: var(--card); margin-top: 22px; }
.box h3 { margin: 0 0 8px; font-size: 16px; }
.box p, .box ol { margin: 0 0 10px; color: var(--muted); font-size: 14px; }
.box ol { padding-left: 20px; }
.big-code { font-size: 40px; font-weight: 700; letter-spacing: 8px; text-align: center; margin: 10px 0 4px; font-variant-numeric: tabular-nums; }

/* Sheet */
.sheet { position: fixed; inset: 0; z-index: 20; background: rgba(0,0,0,.45); display: flex; align-items: flex-end; animation: fade .2s; }
.sheet-card { width: 100%; max-height: 92vh; overflow-y: auto; background: var(--bg); border-radius: 18px 18px 0 0; padding: 8px 18px calc(var(--safe-b) + 22px); animation: up .25s cubic-bezier(.2,.8,.2,1); }
@media (min-width: 700px) { .sheet { align-items: center; justify-content: center; } .sheet-card { max-width: 520px; border-radius: 18px; } }
.sheet-grab { width: 38px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 10px; }
.sheet-head { display: flex; align-items: center; margin-bottom: 14px; }
.sheet-head h2 { flex: 1; margin: 0; font-size: 20px; }
.sheet-head button { color: var(--accent2); font-weight: 600; }
.section { margin: 20px 0 8px 2px; font-size: 13px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }
.rows { border-radius: 14px; background: var(--card); overflow: hidden; }
.row { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--line); min-height: 48px; }
.row:last-child { border-bottom: 0; }
.row .grow { flex: 1; min-width: 0; }
.row small { display: block; color: var(--muted); font-size: 13px; }
.row input { flex: 1; min-width: 0; background: transparent; border: 0; outline: none; text-align: right; color: var(--muted); }
.dot { width: 8px; height: 8px; border-radius: 4px; background: var(--ok); flex: none; }
.dot.off { background: var(--danger); }
.detail-site { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .4px; }
.detail-title { font-size: 22px; font-weight: 700; margin: 4px 0 8px; }
.detail-body { white-space: pre-wrap; word-wrap: break-word; margin-bottom: 14px; }
.detail-meta { color: var(--muted); font-size: 13px; margin-bottom: 18px; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; }

.toast { position: fixed; left: 50%; bottom: calc(var(--safe-b) + 24px); transform: translateX(-50%); z-index: 30; padding: 10px 16px; border-radius: 12px; background: var(--card2); box-shadow: 0 6px 24px rgba(0,0,0,.35); font-size: 14px; max-width: 90vw; animation: fade .2s; }
@keyframes fade { from { opacity: 0; } }
@keyframes up { from { transform: translateY(40px); opacity: .5; } }
.btn { text-decoration: none; }
