/* App shell: side menu, toolbar, phone bars and the "Więcej" sheet, Agent panel. Then Plan (month, list) and Skrzynka. */
body.signed-in .workspace { max-width: none; padding: 0; }
#studio:not([hidden]) { display: grid; grid-template-columns: 256px minmax(0, 1fr) 364px; min-height: 100vh; min-height: 100dvh; }
#studio.agent-hidden { grid-template-columns: 256px minmax(0, 1fr); }
#studio.agent-hidden .agent-panel { display: none; }
.studio-body { width: 100%; max-width: 1200px; min-width: 0; margin: 0 auto; padding: 0 clamp(20px, 2vw, 32px) var(--space-12); }

/* ---- Side menu: a grey tile that floats in the window ---- */
.sidebar { position: sticky; top: var(--shell-gap); display: flex; flex-direction: column; gap: var(--space-2); height: calc(100vh - 2 * var(--shell-gap)); height: calc(100dvh - 2 * var(--shell-gap));
  margin: var(--shell-gap) 0 var(--shell-gap) var(--shell-gap); padding: var(--space-4) var(--space-3) var(--space-3); border-radius: var(--radius-xl); background: var(--color-tile); }
.app-nav-brand { display: flex; align-items: center; min-height: 48px; padding: 0 10px var(--space-2); }
.app-nav-brand img { display: block; width: auto; height: auto; max-width: 160px; max-height: 40px; object-fit: contain; }
.app-nav-brand .brand-wordmark { max-width: 200px; font-size: var(--text-headline); }
.nav-sheet { display: contents; }
.nav-sheet-heading, .tab-bar, .nav-backdrop { display: none; }
.app-nav { flex: 1 1 auto; min-height: 0; overflow-y: auto; margin: 0 calc(-1 * var(--space-1)); padding: 0 var(--space-1) var(--space-1); scrollbar-width: thin; }
.app-nav-links { display: flex; flex-direction: column; gap: var(--space-3); }
.nav-group { display: flex; flex-direction: column; gap: 2px; }
.nav-group:not(:has(a:not([hidden]))) { display: none; }
.nav-group-title { margin: var(--space-1) 12px 4px; color: var(--color-text-3); font-size: var(--text-caption); font-weight: 600; }
.app-nav a, .app-nav-item { display: flex; align-items: center; justify-content: flex-start; gap: 12px; width: 100%; min-height: 40px; margin: 0; padding: 0 12px; border: 0; border-radius: var(--radius-md);
  background: none; color: var(--color-text); font: inherit; font-size: var(--text-body); font-weight: 500; text-align: left; text-decoration: none; cursor: pointer; transition: background-color var(--duration-fast), color var(--duration-fast), box-shadow var(--duration-fast); }
