:root {
    --ink: #172a2e;
    --ink-soft: #52666a;
    --deep-water: #17383c;
    --tide: #24767b;
    --tide-dark: #185c61;
    --river-glass: #dbe9e7;
    --mist: #eef4f3;
    --paper: #fbfdfc;
    --moss: #799475;
    --coral: #bf624f;
    --line: #cbdad7;
    --shadow: 0 16px 46px rgba(23, 56, 60, 0.09);
    --radius: 18px;
    --display: Georgia, "Times New Roman", serif;
    --body: "Avenir Next", Avenir, "Segoe UI", sans-serif;
    --utility: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    min-height: 100%;
    background: var(--mist);
}

body {
    min-height: 100vh;
    margin: 0;
    color: var(--ink);
    background:
        radial-gradient(circle at 90% -10%, rgba(36, 118, 123, 0.13), transparent 38rem),
        linear-gradient(180deg, var(--mist) 0, #f6f9f8 25rem, var(--paper) 100%);
    font-family: var(--body);
    font-size: 16px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

a {
    color: inherit;
}

button,
input,
textarea,
select {
    font: inherit;
}

button,
input[type="radio"] + span,
summary {
    -webkit-tap-highlight-color: transparent;
}

h1,
h2,
p {
    margin-top: 0;
}

h1,
h2 {
    font-family: var(--display);
    font-weight: 400;
    line-height: 1.08;
    letter-spacing: -0.03em;
}

h1 {
    margin-bottom: 0.5em;
    font-size: clamp(2.35rem, 5vw, 4.7rem);
}

h2 {
    margin-bottom: 0.5em;
    font-size: clamp(1.55rem, 2.5vw, 2.25rem);
}

.shell {
    width: min(1120px, calc(100% - 40px));
    margin-inline: auto;
}

.main-content {
    min-height: calc(100vh - 176px);
    padding-block: clamp(40px, 7vw, 78px) 70px;
}

.skip-link {
    position: fixed;
    z-index: 100;
    top: 12px;
    left: 12px;
    padding: 10px 14px;
    color: white;
    background: var(--deep-water);
    border-radius: 8px;
    transform: translateY(-160%);
}

.skip-link:focus {
    transform: translateY(0);
}

.site-header {
    border-bottom: 1px solid rgba(82, 102, 106, 0.2);
    background: rgba(251, 253, 252, 0.8);
    backdrop-filter: blur(14px);
}

.header-inner {
    min-height: 74px;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 24px;
}

.brand {
    justify-self: start;
    display: inline-flex;
    align-items: center;
    gap: 11px;
    color: var(--deep-water);
    font-family: var(--display);
    font-size: 1.25rem;
    text-decoration: none;
}

.brand-mark {
    width: 27px;
    height: 25px;
    display: flex;
    align-items: flex-end;
    gap: 3px;
}

.brand-mark i {
    width: 7px;
    display: block;
    border-radius: 6px 6px 2px 2px;
    background: var(--tide);
}

.brand-mark i:nth-child(1) { height: 9px; opacity: 0.55; }
.brand-mark i:nth-child(2) { height: 17px; opacity: 0.78; }
.brand-mark i:nth-child(3) { height: 24px; }

.primary-nav {
    display: flex;
    align-items: center;
    gap: 8px;
}

.primary-nav a,
.text-button {
    padding: 8px 12px;
    color: var(--ink-soft);
    border: 0;
    border-radius: 9px;
    background: transparent;
    font-size: 0.9rem;
    font-weight: 650;
    text-decoration: none;
    cursor: pointer;
}

.primary-nav a:hover,
.text-button:hover {
    color: var(--deep-water);
    background: var(--mist);
}

.logout-form {
    justify-self: end;
    margin: 0;
}

.privacy-note {
    grid-column: 3;
    justify-self: end;
    color: var(--ink-soft);
    font-family: var(--utility);
    font-size: 0.7rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.site-footer {
    min-height: 102px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: var(--ink-soft);
    border-top: 1px solid var(--line);
    font-size: 0.82rem;
}

.eyebrow {
    margin-bottom: 12px;
    color: var(--tide-dark);
    font-family: var(--utility);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.panel {
    background: rgba(251, 253, 252, 0.94);
    border: 1px solid rgba(139, 166, 161, 0.42);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.button {
    min-height: 46px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 11px 18px;
    border: 1px solid transparent;
    border-radius: 11px;
    font-size: 0.92rem;
    font-weight: 750;
    line-height: 1.2;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    transition: transform 150ms ease, box-shadow 150ms ease, background-color 150ms ease;
}

.button:hover {
    transform: translateY(-1px);
}

.button-primary {
    color: white;
    background: var(--tide-dark);
    box-shadow: 0 9px 22px rgba(24, 92, 97, 0.18);
}

.button-primary:hover {
    background: var(--deep-water);
    box-shadow: 0 12px 26px rgba(23, 56, 60, 0.24);
}

.button-secondary {
    color: var(--deep-water);
    background: transparent;
    border-color: rgba(23, 56, 60, 0.35);
}

.button-secondary:hover {
    background: rgba(255, 255, 255, 0.55);
}

.button-quiet {
    color: var(--ink-soft);
    background: transparent;
}

.button-full {
    width: 100%;
}

.quiet-link {
    color: var(--tide-dark);
    font-size: 0.9rem;
    font-weight: 700;
    text-decoration: none;
}

.quiet-link:hover {
    text-decoration: underline;
    text-underline-offset: 4px;
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
summary:focus-visible {
    outline: 3px solid rgba(36, 118, 123, 0.35);
    outline-offset: 3px;
}

.flash {
    margin: -22px 0 30px;
    padding: 13px 16px;
    border: 1px solid var(--line);
    border-radius: 10px;
    font-size: 0.9rem;
}

.flash-success {
    color: #28482d;
    background: #edf6eb;
    border-color: #b9d2b5;
}

.auth-page .main-content {
    display: grid;
    align-items: center;
}

.auth-shell {
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) minmax(330px, 0.72fr);
    align-items: center;
    gap: clamp(48px, 9vw, 110px);
    padding-block: 24px;
}

.auth-intro {
    max-width: 650px;
}

.auth-intro h1 {
    max-width: 12ch;
}

.auth-intro > p:not(.eyebrow) {
    max-width: 55ch;
    color: var(--ink-soft);
    font-size: 1.08rem;
}

.auth-panel {
    padding: clamp(28px, 5vw, 46px);
}

.auth-panel h2 {
    font-size: 2rem;
}

.panel-lede {
    margin-bottom: 28px;
    color: var(--ink-soft);
}

.horizon {
    width: min(470px, 100%);
    height: 90px;
    display: flex;
    align-items: end;
    gap: 13px;
    margin-top: 50px;
    padding-bottom: 1px;
    border-bottom: 1px solid rgba(23, 56, 60, 0.25);
}

.horizon span {
    flex: 1;
    border-radius: 30px 30px 2px 2px;
    background: var(--tide);
    opacity: 0.2;
}

.horizon span:nth-child(1) { height: 28%; }
.horizon span:nth-child(2) { height: 72%; }
.horizon span:nth-child(3) { height: 44%; }
.horizon span:nth-child(4) { height: 19%; }
.horizon span:nth-child(5) { height: 55%; opacity: 0.72; }

.compact-auth .auth-intro h1 {
    font-size: clamp(2.6rem, 5vw, 4.6rem);
}

.stacked-form {
    display: flex;
    flex-direction: column;
    align-items: stretch;
}

.stacked-form label,
.field-group > label,
.compact-field > label {
    margin-bottom: 7px;
    color: var(--ink);
    font-size: 0.85rem;
    font-weight: 750;
}

.stacked-form input + label {
    margin-top: 19px;
}

.stacked-form .field-hint + label,
.stacked-form .form-error + label {
    margin-top: 19px;
}

input,
textarea,
select {
    width: 100%;
    color: var(--ink);
    background: white;
    border: 1px solid #adbfbc;
    border-radius: 10px;
}

input,
select {
    min-height: 47px;
    padding: 10px 13px;
}

textarea {
    min-height: 120px;
    padding: 12px 13px;
    resize: vertical;
}

input:hover,
textarea:hover,
select:hover {
    border-color: #75918d;
}

.stacked-form .button {
    margin-top: 26px;
}

.code-input {
    font-family: var(--utility);
    font-size: 1.35rem;
    font-weight: 700;
    letter-spacing: 0.18em;
}

.form-error {
    margin: 7px 0 0;
    color: #944535;
    font-size: 0.82rem;
    font-weight: 650;
}

.summary-error {
    margin: 0 0 20px;
    padding: 10px 12px;
    background: #fbefec;
    border-left: 3px solid var(--coral);
}

.page-heading {
    margin-bottom: clamp(32px, 5vw, 52px);
}

.page-heading h1 {
    margin-bottom: 16px;
}

.page-heading > p:not(.eyebrow),
.page-heading > div > p:not(.eyebrow) {
    color: var(--ink-soft);
    font-size: 1.05rem;
}

.narrow-heading {
    max-width: 700px;
}

.setup-flow {
    max-width: 960px;
    margin-inline: auto;
}

.setup-grid {
    display: grid;
    grid-template-columns: 1.15fr 0.85fr;
    gap: 22px;
    align-items: start;
}

.numbered-panel {
    min-height: 100%;
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 20px;
    padding: clamp(25px, 4vw, 38px);
}

.step-number {
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    color: white;
    background: var(--deep-water);
    border-radius: 50%;
    font-family: var(--utility);
    font-size: 0.76rem;
    font-weight: 700;
}

.numbered-panel h2 {
    font-size: 1.7rem;
}

.numbered-panel p {
    color: var(--ink-soft);
}

.setup-values {
    margin: 25px 0 20px;
}

.setup-values div {
    padding: 12px 0;
    border-top: 1px solid var(--line);
}

.setup-values dt {
    color: var(--ink-soft);
    font-family: var(--utility);
    font-size: 0.67rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.setup-values dd {
    margin: 4px 0 0;
    overflow-wrap: anywhere;
}

.secret-code {
    font-family: var(--utility);
    font-size: 0.95rem;
    font-weight: 700;
    letter-spacing: 0.06em;
}

.technical-detail {
    color: var(--ink-soft);
    font-size: 0.8rem;
}

.technical-detail summary {
    cursor: pointer;
}

.technical-detail code {
    display: block;
    max-height: 85px;
    margin-top: 9px;
    padding: 9px;
    overflow: auto;
    background: var(--mist);
    border-radius: 7px;
    overflow-wrap: anywhere;
}

.recovery-shell {
    max-width: 690px;
    margin-inline: auto;
}

.recovery-panel {
    padding: clamp(25px, 5vw, 44px);
}

.recovery-list {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 9px;
    margin: 0 0 30px;
    padding: 0;
    list-style: none;
}

.recovery-list li {
    padding: 10px 13px;
    background: var(--mist);
    border-radius: 8px;
}

.recovery-list code {
    font-family: var(--utility);
    font-weight: 700;
    letter-spacing: 0.1em;
}

.dashboard-hero {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 300px;
    align-items: end;
    gap: 48px;
    margin-bottom: clamp(48px, 8vw, 80px);
}

.dashboard-hero h1 {
    max-width: 820px;
    font-size: clamp(2.8rem, 6vw, 5.5rem);
}

.hero-copy {
    max-width: 560px;
    margin-bottom: 0;
    color: var(--ink-soft);
    font-size: 1.05rem;
}

.today-action {
    position: relative;
    padding: 24px;
    overflow: hidden;
    color: white;
    background: var(--deep-water);
    border-radius: 16px;
    box-shadow: 0 18px 38px rgba(23, 56, 60, 0.2);
}

.today-action::after {
    content: "";
    position: absolute;
    right: -35px;
    bottom: -45px;
    width: 130px;
    height: 130px;
    border: 22px solid rgba(255, 255, 255, 0.06);
    border-radius: 50%;
}

.today-action > * {
    position: relative;
    z-index: 1;
}

.action-status {
    display: block;
    margin-bottom: 14px;
    color: #bcd4d1;
    font-family: var(--utility);
    font-size: 0.66rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.today-action strong {
    display: block;
    margin-bottom: 21px;
    font-family: var(--display);
    font-size: 1.8rem;
    font-weight: 400;
    line-height: 1.1;
}

.today-action strong small {
    display: block;
    margin-top: 4px;
    font-family: var(--body);
    font-size: 0.78rem;
    font-weight: 500;
}

.today-action .button-primary {
    color: var(--deep-water);
    background: white;
}

.today-action .button-secondary {
    color: white;
    border-color: rgba(255, 255, 255, 0.45);
}

.trajectory {
    padding: clamp(24px, 4vw, 42px);
}

.section-heading {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 30px;
    margin-bottom: 28px;
}

.section-heading h2 {
    margin-bottom: 0;
}

.section-heading .eyebrow {
    margin-bottom: 8px;
}

.goal-key {
    flex: none;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    color: var(--ink-soft);
    font-size: 0.75rem;
}

.goal-key i {
    width: 20px;
    border-top: 1px dashed var(--moss);
}

.chart-wrap {
    overflow-x: auto;
}

.path-chart {
    width: 100%;
    min-width: 660px;
    display: block;
    overflow: visible;
}

.goal-line {
    stroke: var(--moss);
    stroke-width: 1;
    stroke-dasharray: 4 5;
}

.data-segment {
    stroke: var(--tide);
    stroke-width: 3;
    stroke-linecap: round;
}

.data-dot {
    stroke: var(--paper);
    stroke-width: 3;
}

.data-dot.within { fill: var(--tide); }
.data-dot.above { fill: var(--coral); }
.empty-dot { fill: #bdcac8; }

.chart-day {
    fill: var(--ink-soft);
    font-family: var(--utility);
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
}

.chart-note,
.panel-footnote {
    margin: 3px 0 0;
    color: var(--ink-soft);
    font-size: 0.78rem;
}

.snapshot {
    padding: clamp(48px, 7vw, 76px) 0 15px;
}

.stat-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
}

.stat-block {
    min-height: 155px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 25px 28px;
    border-right: 1px solid var(--line);
}

.stat-block:last-child {
    border-right: 0;
}

.stat-block strong {
    margin-bottom: 8px;
    color: var(--deep-water);
    font-family: var(--display);
    font-size: clamp(2.3rem, 4vw, 3.8rem);
    font-weight: 400;
    line-height: 1;
}

.stat-block strong small {
    color: var(--ink-soft);
    font-family: var(--body);
    font-size: 0.9rem;
}

.stat-block span {
    max-width: 16ch;
    color: var(--ink-soft);
    font-size: 0.78rem;
}

.checkin-shell {
    max-width: 850px;
    margin-inline: auto;
}

.checkin-heading h1 {
    font-size: clamp(2.7rem, 6vw, 4.8rem);
}

.checkin-form {
    display: grid;
    gap: 18px;
}

.form-section {
    padding: clamp(24px, 4vw, 36px);
}

.field-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 25px;
}

.core-questions {
    padding-block: 0;
}

.core-field-row {
    grid-template-columns: minmax(220px, 0.8fr) minmax(300px, 1.2fr);
    gap: 0;
}

.core-field {
    justify-content: center;
    padding-block: 30px;
}

.core-date-field {
    padding-right: 34px;
}

.core-drinks-field {
    padding-left: 34px;
    border-left: 1px solid var(--line);
}

.field-kicker {
    margin-bottom: 12px;
    color: var(--tide-dark);
    font-family: var(--utility);
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.field-group,
.compact-field {
    display: flex;
    flex-direction: column;
}

.field-group + .field-group {
    margin-top: 25px;
}

.field-group label span {
    color: var(--ink-soft);
    font-weight: 500;
}

.field-hint {
    margin: 7px 0 0;
    color: var(--ink-soft);
    font-size: 0.78rem;
}

fieldset {
    min-width: 0;
    margin: 0;
    padding: 0;
    border: 0;
}

legend {
    margin-bottom: 4px;
    font-family: var(--display);
    font-size: 1.45rem;
}

.scale-input {
    display: grid;
    gap: 7px;
    margin-top: 21px;
}

.craving-scale {
    grid-template-columns: repeat(11, 1fr);
}

.mood-scale {
    grid-template-columns: repeat(5, 1fr);
}

.scale-input label {
    min-width: 0;
    cursor: pointer;
}

.scale-input input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
}

.scale-input span {
    min-height: 43px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--ink-soft);
    background: var(--mist);
    border: 1px solid transparent;
    border-radius: 9px;
    font-family: var(--utility);
    font-size: 0.78rem;
    font-weight: 700;
    transition: background-color 120ms ease, color 120ms ease, border-color 120ms ease;
}

.scale-input label:hover span {
    border-color: #91aaa6;
}

.scale-input input:checked + span {
    color: white;
    background: var(--tide-dark);
    border-color: var(--tide-dark);
}

.scale-input input:focus-visible + span {
    outline: 3px solid rgba(36, 118, 123, 0.35);
    outline-offset: 3px;
}

.mood-scale span {
    flex-direction: column;
    min-height: 65px;
    font-family: var(--body);
    font-size: 0.72rem;
    font-weight: 600;
}

.mood-scale span b {
    font-family: var(--utility);
    font-size: 0.84rem;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding-top: 8px;
}

.split-heading {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 30px;
}

.split-heading h1 {
    margin-bottom: 8px;
}

.split-heading p:last-child {
    margin-bottom: 0;
}

.history-panel {
    overflow: hidden;
}

.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

th,
td {
    padding: 17px 19px;
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}

th {
    color: var(--ink-soft);
    background: rgba(238, 244, 243, 0.7);
    font-family: var(--utility);
    font-size: 0.67rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

td {
    font-size: 0.88rem;
}

tbody tr:hover {
    background: rgba(238, 244, 243, 0.6);
}

.context-cell {
    max-width: 280px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.muted {
    color: var(--ink-soft);
    font-size: 0.75rem;
}

.history-panel .panel-footnote {
    padding: 16px 19px;
}

.empty-state {
    padding: clamp(38px, 7vw, 70px);
    text-align: center;
}

.empty-mark {
    color: var(--tide);
    font-family: var(--display);
    font-size: 5rem;
    line-height: 1;
}

.empty-state h2 {
    margin-top: 15px;
}

.empty-state p {
    max-width: 530px;
    margin: 0 auto 26px;
    color: var(--ink-soft);
}

.settings-grid {
    display: grid;
    grid-template-columns: 1fr 0.86fr;
    gap: 24px;
    align-items: start;
}

.settings-panel {
    padding: clamp(27px, 4vw, 40px);
}

.settings-panel h2 {
    font-size: 1.8rem;
}

.primary-entry-panel {
    padding: 0;
    overflow: hidden;
}

.primary-entry-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.primary-entry-field {
    min-width: 0;
    padding: 28px 25px;
}

.primary-entry-field input,
.history-control input,
.history-control select {
    min-width: 0;
    max-width: 100%;
}

input[type="date"] {
    display: block;
    min-inline-size: 0;
    max-inline-size: 100%;
}

input[type="date"]::-webkit-date-and-time-value,
input[type="date"]::-webkit-datetime-edit {
    min-width: 0;
    padding: 0;
    text-align: left;
}

.primary-entry-grid > .field-group + .field-group {
    margin-top: 0;
    border-left: 1px solid var(--line);
}

.primary-entry-field > label {
    min-height: 22px;
    margin-bottom: 7px;
    font-size: 0.82rem;
    font-weight: 750;
}

.primary-entry-field .field-hint {
    min-height: 38px;
}

.tag-input {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
    margin-top: 20px;
}

.tag-input label {
    cursor: pointer;
}

.tag-input input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
}

.tag-input span {
    min-height: 44px;
    display: grid;
    place-items: center;
    padding: 8px 10px;
    color: var(--ink-soft);
    background: var(--mist);
    border: 1px solid transparent;
    border-radius: 10px;
    font-size: 0.78rem;
    font-weight: 700;
    text-align: center;
}

.tag-input label:hover span {
    border-color: #91aaa6;
}

.tag-input input:checked + span {
    color: white;
    background: var(--tide-dark);
}

.tag-input input:focus-visible + span {
    outline: 3px solid rgba(36, 118, 123, 0.35);
    outline-offset: 3px;
}

.record-chart,
.weekly-chart {
    width: 100%;
    min-width: 760px;
    display: block;
    overflow: visible;
}

.chart-grid-line {
    stroke: #dce6e4;
    stroke-width: 1;
}

.chart-axis-label,
.chart-sub-label {
    fill: var(--ink-soft);
    font-family: var(--utility);
    font-size: 8px;
}

.drink-bar.within,
.week-bar {
    fill: var(--tide);
}

.drink-bar.above {
    fill: var(--coral);
}

.plan-mark {
    stroke: var(--deep-water);
    stroke-width: 2;
    stroke-linecap: round;
}

.chart-legend {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px 16px;
    color: var(--ink-soft);
    font-size: 0.72rem;
}

.chart-legend span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.chart-legend i {
    width: 18px;
    height: 8px;
    display: inline-block;
}

.legend-actual {
    background: var(--tide);
    border-radius: 3px;
}

.legend-plan {
    border-top: 2px solid var(--deep-water);
}

.legend-goal {
    border-top: 1px dashed var(--moss);
}

.dashboard-stat-row {
    grid-template-columns: repeat(5, 1fr);
}

.dashboard-readings {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
    padding-top: 28px;
}

.reading-card {
    min-width: 0;
    padding: 25px;
    background: rgba(251, 253, 252, 0.68);
    border: 1px solid var(--line);
    border-radius: 14px;
}

.reading-card .eyebrow {
    margin-bottom: 16px;
}

.reading-card > strong {
    display: block;
    margin-bottom: 8px;
    color: var(--deep-water);
    font-family: var(--display);
    font-size: 1.7rem;
    font-weight: 400;
    line-height: 1.1;
}

.reading-card > strong small {
    color: var(--ink-soft);
    font-family: var(--body);
    font-size: 0.8rem;
}

.reading-card p:last-child {
    margin: 0;
    color: var(--ink-soft);
    font-size: 0.78rem;
}

.history-heading {
    margin-bottom: 30px;
}

.history-controls {
    display: grid;
    grid-template-columns: 0.9fr 1fr 1fr 1.1fr 1.7fr auto;
    align-items: end;
    gap: 12px;
    margin-bottom: 54px;
    padding: 20px;
}

.history-control label {
    display: block;
    margin-bottom: 6px;
    color: var(--ink-soft);
    font-family: var(--utility);
    font-size: 0.64rem;
    font-weight: 700;
    letter-spacing: 0.07em;
    text-transform: uppercase;
}

.history-control {
    min-width: 0;
}

.history-control input,
.history-control select {
    min-height: 43px;
    padding: 8px 10px;
    font-size: 0.82rem;
}

.history-controls .button {
    min-height: 43px;
    white-space: nowrap;
}

.compact-heading {
    margin-bottom: 20px;
}

.compact-heading h2 {
    font-size: 1.8rem;
}

.completeness-note {
    color: var(--ink-soft);
    font-family: var(--utility);
    font-size: 0.68rem;
}

.history-summary {
    margin-bottom: 25px;
}

.history-stat-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
}

.history-stat-grid article {
    min-width: 0;
    padding: 20px 18px;
    border-right: 1px solid var(--line);
}

.history-stat-grid article:last-child {
    border-right: 0;
}

.history-stat-grid strong {
    display: block;
    margin-bottom: 7px;
    color: var(--deep-water);
    font-family: var(--display);
    font-size: clamp(1.8rem, 3vw, 2.6rem);
    font-weight: 400;
    line-height: 1;
}

.history-stat-grid span {
    display: block;
    color: var(--ink-soft);
    font-size: 0.72rem;
}

.comparison-strip {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    margin-top: 16px;
    background: var(--deep-water);
    border-radius: 13px;
    overflow: hidden;
}

.comparison-strip > div {
    padding: 18px 20px;
    border-right: 1px solid rgba(255, 255, 255, 0.14);
}

.comparison-strip > div:last-child {
    border-right: 0;
}

.comparison-strip span,
.comparison-strip strong {
    display: block;
}

.comparison-strip span {
    margin-bottom: 4px;
    color: #bcd4d1;
    font-size: 0.68rem;
}

.comparison-strip strong {
    color: white;
    font-size: 0.88rem;
}

.report-chart-panel,
.pattern-panel,
.context-pattern-panel {
    padding: clamp(23px, 3.5vw, 36px);
}

.report-chart-panel {
    margin-bottom: 18px;
}

.report-chart-heading {
    margin-bottom: 18px;
}

.history-analysis-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.55fr) minmax(250px, 0.65fr);
    gap: 18px;
}

.signal-panel {
    margin-bottom: 18px;
    padding: clamp(23px, 3.5vw, 36px);
}

.signal-chart {
    width: 100%;
    min-width: 760px;
    display: block;
}

.signal-lane-label {
    fill: var(--ink-soft);
    font-family: var(--utility);
    font-size: 7px;
    font-weight: 700;
    letter-spacing: 0.08em;
}

.signal-guide {
    stroke: #dce6e4;
    stroke-width: 1;
}

.craving-signal-line,
.mood-signal-line {
    stroke-width: 2.5;
    stroke-linecap: round;
}

.craving-signal-line {
    stroke: var(--coral);
}

.mood-signal-line {
    stroke: var(--tide);
}

.craving-signal-dot {
    fill: var(--coral);
}

.mood-signal-dot {
    fill: var(--tide);
}

.signal-legend {
    display: flex;
    gap: 16px;
    color: var(--ink-soft);
    font-size: 0.72rem;
}

.signal-legend span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.signal-legend i {
    width: 9px;
    height: 9px;
    background: var(--coral);
    border-radius: 50%;
}

.signal-legend span:last-child i {
    background: var(--tide);
}

.weekly-panel {
    margin: 0;
}

.pattern-panel h2 {
    font-size: 1.65rem;
}

.weekday-patterns {
    display: grid;
    gap: 11px;
    margin-top: 24px;
}

.weekday-pattern {
    display: grid;
    grid-template-columns: 34px minmax(90px, 1fr) 26px;
    align-items: center;
    gap: 9px;
    color: var(--ink-soft);
    font-family: var(--utility);
    font-size: 0.67rem;
}

.weekday-pattern strong {
    color: var(--ink);
    font-size: 0.7rem;
}

.weekday-pattern meter {
    width: 100%;
    height: 9px;
}

.weekday-pattern meter::-webkit-meter-bar {
    background: var(--mist);
    border: 0;
    border-radius: 8px;
}

.weekday-pattern meter::-webkit-meter-optimum-value {
    background: var(--tide);
    border-radius: 8px;
}

.pattern-waiting {
    margin: 22px 0 0;
    color: var(--ink-soft);
    font-size: 0.84rem;
}

.context-pattern-panel {
    margin-top: 18px;
}

.context-patterns {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    border-top: 1px solid var(--line);
    border-left: 1px solid var(--line);
}

.context-patterns article {
    min-width: 0;
    padding: 18px;
    border-right: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
}

.context-patterns span,
.context-patterns strong,
.context-patterns small {
    display: block;
}

.context-patterns span {
    margin-bottom: 14px;
    color: var(--ink-soft);
    font-size: 0.72rem;
}

.context-patterns strong {
    color: var(--deep-water);
    font-family: var(--display);
    font-size: 2rem;
    font-weight: 400;
}

.context-patterns small {
    color: var(--ink-soft);
    font-size: 0.66rem;
}

.history-record-section {
    margin-top: clamp(45px, 7vw, 78px);
}

.history-record-heading {
    align-items: end;
}

.history-actions,
.view-switch {
    display: flex;
    align-items: center;
    gap: 8px;
}

.view-switch {
    padding: 4px;
    background: var(--mist);
    border-radius: 10px;
}

.view-switch a {
    padding: 7px 10px;
    color: var(--ink-soft);
    border-radius: 7px;
    font-size: 0.75rem;
    font-weight: 700;
    text-decoration: none;
}

.view-switch a[aria-current="page"] {
    color: white;
    background: var(--deep-water);
}

.button-small {
    min-height: 38px;
    padding: 8px 13px;
    font-size: 0.75rem;
}

.table-tags {
    display: block;
    color: var(--tide-dark);
    font-size: 0.7rem;
    font-weight: 700;
}

.empty-filter-state {
    padding: 30px;
    text-align: center;
}

.empty-filter-state p {
    margin-bottom: 6px;
}

.history-calendar {
    padding: clamp(20px, 3.5vw, 34px);
}

.calendar-heading {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 20px;
}

.calendar-heading h3 {
    margin: 0;
    font-family: var(--display);
    font-size: 1.6rem;
    font-weight: 400;
}

.calendar-heading span {
    color: var(--ink-soft);
    font-size: 0.72rem;
}

.calendar-weekdays,
.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
}

.calendar-weekdays span {
    padding: 7px;
    color: var(--ink-soft);
    font-family: var(--utility);
    font-size: 0.64rem;
    text-align: center;
    text-transform: uppercase;
}

.calendar-day {
    min-height: 94px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    padding: 10px;
    color: var(--ink);
    background: white;
    border-top: 1px solid var(--line);
    border-left: 1px solid var(--line);
    text-decoration: none;
}

.calendar-day:nth-child(7n) {
    border-right: 1px solid var(--line);
}

.calendar-day:nth-last-child(-n + 7) {
    border-bottom: 1px solid var(--line);
}

.calendar-day b {
    color: var(--ink-soft);
    font-family: var(--utility);
    font-size: 0.68rem;
}

.calendar-day strong {
    margin-top: auto;
    font-family: var(--display);
    font-size: 1.5rem;
    font-weight: 400;
}

.calendar-day small {
    color: var(--ink-soft);
    font-size: 0.62rem;
}

.calendar-day.free {
    background: #edf6f0;
}

.calendar-day.within {
    background: var(--river-glass);
}

.calendar-day.above {
    background: #f8e8e3;
}

.calendar-day:not(.outside):hover {
    position: relative;
    z-index: 1;
    outline: 2px solid var(--tide);
    outline-offset: -2px;
}

.calendar-day.outside {
    color: #9aaba8;
    background: rgba(238, 244, 243, 0.45);
}

.pagination {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    margin-top: 18px;
    color: var(--ink-soft);
    font-size: 0.78rem;
}

.pagination a {
    color: var(--tide-dark);
    font-weight: 700;
}

.pagination a:last-child {
    justify-self: end;
}

.security-panel p:not(.eyebrow):not(.security-status) {
    color: var(--ink-soft);
}

.security-status {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #345837;
    font-weight: 700;
}

.security-status span {
    width: 28px;
    height: 28px;
    display: grid;
    place-items: center;
    color: white;
    background: var(--moss);
    border-radius: 50%;
}

.error-shell {
    max-width: 650px;
    margin: 9vh auto 0;
    text-align: center;
}

.error-code {
    color: var(--tide);
    font-family: var(--utility);
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.error-shell p:not(.error-code) {
    margin-bottom: 25px;
    color: var(--ink-soft);
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

@media (max-width: 820px) {
    .site-header {
        backdrop-filter: none;
    }

    .header-inner {
        grid-template-columns: 1fr auto;
    }

    .primary-nav {
        position: fixed;
        z-index: 20;
        right: 16px;
        bottom: 16px;
        left: 16px;
        justify-content: space-around;
        padding: 7px;
        background: rgba(23, 56, 60, 0.96);
        border: 1px solid rgba(255, 255, 255, 0.14);
        border-radius: 15px;
        box-shadow: 0 14px 35px rgba(23, 56, 60, 0.3);
    }

    .primary-nav a {
        color: white;
    }

    .primary-nav a:hover {
        color: white;
        background: rgba(255, 255, 255, 0.1);
    }

    .logout-form {
        grid-column: 2;
    }

    .site-footer {
        padding-bottom: 90px;
    }

    .auth-shell,
    .setup-grid,
    .dashboard-hero,
    .settings-grid {
        grid-template-columns: 1fr;
    }

    .auth-shell {
        gap: 38px;
    }

    .horizon {
        display: none;
    }

    .dashboard-hero {
        align-items: stretch;
        gap: 28px;
    }

    .today-action {
        max-width: 420px;
    }

    .stat-row {
        grid-template-columns: repeat(2, 1fr);
    }

    .dashboard-stat-row .stat-block:last-child {
        grid-column: 1 / -1;
        border-top: 1px solid var(--line);
        border-right: 0;
    }

    .dashboard-readings {
        grid-template-columns: 1fr;
    }

    .chart-wrap {
        width: 100%;
        max-width: 100%;
        overflow-x: hidden;
    }

    .path-chart,
    .record-chart,
    .weekly-chart,
    .signal-chart {
        min-width: 0;
        max-width: 100%;
    }

    .record-chart .chart-day,
    .weekly-chart .chart-day,
    .signal-chart .chart-day {
        font-size: 16px;
    }

    .record-chart .chart-axis-label,
    .weekly-chart .chart-axis-label,
    .weekly-chart .chart-sub-label,
    .signal-chart .chart-axis-label {
        font-size: 14px;
    }

    .signal-chart .signal-lane-label {
        font-size: 12px;
    }

    .history-controls {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .history-search,
    .history-controls .button {
        grid-column: 1 / -1;
    }

    .history-stat-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .history-stat-grid article:nth-child(3n) {
        border-right: 0;
    }

    .history-stat-grid article:nth-child(-n + 3) {
        border-bottom: 1px solid var(--line);
    }

    .history-analysis-grid {
        grid-template-columns: 1fr;
    }

    .context-patterns {
        grid-template-columns: repeat(2, 1fr);
    }

    .stat-block:nth-child(2) {
        border-right: 0;
    }

    .stat-block:nth-child(-n + 2) {
        border-bottom: 1px solid var(--line);
    }

    .craving-scale {
        grid-template-columns: repeat(6, 1fr);
    }
}

@media (max-width: 560px) {
    .shell {
        width: min(100% - 28px, 1120px);
    }

    .main-content {
        padding-top: 38px;
    }

    .privacy-note {
        display: none;
    }

    .site-footer {
        flex-direction: column;
        gap: 0;
        text-align: center;
    }

    .auth-shell {
        padding-top: 0;
    }

    .auth-intro h1,
    .dashboard-hero h1 {
        font-size: 2.75rem;
    }

    .auth-panel,
    .numbered-panel {
        padding: 24px;
    }

    .numbered-panel {
        grid-template-columns: 1fr;
    }

    .recovery-list,
    .field-row {
        grid-template-columns: 1fr;
    }

    .primary-entry-grid {
        grid-template-columns: 1fr;
    }

    .primary-entry-field {
        width: 100%;
        padding: 22px;
        overflow: hidden;
    }

    .primary-entry-field input[type="date"] {
        width: 100%;
        min-width: 0;
        max-width: 100%;
        font-size: 0.95rem;
    }

    .primary-entry-grid > .field-group + .field-group {
        border-top: 1px solid var(--line);
        border-left: 0;
    }

    .primary-entry-field .field-hint {
        min-height: 0;
    }

    .tag-input {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .core-questions {
        padding-block: 10px;
    }

    .core-field {
        padding-block: 20px;
    }

    .core-date-field {
        padding-right: 0;
    }

    .core-drinks-field {
        padding-left: 0;
        border-top: 1px solid var(--line);
        border-left: 0;
    }

    .section-heading,
    .split-heading {
        align-items: flex-start;
        flex-direction: column;
    }

    .trajectory-heading,
    .report-chart-heading,
    .history-record-heading {
        gap: 14px;
    }

    .chart-legend {
        justify-content: flex-start;
    }

    .history-controls {
        grid-template-columns: 1fr;
        margin-bottom: 40px;
    }

    .history-search,
    .history-controls .button {
        grid-column: auto;
    }

    .history-stat-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .history-stat-grid article,
    .history-stat-grid article:nth-child(3n) {
        border-right: 1px solid var(--line);
        border-bottom: 1px solid var(--line);
    }

    .history-stat-grid article:nth-child(2n) {
        border-right: 0;
    }

    .history-stat-grid article:nth-last-child(-n + 2) {
        border-bottom: 0;
    }

    .comparison-strip {
        grid-template-columns: 1fr;
    }

    .comparison-strip > div {
        border-right: 0;
        border-bottom: 1px solid rgba(255, 255, 255, 0.14);
    }

    .comparison-strip > div:last-child {
        border-bottom: 0;
    }

    .context-patterns {
        grid-template-columns: 1fr;
    }

    .history-actions {
        width: 100%;
        justify-content: space-between;
    }

    .calendar-heading {
        align-items: flex-start;
        flex-direction: column;
        gap: 2px;
    }

    .calendar-day {
        min-height: 66px;
        padding: 6px;
    }

    .calendar-day strong {
        font-size: 1.1rem;
    }

    .calendar-day small {
        display: none;
    }

    .snapshot-heading {
        gap: 12px;
    }

    .stat-block {
        min-height: 130px;
        padding: 20px;
    }

    .stat-block strong {
        font-size: 2.4rem;
    }

    .form-section {
        border-radius: 14px;
    }

    .craving-scale {
        grid-template-columns: repeat(4, 1fr);
    }

    .mood-scale {
        grid-template-columns: repeat(3, 1fr);
    }

    .form-actions {
        display: grid;
        grid-template-columns: 0.7fr 1.3fr;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
    }
}
