:root {
	--bg: #f1f3ef;
	--bg-strong: #e8ece4;
	--surface: #f8faf6;
	--surface-strong: #ffffff;
	--text: #17221c;
	--muted: #5e6b62;
	--line: #ccd4cb;
	--primary: #254f3d;
	--primary-strong: #163326;
	--warn: #99552c;
	--radius: 14px;
	--shadow: 0 12px 30px rgba(31, 45, 37, 0.08);
}

* {
	box-sizing: border-box;
}

body {
	margin: 0;
	font-family: "IBM Plex Sans", "Helvetica Neue", sans-serif;
	color: var(--text);
	background:
		radial-gradient(circle at 20% 0%, rgba(255, 255, 255, 0.7) 0%, transparent 45%),
		linear-gradient(160deg, var(--bg) 0%, var(--bg-strong) 100%);
	min-height: 100vh;
}

.page-shell {
	max-width: 1050px;
	margin: 0 auto;
	padding: 8px 16px 26px;
	animation: fade-in 280ms ease-out;
}

.app-header {
	position: sticky;
	top: 6px;
	z-index: 30;
	padding: 8px 10px;
	border: 1px solid var(--line);
	border-radius: var(--radius);
	background: color-mix(in hsl, var(--surface-strong) 85%, transparent);
	backdrop-filter: blur(8px);
	box-shadow: var(--shadow);
}

.header-top {
	display: grid;
	grid-template-columns: 1fr auto 1fr;
	align-items: center;
	gap: 10px;
	min-height: 34px;
}

.brand-mark {
	display: inline-flex;
	align-items: center;
	gap: 10px;
	justify-self: start;
	font-family: "Space Grotesk", "IBM Plex Sans", sans-serif;
	font-weight: 700;
	letter-spacing: 0.03em;
}

