
* {
	box-sizing: border-box;
	margin: 0;
	padding: 0;
}

:root {
	color-scheme: light;
	--bg: #f5f6fa;
	--card: #ffffff;
	--text: #0f1720;
	--muted: #4b5563;
	--primary: #5b6bff;
	--primary-soft: rgba(91, 107, 255, 0.12);
	--accent: #f6e07b;
	--accent-deep: #f0c755;
	--shadow: 0 18px 40px rgba(22, 25, 38, 0.12);
	--border: rgba(20, 28, 45, 0.12);
}

body {
	font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
	background: var(--bg);
	color: var(--text);
	min-height: 100vh;
}

.app-shell {
	max-width: 1400px;
	margin: 0 auto;
	padding: 1.5rem 1.5rem 3rem;
}

.topbar {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 0.75rem 0;
	border-bottom: 1px solid var(--border);
}

.brand {
	display: flex;
	align-items: center;
	gap: 0.6rem;
	font-weight: 700;
	color: var(--primary);
	font-size: 1.1rem;
}

.brand__dot {
	width: 10px;
	height: 10px;
	border-radius: 50%;
	background: var(--primary);
	box-shadow: 0 0 0 4px rgba(91, 107, 255, 0.15);
}

.topbar__actions {
	display: flex;
	align-items: center;
	gap: 0.75rem;
}

.toolbar {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 1rem;
	margin: 1.5rem 0 1.25rem;
	flex-wrap: wrap;
}

.toolbar__left {
	display: flex;
	align-items: center;
	gap: 1rem;
	flex-wrap: wrap;
}

.toolbar__range {
	color: var(--muted);
	font-size: 0.95rem;
}

.toolbar__right {
	display: flex;
	align-items: center;
	gap: 0.75rem;
	flex: 1;
	justify-content: flex-end;
}

.toolbar__right input {
	min-width: min(420px, 100%);
	border: 1px solid var(--border);
	border-radius: 12px;
	padding: 0.65rem 0.9rem;
	background: #fff;
}

.auth-gate {
	position: fixed;
	inset: 0;
	background: rgba(15, 23, 42, 0.55);
	display: none;
	align-items: center;
	justify-content: center;
	padding: 1.5rem;
	backdrop-filter: blur(6px);
	z-index: 999;
}

.auth-gate.is-visible {
	display: flex;
}

.auth-card {
	width: min(460px, 100%);
	background: #fff;
	border-radius: 18px;
	box-shadow: var(--shadow);
	padding: 1.5rem;
	display: flex;
	flex-direction: column;
	gap: 1.25rem;
}

.auth-card__header h2 {
	margin-bottom: 0.25rem;
}

.auth-card__header p {
	color: var(--muted);
}

.auth-card__body label {
	display: flex;
	flex-direction: column;
	gap: 0.45rem;
	margin-bottom: 0.85rem;
}

.auth-card__body input {
	border: 1px solid var(--border);
	border-radius: 12px;
	padding: 0.7rem 0.9rem;
}

.auth-actions {
	display: flex;
	flex-direction: column;
	gap: 0.6rem;
}

.auth-error {
	color: #b91c1c;
	min-height: 1.25rem;
}

.board {
	background: #f1f3f8;
	border-radius: 18px;
	padding: 1rem;
	box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

.board__grid {
	display: grid;
	grid-template-columns: repeat(3, minmax(240px, 1fr));
	gap: 1rem;
}

.journal-card {
	background: var(--card);
	border-radius: 16px;
	border: 1px solid var(--border);
	box-shadow: var(--shadow);
	padding: 1rem;
	display: flex;
	flex-direction: column;
	gap: 1rem;
	min-height: 360px;
}

.journal-card__header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	border-bottom: 2px solid var(--primary);
	padding-bottom: 0.6rem;
}

.header-actions {
	opacity: 0;
	pointer-events: none;
	transition: opacity 0.2s ease;
}

