/* =========================================================================
   Layout "tabs" — Today · Directives · Habits (2026-10-27, MDLAYOUT layout 02 + Directives C).
   Positions only: colours, type and sizes stay the skin's (hud.css tokens, or skin-instrument.css).
   Loaded by hud.php only when Layout = Tabs, so the one-screen layout is untouched.
   ========================================================================= */

/* header: screen tabs sit left of the LOG flag; the timer chip follows them on Directives and Habits */
.md-layout-tabs .bar-mid { align-items: center; flex-wrap: wrap; }
.p-tabs { display: flex; gap: 8px; }
.p-tab { font-size: 16px; padding: 7px 22px; }
.p-timer { white-space: nowrap; }

/* Now strip: label · title · project · actions, one line */
.p-now { grid-area: now; display: flex; align-items: center; gap: 18px; padding: 14px 20px; }
.p-now-k { color: var(--md-ink-dim); font-size: var(--md-fs-label); letter-spacing: .24em; white-space: nowrap; }
.p-now-title { flex: 1; min-width: 0; color: var(--md-ink); font-size: 19px; letter-spacing: .02em; }
.p-now.empty .p-now-title { color: var(--md-ink-dim); }
.p-now .p-act { padding: 7px 16px; font-size: 14px; }

/* Directives chip row and list label */
.p-chips { grid-area: chips; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.p-chips-k { color: var(--md-ink-dim); font-size: var(--md-fs-label); letter-spacing: .24em; margin-right: 8px; }
.p-sub { color: var(--md-ink-dim); font-size: var(--md-fs-label); letter-spacing: .24em; margin: 4px 0 6px; }
.p-rail { position: absolute; width: 2px; background: var(--md-line); pointer-events: none; z-index: 0; }

/* every screen hides what isn't its own */
.md-layout-tabs #todoTabs { display: none; }
.md-layout-tabs[data-screen="today"] .panel-todos,
.md-layout-tabs[data-screen="today"] .panel-habits,
.md-layout-tabs[data-screen="today"] .p-chips { display: none; }
.md-layout-tabs[data-screen="directives"] .mission,
.md-layout-tabs[data-screen="directives"] .rail-plan,
.md-layout-tabs[data-screen="directives"] .col-ring,
.md-layout-tabs[data-screen="directives"] .panel-habits,
.md-layout-tabs[data-screen="directives"] .panel-sessions,
.md-layout-tabs[data-screen="directives"] .col-tiles { display: none; }
.md-layout-tabs[data-screen="habits"] .mission,
.md-layout-tabs[data-screen="habits"] .rail-plan,
.md-layout-tabs[data-screen="habits"] .col-ring,
.md-layout-tabs[data-screen="habits"] .panel-todos,
.md-layout-tabs[data-screen="habits"] .panel-sessions,
.md-layout-tabs[data-screen="habits"] .col-tiles,
.md-layout-tabs[data-screen="habits"] .p-chips,
.md-layout-tabs[data-screen="habits"] .p-now { display: none; }

/* Directives: the add field carries its project picker inline, so the screen has one chip row (the filter) */
.md-layout-tabs[data-screen="directives"] .todo-form { display: flex; align-items: center; gap: 12px; }
.md-layout-tabs[data-screen="directives"] #todoInput { flex: 1 1 auto; min-width: 0; }
.md-layout-tabs[data-screen="directives"] .todo-pick { margin-top: 0; flex: none; flex-wrap: nowrap; }
.md-layout-tabs[data-screen="directives"] .todo-pick[hidden] { display: none; }

/* Habits: the list left, the daily review right */
.md-layout-tabs[data-screen="habits"] .panel-habits {
	display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); grid-template-rows: auto 1fr; column-gap: 48px; align-content: start;
}
.md-layout-tabs[data-screen="habits"] .panel-habits > .panel-k:first-of-type { grid-column: 1; grid-row: 1; }
.md-layout-tabs[data-screen="habits"] #habitList { grid-column: 1; grid-row: 2; }
.md-layout-tabs[data-screen="habits"] .panel-habits > .panel-k.gap-top { grid-column: 2; grid-row: 1; margin-top: 0; }
.md-layout-tabs[data-screen="habits"] #videoZone { grid-column: 2; grid-row: 2; }

