.phone-page, .card-page { display: flex; flex-direction: column; gap: 16px; padding-bottom: 16px; }
@media (min-width: 600px) {
  .phone-page { max-width: 480px; margin-inline: auto; }
}
@media (max-width: 599.98px) {
  .phone-page, .card-page, .today-page {
    --page-gutter-left: calc(env(safe-area-inset-left) + 16px);
    --page-gutter-right: calc(env(safe-area-inset-right) + 16px);
    margin-left: calc(var(--page-gutter-left) - var(--container-pad-left));
    margin-right: calc(var(--page-gutter-right) - var(--container-pad-right));
  }
  :is(.phone-page, .card-page, .today-page) :is(.card, .section, .history-entry, .featured-concept, .progress-group):not(:is(.card, .section, .history-entry, .featured-concept, .progress-group) *) {
    margin-left: calc(env(safe-area-inset-left) - var(--page-gutter-left));
    margin-right: calc(env(safe-area-inset-right) - var(--page-gutter-right));
    border-inline: 0;
    border-radius: 0;
  }
}

.card { padding: 16px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); }
.card h2 { font-size: 1rem; margin-bottom: .4rem; }
.card-note { color: var(--muted); font-size: .85rem; }
.card .card-note { margin-bottom: .75rem; }
.card > :where(form, .btn-block) + :where(form, .btn-block), .switch-row + .btn-block { margin-top: .5rem; }

.btn.btn-block { display: flex; align-items: center; justify-content: center; width: 100%; min-height: 48px; text-align: center; }

.switch-row { display: flex; align-items: center; justify-content: space-between; gap: .75rem; min-height: 48px; cursor: pointer; }
.switch { appearance: none; flex: none; width: 44px; height: 26px; border-radius: 999px; background: var(--muted); position: relative; cursor: pointer; }
.switch::before { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: var(--surface); transition: transform .15s; }
.switch:checked { background: var(--accent); }
.switch:checked::before { transform: translateX(18px); }
.switch:disabled { opacity: .4; cursor: not-allowed; }
.switch-row:has(.switch:disabled) { color: var(--muted); cursor: not-allowed; }
.switch:focus-visible { outline: var(--focus-ring-width) solid var(--focus-ring); outline-offset: var(--focus-ring-offset); }
@media (prefers-reduced-motion: reduce) {
  .switch::before { transition: none; }
}
@media (forced-colors: active) {
  .switch { appearance: auto; }
  .switch::before { content: none; }
}

.card :is(.value-row, .segmented, input:not([type="hidden"])) + .card-note { margin-top: .4rem; }
.card .card-note:empty { margin: 0; }
.switch-status:not(:empty) { margin-top: .25rem; }

.card-heading { display: flex; flex-wrap: wrap; align-items: baseline; gap: .15rem .75rem; margin-bottom: .4rem; }
.card-heading h2 { margin-bottom: 0; }
.card-tag { color: var(--muted); font-size: .85rem; }

.value-row { position: relative; display: flex; flex-wrap: wrap; align-items: center; gap: .25rem .75rem; min-height: 52px; padding: .5rem 1.75rem .5rem 0; border-bottom: 1px solid var(--border); }
.value-row > label { flex: 0 1 auto; }
.value-row-value { flex: 1 1 auto; text-align: end; overflow-wrap: anywhere; font-size: var(--input-font-size); color: var(--muted); }
.value-row::after { content: ""; position: absolute; right: 4px; top: 50%; width: 8px; height: 8px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: translateY(-70%) rotate(45deg); pointer-events: none; }
.value-row select { position: absolute; inset: 0 0 -1px; opacity: 0; width: 100%; height: calc(100% + 1px); font-size: var(--input-font-size); }
.value-row:has(select:focus-visible) { outline: var(--focus-ring-width) solid var(--focus-ring); outline-offset: var(--focus-ring-offset); }
.value-row:has(select:disabled) { opacity: .6; }

.field-group { border: 0; padding: 0; margin: 0; min-width: 0; }
.field-group legend { color: var(--muted); font-size: .85rem; margin-bottom: .4rem; }
.segmented { display: flex; gap: 3px; padding: 3px; border: 1px solid var(--border); border-radius: 999px; }
.segment { position: relative; flex: 1; display: flex; align-items: center; justify-content: center; min-height: 44px; text-align: center; border-radius: 999px; cursor: pointer; }
.segment input { position: absolute; inset: 0; margin: 0; opacity: 0; cursor: pointer; }
.segment:has(:checked) { background: var(--button-bg); color: #fff; }
.segment:has(:focus-visible) { outline: var(--focus-ring-width) solid var(--focus-ring); outline-offset: var(--focus-ring-offset); }
@media (forced-colors: active) {
  .segment:has(:checked) { outline: 2px solid Highlight; }
}

details.card > summary { min-height: 48px; display: flex; align-items: center; list-style: none; padding-block: .75rem; cursor: pointer; font-weight: 600; }
details.card > summary::-webkit-details-marker { display: none; }

/* Any author display beats the browser's [hidden] rule, so this restores it for every element on the page. */
:is(.phone-page, .card-page) [hidden] { display: none; }

@media (forced-colors: none) {
  .card input[type="range"] { appearance: none; width: 100%; height: 44px; font-size: var(--input-font-size); margin: 0; padding: 0; background: transparent; border: 0; }
  .card input[type="range"]::-webkit-slider-runnable-track { height: 6px; border-radius: 3px; background: var(--muted); }
  .card input[type="range"]::-moz-range-track { height: 6px; border-radius: 3px; background: var(--muted); }
  .card input[type="range"]::-webkit-slider-thumb { appearance: none; box-sizing: border-box; width: 28px; height: 28px; margin-top: -11px; border-radius: 50%; background: var(--button-bg); border: 2px solid var(--surface); }
  .card input[type="range"]::-moz-range-thumb { box-sizing: border-box; width: 28px; height: 28px; border-radius: 50%; background: var(--button-bg); border: 2px solid var(--surface); }
}
.card input[type="range"]:disabled { opacity: .4; }
@media (forced-colors: active) {
  .card input[type="range"] { appearance: auto; height: auto; }
}
