:root {
	color-scheme: dark;
	--bg: #0b0d12;
	--panel: #151821;
	--panel-border: rgba(255, 255, 255, 0.1);
	--panel-strong: rgba(255, 255, 255, 0.18);
	--text: #eef1f6;
	--muted: #9aa3b2;
	--accent: #ffd300;
	--danger: #e2453c;
	--success: #2ecc71;
}

* { box-sizing: border-box; }

.site-watermark {
	position: fixed;
	left: 0;
	right: 0;
	bottom: 8px;
	text-align: center;
	font-size: 0.7rem;
	letter-spacing: 0.05em;
	color: var(--muted);
	opacity: 0.6;
	pointer-events: none;
	z-index: 20;
}

body {
	margin: 0;
	min-height: 100vh;
	background: var(--bg);
	color: var(--text);
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.page {
	width: min(700px, calc(100% - 32px));
	margin: 0 auto;
	padding: 32px 0 60px;
}

h1, h2, h3 { margin: 0; letter-spacing: -0.02em; }

/* ── Home ── */
.home-wrap {
	max-width: 480px;
	margin: 40px auto 0;
}

.home-wrap h1 {
	font-size: clamp(2.2rem, 6vw, 3.2rem);
	margin-bottom: 8px;
	text-align: center;
}

.home-sub {
	color: var(--muted);
	margin-bottom: 32px;
	text-align: center;
}

.home-wrap h2 { font-size: 1.1rem; margin-bottom: 14px; }

.join-form { display: flex; gap: 8px; }
.join-form input { flex: 1; }

/* ── Shared form elements ── */
input[type="text"],
input[type="number"],
input[type="password"] {
	width: 100%;
	padding: 12px 14px;
	border: 1px solid var(--panel-strong);
	border-radius: 10px;
	background: var(--panel);
	color: var(--text);
	font-family: inherit;
	font-size: 1rem;
	outline: none;
}

input[type="text"]:focus,
input[type="number"]:focus,
input[type="password"]:focus {
	border-color: var(--accent);
}

label { display: flex; flex-direction: column; gap: 6px; font-size: 0.85rem; color: var(--muted); }

.form-row {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 12px;
	margin-bottom: 14px;
}

.form-row-single { margin-bottom: 14px; }

.people-inputs { display: flex; flex-direction: column; gap: 8px; margin-bottom: 18px; }

.checkbox-row {
	flex-direction: row;
	align-items: center;
	gap: 8px;
	color: var(--text);
	font-size: 0.9rem;
	margin-bottom: 14px;
}

.checkbox-row input[type="checkbox"] {
	width: 18px;
	height: 18px;
	flex: none;
	accent-color: var(--accent);
	cursor: pointer;
}

.btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 6px;
	padding: 10px 18px;
	border-radius: 10px;
	border: 1px solid var(--panel-strong);
	background: transparent;
	color: var(--text);
	font-family: inherit;
	font-size: 0.95rem;
	cursor: pointer;
	text-decoration: none;
}

.btn--primary { background: var(--accent); color: #14161c; border-color: var(--accent); font-weight: 600; }
.btn--full { width: 100%; }
.btn--sm { padding: 6px 12px; font-size: 0.85rem; }

.error {
	color: var(--danger);
	font-size: 0.9rem;
	margin-top: 8px;
}

.hint { color: var(--muted); font-size: 0.85rem; margin: -4px 0 12px; }

.screen-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	margin-bottom: 16px;
	gap: 12px;
	flex-wrap: wrap;
}

.header-actions { display: flex; gap: 8px; }

.code-badge {
	display: inline-block;
	margin-left: 8px;
	padding: 3px 10px;
	border-radius: 999px;
	background: rgba(255, 211, 0, 0.12);
	border: 1px solid rgba(255, 211, 0, 0.35);
	color: var(--accent);
	font-size: 0.9rem;
	font-weight: 600;
	letter-spacing: 0.06em;
	vertical-align: middle;
}

.card {
	background: var(--panel);
	border: 1px solid var(--panel-border);
	border-radius: 16px;
	padding: 20px;
	margin-bottom: 20px;
}

.empty { color: var(--muted); }

/* ── Tabs ── */
.tab-bar {
	display: flex;
	gap: 6px;
	margin-bottom: 20px;
	overflow-x: auto;
}

.tab-btn {
	flex: 1;
	padding: 10px 12px;
	border-radius: 10px;
	border: 1px solid var(--panel-strong);
	background: transparent;
	color: var(--muted);
	font-family: inherit;
	font-size: 0.9rem;
	font-weight: 600;
	cursor: pointer;
	white-space: nowrap;
}