/* ---- wide screens (≥1181px): one screen tall, no page scroll; panels fill their cell ---- */
/* fit-to-screen only when the window is tall enough to hold Today (measured 1046px stack → ≥1046px); a shorter window (an iPad in landscape)
   scrolls the page instead of clipping it (QA round 19) */
@media (min-width: 1181px) and (min-height: 1046px) {
	/* one screen tall; a day that needs more height scrolls the page instead of clipping (QA round 22) */
	body.md-layout-tabs { height: 100vh; overflow-x: hidden; overflow-y: auto; }
	/* Today's deck never shrinks below its content: a long day grows the page (and it scrolls) instead of running into the footer */
	.md-layout-tabs[data-screen="today"] .deck { min-height: auto; flex: 1 1 0; } /* basis 0: fill the free height, never below content */
	/* …and Today's page grows with it, so body-anchored pieces (attribution lane, Classic's corners) stay at its foot */
	body.md-layout-tabs[data-screen="today"] { height: auto; min-height: 100vh; }
	.md-layout-tabs .deck { flex: 1 1 auto; min-height: 0; align-items: stretch; }
	.md-layout-tabs[data-screen="directives"] .panel-todos,
	.md-layout-tabs[data-screen="habits"] .panel-habits { overflow-y: auto; }
}
@media (min-width: 1181px) {
	.md-layout-tabs .deck-rail .panel-todos, .md-layout-tabs .deck-rail .panel-habits { max-height: none; }
	.md-layout-tabs[data-screen="today"] .deck {
		grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr) minmax(0, 1.05fr);
		grid-template-rows: auto auto minmax(min-content, 1fr);
		grid-template-areas: "plan plan plan" "now now now" "sess ring tiles";
	}
	.md-layout-tabs[data-screen="directives"] .deck {
		grid-template-columns: minmax(0, 1fr);
		grid-template-rows: auto auto minmax(0, 1fr);
		grid-template-areas: "now" "chips" "dir";
	}
	.md-layout-tabs[data-screen="habits"] .deck {
		grid-template-columns: minmax(0, 1fr);
		grid-template-rows: minmax(0, 1fr);
		grid-template-areas: "habits";
	}
}

/* ---- phones and tablets (≤1180px): one column that scrolls; the tabs take the header's full width ---- */
@media (max-width: 1180px) {
	.md-layout-tabs .bar-mid { order: 3; flex-basis: 100%; }
	.md-layout-tabs .p-tabs { flex: 1 1 100%; }
	.md-layout-tabs .p-tab { flex: 1 1 0; padding: 9px 6px; }
	.md-layout-tabs[data-screen="today"] .deck { grid-template-areas: "now" "ring" "plan" "sess" "tiles"; }
	.md-layout-tabs[data-screen="directives"] .deck { grid-template-areas: "now" "chips" "dir"; }
	.md-layout-tabs[data-screen="habits"] .deck { grid-template-areas: "habits"; }
	.md-layout-tabs .p-now { flex-wrap: wrap; gap: 10px 14px; }
	.md-layout-tabs .p-now-title { flex-basis: 100%; order: 2; }
	.md-layout-tabs .p-now-k { order: 1; }
	.md-layout-tabs .p-now-chip, .md-layout-tabs .p-now .p-act { order: 3; }
	.md-layout-tabs[data-screen="directives"] .todo-form { flex-wrap: wrap; }
	.md-layout-tabs[data-screen="directives"] .todo-pick { flex-wrap: wrap; flex-basis: 100%; }
	.md-layout-tabs[data-screen="habits"] .panel-habits { grid-template-columns: minmax(0, 1fr); }
	.md-layout-tabs[data-screen="habits"] .panel-habits > .panel-k.gap-top { grid-column: 1; grid-row: 3; }
	.md-layout-tabs[data-screen="habits"] #videoZone { grid-column: 1; grid-row: 4; }
}