.journal-card:hover .header-actions,
.journal-card:focus-within .header-actions {
	opacity: 1;
	pointer-events: auto;
}

.journal-card__header h3 {
	font-size: 1.05rem;
	font-weight: 700;
	color: var(--primary);
}

.journal-card__header p {
	color: var(--muted);
	font-size: 0.8rem;
}

.journal-card__block {
	background: transparent;
	border-radius: 12px;
	padding: 0;
	border: none;
	position: relative;
}

.block-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	margin-bottom: 0.6rem;
}

.block-actions,
.item-actions {
	display: flex;
	gap: 0.4rem;
	opacity: 0;
	pointer-events: none;
	transition: opacity 0.18s ease, transform 0.18s ease;
	position: absolute;
	top: 8px;
	right: 8px;
	z-index: 6;
	transform: translateY(-4px);
	background: rgba(255, 255, 255, 0.88);
	border: 1px solid var(--border);
	padding: 0.25rem 0.35rem;
	border-radius: 999px;
	box-shadow: 0 8px 18px rgba(22, 25, 38, 0.08);
	backdrop-filter: blur(6px);
}

/* Make item-action text tiny and tighten spacing for compact UI */
.item-actions {
	font-size: 0.68rem;
	left: 8px;
	right: auto;
	top: -22px;
}

/* Prevent the first item-actions from being clipped by scroll containers */
.task-list,
.appointment-list {
	padding-top: 1.4rem;
}

/* In the Journal Preview modal, keep actions inside the item */
.journal-modal__section .item-actions {
	top: 8px;
}

/* Float Journal Preview item-actions slightly above the card (like main page) */
.journal-modal__section .item-actions {
	left: 8px;
	right: auto;
	top: -18px;
	transform: translateY(0);
}

/* Make sure buttons inside the modal item-actions are vertically centered */
.journal-modal__section .item-actions button,
.journal-modal__section .item-actions .action-btn,
.journal-modal__section .item-actions .btn {
	display: inline-flex;
}
.journal-modal__section .item-actions button {
	align-items: center;
	justify-content: center;
}

/* Ensure first item in modal isn't clipped by floating actions */
.journal-modal__section .task-list,
.journal-modal__section .appointment-list {
	padding-top: 1.4rem;
}
.item-actions .action-btn,
.item-actions .btn,
.item-actions .icon-btn,
.item-actions .color-btn {
	font-size: 0.68rem;
	padding: 0.12rem 0.32rem;
}
.move-btn {
	min-width: 22px;
	padding: 0.08rem 0.28rem;
	font-size: 0.7rem;
}

.journal-card__block:hover .block-actions,
.journal-card__block:focus-within .block-actions {
	opacity: 1;
	pointer-events: auto;
	transform: translateY(0);
}

.task:hover .item-actions,
.task:focus-within .item-actions,
.appointment:hover .item-actions,
.appointment:focus-within .item-actions,
.note:hover .item-actions,
.note:focus-within .item-actions {
	opacity: 1;
	pointer-events: auto;
	transform: translateY(0);
}

/* When editing inline, keep the floating actions out of the way */
.task.is-editing .item-actions,
.note.is-editing .item-actions,
.appointment.is-editing .item-actions {
	opacity: 0 !important;
	pointer-events: none !important;
}

.item-actions:hover {
	opacity: 1;
}

.block-header h4 {
	font-size: 0.7rem;
	text-transform: uppercase;
	letter-spacing: 0.04em;
	color: var(--muted);
}

.task-input {
	display: flex;
	gap: 0.5rem;
	margin-bottom: 0.75rem;
}

.appointment-input {
	display: grid;
	grid-template-columns: 1fr;
	gap: 0.5rem;
	margin-bottom: 0.75rem;
}

.appointment-input input {
	border: 1px solid var(--border);
	border-radius: 10px;
	padding: 0.55rem 0.75rem;
	background: #fff;
}

