/* Jack Yu Habits — follows the theme tokens. */

.jy-hb {
	--hb-line: var(--jy-line, rgba(34, 32, 28, 0.16));
	--hb-ok: var(--wp--preset--color--primary);
	--hb-bad: #b23b2c;
	--hb-warn: #c98d1e;
	max-width: 900px;
	margin: 0 auto;
}

.jy-hb *,
.jy-hb-cele * {
	box-sizing: border-box;
}

.jy-hb__head {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 0.6rem 1rem;
	margin-bottom: 1rem;
}

.jy-hb__sum {
	margin: 0;
	font-size: 0.95rem;
}

.jy-hb__sum strong {
	font-size: 1.5rem;
	color: var(--hb-ok);
}

.jy-hb__best {
	display: block;
	font-size: 0.8rem;
	color: var(--wp--preset--color--muted);
}

.jy-hb__empty,
.jy-hb__note,
.jy-hb__loading {
	font-size: 0.875rem;
	color: var(--wp--preset--color--muted);
}

/* cards */
.jy-hb-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
	gap: 0.9rem;
}

.jy-hb-card {
	position: relative;
	padding: 0.95rem 1rem 0.8rem;
	border: 1px solid var(--hb-line);
	border-left: 4px solid var(--hb-ok);
	border-radius: 12px;
	background: var(--wp--preset--color--surface);
	transition: opacity 0.2s ease, transform 0.2s ease;
}