.tab-btn--active { background: var(--accent); border-color: var(--accent); color: #14161c; }

/* ── Setup ── */
.rate-line { color: var(--muted); font-size: 0.85rem; margin: 10px 0 0; }

.people-list { list-style: none; padding: 0; margin: 0 0 14px; }
.people-list li {
	padding: 8px 0;
	border-top: 1px solid var(--panel-border);
}
.people-list li:first-child { border-top: none; }

.add-person-form { display: flex; gap: 8px; }
.add-person-form input { flex: 1; }

/* ── Items ── */
.unit-preview { color: var(--accent); font-size: 0.85rem; margin: -4px 0 12px; min-height: 1.2em; }

.running-total {
	color: var(--muted);
	font-size: 0.85rem;
	margin: 0 0 12px;
	font-variant-numeric: tabular-nums;
}

.running-total--over { color: var(--danger); }

.items-list { list-style: none; padding: 0; margin: 0; }

.item-row {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 10px 0;
	border-top: 1px solid var(--panel-border);
}
.item-row:first-child { border-top: none; }

.item-row-name { flex: 1; word-break: break-word; }
.item-row-price { color: var(--muted); font-variant-numeric: tabular-nums; }

.item-row-edit,
.item-row-delete {
	flex: none;
	background: transparent;
	border: none;
	color: var(--muted);
	font-size: 1.1rem;
	line-height: 1;
	cursor: pointer;
	padding: 4px 6px;
}
.item-row-edit:hover { color: var(--accent); }
.item-row-delete:hover { color: var(--danger); }

.item-row--editing {
	flex-wrap: wrap;
	gap: 8px;
}
.item-row--editing .edit-item-name { flex: 2 1 140px; }
.item-row--editing .edit-item-qty { flex: 0 1 70px; }
.item-row--editing .edit-item-total { flex: 0 1 90px; }
.item-row--editing input {
	padding: 6px 10px;
	font-size: 0.9rem;
}

/* ── Assign ── */
.assign-list { list-style: none; padding: 0; margin: 0; }

.assign-item {
	padding: 14px 0;
	border-top: 1px solid var(--panel-border);
}
.assign-item:first-child { border-top: none; }

.assign-item-header {
	display: flex;
	justify-content: space-between;
	margin-bottom: 10px;
	font-weight: 600;
}

.assign-item-price { color: var(--muted); font-weight: 400; font-variant-numeric: tabular-nums; }

.assign-people { display: flex; flex-direction: column; gap: 6px; }

/* .assign-person is a <label> — the global `label { flex-direction: column }`
   rule would otherwise stack name/input/amount vertically per person, since
   nothing here overrode it. Grid instead of flex sidesteps that entirely and
   keeps every person on one compact row regardless of name length. */
.assign-person {
	display: grid;
	grid-template-columns: 1fr 64px 64px;
	align-items: center;
	gap: 10px;
	padding: 4px 0;
}

.assign-person-name {
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.assign-qty {
	width: 100% !important;
	padding: 4px 8px !important;
	font-size: 0.85rem !important;
	text-align: center;
}

.assign-share {
	text-align: right;
	color: var(--accent);
	font-size: 0.85rem;
	font-variant-numeric: tabular-nums;
}

.assign-remaining {
	margin: 10px 0 0;
	color: var(--muted);
	font-size: 0.8rem;
	text-align: right;
}

.assign-remaining--over { color: var(--danger); font-weight: 600; }

/* ── Summary ── */
.totals-list { list-style: none; padding: 0; margin: 0; }

.totals-row {
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: 12px 0;
	border-top: 1px solid var(--panel-border);
}
.totals-row:first-child { border-top: none; }

.totals-row-name { font-weight: 600; }

.totals-row-amounts {
	display: flex;
	flex-direction: column;
	align-items: flex-end;
	gap: 2px;
	font-variant-numeric: tabular-nums;
}

.totals-row-local { color: var(--muted); font-size: 0.85rem; }

#confirmBtn { margin-top: 18px; }

#confirmOutput { margin-top: 14px; display: flex; flex-direction: column; gap: 8px; }

.confirm-text {
	width: 100%;
	padding: 12px 14px;
	border: 1px solid var(--panel-strong);
	border-radius: 10px;
	background: var(--panel);
	color: var(--text);
	font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
	font-size: 0.9rem;
	line-height: 1.5;
	resize: vertical;
}

.copy-feedback {
	color: var(--success);
	font-size: 0.85rem;
	font-weight: 600;
}