.appointment-list {
	display: flex;
	flex-direction: column;
	gap: 0.5rem;
	max-height: 220px;
	overflow-y: auto;
}

.appointment {
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	gap: 0.75rem;
	padding: 1.05rem 0.8rem 0.6rem;
	border-radius: 12px;
	background: #ffffff;
	border: 1px solid var(--border);
	position: relative;
}

.appointment.is-done {
	background: #f3f4f8;
	border: 1px dashed rgba(122, 129, 148, 0.35);
}

.appointment strong {
	display: block;
	font-size: 0.78rem;
	margin-bottom: 0.2rem;
	color: var(--muted);
}

.appointment span {
	color: var(--muted);
	font-size: 0.78rem;
}

.appointment__meta {
	background: var(--primary-soft);
	color: var(--primary);
	font-weight: 600;
	font-size: 0.68rem;
	padding: 0.25rem 0.5rem;
	border-radius: 999px;
}

.appointment__done {
	color: #1f8f54;
}

.task-input input {
	flex: 1;
	border: 1px solid var(--border);
	border-radius: 10px;
	padding: 0.6rem 0.8rem;
	background: #fff;
}

.task-list {
	list-style: none;
	display: flex;
	flex-direction: column;
	gap: 0.5rem;
	max-height: 360px;
	overflow-y: auto;
	padding-right: 0.25rem;
}

.task {
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	gap: 0.5rem;
	background: #ffffff;
	border-radius: 12px;
	padding: 1.05rem 0.8rem 0.6rem;
	border: 1px solid var(--border);
	box-shadow: 0 6px 14px rgba(22, 25, 38, 0.04);
	font-size: 0.88rem;
	position: relative;
}

.task.is-done {
	background: #f3f4f8;
	border: 1px dashed rgba(122, 129, 148, 0.35);
	box-shadow: none;
}

.task.is-focused,
.appointment.is-focused,
.note.is-focused {
	outline: 2px solid rgba(91, 107, 255, 0.35);
	outline-offset: 2px;
}

.task label {
	display: flex;
	align-items: flex-start;
	gap: 0.6rem;
	flex: 1 1 auto;
	width: 100%;
}

.task__done {
	color: #1f8f54;
}

.task__text.is-done {
	text-decoration: line-through;
	font-size: 0.78rem;
}

.task__text {
	font-size: 0.78rem;
	color: var(--muted);
	white-space: pre-line;
}

.task__color,
.color-btn {
	width: 20px;
	height: 20px;
	border-radius: 6px;
	border: 1px solid rgba(0,0,0,0.08);
	padding: 0;
	margin-left: 6px;
	background: #fff;
	cursor: pointer;
}

