/* IBM Carbon Design System: White theme, with Gray 100 for dark mode. */
@font-face { font-family: 'IBM Plex Sans'; font-weight: 400; font-display: swap; src: url('/fonts/ibm-plex-sans-latin-400-normal.woff2') format('woff2'); }
@font-face { font-family: 'IBM Plex Sans'; font-weight: 600; font-display: swap; src: url('/fonts/ibm-plex-sans-latin-600-normal.woff2') format('woff2'); }
@font-face { font-family: 'IBM Plex Mono'; font-weight: 400; font-display: swap; src: url('/fonts/ibm-plex-mono-latin-400-normal.woff2') format('woff2'); }
@font-face { font-family: 'IBM Plex Mono'; font-weight: 600; font-display: swap; src: url('/fonts/ibm-plex-mono-latin-600-normal.woff2') format('woff2'); }

:root {
	color-scheme: light dark;
	--background: #ffffff;
	--layer: #f4f4f4;
	--layer-hover: #e8e8e8;
	--layer-selected: #e0e0e0;
	--border-subtle: #e0e0e0;
	--border-strong: #8d8d8d;
	--text-primary: #161616;
	--text-secondary: #525252;
	--text-placeholder: #6f6f6f;
	--text-on-color: #ffffff;
	--interactive: #0f62fe;
	--button-primary: #0f62fe;
	--button-primary-active: #002d9c;
	--button-secondary: #393939;
	--button-secondary-active: #6f6f6f;
	--button-danger: #da1e28;
	--button-disabled: #c6c6c6;
	--text-on-disabled: #8d8d8d;
	--focus: #0f62fe;
	--support-success: #24a148;
	--support-warning: #f1c21b;
	--support-error: #da1e28;
	--support-info: #0043ce;
	--success-bg: #defbe6;
	--success-text: #0e6027;
	--warning-bg: #fcf4d6;
	--warning-text: #684e00;
	--error-bg: #fff1f1;
	--error-text: #a2191f;
	--blue-tag-bg: #d0e2ff;
	--blue-tag-text: #002d9c;
	--gray-tag-bg: #e0e0e0;
	--gray-tag-text: #161616;
	--tap: 48px;
}

@media (prefers-color-scheme: dark) {
	:root {
		--background: #161616;
		--layer: #262626;
		--layer-hover: #333333;
		--layer-selected: #393939;
		--border-subtle: #393939;
		--border-strong: #6f6f6f;
		--text-primary: #f4f4f4;
		--text-secondary: #c6c6c6;
		--text-placeholder: #a8a8a8;
		--interactive: #78a9ff;
		--button-secondary: #6f6f6f;
		--button-secondary-active: #393939;
		--button-disabled: #525252;
		--focus: #ffffff;
		--support-success: #42be65;
		--support-error: #fa4d56;
		--support-info: #4589ff;
		--success-bg: #044317;
		--success-text: #a7f0ba;
		--warning-bg: #302400;
		--warning-text: #f1c21b;
		--error-bg: #520408;
		--error-text: #ffd7d9;
		--blue-tag-bg: #002d9c;
		--blue-tag-text: #d0e2ff;
		--gray-tag-bg: #525252;
		--gray-tag-text: #f4f4f4;
	}
}

* {
	box-sizing: border-box;
	-webkit-tap-highlight-color: transparent;
}

html,
body {
	margin: 0;
	height: 100%;
}

body {
	background: var(--background);
	color: var(--text-primary);
	font: 400 16px/1.5 'IBM Plex Sans', system-ui, sans-serif;
}

button,
input {
	font: inherit;
	color: inherit;
}

button {
	cursor: pointer;
	border-radius: 0;
}

button:focus-visible,
label:focus-visible {
	outline: 2px solid var(--focus);
	outline-offset: -2px;
}

h1,
h2,
p {
	margin: 0;
}

.icon {
	display: inline-flex;
	flex: none;
}

.code {
	font-family: 'IBM Plex Mono', ui-monospace, monospace;
	font-weight: 600;
	font-size: 14px;
	letter-spacing: 0.16px;
	overflow-wrap: anywhere;
}

#app {
	height: 100dvh;
}

.camera-input {
	position: fixed;
	width: 1px;
	height: 1px;
	opacity: 0;
	pointer-events: none;
}