.jy-hb-card.is-health { border-left-color: #3f8f63; }
.jy-hb-card.is-study { border-left-color: #3d6fa8; }
.jy-hb-card.is-discipline { border-left-color: #8a5aa8; }
.jy-hb-card.is-work { border-left-color: #c07a2c; }
.jy-hb-card.is-family { border-left-color: #c2546b; }

.jy-hb-card.is-done {
	background: color-mix(in srgb, var(--hb-ok) 9%, var(--wp--preset--color--surface));
}

.jy-hb-card.is-rest {
	opacity: 0.72;
}

.jy-hb-card.is-busy {
	opacity: 0.5;
	pointer-events: none;
}

.jy-hb-card__top {
	display: flex;
	align-items: center;
	gap: 0.7rem;
}

.jy-hb-card__icon {
	flex: none;
	width: 2.4rem;
	height: 2.4rem;
	display: flex;
	align-items: center;
	justify-content: center;
	border-radius: 10px;
	background: var(--wp--preset--color--base);
	font-size: 1.35rem;
}

.jy-hb-card__tt {
	flex: 1;
	min-width: 0;
}

.jy-hb-card__name {
	margin: 0;
	font-weight: 700;
	font-size: 1.02rem;
	line-height: 1.3;
}

.jy-hb-card__rule {
	margin: 0.1rem 0 0;
	font-size: 0.78rem;
	color: var(--wp--preset--color--muted);
}

.jy-hb-check {
	flex: none;
	position: relative;
	width: 44px;
	height: 44px;
	padding: 0;
	border: 2.5px solid var(--wp--preset--color--muted);
	border-radius: 50%;
	background: var(--wp--preset--color--base);
	cursor: pointer;
	transition: transform 0.15s ease;
}

.jy-hb-check:active {
	transform: scale(0.9);
}

.jy-hb-check:disabled {
	opacity: 0.35;
	cursor: default;
}

.jy-hb-check::after {
	content: "";
	position: absolute;
	left: 13px;
	top: 6px;
	width: 10px;
	height: 19px;
	border: solid var(--wp--preset--color--on-primary);
	border-width: 0 3.5px 3.5px 0;
	transform: rotate(45deg);
	opacity: 0;
}

.jy-hb-check.is-on {
	border-color: var(--hb-ok);
	background: var(--hb-ok);
}

.jy-hb-check.is-on::after {
	opacity: 1;
}

.jy-hb-state {
	flex: none;
	font-size: 0.8rem;
	font-weight: 700;
	color: var(--wp--preset--color--muted);
}

.jy-hb-card.is-done .jy-hb-state {
	color: var(--hb-ok);
}

.jy-hb-count {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.4rem 0.6rem;
	margin-top: 0.7rem;
}

.jy-hb-bar {
	flex: 1 1 100%;
	height: 8px;
	border-radius: 999px;
	background: var(--hb-line);
	overflow: hidden;
}

.jy-hb-bar span {
	display: block;
	height: 100%;
	background: var(--hb-ok);
	transition: width 0.3s ease;
}

.jy-hb-count__n {
	font-weight: 700;
	font-size: 0.95rem;
}

.jy-hb-count__tools {
	display: flex;
	gap: 0.3rem;
	margin-left: auto;
}

.jy-hb-mini {
	min-width: 38px;
	min-height: 34px;
	padding: 0 0.55rem;
	border: 1px solid var(--hb-line);
	border-radius: 8px;
	background: var(--wp--preset--color--base);
	color: inherit;
	font: 0.85rem/1 var(--wp--preset--font-family--body);
	cursor: pointer;
}

.jy-hb-mini.is-plus {
	border-color: var(--hb-ok);
	background: var(--hb-ok);
	color: var(--wp--preset--color--on-primary);
	font-weight: 700;
}

.jy-hb-mini.is-danger {
	color: var(--hb-bad);
}

.jy-hb-card__wk {
	margin: 0.6rem 0 0;
	font-size: 0.88rem;
	font-weight: 700;
}

.jy-hb-week {
	display: grid;
	grid-template-columns: repeat(7, 1fr);
	gap: 4px;
	margin-top: 0.75rem;
}

.jy-hb-week__d {
	display: flex;
	align-items: center;
	justify-content: center;
	height: 26px;
	border: 1.5px solid var(--hb-line);
	border-radius: 6px;
	font-size: 0.7rem;
	color: var(--wp--preset--color--muted);
}

.jy-hb-week__d i {
	font-style: normal;
}

.jy-hb-week__d.is-done {
	border-color: var(--hb-ok);
	background: var(--hb-ok);
	color: var(--wp--preset--color--on-primary);
}

.jy-hb-week__d.is-part {
	background: color-mix(in srgb, var(--hb-ok) 30%, transparent);
}

.jy-hb-week__d.is-off {
	border-style: dashed;
	opacity: 0.45;
}

.jy-hb-week__d.is-future {
	opacity: 0.5;
}

.jy-hb-week__d.is-today {
	outline: 2px solid var(--hb-warn);
	outline-offset: 1px;
}

.jy-hb-card__foot {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.3rem 0.9rem;
	margin-top: 0.65rem;
	font-size: 0.78rem;
	color: var(--wp--preset--color--muted);
}

.jy-hb-streak.is-hot {
	color: var(--hb-warn);
	font-weight: 700;
}

.jy-hb .jy-hb-link {
	padding: 0;
	border: 0;
	background: none;
	color: var(--wp--preset--color--primary);
	font: inherit;
	cursor: pointer;
	text-decoration: underline;
}

/* calendar */
.jy-hb-chips {
	margin-bottom: 0.8rem;
}

.jy-hb-cal__head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	margin-bottom: 0.6rem;
}

.jy-hb-nav {
	width: 40px;
	height: 40px;
	border: 1px solid var(--hb-line);
	border-radius: 50%;
	background: transparent;
	color: inherit;
	font-size: 1.3rem;
	cursor: pointer;
}

.jy-hb-nav:disabled {
	opacity: 0.3;
}

.jy-hb-cal__grid {
	display: grid;
	grid-template-columns: repeat(7, minmax(0, 1fr));
	gap: 0.3rem;
}

.jy-hb-cal__wd {
	text-align: center;
	font-size: 0.75rem;
	color: var(--wp--preset--color--muted);
}

.jy-hb-cal__d {
	position: relative;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 2px;
	aspect-ratio: 1;
	border: 1.5px solid transparent;
	border-radius: 8px;
	background: var(--wp--preset--color--surface);
	font-size: 0.85rem;
}

.jy-hb-cal__d small {
	font-size: 0.7rem;
	line-height: 1;
}

.jy-hb-cal__d.is-done {
	background: var(--hb-ok);
	color: var(--wp--preset--color--on-primary);
}

.jy-hb-cal__d.is-part {
	background: color-mix(in srgb, var(--hb-ok) 30%, var(--wp--preset--color--surface));
}

.jy-hb-cal__d.is-miss,
.jy-hb-cal__d.is-weekmiss {
	border-color: color-mix(in srgb, var(--hb-bad) 60%, transparent);
}

.jy-hb-cal__d.is-off {
	opacity: 0.45;
}

.jy-hb-cal__d.is-today {
	outline: 2px solid var(--hb-warn);
	outline-offset: -2px;
}

.jy-hb-cal__dots {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	gap: 2px;
	max-width: 90%;
}

.jy-hb-cal__dots i {
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background: var(--hb-line);
}

.jy-hb-cal__dots i.is-done {
	background: var(--hb-ok);
}

.jy-hb-cal__d.is-done .jy-hb-cal__dots i.is-done {
	background: var(--wp--preset--color--on-primary);
}

.jy-hb-cal__dots i.is-part {
	background: color-mix(in srgb, var(--hb-ok) 45%, transparent);
}

.jy-hb-cal__dots i.is-miss {
	background: var(--hb-bad);
}

/* manage */
.jy-hb-tpl {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.4rem;
	margin: 1rem 0;
}

.jy-hb-tpl .jy-hb__note {
	margin: 0;
}

.jy-hb-mlist {
	margin: 0;
	padding: 0;
	list-style: none;
}

.jy-hb-mitem {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.6rem;
	padding: 0.7rem 0;
	border-bottom: 1px solid var(--hb-line);
}

.jy-hb-mitem.is-archived {
	opacity: 0.55;
}

.jy-hb-mitem__t {
	flex: 1;
	min-width: 10rem;
	display: flex;
	flex-direction: column;
}

.jy-hb-mitem__t span {
	font-size: 0.78rem;
	color: var(--wp--preset--color--muted);
}

.jy-hb-mitem__tools {
	display: flex;
	flex-wrap: wrap;
	gap: 0.3rem;
}

.jy-hb-form {
	max-width: 560px;
}

.jy-hb .jy-hb-form__h {
	margin: 0 0 1rem;
	font-size: 1.15rem;
}

.jy-hb .jy-hb-form__h::before {
	content: none;
}

.jy-hb-f {
	display: flex;
	flex-direction: column;
	gap: 0.3rem;
	margin-bottom: 0.9rem;
}

.jy-hb-f[hidden] {
	display: none;
}

.jy-hb-f__l {
	font-weight: 700;
	font-size: 0.9rem;
}

.jy-hb-f__h {
	font-size: 0.78rem;
	color: var(--wp--preset--color--muted);
}

.jy-hb-f input[type="text"],
.jy-hb-f input[type="number"],
.jy-hb-f input[type="date"],
.jy-hb-f select {
	min-height: 42px;
	padding: 0 0.65rem;
	border: 1.5px solid var(--hb-line);
	border-radius: 8px;
	background: var(--wp--preset--color--base);
	color: inherit;
	font: 1rem/1.4 var(--wp--preset--font-family--body);
}

.jy-hb-f input[type="checkbox"] {
	width: 22px;
	height: 22px;
	accent-color: var(--hb-ok);
}

.jy-hb-icons {
	display: flex;
	flex-wrap: wrap;
	gap: 0.25rem;
}

.jy-hb-icon {
	width: 38px;
	height: 38px;
	border: 1px solid var(--hb-line);
	border-radius: 8px;
	background: var(--wp--preset--color--base);
	font-size: 1.15rem;
	cursor: pointer;
}

.jy-hb-types,
.jy-hb-days {
	display: flex;
	flex-wrap: wrap;
	gap: 0.35rem;
}

.jy-hb-types label,
.jy-hb-days label {
	display: inline-flex;
	align-items: center;
	gap: 0.3rem;
	cursor: pointer;
}

.jy-hb-types input,
.jy-hb-days input {
	accent-color: var(--hb-ok);
}

.jy-hb-tgt {
	display: flex;
	gap: 0.5rem;
}

.jy-hb-tgt input[type="number"] {
	width: 7rem;
}

.jy-hb-tgt input[type="text"] {
	width: 5rem;
}

.jy-hb-form__acts {
	display: flex;
	align-items: center;
	gap: 1rem;
}

.jy-hb-form__msg {
	color: var(--hb-bad);
	font-size: 0.9rem;
}

/* celebration */
.jy-hb-cele {
	position: fixed;
	inset: 0;
	z-index: 100002;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 1.2rem;
	background: rgba(14, 12, 9, 0);
	transition: background-color 0.25s ease;
}

.jy-hb-cele.is-in {
	background: rgba(14, 12, 9, 0.62);
}

html.jy-hb-open {
	overflow: hidden;
}

.jy-hb-cele__box {
	width: min(420px, 100%);
	padding: 1.6rem 1.4rem 1.3rem;
	border-radius: 18px;
	background: var(--wp--preset--color--base);
	color: var(--wp--preset--color--contrast);
	text-align: center;
	box-shadow: 0 24px 50px -20px rgba(0, 0, 0, 0.6);
	transform: scale(0.85) translateY(20px);
	opacity: 0;
	transition: transform 0.3s cubic-bezier(0.2, 1.4, 0.4, 1), opacity 0.25s ease;
}

.jy-hb-cele.is-in .jy-hb-cele__box {
	transform: none;
	opacity: 1;
}

.jy-hb-cele__tick {
	width: 64px;
	height: 64px;
	margin: 0 auto 0.6rem;
	border-radius: 50%;
	background: var(--wp--preset--color--primary);
	color: var(--wp--preset--color--on-primary);
	font-size: 2.1rem;
	line-height: 64px;
	font-weight: 700;
}

.jy-hb-cele__badge {
	margin: 0;
	font-size: 3.2rem;
	line-height: 1.1;
}

.jy-hb-cele__title {
	margin: 0.3rem 0 0;
	font-size: 1.15rem;
	font-weight: 700;
}

.jy-hb-cele__streak,
.jy-hb-cele__ms {
	margin: 0.35rem 0 0;
	font-size: 0.95rem;
	color: #c98d1e;
	font-weight: 700;
}

.jy-hb-cele__ms {
	font-weight: 400;
	color: inherit;
	line-height: 1.6;
}

.jy-hb-cele__q {
	margin: 1.1rem 0 1rem;
	padding: 0.9rem 1rem;
	border: 0;
	border-radius: 12px;
	background: var(--wp--preset--color--surface);
	text-align: left;
}

.jy-hb-cele__q::before,
.jy-hb-cele__q::after {
	content: none;
}

.jy-hb-cele__en {
	margin: 0;
	font: italic 1.02rem/1.55 var(--wp--preset--font-family--serif, Georgia, serif);
}

.jy-hb-cele__zh {
	margin: 0.45rem 0 0;
	font-size: 0.95rem;
	line-height: 1.6;
}

.jy-hb-cele__by {
	margin: 0.35rem 0 0;
	font-size: 0.8rem;
	color: var(--wp--preset--color--muted);
	text-align: right;
}

.jy-hb-cele__all {
	margin: 0 0 0.9rem;
	font-weight: 700;
	color: var(--wp--preset--color--primary);
}

/* 待办 page: +1 button */
.jy-hb-plus {
	flex: none;
	width: 38px;
	height: 30px;
	border: 0;
	border-radius: 999px;
	background: var(--wp--preset--color--primary);
	color: var(--wp--preset--color--on-primary);
	font: 700 0.8rem/1 var(--wp--preset--font-family--body);
	cursor: pointer;
}

@media (max-width: 640px) {
	.jy-hb-grid {
		grid-template-columns: 1fr;
	}

	.jy-hb-cal__d {
		font-size: 0.78rem;
	}
}

/* view toggle (same look as the photo module) */
.jy-hb .jy-views {
	display: inline-flex;
	border: 1.5px solid var(--wp--preset--color--primary);
	border-radius: var(--jy-l-radius, 3px);
	overflow: hidden;
}

.jy-hb .jy-views__btn {
	min-height: 38px;
	padding: 0.35rem 1rem;
	border: 0;
	background: transparent;
	color: var(--wp--preset--color--primary);
	font: 700 0.875rem/1.4 var(--wp--preset--font-family--body);
	cursor: pointer;
}

.jy-hb .jy-views__btn + .jy-views__btn {
	border-left: 1.5px solid var(--wp--preset--color--primary);
}

.jy-hb .jy-views__btn.is-active {
	background: var(--wp--preset--color--primary);
	color: var(--wp--preset--color--on-primary);
}


/* 读书 habit linked to the library */
.jy-hb-read {
	margin-top: 0.7rem;
}

.jy-hb-read .jy-hb-count__n {
	display: block;
	margin: 0.4rem 0 0.2rem;
}

.jy-hb-readform {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.35rem;
	margin-top: 0.5rem;
}

.jy-hb-readform select,
.jy-hb-readform input {
	min-height: 36px;
	padding: 0 0.5rem;
	border: 1px solid var(--hb-line);
	border-radius: 8px;
	background: var(--wp--preset--color--base);
	color: inherit;
	font: 0.9rem/1.2 var(--wp--preset--font-family--body);
}

.jy-hb-readform input {
	width: 5.5rem;
}

a.jy-hb-plus {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	text-decoration: none;
}

.jy-hb__sum strong {
	background: none !important;
	box-shadow: none !important;
}
