*, *::before, *::after {
	box-sizing: border-box;
	margin: 0;
	padding: 0;
}

.icon {
	display: inline-block;
	vertical-align: -3px;
	flex-shrink: 0;
}

:root {
	color-scheme: light dark;
	--bg: light-dark(#f8f8ff, #1e2a2a);
	--bg2: light-dark(#eeeef5, #243030);
	--surface: light-dark(#fff, #2a3838);
	--border: light-dark(#d0d0dd, #3a4a4a);
	--text: light-dark(#2f4f4f, #e8f0f0);
	--text-muted: light-dark(#527070, #96b0b0);
	--accent: light-dark(#3b82f6, #60a5fa);
	--accent-hover: light-dark(#2563eb, #3b82f6);
	--dot: #3b82f6;
	font-family: ui-monospace, 'Cascadia Code', 'Fira Code', monospace;
	font-size: 13px;
}

html, body {
	height: 100%;
	background: var(--bg);
	color: var(--text);
}

#app {
	height: 100dvh;
	display: flex;
	flex-direction: column;
}

/* ── App shell ── */
.app {
	display: grid;
	grid-template-rows: 40px auto 1fr;
	height: 100dvh;
	overflow: hidden;
}

.hash-error-bar {
	display: flex;
	align-items: center;
	gap: 6px;
	padding: 6px 12px;
	background: #c0392b;
	color: #fff;
	font-size: 12px;
}

.hash-error-close {
	margin-left: auto;
	background: none;
	border: none;
	color: inherit;
	cursor: pointer;
	padding: 0 2px;
	display: flex;
}

/* ── Topbar ── */
.topbar {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 0 12px;
	border-bottom: 1px solid var(--border);
	background: var(--surface);
	gap: 8px;
}

.logo {
	display: flex;
	align-items: center;
	gap: 6px;
	text-decoration: none;
	color: var(--text);
	font-weight: 600;
	font-size: 14px;
}

.logo-dot {
	width: 8px;
	height: 8px;
	border-radius: 50%;
	background: var(--dot);
}

.topbar-actions {
	display: flex;
	align-items: center;
	gap: 6px;
}

/* ── Buttons ── */
.btn {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	padding: 4px 10px;
	border-radius: 5px;
	border: 1px solid var(--border);
	background: var(--bg2);
	color: var(--text);
	font-size: 12px;
	cursor: pointer;
	font-family: inherit;
	transition: background 0.1s;
}

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

.btn-primary {
	background: var(--accent);
	border-color: var(--accent);
	color: #fff;
}

.btn-primary:hover {
	background: var(--accent-hover);
	border-color: var(--accent-hover);
}

.btn-icon {
	padding: 4px 6px;
}

/* ── Main layout ── */
.main {
	grid-row: 3;
	display: grid;
	grid-template-columns: 200px 1fr;
	overflow: hidden;
}

/* When collapsed, keep a 28px strip visible so the expand button is reachable */
.main.sidebar-collapsed {
	grid-template-columns: 28px 1fr;
}

/* ── Sidebar ── */
.sidebar {
	display: flex;
	flex-direction: column;
	border-right: 1px solid var(--border);
	background: var(--bg2);
	overflow: hidden;
	min-width: 0;
}

.sidebar.collapsed .file-list,
.sidebar.collapsed .add-file,
.sidebar.collapsed .starter-row {
	display: none;
}

.sidebar.collapsed .sidebar-header {
	justify-content: center;
	padding: 6px 4px;
}

.sidebar.collapsed .sidebar-title {
	display: none;
}

.sidebar-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 6px 10px;
	font-size: 11px;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.05em;
	color: var(--text-muted);
	border-bottom: 1px solid var(--border);
}

.starter-row {
	display: flex;
	align-items: center;
	gap: 6px;
	padding: 6px 10px;
	border-bottom: 1px solid var(--border);
}

.starter-label {
	font-size: 11px;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.05em;
	color: var(--text-muted);
}

.starter-select {
	flex: 1;
	min-width: 0;
	background: var(--bg);
	border: 1px solid var(--border);
	color: inherit;
	font-family: inherit;
	font-size: 12px;
	padding: 3px 4px;
	border-radius: 4px;
	cursor: pointer;
}

.starter-select:hover {
	border-color: var(--accent);
}

.file-list {
	list-style: none;
	overflow-y: auto;
	flex: 1;
}

.file-item {
	display: flex;
	align-items: center;
	gap: 6px;
	padding: 5px 10px;
	cursor: pointer;
	user-select: none;
	font-size: 12px;
	border-left: 2px solid transparent;
}

.file-item:hover {
	background: var(--border);
}

.file-item.active {
	background: var(--surface);
	border-left-color: var(--accent);
	color: var(--accent);
}

.file-item-name {
	flex: 1;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.file-item-action {
	opacity: 0;
	background: none;
	border: none;
	color: var(--text-muted);
	cursor: pointer;
	padding: 0 2px;
	font-size: 12px;
}

.file-item:hover .file-item-action {
	opacity: 1;
}

.add-file {
	padding: 6px 10px;
	border-top: 1px solid var(--border);
	display: flex;
	gap: 4px;
}

.add-file-btn {
	background: none;
	border: 1px dashed var(--border);
	color: var(--text-muted);
	width: 100%;
	padding: 4px;
	border-radius: 4px;
	cursor: pointer;
	font-family: inherit;
	font-size: 11px;
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 4px;
}

.add-file-btn:hover {
	border-color: var(--accent);
	color: var(--accent);
}

.file-item-rename-input {
	flex: 1;
	min-width: 0;
	background: transparent;
	border: none;
	border-bottom: 1px solid var(--accent);
	color: inherit;
	font-family: inherit;
	font-size: 12px;
	padding: 0;
	outline: none;
}

/* hidden file input */
.file-input-hidden {
	display: none;
}

/* ── Right panel ── */
.right {
	display: grid;
	grid-template-rows: 1fr 4px 1fr;
	overflow: hidden;
}

.panel {
	display: flex;
	flex-direction: column;
	overflow: hidden;
}

.panel-header {
	display: flex;
	align-items: center;
	gap: 6px;
	padding: 4px 10px;
	font-size: 11px;
	font-weight: 600;
	color: var(--text-muted);
	border-bottom: 1px solid var(--border);
	background: var(--bg2);
}

/* ── Editor ── */
.editor-body {
	flex: 1;
	overflow: auto;
	background: var(--surface);
}

.editor-textarea {
	width: 100%;
	height: 100%;
	min-height: 100%;
	background: transparent;
	color: var(--text);
	border: none;
	outline: none;
	font-family: inherit;
	font-size: 13px;
	line-height: 1.5;
	padding: 10px;
	resize: none;
	tab-size: 2;
}

.editor-empty {
	display: flex;
	align-items: center;
	justify-content: center;
	color: var(--text-muted);
	font-size: 13px;
}

.editor-binary-notice {
	padding: 16px;
	color: var(--text-muted);
	font-size: 13px;
}

.editor-image-viewer {
	flex: 1;
	display: flex;
	flex-direction: column;
	overflow: auto;
	background: var(--surface);
	background-image: linear-gradient(45deg, var(--bg2) 25%, transparent 25%),
		linear-gradient(-45deg, var(--bg2) 25%, transparent 25%),
		linear-gradient(45deg, transparent 75%, var(--bg2) 75%),
		linear-gradient(-45deg, transparent 75%, var(--bg2) 75%);
	background-size: 16px 16px;
	background-position: 0 0, 0 8px, 8px -8px, -8px 0;
}

.editor-image {
	max-width: 100%;
	max-height: calc(100% - 48px);
	object-fit: contain;
	align-self: center;
	margin: auto;
	padding: 16px;
}

.editor-image-actions {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 8px 12px;
	border-top: 1px solid var(--border);
	background: var(--bg2);
	flex-shrink: 0;
}

.editor-image-hint {
	font-size: 11px;
	color: var(--text-muted);
	margin-right: 4px;
}

/* ── Divider/drag handle ── */
.divider-handle {
	background: var(--border);
	cursor: row-resize;
	position: relative;
}

.divider-handle:hover {
	background: var(--accent);
}

/* ── Mobile editor/preview tab bar (hidden on desktop) ── */
.mobile-tabs {
	display: none;
}

.mobile-tab {
	flex: 1;
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 6px;
	padding: 8px;
	background: none;
	border: none;
	border-bottom: 2px solid transparent;
	color: var(--text-muted);
	font-family: inherit;
	font-size: 12px;
	font-weight: 600;
	cursor: pointer;
}

.mobile-tab.active {
	color: var(--accent);
	border-bottom-color: var(--accent);
}

/* ── Preview iframe ── */
.preview-iframe {
	flex: 1;
	width: 100%;
	border: none;
	background: #fff;
}

/* ── Modal ── */
.modal-backdrop {
	position: fixed;
	inset: 0;
	background: rgba(0, 0, 0, 0.5);
	display: flex;
	align-items: center;
	justify-content: center;
	z-index: 100;
}

.modal {
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: 8px;
	padding: 20px;
	width: min(480px, 90vw);
	display: flex;
	flex-direction: column;
	gap: 14px;
}

.modal-title {
	font-size: 15px;
	font-weight: 600;
}

.modal-row {
	display: flex;
	flex-direction: column;
	gap: 6px;
}

.modal-row label {
	font-size: 11px;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.04em;
	color: var(--text-muted);
}

.modal select,
.modal input[type='text'],
.modal input[type='password'] {
	background: var(--bg2);
	border: 1px solid var(--border);
	border-radius: 4px;
	color: var(--text);
	font-family: inherit;
	font-size: 13px;
	padding: 6px 8px;
	width: 100%;
}

.modal-url {
	font-size: 11px;
	word-break: break-all;
	padding: 6px 8px;
	background: var(--bg2);
	border-radius: 4px;
	border: 1px solid var(--border);
	color: var(--text-muted);
	max-height: 120px;
	overflow-y: auto;
}

.modal-url-length {
	font-weight: 400;
	color: var(--text-muted);
	text-transform: none;
	letter-spacing: 0;
}

.modal-ecdh-guide {
	font-size: 12px;
	color: var(--text);
	line-height: 1.6;
	padding-left: 18px;
}

.modal-ecdh-guide a {
	color: var(--accent);
}

.modal-error {
	color: #e05a5a;
	font-size: 12px;
}

.modal textarea,
.modal-textarea {
	background: var(--bg2);
	border: 1px solid var(--border);
	border-radius: 4px;
	color: var(--text);
	font-family: inherit;
	font-size: 12px;
	padding: 6px 8px;
	width: 100%;
	resize: vertical;
	min-height: 60px;
}

.preview-notice {
	display: flex;
	align-items: center;
	gap: 6px;
	padding: 6px 10px;
	font-size: 11px;
	color: var(--text-muted);
	background: var(--bg2);
	border-bottom: 1px solid var(--border);
}

.modal-actions {
	display: flex;
	gap: 8px;
	justify-content: flex-end;
}

/* ── Receive page ── */
.receive-page {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	height: 100dvh;
	gap: 16px;
	padding: 24px;
}

.receive-page h1 {
	font-size: 22px;
}

.receive-logo {
	margin-bottom: 24px;
}

.receive-card {
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: 8px;
	padding: 24px;
	width: min(440px, 90vw);
	display: flex;
	flex-direction: column;
	gap: 14px;
}

.receive-section-title {
	font-weight: 600;
	font-size: 15px;
}

.receive-hint {
	font-size: 12px;
	color: var(--text-muted);
	line-height: 1.5;
}

.receive-pubkey {
	font-family: monospace;
	font-size: 11px;
	word-break: break-all;
	padding: 8px;
	background: var(--bg2);
	border: 1px solid var(--border);
	border-radius: 4px;
	color: var(--text-muted);
	user-select: all;
}

.receive-divider {
	border: none;
	border-top: 1px solid var(--border);
	margin: 4px 0;
}

.receive-file-list {
	list-style: none;
	display: flex;
	flex-direction: column;
	gap: 4px;
}

.receive-file-list li {
	display: flex;
	align-items: center;
	gap: 6px;
	font-size: 12px;
}

.receive-file-size {
	color: var(--text-muted);
	margin-left: auto;
}

/* ── About page ── */
.about-page {
	max-width: 640px;
	margin: 0 auto;
	padding: 40px 24px;
	line-height: 1.6;
}

.about-page h1 {
	font-size: 24px;
	margin-bottom: 16px;
}

.about-page p {
	color: var(--text-muted);
	margin-bottom: 12px;
}

/* ── Mobile ── */
@media (max-width: 640px) {
	.main {
		grid-template-columns: 1fr;
		grid-template-rows: auto 1fr;
	}

	.sidebar {
		max-height: 200px;
		overflow-y: auto;
		border-right: none;
		border-bottom: 1px solid var(--border);
	}

	.right {
		display: flex;
		flex-direction: column;
	}

	.mobile-tabs {
		display: flex;
		background: var(--bg2);
		border-bottom: 1px solid var(--border);
	}

	.right .editor-panel,
	.right .preview-panel {
		flex: 1;
		min-height: 0;
	}

	.right .divider-handle {
		display: none;
	}

	.right.mobile-tab-editor .preview-panel {
		display: none;
	}

	.right.mobile-tab-preview .editor-panel {
		display: none;
	}
}