.screen {
	height: 100%;
	display: flex;
	flex-direction: column;
}

/* UI shell header */
.topbar {
	flex: none;
	display: flex;
	align-items: center;
	min-height: 48px;
	padding-top: env(safe-area-inset-top);
	background: #161616;
	color: #f4f4f4;
	border-bottom: 1px solid #393939;
}

.topbar-title {
	flex: 1;
	min-width: 0;
	padding: 0 16px;
	font-size: 14px;
	font-weight: 600;
	letter-spacing: 0.1px;
}

.icon-button + .topbar-title {
	padding-left: 4px;
}

.topbar-item .code {
	display: block;
	color: #ffffff;
	line-height: 1.3;
}

.topbar-item .name {
	display: block;
	font-size: 12px;
	font-weight: 400;
	line-height: 1.3;
	color: #c6c6c6;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.icon-button {
	flex: none;
	width: 48px;
	height: 48px;
	display: grid;
	place-items: center;
	border: 0;
	background: transparent;
	color: inherit;
}

.icon-button:active {
	background: #393939;
}

.uploads-pill {
	flex: none;
	align-self: stretch;
	display: inline-flex;
	align-items: center;
	gap: 8px;
	min-height: 48px;
	padding: 0 16px;
	border: 0;
	border-left: 1px solid #393939;
	background: transparent;
	color: inherit;
	font-size: 14px;
}

.uploads-pill:active {
	background: #393939;
}

.uploads-pill.problem {
	background: #f1c21b;
	border-left-color: #f1c21b;
	color: #161616;
}

/* Page body and action bar */
.content {
	flex: 1;
	min-height: 0;
	overflow-y: auto;
	padding: 16px;
	display: flex;
	flex-direction: column;
	gap: 16px;
}

.bottom-bar {
	flex: none;
	background: var(--background);
	border-top: 1px solid var(--border-subtle);
	padding-bottom: env(safe-area-inset-bottom);
}

.button {
	display: block;
	width: 100%;
	min-height: 64px;
	padding: 12px 16px;
	border: 0;
	background: var(--button-primary);
	color: var(--text-on-color);
	font-size: 16px;
	text-align: left;
}

.button:active {
	background: var(--button-primary-active);
}

.button:disabled {
	background: var(--button-disabled);
	color: var(--text-on-disabled);
}

.button.secondary {
	background: var(--button-secondary);
	color: var(--text-on-color);
}

.button.secondary:active {
	background: var(--button-secondary-active);
}

.button.danger {
	background: var(--button-danger);
	color: #ffffff;
}

.button.small {
	width: auto;
	min-width: 128px;
	min-height: var(--tap);
	font-size: 14px;
}

/* Search */
.search-bar {
	flex: none;
	background: var(--background);
}

.search-box {
	position: relative;
}

.search-box .icon {
	position: absolute;
	left: 16px;
	top: 18px;
	color: var(--text-secondary);
	pointer-events: none;
}

.search-box input {
	display: block;
	width: 100%;
	height: 56px;
	padding: 0 16px 0 48px;
	border: 0;
	border-bottom: 1px solid var(--border-strong);
	border-radius: 0;
	background: var(--layer);
	font-size: 16px;
	outline: 2px solid transparent;
	outline-offset: -2px;
}

.search-box:has(.search-photo) input {
	padding-right: 56px;
}

.search-photo {
	position: absolute;
	right: 0;
	top: 0;
	width: 56px;
	height: 56px;
	display: grid;
	place-items: center;
	border: 0;
	background: transparent;
	color: var(--text-primary);
}

.search-photo:active {
	background: var(--layer-selected);
}

.search-box input::placeholder {
	color: var(--text-placeholder);
}

.search-box input:focus {
	outline-color: var(--focus);
}

/* Lists */
.result-list,
.unsaved-list {
	list-style: none;
	margin: 0;
	padding: 0;
	display: flex;
	flex-direction: column;
	gap: 1px;
	background: var(--border-subtle);
	border-block: 1px solid var(--border-subtle);
}

.result {
	width: 100%;
	display: flex;
	align-items: center;
	gap: 16px;
	min-height: 80px;
	padding: 8px 16px 8px 8px;
	border: 0;
	background: var(--layer);
	text-align: left;
}