.brand-dot {
	width: 12px;
	height: 12px;
	border-radius: 999px;
	background: linear-gradient(140deg, #2f7056, #183b2c);
	box-shadow: 0 0 0 4px rgba(47, 112, 86, 0.18);
}

.state-title {
	font-size: 11px;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	color: var(--muted);
}

.state-badge {
	font-size: 12px;
	text-transform: uppercase;
	letter-spacing: 0.06em;
	padding: 5px 8px;
	border-radius: 999px;
	background: #e0e8e0;
	color: #2f493d;
}

.header-tools {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	justify-self: end;
}

.header-actions {
	margin-top: 0;
	display: flex;
	justify-content: center;
	gap: 8px;
	flex-wrap: wrap;
	justify-self: center;
}

.icon-btn {
	border: 1px solid var(--line);
	background: #e8ece8;
	color: var(--text);
	border-radius: 10px;
	padding: 8px 10px;
	font-size: 16px;
	cursor: pointer;
	line-height: 1;
}

.icon-btn:hover {
	background: #dde4dc;
}

.settings-panel {
	margin-top: 10px;
	padding: 10px;
	border: 1px solid var(--line);
	border-radius: 12px;
	background: var(--surface);
}

.settings-grid {
	display: grid;
	grid-template-columns: repeat(2, minmax(160px, 1fr));
	gap: 10px;
}

.field-row {
	display: grid;
	gap: 6px;
	font-size: 13px;
	color: var(--muted);
}

.field-row span {
	font-size: 12px;
	letter-spacing: 0.04em;
	text-transform: uppercase;
}

select,
input[type="search"],
button {
	font: inherit;
}

select,
input[type="search"] {
	min-height: 36px;
	padding: 8px 11px;
	border: 1px solid var(--line);
	border-radius: 10px;
	background: var(--surface-strong);
	color: var(--text);
}

.view {
	margin-top: 14px;
}

.hidden {
	display: none;
}

.hero-card,
.action-panel,
.history-header,
.history-list,
.history-detail {
	border: 1px solid var(--line);
	border-radius: var(--radius);
	background: var(--surface);
	box-shadow: var(--shadow);
}

.hero-card {
	padding: 20px;
}

.hero-label {
	margin: 0;
	font-size: 12px;
	text-transform: uppercase;
	letter-spacing: 0.08em;
	color: var(--muted);
}

.active-email {
	margin: 8px 0 0;
	font-size: clamp(24px, 3vw, 38px);
	line-height: 1.12;
	letter-spacing: -0.02em;
	font-family: "Space Grotesk", "IBM Plex Sans", sans-serif;
	word-break: break-word;
}

.mail-state-wrap {
	margin-top: 10px;
	display: inline-grid;
	gap: 3px;
}

.copy-status {
	margin: 12px 0 0;
	font-size: 13px;
	color: var(--muted);
	min-height: 20px;
}

.action-panel {
	margin-top: 14px;
	padding: 18px;
}

.action-panel h2 {
	margin: 0 0 10px;
	font-size: 18px;
}

.inbox-split {
	display: grid;
	grid-template-columns: 320px 1fr;
	gap: 12px;
	min-height: 400px;
}

@media (max-width: 768px) {
	.inbox-split {
		grid-template-columns: 1fr;
	}
	.inbox-detail-pane {
		display: none;
	}
	.inbox-list-pane.has-selection + .inbox-detail-pane {
		display: block;
	}
	.inbox-list-pane.has-selection {
		display: none;
	}
}

.inbox-list-pane {
	border: 1px solid var(--line);
	border-radius: 12px;
	background: var(--surface-strong);
	overflow: hidden;
}

.inbox-list {
	height: 100%;
	overflow-y: auto;
}

.inbox-item {
	padding: 12px 14px;
	border-bottom: 1px solid var(--line);
	cursor: pointer;
	transition: background 150ms ease;
}

.inbox-item:last-child {
	border-bottom: none;
}

.inbox-item:hover {
	background: var(--bg);
}

.inbox-item.selected {
	background: var(--bg-strong);
	border-left: 3px solid var(--primary);
}

.inbox-item-header {
	display: flex;
	justify-content: space-between;
	align-items: baseline;
	gap: 8px;
	margin-bottom: 4px;
}

.inbox-item-from {
	font-weight: 600;
	font-size: 14px;
	flex: 1;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.inbox-item-time {
	font-size: 11px;
	color: var(--muted);
	flex-shrink: 0;
}

.inbox-item-subject {
	font-size: 13px;
	color: var(--text);
	margin-bottom: 2px;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.inbox-item-preview {
	font-size: 12px;
	color: var(--muted);
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.inbox-detail-pane {
	border: 1px solid var(--line);
	border-radius: 12px;
	background: var(--surface-strong);
	overflow: hidden;
}

.inbox-detail {
	height: 100%;
	padding: 14px;
	overflow-y: auto;
}

.inbox-detail .waiting-text {
	display: flex;
	align-items: center;
	justify-content: center;
	height: 100%;
	color: var(--muted);
}

.inbox-content {
	padding: 14px;
	border: 1px dashed var(--line);
	border-radius: 12px;
	min-height: 130px;
	background: var(--surface-strong);
	animation: lift-in 210ms ease-out;
}

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

.otp-box {
	display: inline-flex;
	align-items: center;
	gap: 10px;
	margin-top: 10px;
	padding: 10px 12px;
	border-radius: 10px;
	border: 1px solid #dbc9b4;
	background: #fdf5ec;
}

.otp-code {
	font-weight: 700;
	font-size: 28px;
	letter-spacing: 0.14em;
	font-family: "Space Grotesk", "IBM Plex Sans", sans-serif;
}

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

.raw-fallback {
	margin-top: 10px;
	padding: 10px;
	border-radius: 10px;
	background: #f0f5f1;
	border: 1px solid #d5ddd4;
	font-size: 13px;
	line-height: 1.5;
	max-height: 120px;
	overflow: auto;
}

.btn-primary,
.btn-quiet,
.btn-inline {
	border: 0;
	border-radius: 10px;
	padding: 8px 12px;
	cursor: pointer;
	font-weight: 600;
	transition:
		transform 120ms ease,
		background-color 120ms ease;
}

.btn-primary,
.btn-inline {
	background: var(--primary);
	color: #f4fbf6;
}

.btn-primary:hover,
.btn-inline:hover {
	background: var(--primary-strong);
	transform: translateY(-1px);
}

.btn-quiet {
	background: #e8ece8;
	color: var(--text);
}

.btn-quiet:hover {
	background: #dde4dc;
}

.warning-inline {
	color: var(--warn);
	font-size: 13px;
}

.btn-link {
	text-decoration: none;
	color: #f4fbf6;
}

.btn-link:visited {
	color: #f4fbf6;
}

.raw-content-details {
	margin-top: 16px;
	border: 1px solid var(--line);
	border-radius: 10px;
	background: var(--surface);
}

.raw-content-summary {
	padding: 12px 16px;
	cursor: pointer;
	font-weight: 500;
	color: var(--primary);
	user-select: none;
	list-style: none;
}

.raw-content-summary:hover {
	background: var(--bg);
}

.raw-content-summary::marker {
	display: none;
}

.raw-content-summary::-webkit-details-marker {
	display: none;
}

.raw-content-pre {
	margin: 0;
	padding: 16px;
	border-top: 1px solid var(--line);
	background: #f8f9fa;
	font-family: "Courier New", monospace;
	font-size: 13px;
	line-height: 1.6;
	white-space: pre-wrap;
	word-break: break-word;
	overflow-x: auto;
	max-height: 500px;
	overflow-y: auto;
}

.history-header {
	padding: 16px;
	display: grid;
	gap: 10px;
}

.history-header h2 {
	margin: 0;
}

.history-detail-header {
	display: flex;
	justify-content: space-between;
	align-items: flex-start;
	gap: 16px;
	margin-bottom: 12px;
}

.history-detail-header h3 {
	flex: 1;
	margin: 0;
}

.history-detail-header button {
	flex-shrink: 0;
}

.history-filters {
	display: grid;
	grid-template-columns: minmax(260px, 1fr) repeat(3, minmax(140px, 190px));
	gap: 10px;
	align-items: end;
}

.history-cleanup-btn {
	min-height: 36px;
}

.check-row {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	min-height: 36px;
	padding: 0 10px;
	border: 1px solid var(--line);
	border-radius: 10px;
	background: var(--surface-strong);
	font-size: 13px;
	color: var(--muted);
}

.check-row input {
	margin: 0;
}

.history-grid {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 12px;
	margin-top: 10px;
}

.history-list,
.history-detail {
	padding: 10px;
	min-height: 320px;
	max-height: 65vh;
	overflow: auto;
}

.history-item {
	width: 100%;
	text-align: left;
	margin-bottom: 8px;
	padding: 10px;
	border: 1px solid var(--line);
	border-radius: 10px;
	background: var(--surface-strong);
	cursor: pointer;
}

.history-item:hover {
	border-color: #9db2a3;
}

.history-meta {
	margin-top: 4px;
	font-size: 12px;
	color: var(--muted);
	line-height: 1.4;
}

.history-tags {
	display: flex;
	flex-wrap: wrap;
	gap: 5px;
	margin-top: 8px;
}

.history-tag {
	font-size: 11px;
	padding: 3px 8px;
	border-radius: 999px;
	background: #e7eee8;
	color: #2f493d;
}

@keyframes fade-in {
	from {
		opacity: 0;
		transform: translateY(4px);
	}
	to {
		opacity: 1;
		transform: translateY(0);
	}
}

@keyframes lift-in {
	from {
		opacity: 0;
		transform: translateY(4px);
	}
	to {
		opacity: 1;
		transform: translateY(0);
	}
}

@media (max-width: 920px) {
	.header-top {
		grid-template-columns: 1fr;
		justify-items: center;
		gap: 8px;
	}

	.brand-mark {
		justify-self: center;
	}

	.header-tools {
		justify-self: center;
		justify-content: center;
	}

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

	.history-filters {
		grid-template-columns: 1fr;
	}

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

@media (max-width: 620px) {
	.page-shell {
		padding: 8px 12px 22px;
	}

	.app-header {
		top: 6px;
	}
}

/* Floating Logs Button */
.logs-floating-btn {
	position: fixed;
	bottom: 24px;
	right: 24px;
	width: 56px;
	height: 56px;
	border: none;
	border-radius: 50%;
	background: var(--primary);
	color: white;
	cursor: pointer;
	box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
	transition: all 0.2s ease;
	z-index: 100;
	display: flex;
	align-items: center;
	justify-content: center;
}

.logs-floating-btn:hover {
	background: var(--primary-strong);
	box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
	transform: translateY(-2px);
}

.logs-floating-btn:active {
	transform: translateY(0);
}

/* Sessions Modal */
.sessions-modal {
	position: fixed;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	background: rgba(0, 0, 0, 0.5);
	z-index: 200;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 16px;
	animation: fade-in 200ms ease-out;
}

.sessions-modal.hidden {
	display: none;
}

.sessions-modal-content {
	background: var(--surface-strong);
	border-radius: var(--radius);
	box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
	width: 100%;
	max-width: 700px;
	max-height: 80vh;
	display: flex;
	flex-direction: column;
}

.sessions-modal-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 20px 24px;
	border-bottom: 1px solid var(--line);
}

.sessions-modal-header h2 {
	margin: 0;
	font-size: 1.25rem;
	font-weight: 600;
}

.sessions-modal-body {
	flex: 1;
	overflow-y: auto;
	padding: 16px 24px;
}

.sessions-content {
	display: flex;
	flex-direction: column;
	gap: 12px;
}

.session-item {
	padding: 16px;
	border: 1px solid var(--line);
	border-radius: 10px;
	background: var(--surface);
	transition: all 0.2s ease;
}

.session-item:hover {
	border-color: var(--primary);
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.session-active {
	background: color-mix(in hsl, var(--primary) 5%, var(--surface));
	border-color: var(--primary);
}

.session-email {
	display: flex;
	align-items: center;
	gap: 8px;
	margin-bottom: 8px;
}

.session-email strong {
	font-size: 1.05rem;
	color: var(--text);
}

.session-badge {
	display: inline-block;
	padding: 2px 8px;
	border-radius: 4px;
	background: var(--primary);
	color: white;
	font-size: 0.75rem;
	font-weight: 600;
}

.session-meta {
	display: flex;
	gap: 16px;
	font-size: 0.875rem;
	color: var(--muted);
	margin-bottom: 4px;
}

.btn-switch {
	margin-top: 12px;
}

/* Logs Modal */
.logs-modal {
	position: fixed;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	background: rgba(0, 0, 0, 0.5);
	z-index: 200;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 16px;
	animation: fade-in 200ms ease-out;
}

.logs-modal.hidden {
	display: none;
}

.logs-modal-content {
	background: var(--surface-strong);
	border-radius: var(--radius);
	box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
	width: 100%;
	max-width: 900px;
	max-height: 80vh;
	display: flex;
	flex-direction: column;
}

.logs-modal-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 20px 24px;
	border-bottom: 1px solid var(--line);
}

.logs-modal-header h2 {
	margin: 0;
	font-size: 1.25rem;
	font-weight: 600;
}

.logs-modal-body {
	flex: 1;
	overflow: hidden;
	display: flex;
	flex-direction: column;
}

.logs-controls {
	display: flex;
	gap: 12px;
	padding: 16px 24px;
	border-bottom: 1px solid var(--line);
	align-items: center;
	flex-wrap: wrap;
}

.logs-content {
	flex: 1;
	overflow-y: auto;
	padding: 16px 24px;
	font-family: "Courier New", monospace;
	font-size: 0.875rem;
	line-height: 1.6;
}

.log-entry {
	padding: 8px 12px;
	margin-bottom: 4px;
	border-radius: 6px;
	background: var(--surface);
	border-left: 3px solid var(--line);
}

.log-entry.log-info {
	border-left-color: #3b82f6;
	background: color-mix(in hsl, #3b82f6 5%, var(--surface));
}

.log-entry.log-success {
	border-left-color: #10b981;
	background: color-mix(in hsl, #10b981 5%, var(--surface));
}

.log-entry.log-warn {
	border-left-color: #f59e0b;
	background: color-mix(in hsl, #f59e0b 5%, var(--surface));
}

.log-entry.log-error {
	border-left-color: #ef4444;
	background: color-mix(in hsl, #ef4444 5%, var(--surface));
}

.log-timestamp {
	color: var(--muted);
	font-size: 0.8125rem;
	margin-right: 8px;
}

.log-message {
	color: var(--text);
	word-break: break-word;
}

/* Custom Email Button */
.btn-icon-quiet {
	padding: 8px 14px;
	background: none;
	border: 1px solid var(--line);
	border-radius: 8px;
	font-size: 1.25rem;
	font-weight: 600;
	color: var(--text);
	cursor: pointer;
	transition: all 0.2s ease;
	line-height: 1;
}

.btn-icon-quiet:hover {
	background: var(--surface-hover);
	border-color: var(--primary);
	color: var(--primary);
	transform: scale(1.05);
}

.btn-icon-quiet:active {
	transform: scale(0.98);
}

/* Custom Email Modal */
.custom-email-modal {
	position: fixed;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	background: rgba(0, 0, 0, 0.5);
	z-index: 200;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 16px;
	animation: fade-in 200ms ease-out;
}

.custom-email-modal.hidden {
	display: none;
}

.custom-email-modal-content {
	background: var(--surface-strong);
	border-radius: var(--radius);
	box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
	width: 100%;
	max-width: 500px;
	display: flex;
	flex-direction: column;
}

.custom-email-modal-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 20px 24px;
	border-bottom: 1px solid var(--line);
}

.custom-email-modal-header h2 {
	margin: 0;
	font-size: 1.25rem;
	font-weight: 600;
}

.custom-email-modal-body {
	padding: 24px;
}

.custom-email-form {
	display: flex;
	flex-direction: column;
	gap: 20px;
}

.custom-email-form input[type="text"] {
	width: 100%;
	padding: 10px 14px;
	border: 1px solid var(--line);
	border-radius: 8px;
	background: var(--surface);
	color: var(--text);
	font-size: 1rem;
	transition: all 0.2s ease;
}

.custom-email-form input[type="text"]:focus {
	outline: none;
	border-color: var(--primary);
	box-shadow: 0 0 0 3px color-mix(in hsl, var(--primary) 15%, transparent);
}

.custom-email-form input[type="text"]::placeholder {
	color: var(--muted);
}

.custom-email-form select {
	width: 100%;
	padding: 10px 14px;
	border: 1px solid var(--line);
	border-radius: 8px;
	background: var(--surface);
	color: var(--text);
	font-size: 1rem;
	cursor: pointer;
	transition: all 0.2s ease;
}

.custom-email-form select:focus {
	outline: none;
	border-color: var(--primary);
	box-shadow: 0 0 0 3px color-mix(in hsl, var(--primary) 15%, transparent);
}

.custom-email-preview {
	padding: 16px;
	background: var(--surface);
	border: 1px solid var(--line);
	border-radius: 8px;
	display: flex;
	align-items: center;
	gap: 8px;
	font-size: 0.9375rem;
}

.custom-email-preview strong {
	color: var(--muted);
	font-weight: 500;
}

.email-preview {
	color: var(--primary);
	font-family: "Courier New", monospace;
	font-weight: 600;
	word-break: break-all;
}

.custom-email-actions {
	display: flex;
	gap: 12px;
	justify-content: flex-end;
	margin-top: 4px;
}
