:root {
	--bg: #f7f7f5;
	--surface: #ffffff;
	--surface-2: #f1efeb;
	--border: #e5e2dd;
	--text: #232321;
	--muted: #77736c;
	--blue: #2783de;
	--blue-soft: #e8f2fc;
	--green: #2f8f62;
	--green-soft: #e8f5ef;
	--orange: #cf7a32;
	--orange-soft: #fbeee0;
	--red: #d8564b;
	--red-soft: #fde9e7;
	--shadow: 0 1px 2px rgba(0, 0, 0, 0.05), 0 6px 24px rgba(0, 0, 0, 0.04);
	--radius: 12px;
}

* {
	box-sizing: border-box;
}

html, body {
	margin: 0;
	padding: 0;
	background: var(--bg);
	color: var(--text);
	font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
}

body {
	font-size: 16px;
	line-height: 1.5;
}

button, input, select, textarea {
	font: inherit;
}

h1, h2, h3, p {
	margin: 0;
}

.hidden {
	display: none !important;
}

.small {
	font-size: 13px;
}

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

.app-shell {
	max-width: 1280px;
	margin: 0 auto;
	padding: 24px;
}

.topbar {
	display: flex;
	justify-content: space-between;
	align-items: center;
	gap: 16px;
	margin-bottom: 24px;
}

.brand {
	display: flex;
	align-items: center;
	gap: 12px;
}

.brand-mark {
	width: 44px;
	height: 44px;
	border-radius: 14px;
	background: linear-gradient(135deg, #5b9ee7, #2783de);
	color: white;
	display: grid;
	place-items: center;
	font-weight: 700;
	letter-spacing: 0.02em;
}

.brand-title {
	font-size: 20px;
	font-weight: 700;
}

.brand-subtitle {
	font-size: 13px;
	color: var(--muted);
}

.top-actions {
	display: flex;
	gap: 10px;
	flex-wrap: wrap;
}

.layout {
	display: grid;
	grid-template-columns: 260px 1fr;
	gap: 24px;
	align-items: start;
}

.card {
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	box-shadow: var(--shadow);
}

.sidebar,
.upload-card,
.empty-state {
	padding: 18px;
}

.section-head {
	display: flex;
	justify-content: space-between;
	align-items: start;
	gap: 12px;
	margin-bottom: 14px;
}

.section-head h2,
.toolbar h2,
.modal h2 {
	font-size: 18px;
	font-weight: 700;
}

.section-head p {
	margin-top: 6px;
	color: var(--muted);
	font-size: 14px;
}

.subject-form,
.upload-controls,
.helper-row,
.modal-actions,
.modal-head,
.card-actions,
.card-meta {
	display: flex;
	gap: 10px;
}

.subject-form,
.upload-controls,
.helper-row,
.modal-actions {
	margin-bottom: 12px;
	flex-wrap: wrap;
}

.subject-form input,
.upload-controls input,
.upload-controls select,
.modal input,
.modal select,
textarea {
	border: 1px solid var(--border);
	background: var(--surface);
	border-radius: 10px;
	padding: 11px 12px;
	color: var(--text);
	min-height: 44px;
}

.subject-form input,
.upload-controls input,
textarea {
	flex: 1;
	min-width: 0;
}

.upload-controls select {
	min-width: 220px;
}

.btn {
	border: 1px solid var(--border);
	background: var(--surface);
	color: var(--text);
	padding: 10px 14px;
	border-radius: 10px;
	cursor: pointer;
	font-weight: 600;
	min-height: 44px;
}

.btn:hover {
	background: var(--surface-2);
}

.btn-primary {
	background: var(--blue);
	border-color: var(--blue);
	color: white;
}

.btn-primary:hover {
	background: #1c70c3;
}

.btn-secondary {
	background: transparent;
}

.dropzone {
	display: grid;
	place-items: center;
	text-align: center;
	padding: 28px 18px;
	border: 1.5px dashed #cfd7df;
	background: #fbfcfe;
	border-radius: 14px;
	cursor: pointer;
	transition: 0.15s ease;
}

.dropzone.dragover {
	background: var(--blue-soft);
	border-color: var(--blue);
}

.dropzone-title {
	font-weight: 700;
	margin-bottom: 4px;
}

.dropzone-sub {
	font-size: 14px;
	color: var(--muted);
}

.toolbar {
	display: flex;
	justify-content: space-between;
	gap: 16px;
	align-items: center;
	margin: 20px 0 16px;
	flex-wrap: wrap;
}

.status-filter {
	display: flex;
	gap: 8px;
	flex-wrap: wrap;
}

.chip {
	border: 1px solid var(--border);
	background: var(--surface);
	color: var(--muted);
	padding: 8px 12px;
	border-radius: 999px;
	cursor: pointer;
	font-size: 13px;
	font-weight: 600;
}

.chip.active {
	background: var(--blue-soft);
	border-color: #c9def4;
	color: #14508d;
}

.subject-list {
	display: flex;
	flex-direction: column;
	gap: 6px;
}

.subject-item {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
	padding: 10px 12px;
	border-radius: 10px;
	cursor: pointer;
}

.subject-item:hover {
	background: var(--surface-2);
}

.subject-item.active {
	background: var(--blue-soft);
}

.subject-main {
	display: flex;
	align-items: center;
	gap: 8px;
	min-width: 0;
	flex: 1;
}

.subject-name {
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	font-weight: 600;
}

.subject-count,
.badge {
	padding: 3px 9px;
	border-radius: 999px;
	font-size: 12px;
	font-weight: 700;
	background: var(--surface-2);
	color: var(--muted);
}

.subject-delete {
	border: none;
	background: transparent;
	color: var(--muted);
	cursor: pointer;
	font-size: 16px;
	padding: 0 4px;
}

.homework-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
	gap: 16px;
}