.result:active {
	background: var(--layer-selected);
}

.result-thumb {
	flex: none;
	width: 64px;
	height: 64px;
	display: grid;
	place-items: center;
	background: var(--layer-selected);
	color: var(--text-secondary);
	overflow: hidden;
}

.result-thumb img {
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.result-text {
	flex: 1;
	min-width: 0;
	display: flex;
	flex-direction: column;
	align-items: flex-start;
}

.result-name {
	color: var(--text-secondary);
	font-size: 14px;
	line-height: 1.3;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

/* Photo search */
.your-photo {
	height: 120px;
	background: var(--layer-selected);
}

.your-photo img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: contain;
}

.match {
	display: flex;
	flex-direction: column;
	gap: 8px;
	padding: 8px 16px 16px 8px;
	background: var(--layer);
}

.match-head {
	display: flex;
	align-items: center;
	gap: 16px;
}

.match-name {
	color: var(--text-secondary);
	font-size: 14px;
	line-height: 1.3;
}

.stock-table {
	width: calc(100% - 8px);
	margin-left: 8px;
	border-collapse: collapse;
	table-layout: fixed;
	font-size: 14px;
}

/* Fixed widths line the columns up from one match to the next. */
.stock-table th:first-child {
	width: 32%;
}

.stock-table th.stock-qty {
	width: 20%;
	font-weight: 400;
}

.stock-table th {
	padding: 4px 8px 4px 0;
	color: var(--text-secondary);
	font-size: 12px;
	font-weight: 400;
	text-align: left;
	border-bottom: 1px solid var(--border-subtle);
}

.stock-table td {
	padding: 8px 8px 8px 0;
	border-bottom: 1px solid var(--border-subtle);
	vertical-align: top;
}

.stock-bins {
	font-family: var(--font-mono, 'IBM Plex Mono', monospace);
	overflow-wrap: anywhere;
}

.stock-table .stock-qty {
	padding-right: 0;
	text-align: right;
	font-weight: 600;
	white-space: nowrap;
}

.stock-table td.stock-qty.none {
	color: var(--text-secondary);
	font-weight: 400;
}

.tag {
	display: inline-block;
	margin-top: 4px;
	padding: 2px 8px;
	border-radius: 999px;
	font-size: 12px;
	line-height: 16px;
	letter-spacing: 0.32px;
}

.tag.good {
	background: var(--success-bg);
	color: var(--success-text);
}

.tag.warn {
	background: var(--warning-bg);
	color: var(--warning-text);
}

.section-label {
	color: var(--text-secondary);
	font-size: 12px;
	line-height: 16px;
	letter-spacing: 0.32px;
}

.content > .section-label {
	margin-bottom: -8px;
}

.unsaved .section-label {
	margin-bottom: 8px;
}

.unsaved:empty {
	display: none;
}

.message {
	flex: 1;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 16px;
	padding: 24px;
	color: var(--text-secondary);
	font-size: 14px;
	text-align: center;
}

/* Sign in */
.login-form {
	display: flex;
	flex-direction: column;
	gap: 24px;
	width: 100%;
	margin: auto 0;
}

.login-field {
	display: flex;
	flex-direction: column;
	gap: 8px;
	color: var(--text-secondary);
	font-size: 12px;
	letter-spacing: 0.32px;
}

.login-field input {
	height: 48px;
	padding: 0 16px;
	border: 0;
	border-bottom: 1px solid var(--border-strong);
	border-radius: 0;
	background: var(--layer);
	color: var(--text-primary);
	font-size: 16px;
	letter-spacing: normal;
	outline: 2px solid transparent;
	outline-offset: -2px;
}

.login-field input:focus {
	outline-color: var(--focus);
}

/* Inline notifications */
.notice {
	display: flex;
	gap: 12px;
	align-items: flex-start;
	padding: 12px 16px;
	border-left: 3px solid var(--support-info);
	background: var(--layer);
	font-size: 14px;
	line-height: 1.3;
}

.notice.warn {
	border-left-color: var(--support-warning);
	background: var(--warning-bg);
	color: var(--text-primary);
}

.notice.warn .icon {
	color: var(--warning-text);
}

.notice.bad {
	border-left-color: var(--support-error);
	background: var(--error-bg);
	color: var(--text-primary);
}

.notice.bad .icon {
	color: var(--support-error);
}

/* Capture */
.tile-grid {
	flex: 1 0 auto;
	display: grid;
	grid-template-columns: repeat(2, 1fr);
	grid-auto-rows: minmax(130px, 1fr);
	gap: 1px;
	background: var(--border-subtle);
	border: 1px solid var(--border-subtle);
}

@media (min-width: 700px) {
	.tile-grid {
		grid-template-columns: repeat(3, 1fr);
	}
}

.tile {
	position: relative;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 8px;
	padding: 8px;
	background: var(--background);
	color: var(--text-secondary);
	font-size: 14px;
	text-align: center;
	overflow: hidden;
}

label.tile {
	cursor: pointer;
}

.tile.next {
	background: var(--layer);
	color: var(--interactive);
}

.tile.next:active {
	background: var(--layer-selected);
}

.tile.empty {
	color: var(--text-on-disabled);
}

.tile.filled {
	padding: 0;
	background: var(--layer-selected);
}

.tile.filled img {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.tile-caption {
	position: absolute;
	left: 0;
	right: 0;
	bottom: 0;
	padding: 4px 8px;
	background: rgb(22 22 22 / 0.82);
	color: #ffffff;
	font-size: 12px;
	line-height: 16px;
	letter-spacing: 0.32px;
}

.tile-main {
	position: absolute;
	top: 8px;
	left: 8px;
	padding: 4px 8px;
	border: 0;
	border-radius: 999px;
	background: var(--success-bg);
	color: var(--success-text);
	font-size: 12px;
	line-height: 16px;
	letter-spacing: 0.32px;
}

.tile-star,
.tile-remove {
	position: absolute;
	top: 0;
	width: 48px;
	height: 48px;
	display: grid;
	place-items: center;
	padding: 0;
	border: 0;
	background: transparent;
	color: #ffffff;
}

.tile-star {
	left: 0;
}

.tile-remove {
	right: 0;
}

.tile-star .icon,
.tile-remove .icon {
	padding: 6px;
	background: rgb(22 22 22 / 0.82);
}

/* Photos already on the Item */
.current-photos:empty {
	display: none;
}

.current-photos .section-label {
	margin-bottom: 8px;
}

.current-photos .notice {
	flex-direction: column;
}

.current-strip {
	display: flex;
	gap: 1px;
	overflow-x: auto;
}

.current-photo {
	position: relative;
	flex: none;
	width: 112px;
	height: 112px;
	background: var(--layer-selected);
	overflow: hidden;
}

.current-photo img {
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.current-photo.marked img {
	opacity: 0.25;
}

.current-main {
	position: absolute;
	left: 4px;
	bottom: 4px;
	padding: 0 8px;
	border-radius: 999px;
	background: var(--success-bg);
	color: var(--success-text);
	font-size: 12px;
	line-height: 20px;
}

.current-marked-text {
	position: absolute;
	left: 0;
	right: 0;
	top: 8px;
	color: var(--error-text);
	font-size: 12px;
	font-weight: 600;
	text-align: center;
}

.current-undo {
	position: absolute;
	inset: auto 0 0;
	min-height: 48px;
	border: 0;
	background: var(--button-secondary);
	color: #ffffff;
	font-size: 14px;
}

/* Video links */
.video-links .section-label {
	margin-bottom: 8px;
}

.link-list:not(:empty) {
	margin-bottom: 8px;
	border-top: 1px solid var(--border-subtle);
}

.link-row {
	display: flex;
	align-items: center;
	gap: 8px;
	min-height: 48px;
	padding-left: 12px;
	background: var(--layer);
	border-bottom: 1px solid var(--border-subtle);
}

.link-row .tag {
	margin: 0 12px 0 0;
}

.link-url {
	flex: 1;
	min-width: 0;
	font-size: 14px;
	line-height: 1.3;
	color: var(--text-secondary);
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.link-entry {
	display: flex;
}

.link-entry input {
	flex: 1;
	min-width: 0;
	height: 48px;
	padding: 0 16px;
	border: 0;
	border-bottom: 1px solid var(--border-strong);
	border-radius: 0;
	background: var(--layer);
	font-size: 16px;
	outline: 2px solid transparent;
	outline-offset: -2px;
}

.link-entry input::placeholder {
	color: var(--text-placeholder);
}

.link-entry input:focus {
	outline-color: var(--focus);
}

.button.link-add {
	flex: none;
	width: auto;
	min-width: 80px;
	min-height: 48px;
	font-size: 14px;
}

.link-error {
	margin-top: 8px;
	color: var(--support-error);
	font-size: 12px;
	line-height: 16px;
}

/* Uploads */
.upload-main {
	margin: 0 0 0 8px;
	vertical-align: 1px;
}

.upload-group {
	display: flex;
	flex-direction: column;
	background: var(--layer);
	border-top: 1px solid var(--border-subtle);
}

.upload-group-head {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: 16px;
	padding: 12px 16px;
	border-bottom: 1px solid var(--border-subtle);
}

.upload-group-name {
	color: var(--text-secondary);
	font-size: 12px;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.upload-row {
	display: flex;
	gap: 16px;
	padding: 12px 16px;
}

.upload-row + .upload-row {
	border-top: 1px solid var(--border-subtle);
}

.upload-thumb {
	flex: none;
	width: 48px;
	height: 48px;
	display: grid;
	place-items: center;
	background: var(--layer-selected);
	color: var(--text-secondary);
	overflow: hidden;
}

.upload-thumb img {
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.upload-body {
	flex: 1;
	min-width: 0;
	display: flex;
	flex-direction: column;
	gap: 8px;
}

.upload-title {
	font-size: 14px;
	font-weight: 600;
	line-height: 1.3;
}

.upload-size {
	color: var(--text-secondary);
	font-weight: 400;
}

.steps {
	display: flex;
	flex-wrap: wrap;
	gap: 4px;
	margin: 0;
	padding: 0;
	list-style: none;
}

.step {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	padding: 2px 8px 2px 6px;
	border-radius: 999px;
	background: var(--gray-tag-bg);
	color: var(--gray-tag-text);
	font-size: 12px;
	line-height: 16px;
	letter-spacing: 0.32px;
}

.step.done {
	background: var(--success-bg);
	color: var(--success-text);
}

.step.active {
	background: var(--blue-tag-bg);
	color: var(--blue-tag-text);
}

.step.stopped {
	background: var(--error-bg);
	color: var(--error-text);
}

.step-dot {
	width: 8px;
	height: 8px;
	margin: 0 3px;
	border-radius: 999px;
	background: currentColor;
	opacity: 0.45;
}

.step.active .step-dot {
	opacity: 1;
	animation: pulse 1s ease-in-out infinite;
}

@keyframes pulse {
	50% {
		opacity: 0.25;
	}
}

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

.progress {
	height: 8px;
	background: var(--layer-selected);
	overflow: hidden;
}

.progress span {
	display: block;
	height: 100%;
	background: var(--interactive);
	transition: width 110ms cubic-bezier(0.2, 0, 0.38, 0.9);
}

.upload-status {
	color: var(--text-secondary);
	font-size: 12px;
	line-height: 16px;
	letter-spacing: 0.32px;
}

.upload-status.bad {
	color: var(--support-error);
}

.upload-status.warn {
	color: var(--warning-text);
}

/* Modal and toast */
.sheet {
	width: 100%;
	max-width: none;
	margin: auto 0 0;
	padding: 0;
	padding-bottom: env(safe-area-inset-bottom);
	border: 0;
	background: var(--layer);
	color: var(--text-primary);
}

.sheet::backdrop {
	background: rgb(22 22 22 / 0.5);
}

.sheet-message {
	padding: 16px;
	font-size: 16px;
}

.sheet .button + .button {
	margin-top: 1px;
}

.toast {
	position: fixed;
	left: 16px;
	right: 16px;
	bottom: calc(80px + env(safe-area-inset-bottom));
	padding: 12px 16px;
	border-left: 3px solid #42be65;
	background: #393939;
	color: #f4f4f4;
	font-size: 14px;
	line-height: 1.3;
	opacity: 0;
	pointer-events: none;
	transition: opacity 110ms cubic-bezier(0.2, 0, 0.38, 0.9);
}

.toast.show {
	opacity: 1;
}