.app-nav a:hover, .app-nav-item:hover:not(:disabled) { background: var(--color-fill); text-decoration: none; }
.app-nav a[aria-current="page"] { background: var(--color-surface); box-shadow: var(--shadow-card); font-weight: 600; }
.nav-icon { width: 20px; height: 20px; flex: 0 0 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.nav-icon-dots { stroke-width: 3; }
.app-nav a .nav-icon, .app-nav-item .nav-icon { color: var(--color-text-2); }
.app-nav a[aria-current="page"] .nav-icon { color: var(--color-accent); }
.nav-count { margin-left: auto; min-width: 20px; color: var(--color-text-3); font-size: var(--text-footnote); font-weight: 600; line-height: 20px; text-align: right; font-variant-numeric: tabular-nums; }
/* The account: a white card at the foot of the menu, with the way out beside it. */
.app-nav-account { display: flex; align-items: center; gap: 6px; padding: 6px; border-radius: var(--radius-row); background: var(--color-surface); box-shadow: var(--shadow-card); }
.app-nav-account .app-nav-item { border-radius: var(--radius-md); }
.app-nav-user { flex: 1 1 auto; min-width: 0; min-height: 44px; padding: 0 6px; gap: 10px; }
.nav-avatar { display: grid; place-items: center; flex: 0 0 36px; width: 36px; height: 36px; border-radius: 50%; background: var(--color-fill); color: var(--color-text); font-size: var(--text-body); font-weight: 600; text-transform: uppercase; }
.app-nav-user-copy { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.app-nav-user-copy > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.app-nav-user-copy small { color: var(--color-text-3); font-size: var(--text-caption); font-weight: 400; }
#logout { flex: 0 0 40px; justify-content: center; width: 40px; min-height: 40px; padding: 0; border-radius: 50%; background: var(--color-tile); }
#logout:hover { background: var(--color-fill); }
#logout > span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* ---- Toolbar: the bell and the Agent stay at the top right of the content ---- */
.studio-toolbar { position: sticky; top: 0; z-index: 25; display: flex; justify-content: flex-end; align-items: center; gap: var(--space-2); height: 68px; margin-bottom: calc(-1 * var(--space-2)); pointer-events: none; }
.studio-toolbar > * { pointer-events: auto; }
.toolbar-button { position: relative; flex: 0 0 var(--control-height); width: var(--control-height); padding: 0; border-radius: 50%; background: rgba(240, 240, 243, .82); color: var(--color-text);
  -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px); }
.toolbar-button:hover:not(:disabled) { background: var(--color-fill); }
.toolbar-button .nav-icon { width: 18px; height: 18px; flex-basis: 18px; }
.notification-count { position: absolute; top: -3px; right: -3px; min-width: 20px; padding: 0 5px; border: 2px solid var(--color-bg); border-radius: var(--radius-pill); background: #e30000; color: #fff; font-size: 11px; font-weight: 700; line-height: 16px; text-align: center; }
.toolbar-agent { gap: 8px; padding: 0 16px 0 12px; background: rgba(240, 240, 243, .82); color: var(--color-text); -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px); }
.toolbar-agent:hover:not(:disabled) { background: var(--color-fill); }
.toolbar-agent[aria-expanded="true"] { background: var(--color-ink); color: #fff; }
.toolbar-agent[aria-expanded="true"]:hover:not(:disabled) { background: #333336; }
.agent-spark { width: 18px; height: 18px; flex: 0 0 18px; }
/* The Agent cannot work right now: a small mark on its button; the panel says why. */
.toolbar-agent { position: relative; }
.toolbar-agent.is-unavailable::after { content: ""; position: absolute; top: -2px; right: -2px; width: 10px; height: 10px; border: 2px solid var(--color-bg); border-radius: 50%; background: var(--color-warning-fill); }

/* ---- Agent panel: a white sheet that floats beside the content ---- */
.agent-panel { position: sticky; top: var(--shell-gap); display: flex; flex-direction: column; gap: var(--space-3); height: calc(100vh - 2 * var(--shell-gap)); height: calc(100dvh - 2 * var(--shell-gap)); min-width: 0;
  margin: var(--shell-gap) var(--shell-gap) var(--shell-gap) 0; padding: 18px; border-radius: var(--radius-xl); background: var(--color-surface); box-shadow: 0 0 0 1px rgba(0, 0, 0, .06), 0 18px 48px rgba(0, 0, 0, .10); }
.agent-panel-heading { display: flex; align-items: center; gap: var(--space-3); }
.agent-mark { display: grid; place-items: center; flex: 0 0 36px; width: 36px; height: 36px; border-radius: var(--radius-md); background: var(--color-ink); color: #fff; }
.agent-mark svg { width: 20px; height: 20px; }
.agent-panel-title { flex: 1 1 auto; min-width: 0; }
.agent-panel-heading h2 { font-size: var(--text-headline); letter-spacing: -.01em; }
.agent-panel-heading p { margin: 0; font-size: var(--text-footnote); color: var(--color-text-3); }
.agent-panel-heading .button-square { width: 36px; min-width: 36px; height: 36px; min-height: 36px; font-size: 18px; color: var(--color-text-2); background: var(--color-tile); }
.agent-panel-heading .button-square:hover { background: var(--color-fill); }
.agent-unavailable { margin: 0; padding: 10px 14px; border-radius: var(--radius-row); background: var(--color-warning-soft); color: var(--color-warning); font-size: var(--text-footnote); }
.agent-unavailable strong { font-weight: 600; }
.agent-messages { flex: 1; display: flex; flex-direction: column; gap: var(--space-2); overflow-y: auto; overscroll-behavior: contain; padding: 2px; }
.agent-message { max-width: 90%; padding: 10px 14px; border-radius: var(--radius-row); border-bottom-left-radius: 4px; background: var(--color-tile); color: var(--color-text); font-size: var(--text-body); line-height: 1.45; white-space: pre-wrap; overflow-wrap: anywhere; animation: toast-in var(--duration) var(--ease-out); }
.agent-message.from-user { align-self: flex-end; border-radius: var(--radius-row); border-bottom-right-radius: 4px; background: var(--color-accent); color: #fff; }
.agent-message.is-pending { color: var(--color-text-2); font-style: italic; }
.agent-message.is-failed { background: var(--color-danger-soft); color: var(--color-danger); }
.agent-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.agent-actions button { min-height: 32px; padding: 0 12px; background: var(--color-surface); color: var(--color-accent-text); font-size: var(--text-footnote); box-shadow: var(--shadow-card); }
.agent-actions button:hover:not(:disabled) { background: var(--color-accent-soft); }
.agent-actions .is-done { background: var(--color-success-soft); color: var(--color-success); }
.agent-empty { padding: 12px 14px; border-radius: 12px 12px 12px 4px; background: var(--color-tile); color: var(--color-text); font-size: var(--text-body); line-height: 1.45; }
.agent-suggestions { display: flex; flex-direction: column; align-items: flex-start; gap: var(--space-2); margin-top: var(--space-3); }
.agent-suggestions button { justify-content: flex-start; min-height: 40px; padding: 9px 14px; border: 1px solid var(--color-border); border-radius: var(--radius-row); background: var(--color-surface); color: var(--color-text); font-size: 14px; font-weight: 500; line-height: 1.35; text-align: left; }
.agent-suggestions button:hover:not(:disabled) { border-color: var(--color-control-border); background: var(--color-tile); }
.agent-form { display: flex; align-items: flex-end; gap: var(--space-2); padding: 6px 6px 6px 16px; border-radius: var(--radius-lg); background: var(--color-tile); transition: box-shadow var(--duration-fast); }
.agent-form:focus-within { box-shadow: 0 0 0 2px var(--color-accent); }
.agent-form textarea { flex: 1 1 auto; min-height: 36px; max-height: 160px; padding: 8px 0; border: 0; border-radius: 0; background: none; box-shadow: none; resize: none; field-sizing: content; }
.agent-form textarea:focus { box-shadow: none; }
.agent-form textarea:disabled { background: none; }
.agent-send { flex: 0 0 36px; width: 36px; min-height: 36px; height: 36px; padding: 0; border-radius: 50%; }
.agent-send .ui-icon { width: 18px; height: 18px; stroke-width: 2.4; }

/* ---- Segmented controls (one look for every view switch) ---- */
.segmented, .plan-modes, .workshop-preview-tabs, .review-tabs, .publish-seg { display: inline-flex; flex-wrap: nowrap; gap: 2px; max-width: 100%; padding: 3px; border: 0; border-radius: var(--radius-control); background: var(--color-fill); overflow-x: auto; scrollbar-width: none; }
.segmented button, .plan-modes button, .workshop-preview-tab, .review-tab, .publish-seg-tab { flex: 0 0 auto; min-height: calc(var(--control-height) - 6px); padding: 0 18px; border: 0; border-radius: var(--radius-md); background: transparent; color: var(--color-text); font-size: 14px; font-weight: 500; white-space: nowrap; }
.segmented button:hover, .plan-modes button:hover, .workshop-preview-tab:hover, .review-tab:hover, .publish-seg-tab:hover { background: rgba(0, 0, 0, .05); }
.segmented button[aria-pressed="true"], .plan-modes button[aria-pressed="true"], .workshop-preview-tab.is-on, .review-tab.is-on, .publish-seg-tab.is-on {
  background: var(--color-surface); box-shadow: 0 1px 3px rgba(0, 0, 0, .14); font-weight: 600; }

/* ---- Plan: toolbar, month, list ---- */
.calendar-toolbar-end { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-3); }
.month-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; padding: var(--space-3); border-radius: var(--radius-xl); background: var(--color-tile); }
.month-weekday { padding: 6px 4px 8px; color: var(--color-text-3); font-size: var(--text-footnote); font-weight: 600; text-align: center; }
.month-day { display: flex; flex-direction: column; gap: 3px; min-width: 0; min-height: 112px; padding: 6px; border-radius: var(--radius-md); background: var(--color-surface); box-shadow: var(--shadow-card); transition: background-color var(--duration-fast); }
.month-day.is-other { background: transparent; box-shadow: none; }
.month-day.is-other .month-day-number { color: var(--color-text-3); }
.month-day-number { display: flex; justify-content: space-between; align-items: center; min-height: 28px; color: var(--color-text); font-size: var(--text-footnote); font-weight: 600; }
.month-day-number > span { display: grid; place-items: center; min-width: 28px; height: 28px; padding: 0 4px; border-radius: var(--radius-pill); }
.month-day.is-today .month-day-number > span { background: var(--color-accent); color: #fff; }
.month-day-add { width: 26px; min-width: 26px; min-height: 26px; padding: 0; border-radius: 50%; background: none; color: var(--color-text-3); font-size: 17px; font-weight: 400; line-height: 1; opacity: 0; }
.month-day-add:hover { background: var(--color-accent-soft); color: var(--color-accent-text); }
.month-day:hover .month-day-add, .month-day-add:focus-visible { opacity: 1; }
@media (hover: none) { .month-day-add { opacity: 1; } }
.month-chip { display: block; width: 100%; min-height: 0; padding: 3px 8px; border-radius: 8px; background: var(--color-fill-soft); color: var(--color-text); font-size: var(--text-caption); font-weight: 500; line-height: 1.4;
  text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; }
.month-chip[draggable="true"] { cursor: grab; }
.month-chip-time { font-weight: 600; font-variant-numeric: tabular-nums; }
.month-chip.is-ready { background: var(--color-success-soft); color: var(--color-success); }
.month-chip:hover { filter: brightness(.96); }
[draggable="true"].is-dragging { opacity: .4; }
.is-drop-target { outline: 2px dashed var(--color-accent); outline-offset: -2px; background: var(--color-accent-soft) !important; }

.post-filters { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; }
.post-filters input[type="search"] { flex: 1 1 240px; width: auto; }
.post-filters select { width: auto; min-width: 150px; border-radius: var(--radius-control); padding-left: 16px; }
.filter-check { display: flex; align-items: center; gap: 8px; min-height: var(--control-height); margin: 0; font-weight: 500; }
#plan-list-count { margin: var(--space-3) 4px var(--space-2); }
.plan-list { display: flex; flex-direction: column; gap: var(--space-2); padding: var(--space-3); border-radius: var(--radius-xl); background: var(--color-tile); }
.plan-list:has(> .inbox-empty) { padding: 0; background: none; }
.plan-row { display: grid; grid-template-columns: 116px minmax(0, 1fr) auto; gap: var(--space-4); align-items: center; width: 100%; min-height: 64px; padding: 10px var(--space-4);
  border: 0; border-radius: var(--radius-row); background: var(--color-surface); box-shadow: var(--shadow-card); color: var(--color-text); font: inherit; text-align: left; cursor: pointer; }
.plan-row:hover { box-shadow: var(--shadow-card), 0 6px 16px rgba(0, 0, 0, .07); }
.plan-row-date { font-size: var(--text-footnote); font-weight: 600; color: var(--color-text-2); font-variant-numeric: tabular-nums; }
.plan-row > span { display: block; min-width: 0; }
.plan-row-title { display: block; font-weight: 600; font-size: var(--text-body); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.plan-row-meta { display: block; font-size: var(--text-footnote); color: var(--color-text-2); font-weight: 400; }

/* ---- Skrzynka ---- */
.inbox-list { display: flex; flex-direction: column; gap: var(--space-2); }
.inbox-group-heading { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: baseline; justify-content: space-between; margin: var(--space-5) 0 var(--space-2); padding: 0 4px; }
.inbox-group-heading h2 { font-size: var(--text-title-3); }
.inbox-group-items { display: flex; flex-direction: column; gap: var(--space-2); padding: var(--space-3); border-radius: var(--radius-xl); background: var(--color-tile); }
.inbox-item { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: var(--space-2) var(--space-4); padding: 14px var(--space-4); border-radius: var(--radius-row); background: var(--color-surface); box-shadow: var(--shadow-card); }
.inbox-item-body { display: flex; flex: 1 1 300px; flex-direction: column; gap: 4px; min-width: 0; overflow-wrap: anywhere; }
.inbox-item p { margin: 0; font-size: var(--text-footnote); }
.inbox-item strong { font-size: var(--text-body); color: var(--color-text); }
.inbox-item .inline-actions { flex-shrink: 0; flex-wrap: wrap; justify-content: flex-end; align-items: center; gap: 4px; margin: 0 0 0 auto; }
.inbox-item .inline-actions input { width: auto; flex: 1 1 200px; min-height: 40px; }
.inbox-item .inline-actions .button-secondary { background: var(--color-accent-soft); color: var(--color-accent-text); }
.inbox-item .inline-actions .button-secondary:hover:not(:disabled) { background: #d6e8fb; }
.inbox-item.is-agent { background: var(--color-surface); box-shadow: var(--shadow-card), inset 3px 0 0 var(--color-warning-fill); }
.inbox-item.is-failed { background: var(--color-danger-soft); box-shadow: none; }
.inbox-item.is-read strong { font-weight: 500; }
.inbox-item.is-removed { opacity: .65; }
.inbox-dot { width: 8px; height: 8px; flex-shrink: 0; align-self: center; border-radius: 50%; background: transparent; }
.inbox-item.is-new .inbox-dot { background: var(--color-accent); }
.inbox-tags { display: flex; flex-wrap: wrap; gap: 4px 6px; }
.inbox-tag { padding: 0 9px; border-radius: var(--radius-badge); background: var(--color-fill-soft); color: #48484a; font-size: var(--text-caption); font-weight: 600; line-height: 22px; }
.inbox-why { margin-top: 2px !important; color: var(--color-text-3); }
/* "Więcej": mark as read or unread, remove from Skrzynka. */
.inbox-more { position: relative; }
.inbox-more > summary { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; color: var(--color-text-2); font-weight: 700; letter-spacing: 1px; list-style: none; }
.inbox-more > summary::-webkit-details-marker { display: none; }
.inbox-more > summary:hover, .inbox-more[open] > summary { background: var(--color-fill-soft); color: var(--color-text); }
.inbox-menu { position: absolute; top: calc(100% + 4px); right: 0; z-index: 20; display: flex; flex-direction: column; min-width: 230px; padding: 6px; border-radius: var(--radius-row); background: var(--color-surface); box-shadow: var(--shadow-raised); }
.inbox-menu button { justify-content: flex-start; gap: 10px; min-height: 40px; padding: 0 12px; border-radius: var(--radius-md); background: none; color: var(--color-text); font-weight: 400; text-align: left; white-space: nowrap; }
.inbox-menu button:hover:not(:disabled) { background: var(--color-fill-soft); }
.inbox-menu .inbox-remove { color: var(--color-danger); }
.inbox-menu .inbox-remove:hover:not(:disabled) { background: var(--color-danger-soft); }
.inbox-toolbar { display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center; gap: var(--space-2); }
.inbox-undo { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px 12px; padding: 8px 8px 8px var(--space-4); border-radius: var(--radius-lg); background: var(--color-surface); box-shadow: var(--shadow-raised);
  color: var(--color-text-2); font-size: var(--text-footnote); animation: toast-in var(--duration) var(--ease-out); }
.inbox-empty { padding: var(--space-12) var(--space-6); border-radius: var(--radius-xl); background: var(--color-tile); color: var(--color-text-2); font-size: var(--text-headline); text-align: center; }

/* ---- Narrower windows ---- */
@media (max-width: 1280px) {
  #studio:not([hidden]) { grid-template-columns: 240px minmax(0, 1fr) 340px; }
  #studio.agent-hidden { grid-template-columns: 240px minmax(0, 1fr); }
}
@media (max-width: 1080px) {
  #studio:not([hidden]), #studio.agent-hidden { grid-template-columns: 240px minmax(0, 1fr); }
  .agent-panel { position: fixed; top: var(--shell-gap); right: var(--shell-gap); bottom: var(--shell-gap); z-index: 40; width: min(400px, calc(100% - 2 * var(--shell-gap))); height: auto; margin: 0; box-shadow: var(--shadow-sheet); animation: panel-in var(--duration) var(--ease-out); }
}
@keyframes panel-in { from { transform: translateX(24px); opacity: 0; } }

/* ---- Phone: a top bar, a floating glass tab bar, and the rest of the menu in a sheet ---- */
@media (max-width: 760px) {
  #studio:not([hidden]), #studio.agent-hidden { grid-template-columns: minmax(0, 1fr); }
  .studio-body { padding: 68px var(--space-4) calc(112px + env(safe-area-inset-bottom)); }
  .sidebar { display: contents; }
  .app-nav-brand { position: fixed; top: 0; left: 0; z-index: 32; height: 60px; min-height: 0; padding: 0 0 0 var(--space-4); }
  .app-nav-brand img { max-width: 130px; max-height: 34px; }
  .sidebar .app-nav-brand { width: auto; overflow: visible; }
  .studio-toolbar { position: fixed; top: 0; left: 0; right: 0; z-index: 31; height: 60px; margin: 0; padding: 0 var(--space-3); pointer-events: auto;
    background: var(--material-bar); -webkit-backdrop-filter: saturate(180%) blur(22px); backdrop-filter: saturate(180%) blur(22px); }
  .toolbar-button, .toolbar-agent { background: var(--color-fill-soft); -webkit-backdrop-filter: none; backdrop-filter: none; }
  .toolbar-agent { width: 44px; padding: 0; border-radius: 50%; background: var(--color-ink); }
  .toolbar-agent[aria-expanded="false"] { background: var(--color-ink); }
  .toolbar-agent > span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .agent-spark { width: 22px; height: 22px; flex-basis: 22px; }

  .tab-bar { position: fixed; left: 14px; right: 14px; bottom: calc(14px + env(safe-area-inset-bottom)); z-index: 30; display: flex; align-items: center; height: 66px; padding: 0 6px; border-radius: var(--radius-xl);
    background: var(--material-bar); -webkit-backdrop-filter: saturate(180%) blur(22px); backdrop-filter: saturate(180%) blur(22px); box-shadow: 0 0 0 1px rgba(0, 0, 0, .06), 0 12px 34px rgba(0, 0, 0, .16); }
  .tab-bar a, .tab-bar button { position: relative; display: flex; flex: 1 1 0; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-width: 0; height: 54px; min-height: 54px; padding: 0 2px;
    border: 0; border-radius: var(--radius-control); background: none; color: #48484a; font-size: 11px; font-weight: 600; line-height: 1.2; text-decoration: none; }
  .tab-bar .nav-icon { width: 22px; height: 22px; flex-basis: 22px; stroke-width: 1.9; }
  .tab-label { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .tab-bar a[aria-current="page"], .tab-bar button.is-current, .tab-bar button[aria-expanded="true"] { background: rgba(0, 0, 0, .06); color: var(--color-accent-text); }
  .tab-bar .nav-count { position: absolute; top: 3px; left: calc(50% + 6px); min-width: 18px; margin: 0; padding: 0 5px; border-radius: var(--radius-pill); background: #e30000; color: #fff; font-size: 11px; line-height: 18px; text-align: center; }

  .nav-backdrop { position: fixed; inset: 0; z-index: 55; display: block; background: var(--color-scrim); animation: fade-in var(--duration) ease-out; }
  .nav-sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 60; display: flex; flex-direction: column; max-height: calc(100dvh - 48px); padding: 0 var(--space-4) calc(var(--space-4) + env(safe-area-inset-bottom));
    border-radius: var(--radius-xl) var(--radius-xl) 0 0; background: var(--color-bg); box-shadow: var(--shadow-sheet); overflow-y: auto; overscroll-behavior: contain;
    visibility: hidden; transform: translateY(104%); transition: transform .32s var(--ease-out), visibility 0s .32s; }
  body.nav-open .nav-sheet { visibility: visible; transform: none; transition: transform .32s var(--ease-out), visibility 0s; }
  body.nav-open { overflow: hidden; }
  .nav-sheet-heading { position: sticky; top: 0; z-index: 1; display: flex; justify-content: space-between; align-items: center; margin: 0 calc(-1 * var(--space-4)); padding: var(--space-5) var(--space-4) var(--space-2) var(--space-5); background: var(--color-bg); }
  .nav-sheet-heading h2 { font-size: var(--text-title-1); }
  .nav-sheet-heading .button-square { width: 36px; min-width: 36px; height: 36px; min-height: 36px; font-size: 18px; color: var(--color-text-2); background: var(--color-tile); }
  .app-nav { flex: 0 0 auto; overflow: visible; margin: 0; padding: 0; }
  .app-nav-links { gap: 0; }
  .nav-group { gap: 0; margin-top: var(--space-3); padding: 4px; border: 0; border-radius: var(--radius-lg); background: var(--color-tile); }
  .nav-group-title { margin: var(--space-2) var(--space-3) 2px; }
  .app-nav a, .app-nav-item { min-height: 50px; padding: 0 var(--space-3); font-size: 16px; }
  .app-nav a[aria-current="page"] { box-shadow: var(--shadow-card); }
  .app-nav-account { margin-top: var(--space-4); padding: 4px; border-radius: var(--radius-lg); background: var(--color-tile); box-shadow: none; }
  .app-nav-user { min-height: 56px; }
  #logout { flex: 0 0 48px; width: 48px; min-height: 48px; background: var(--color-surface); }

  .agent-panel { inset: 0; z-index: 50; width: 100%; border-radius: 0; box-shadow: none; padding: var(--space-4) var(--space-4) calc(var(--space-4) + env(safe-area-inset-bottom)); }
  /* A save bar that sticks to the bottom of a view stays above the tab bar. */
  .view .profile-savebar { bottom: calc(92px + env(safe-area-inset-bottom)); }
  .calendar-toolbar-end { width: 100%; justify-content: space-between; }
  .month-grid { gap: 2px; padding: var(--space-2); }
  .month-day { min-height: 68px; padding: 3px; border-radius: var(--radius-md); }
  .month-weekday { padding: 6px 0; font-size: 11px; }
  .month-chip { padding: 2px 3px; font-size: 11px; text-align: center; text-overflow: clip; }
  .month-chip-time + .month-chip-title { display: none; }
  .month-chip-time { font-variant-numeric: tabular-nums; }
  .month-day-add { display: none; }
  .plan-row { grid-template-columns: minmax(0, 1fr) auto; gap: 2px 12px; }
  .plan-row-date { grid-column: 1 / -1; }
  .post-filters select { flex: 1 1 140px; }
  .inbox-item { flex-direction: column; flex-wrap: nowrap; align-items: stretch; gap: var(--space-2); }
  .inbox-item-body { flex: 0 0 auto; }
  .inbox-item { position: relative; }
  .inbox-dot { position: absolute; top: 18px; right: 16px; }
  .inbox-menu { right: auto; left: 0; }
  .inbox-item .inline-actions { justify-content: flex-start; margin: 0 0 0 -2px; }
}

/* ---- Fingers: the small secondary controls grow to 44 px on touch screens ---- */
@media (pointer: coarse), (max-width: 760px) {
  .dialog-heading .button-square, .agent-panel-heading .button-square, .nav-sheet-heading .button-square, .history-remove, .notification-close, .inbox-more > summary, .week-navigation .button-square {
    width: 44px; min-width: 44px; height: 44px; min-height: 44px; }
  .copy-label button, .history-actions button, .job-row-actions button, .agent-actions button, .agent-routine .button-text, .editor-section-nav button,
  .overview-panel-heading > a, .overview-panel-heading > button { min-height: 44px; }
  .agent-send { flex-basis: 44px; width: 44px; height: 44px; min-height: 44px; }
  .notice, .history-notice, .job-row { grid-template-columns: 24px minmax(0, 1fr) 44px; }
  .history-notice, .job-row { grid-template-columns: 8px minmax(0, 1fr) 44px; }
}