.task[data-color] {
	--task-color: #fff;
	background: color-mix(in srgb, var(--task-color) 22%, #ffffff);
	border-left: 4px solid var(--task-color);
}

.task[data-color] .task__color {
	background: var(--task-color);
}

.appointment[data-color],
.note[data-color] {
	--item-color: #fff;
	background: color-mix(in srgb, var(--item-color) 22%, #ffffff);
	border-left: 4px solid var(--item-color);
}

.appointment[data-color] .appointment__color,
.note[data-color] .note__color {
	background: var(--item-color);
}

.task__edit {
	border: none;
	background: transparent;
	color: #c08b1e;
	cursor: pointer;
	font-weight: 600;
	font-size: 0.82rem;
}

.action-btn {
	border: none;
	background: rgba(91, 107, 255, 0.12);
	color: var(--primary);
	font-weight: 600;
	font-size: 0.82rem;
	border-radius: 8px;
	padding: 0.2rem 0.5rem;
	cursor: pointer;
	opacity: 0.5;
}

/* Show per-item View buttons only in Journal Preview */
.task__view,
.note__view,
.appointment__view {
	display: none;
}

.journal-modal__section .task__view,
.journal-modal__section .note__view,
.journal-modal__section .appointment__view {
	display: inline-flex;
}

.move-btn {
	min-width: 24px;
	padding: 0.15rem 0.35rem;
	font-size: 0.8rem;
}

.action-btn:hover {
	opacity: 1;
}

.note-list {
	display: grid;
	gap: 0.75rem;
}

.note {
	background: #fff;
	border-radius: 12px;
	padding: 1.1rem 0.8rem 0.8rem;
	border: 1px solid var(--border);
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	gap: 0.75rem;
	position: relative;
}

.note h4 {
	font-size: 0.82rem;
	margin-bottom: 0.2rem;
	display: none;
}

.note p {
	font-size: 0.78rem;
	color: var(--muted);
	white-space: pre-line;
	overflow: hidden;
	text-overflow: ellipsis;
	display: -webkit-box;
	-webkit-box-orient: vertical;
	line-clamp: 3;
	-webkit-line-clamp: 3;
	word-break: break-word;
}

.appointment strong {
	white-space: pre-line;
	font-weight: 400;
	font-size: 0.78rem;
	color: var(--muted);
}

.pill {
	display: inline-flex;
	align-items: center;
	padding: 0.3rem 0.8rem;
	border-radius: 999px;
	background: rgba(95, 111, 251, 0.12);
	color: var(--primary);
	font-weight: 600;
	font-size: 0.85rem;
}

.pill--ghost {
	background: rgba(92, 227, 217, 0.2);
	color: #1d7b77;
}

.meta {
	color: var(--muted);
	font-size: 0.9rem;
}

.btn {
	border: none;
	border-radius: 12px;
	padding: 0.6rem 1rem;
	cursor: pointer;
	font-weight: 600;
	transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.btn--primary {
	background: linear-gradient(135deg, var(--primary), #7b5bff);
	color: #fff;
	box-shadow: 0 12px 24px rgba(95, 111, 251, 0.25);
}

.btn--ghost {
	background: rgba(91, 107, 255, 0.1);
	color: var(--primary);
}

.btn--small {
	padding: 0.4rem 0.8rem;
	font-size: 0.85rem;
}

.copy-btn.is-copied {
	background: rgba(34, 197, 94, 0.16);
	color: #166534;
}

.toast {
	position: fixed;
	left: 50%;
	bottom: 18px;
	transform: translateX(-50%) translateY(10px);
	opacity: 0;
	pointer-events: none;
	z-index: 9999;

	max-width: min(680px, calc(100vw - 32px));
	padding: 0.7rem 0.95rem;
	border-radius: 999px;
	border: 1px solid var(--border);
	box-shadow: 0 18px 40px rgba(22, 25, 38, 0.14);
	backdrop-filter: blur(8px);

	font-weight: 600;
	font-size: 0.9rem;
	transition: opacity 0.18s ease, transform 0.18s ease;
}

.toast.is-visible {
	opacity: 1;
	transform: translateX(-50%) translateY(0);
}

.toast--info {
	background: rgba(91, 107, 255, 0.12);
	color: var(--primary);
}

.toast--success {
	background: rgba(34, 197, 94, 0.14);
	color: #166534;
}

.toast--error {
	background: rgba(239, 68, 68, 0.14);
	color: #991b1b;
}

.btn:hover {
	transform: translateY(-1px);
}

.icon-btn {
	border: none;
	background: rgba(95, 111, 251, 0.12);
	color: var(--primary);
	width: 36px;
	height: 36px;
	border-radius: 50%;
	cursor: pointer;
	font-size: 1rem;
}

.modal {
	position: fixed;
	inset: 0;
	display: grid;
	place-items: center;
	pointer-events: none;
	opacity: 0;
	transition: opacity 0.2s ease;
}

.modal.is-visible {
	pointer-events: auto;
	opacity: 1;
}

.modal__overlay {
	position: absolute;
	inset: 0;
	background: rgba(17, 19, 32, 0.45);
	backdrop-filter: blur(6px);
}

.modal__bubble {
	position: relative;
	z-index: 1;
	width: min(520px, 90vw);
	background: var(--card);
	border-radius: 32px;
	padding: 1.8rem;
	box-shadow: var(--shadow);
	border: 1px solid rgba(91, 107, 255, 0.2);
	animation: bubbleIn 0.25s ease;
}

.modal__bubble--wide {
	width: min(1100px, 95vw);
	max-height: calc(100vh - 3rem);
	overflow: hidden;
	display: flex;
	flex-direction: column;
}

.modal__bubble--wide .modal__body {
	min-height: 0;
	max-height: none;
	overflow-y: auto;
	padding-right: 0.5rem;
}

.journal-modal__section {
	margin-bottom: 1.5rem;
}

.journal-modal__section h4 {
	font-size: 0.82rem;
	text-transform: uppercase;
	letter-spacing: 0.05em;
	color: var(--muted);
	margin-bottom: 0.75rem;
}

/* Journal View: header row with actions on the right (always visible) */
.journal-modal__section .journal-modal__section-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	flex-wrap: wrap;
	gap: 0.75rem;
	margin-bottom: 0.75rem;
}

.journal-modal__section .journal-modal__section-header h4 {
	margin-bottom: 0;
}

.journal-modal__section-actions {
	display: flex;
	align-items: center;
	justify-content: flex-end;
	gap: 0.5rem;
	flex: 0 0 auto;
}

/* Journal View: always show Add/New buttons */
.journal-modal__section .block-actions {
	opacity: 1;
	pointer-events: auto;
	position: static;
	transform: none;
	background: transparent;
	border: none;
	box-shadow: none;
	padding: 0;
}

/* Journal preview: left-align task text for readability */
.journal-modal__section .task label {
	align-items: flex-start;
	font-weight: 400;
}
.journal-modal__section .task .task__text {
	text-align: left;
	font-weight: 400;
}

/* Journal preview: make list items feel clickable for editing */
.journal-modal__section .task,
.journal-modal__section .appointment,
.journal-modal__section .note {
	cursor: pointer;
}
.journal-modal__section .item-actions,
.journal-modal__section .item-actions * {
	cursor: pointer;
}

/* Journal View: make task and appointment typography match notes */
.journal-modal__section .task .task__text {
	font-size: 0.78rem;
	color: var(--muted);
}
.journal-modal__section .appointment strong,
.journal-modal__section .appointment span {
	font-size: 0.78rem;
	color: var(--muted);
}

/* Apply note-style truncation and wrapping to tasks and appointments in journal preview */
.journal-modal__section .task .task__text,
.journal-modal__section .appointment strong,
.journal-modal__section .appointment span {
	white-space: pre-line;
	overflow: hidden;
	text-overflow: ellipsis;
	display: -webkit-box;
	-webkit-box-orient: vertical;
	-webkit-line-clamp: 3;
	word-break: break-word;
}

/* Journal preview lists: let the modal body control scrolling */
.journal-modal__section .task-list {
	max-height: none;
	overflow: visible;
	padding-right: 0;
}

/* Journal preview: expand item to show full content when requested */
.journal-modal__section .task.is-expanded .task__text,
.journal-modal__section .appointment.is-expanded strong,
.journal-modal__section .appointment.is-expanded span,
.journal-modal__section .note.is-expanded p {
	white-space: pre-wrap;
	overflow: visible !important;
	text-overflow: initial !important;
	display: block !important;
	-webkit-box-orient: initial;
	-webkit-line-clamp: unset !important;
	line-clamp: unset !important;
}

/* Inline editors (cards + Journal View) */
.task__editor,
.note__editor,
.appointment__editor,
.appointment__time-editor {
	display: none;
	width: 100%;
	border: 1px solid var(--border);
	border-radius: 10px;
	padding: 0.45rem 0.55rem;
	font-size: 0.78rem;
	color: var(--text);
	background: #fff;
}

.appointment__time-editor {
	margin-top: 0.35rem;
}

.task.is-editing .task__text,
.note.is-editing p,
.appointment.is-editing strong,
.appointment.is-editing span {
	display: none;
}

.task.is-editing .task__editor,
.note.is-editing .note__editor,
.appointment.is-editing .appointment__editor,
.appointment.is-editing .appointment__time-editor {
	display: block;
}

.modal__bubble::after {
	content: '';
	position: absolute;
	width: 26px;
	height: 26px;
	background: var(--card);
	border: 1px solid rgba(91, 107, 255, 0.2);
	border-left: none;
	border-top: none;
	border-radius: 0 0 8px 0;
	transform: rotate(45deg);
	left: 30px;
	bottom: -12px;
}

@keyframes bubbleIn {
	from {
		transform: translateY(10px) scale(0.98);
		opacity: 0;
	}
	to {
		transform: translateY(0) scale(1);
		opacity: 1;
	}
}

.modal__header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	margin-bottom: 1rem;
}

/* Journal modal title: smaller and muted */
#journalModalTitle {
    font-size: 0.95rem;
    color: var(--muted);
    font-weight: 600;
    margin: 0;
}

.modal__body label {
	display: flex;
	flex-direction: column;
	gap: 0.4rem;
	font-weight: 600;
	color: var(--muted);
	margin-bottom: 1rem;
}

.modal__body input,
.modal__body textarea {
	border: 1px solid var(--border);
	border-radius: 14px;
	padding: 0.5rem 0.65rem;
	font-size: 0.9rem;
	min-height: 2.2rem;
	max-height: 180px;
	resize: vertical;
	transition: background 0.2s ease, border-color 0.2s ease;
}

.modal__footer {
	display: flex;
	justify-content: flex-end;
	gap: 0.6rem;
}

@media (max-width: 640px) {
	body {
		font-size: 16px;
	}

	.app-shell {
		padding: 1rem 1rem 2rem;
	}

	.topbar {
		gap: 0.5rem;
	}

	.toolbar {
		gap: 0.75rem;
	}

	.toolbar__right input {
		min-width: 100%;
	}

	.board {
		padding: 0.75rem;
	}

	.journal-card {
		padding: 0.85rem;
		border-radius: 14px;
	}

	.journal-card__header h3 {
		font-size: 1rem;
	}

	.block-header h4 {
		font-size: 0.82rem;
	}

	.task,
	.appointment,
	.note {
		padding: 0.55rem 0.7rem;
	}

	.task__text,
	.note p,
	.appointment span {
		font-size: 0.82rem;
	}

	.item-actions,
	.block-actions {
		top: 6px;
		right: 6px;
	}

	.topbar {
		flex-direction: column;
		align-items: flex-start;
		gap: 0.75rem;
	}

	.toolbar {
		flex-direction: column;
		align-items: stretch;
	}

	.toolbar__right {
		width: 100%;
		justify-content: stretch;
		flex-direction: column;
	}

	.board__grid {
		grid-template-columns: repeat(2, minmax(220px, 1fr));
	}
}

@media (max-width: 520px) {
	.board__grid {
		grid-template-columns: 1fr;
	}

	.modal__bubble {
		width: min(94vw, 480px);
		padding: 1.2rem;
		border-radius: 24px;
	}

	.modal__bubble::after {
		left: 22px;
	}

	.modal__bubble--wide {
		width: min(96vw, 980px);
	}

	.modal__body input,
	.modal__body textarea {
		font-size: 0.9rem;
	}

	.action-btn {
		font-size: 0.6rem;
		padding: 0.2rem 0.45rem;
	}
}

@media (hover: hover) and (pointer: fine) {
	.board__grid {
		grid-template-columns: repeat(3, minmax(240px, 1fr));
	}
}