/* one gap down the whole screen at every width (D-S21): header, mission, deck rows and footer all sit 12px apart —
   the deck's own gap. The layout owns the stack, so a skin's margins never add to it. */
body.md-layout-tabs { display: flex; flex-direction: column; row-gap: 12px; }
body.md-layout-tabs .bar, body.md-layout-tabs .mission, body.md-layout-tabs .hud-foot { margin-top: 0 !important; margin-bottom: 0 !important; }
body.md-layout-tabs .deck { margin: 0; gap: 12px; }
.md-layout-tabs .tile-grid { gap: 12px; }

/* Habits panel: heading, list, review heading, review — one 12px step (two columns on wide screens) */
.md-layout-tabs[data-screen="habits"] .panel-habits { row-gap: 12px; }
.md-layout-tabs[data-screen="habits"] .panel-habits > .panel-k { margin: 0 !important; }

/* Directives panel: heading → field → list label → list on the same 12px step */
.md-layout-tabs .panel-todos > .panel-k { margin-bottom: 12px; }
.md-layout-tabs[data-screen="directives"] .todo-form { margin-bottom: 12px; }
/* the timer chip has its own slot at the right of the header, so the screen tabs never move when a session starts */
.md-layout-tabs .p-sub { margin: 18px 0 0; } /* the list's label sits with its list (proximity): 20px from the field, the rows' own top padding below */
/* a row's label sits one chip-gap from its chips */
.md-layout-tabs .p-chips-k { margin-right: 0; }
/* habit rows: the dot's column hugs the dot, so every gap in the row is the grid gap */
.md-layout-tabs[data-screen="habits"] .habit-item { grid-template-columns: auto minmax(0, 1fr) minmax(0, 2fr) 64px; }

/* header as three columns with equal sides, so the screen tabs sit in the same place whatever the sides hold (QA round 19) */
@media (min-width: 1181px) {
	.md-layout-tabs .bar { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; }
	.md-layout-tabs .bar-right { justify-self: end; justify-content: flex-end; }
}

/* a logged-out viewer (phone, TV kiosk) never sees operator controls, whatever a skin's display rules say (QA round 19) */
.is-readonly .btn, .is-readonly .todo-form, .is-readonly .p-act, .is-readonly .todo-pin, .is-readonly .todo-del, .is-readonly .todo-sub { display: none !important; }
/* hidden means hidden (.todo-proj / .todo-tab set their own display) */
.p-now-chip[hidden], #timerChip[hidden] { display: none !important; }

.todo-form[hidden] { display: none !important; }
/* the timer chip never makes the header taller than the clock line (QA round 21: +2px moved every screen) */
.md-layout-tabs .p-timer { padding-top: 3px !important; padding-bottom: 3px !important; line-height: 1.25; }
/* Classic's wide type can't fit chip + date + clock in the header's right column: the date steps aside while a
   session runs on Directives or Habits (Today still shows it) */