.homework-card {
	overflow: hidden;
}

.preview {
	width: 100%;
	height: 180px;
	object-fit: cover;
	background: var(--surface-2);
	display: block;
}

.card-body {
	padding: 16px;
}

.card-meta {
	justify-content: space-between;
	align-items: center;
	margin-bottom: 12px;
	flex-wrap: wrap;
}

.status {
	padding: 4px 10px;
	border-radius: 999px;
	font-size: 12px;
	font-weight: 700;
}

.status-ocr { background: var(--orange-soft); color: var(--orange); }
.status-ready { background: var(--surface-2); color: var(--muted); }
.status-solving { background: var(--blue-soft); color: #14508d; }
.status-done { background: var(--green-soft); color: var(--green); }
.status-error { background: var(--red-soft); color: var(--red); }

textarea {
	width: 100%;
	min-height: 90px;
	resize: vertical;
	margin-bottom: 10px;
}

.card-actions {
	margin-bottom: 12px;
}

.card-actions .btn {
	flex: 1;
}

.answer-box,
.error-box,
.note-box {
	border-radius: 10px;
	padding: 12px;
	font-size: 14px;
	white-space: pre-wrap;
}

.answer-box {
	background: #faf9f7;
	border: 1px solid var(--border);
	max-height: 280px;
	overflow: auto;
}

.error-box {
	background: var(--red-soft);
	color: var(--red);
}

.note-box {
	background: var(--surface-2);
	color: var(--muted);
}

.empty-state {
	text-align: center;
	color: var(--muted);
}

.modal-backdrop {
	position: fixed;
	inset: 0;
	background: rgba(0, 0, 0, 0.35);
	display: grid;
	place-items: center;
	padding: 16px;
}

.modal {
	width: min(460px, 100%);
	padding: 18px;
}

.modal-head {
	justify-content: space-between;
	align-items: center;
	margin-bottom: 12px;
}

.field-label {
	display: block;
	margin: 10px 0 6px;
	font-size: 14px;
	font-weight: 700;
}

.toast {
	position: fixed;
	left: 50%;
	bottom: 20px;
	transform: translateX(-50%);
	background: #232321;
	color: white;
	padding: 10px 14px;
	border-radius: 10px;
	box-shadow: var(--shadow);
	z-index: 100;
	max-width: calc(100vw - 24px);
}

@media (max-width: 920px) {
	.layout {
		grid-template-columns: 1fr;
	}

	.sidebar {
		order: 2;
	}
}

@media (max-width: 640px) {
	.app-shell {
		padding: 16px;
	}

	.topbar {
		flex-direction: column;
		align-items: stretch;
	}

	.top-actions {
		width: 100%;
	}

	.top-actions .btn,
	.modal-actions .btn,
	.helper-row .btn {
		flex: 1;
	}

	.upload-controls select {
		min-width: 0;
		width: 100%;
	}

	.homework-grid {
		grid-template-columns: 1fr;
	}
}