.md-skin-classic.md-layout-tabs .bar-right:has(#timerChip:not([hidden])) #clockDate { display: none; }

/* the pinned current row has no drag handle in any look (it leads by rule) */
.md-layout-tabs .todo-group:not([draggable]) > .todo-item.pinned .drag-handle { visibility: hidden; }

/* credit in the footer row (Tabs): no reserved bottom strip, so a giveaway install fits the screen like Matt's */
.md-layout-tabs .attribution.in-foot { position: static; margin-left: auto; white-space: nowrap; line-height: 1.25; }
.md-layout-tabs .ticker { flex: 1 1 auto; min-width: 0; }
body.md-hud.md-layout-tabs.has-attr { padding-bottom: 48px; }
@media (min-width: 1181px) { body.md-hud.md-layout-tabs.has-attr { padding-bottom: 20px; } }

/* ---- Diet (2026-11-10, FATLOSS): the day's food left, rules · targets · pills, then the slips and checks. Only on installs with md_diet. ---- */
.md-layout-tabs:not([data-screen="diet"]) .panel-diet { display: none; }
.md-layout-tabs[data-screen="diet"] .mission,
.md-layout-tabs[data-screen="diet"] .rail-plan,
.md-layout-tabs[data-screen="diet"] .col-ring,
.md-layout-tabs[data-screen="diet"] .panel-todos,
.md-layout-tabs[data-screen="diet"] .panel-habits,
.md-layout-tabs[data-screen="diet"] .panel-sessions,
.md-layout-tabs[data-screen="diet"] .col-tiles,
.md-layout-tabs[data-screen="diet"] .p-chips,
.md-layout-tabs[data-screen="diet"] .p-now { display: none; }
.deck-rail .panel-diet { grid-area: diet; }
.md-layout-tabs .panel-diet {
	display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr) minmax(0, 1fr); column-gap: 48px; align-content: start; align-items: start;
}
.md-layout-tabs .diet-col { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.md-layout-tabs .diet-sec { display: flex; flex-direction: column; gap: 12px; }
.md-layout-tabs .diet-sec + .diet-sec { margin-top: 12px; }
.md-layout-tabs .panel-diet .panel-k { margin: 0 !important; }
.md-layout-tabs .diet-note { margin: 0; color: var(--md-ink-dim); }
.md-layout-tabs .diet-meal { display: grid; grid-template-columns: 88px minmax(0, 1fr) auto; column-gap: 20px; align-items: baseline; padding: 12px 0; border-top: 1px solid var(--md-line); }
.md-layout-tabs .diet-time { color: var(--md-ink); font-weight: 600; white-space: nowrap; }
.md-layout-tabs .diet-name { color: var(--md-ink); font-weight: 600; }
.md-layout-tabs .diet-what { color: var(--md-ink-dim); margin-top: 4px; }
.md-layout-tabs .diet-macros { display: flex; flex-direction: column; align-items: flex-end; text-align: right; white-space: nowrap; color: var(--md-ink); }
.md-layout-tabs .diet-macros b { font-weight: 600; }
.md-layout-tabs .diet-macros .dim { color: var(--md-ink-dim); }
.md-layout-tabs .diet-total { border-top-color: var(--md-ink); }
.md-layout-tabs .diet-list { margin: 0; padding-left: 1.25em; display: flex; flex-direction: column; gap: 8px; color: var(--md-ink); line-height: 1.4; }
@media (min-width: 1181px) {
	.md-layout-tabs[data-screen="diet"] .deck {
		grid-template-columns: minmax(0, 1fr);
		grid-template-rows: minmax(0, 1fr);
		grid-template-areas: "diet";
	}
}
@media (min-width: 1181px) and (min-height: 1046px) {
	.md-layout-tabs[data-screen="diet"] .panel-diet { overflow-y: auto; }
}
@media (max-width: 1180px) {
	.md-layout-tabs[data-screen="diet"] .deck { grid-template-areas: "diet"; }
	.md-layout-tabs .panel-diet { grid-template-columns: minmax(0, 1fr); row-gap: 24px; }
}
@media (max-width: 560px) {
	.md-layout-tabs .diet-meal { grid-template-columns: minmax(0, 1fr); row-gap: 8px; }
	.md-layout-tabs .diet-macros { flex-direction: row; flex-wrap: wrap; align-items: baseline; justify-content: flex-start; gap: 4px 12px; text-align: left; }
}
/* the next meal says so in a word (B-97: a word, not a colour or a box); it sits under its time */
.md-layout-tabs .diet-next { display: block; margin-top: 4px; color: var(--md-ink); font-weight: 600; }
.md-layout-tabs .diet-next[hidden] { display: none; }
@media (max-width: 560px) { .md-layout-tabs .diet-next { display: inline; margin: 0 0 0 10px; } }
