:root {
    --bg: #f3f1ea;
    --surface: #fffdf8;
    --surface-muted: #f7f7f1;
    --surface-strong: #edf3ef;
    --text: #20332d;
    --text-soft: #64736d;
    --text-faint: #8b9792;
    --primary: #365d52;
    --primary-dark: #29493f;
    --primary-soft: #dfece6;
    --accent: #d98257;
    --accent-soft: #f7e6dc;
    --egg: #d8a531;
    --egg-soft: #fbf0ce;
    --danger: #ad4747;
    --danger-soft: #f8e1df;
    --success: #327553;
    --success-soft: #dff0e6;
    --warning: #8a6118;
    --warning-soft: #fbefcf;
    --border: #dce1dc;
    --border-strong: #cbd2cc;
    --shadow-sm: 0 1px 2px rgba(32, 51, 45, 0.06), 0 8px 24px rgba(32, 51, 45, 0.04);
    --shadow-md: 0 18px 55px rgba(32, 51, 45, 0.16);
    --radius-sm: 10px;
    --radius-md: 16px;
    --radius-lg: 24px;
    --container: 1180px;
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-width: 320px;
    min-height: 100vh;
    background:
        radial-gradient(circle at 8% 0%, rgba(216, 165, 49, 0.08), transparent 30rem),
        radial-gradient(circle at 100% 10%, rgba(54, 93, 82, 0.08), transparent 34rem),
        var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
    font-size: 16px;
    line-height: 1.55;
    text-rendering: optimizeLegibility;
}

body.dialog-open {
    overflow: hidden;
}

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

button,
a,
input,
select,
textarea {
    -webkit-tap-highlight-color: transparent;
}

a {
    color: inherit;
}

button {
    color: inherit;
}

svg {
    display: block;
}

code {
    padding: 0.1rem 0.35rem;
    border-radius: 6px;
    background: #ebeee9;
    color: #40524c;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.9em;
}

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

.skip-link {
    position: fixed;
    z-index: 1000;
    top: 10px;
    left: 10px;
    padding: 0.65rem 0.9rem;
    border-radius: 8px;
    background: var(--text);
    color: #fff;
    transform: translateY(-160%);
}

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

.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;
}

.muted {
    color: var(--text-soft);
}

.eyebrow {
    margin: 0 0 0.35rem;
    color: var(--primary);
    font-size: 0.75rem;
    font-weight: 800;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.55rem;
    min-height: 44px;
    padding: 0.7rem 1rem;
    border: 1px solid transparent;
    border-radius: 12px;
    cursor: pointer;
    font-weight: 750;
    text-decoration: none;
    transition: transform 120ms ease, box-shadow 120ms ease, background 120ms ease, border-color 120ms ease;
}

.button svg {
    width: 19px;
    height: 19px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

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

.button:active:not(:disabled) {
    transform: translateY(0);
}

.button:disabled {
    cursor: not-allowed;
    opacity: 0.52;
}

.button--primary {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 8px 18px rgba(54, 93, 82, 0.18);
}

.button--primary:hover:not(:disabled) {
    background: var(--primary-dark);
    box-shadow: 0 10px 24px rgba(54, 93, 82, 0.24);
}

.button--secondary {
    border-color: var(--border-strong);
    background: var(--surface);
    color: var(--primary-dark);
}

.button--secondary:hover:not(:disabled) {
    border-color: var(--primary);
    background: var(--surface-strong);
}

.button--wide {
    width: 100%;
}

.inline-form {
    display: inline-flex;
    margin: 0;
}

/* Authentication and setup */
.auth-shell {
    display: grid;
    min-height: 100vh;
    padding: 36px 20px;
    place-items: center;
}

.auth-card {
    width: min(760px, 100%);
    padding: 34px;
    border: 1px solid rgba(203, 210, 204, 0.82);
    border-radius: 28px;
    background: rgba(255, 253, 248, 0.94);
    box-shadow: var(--shadow-md);
    backdrop-filter: blur(12px);
}

.auth-card--compact {
    width: min(480px, 100%);
}

.brand-lockup {
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--text);
    text-decoration: none;
}

.brand-lockup--centered {
    display: flex;
    justify-content: center;
    margin-bottom: 2rem;
}

.brand-lockup > div {
    display: grid;
    line-height: 1.2;
}

.brand-lockup strong {
    font-size: 1.05rem;
    letter-spacing: 0.02em;
}

.brand-lockup span:not(.brand-mark) {
    margin-top: 0.2rem;
    color: var(--text-soft);
    font-size: 0.78rem;
}

.brand-mark {
    display: grid;
    width: 44px;
    height: 44px;
    flex: 0 0 44px;
    border-radius: 14px;
    background: var(--primary);
    color: #fff;
    place-items: center;
    box-shadow: 0 7px 18px rgba(54, 93, 82, 0.2);
}

.brand-mark svg {
    width: 31px;
    height: 31px;
    fill: currentColor;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.brand-mark circle {
    fill: var(--primary-dark);
    stroke: none;
}

.auth-heading {
    margin-bottom: 1.6rem;
}

.auth-heading--centered {
    text-align: center;
}

.auth-heading h1 {
    margin: 0;
    font-size: clamp(1.75rem, 5vw, 2.35rem);
    line-height: 1.18;
    letter-spacing: -0.03em;
}

.auth-heading p:last-child {
    max-width: 620px;
    margin: 0.65rem 0 0;
    color: var(--text-soft);
}

.auth-heading--centered p:last-child {
    margin-inline: auto;
}

.storage-status {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.4rem;
    padding: 0.9rem 1rem;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--surface-muted);
}

.storage-status > span {
    display: grid;
    width: 30px;
    height: 30px;
    flex: 0 0 30px;
    border-radius: 50%;
    font-weight: 900;
    place-items: center;
}

.storage-status > div {
    display: grid;
}

.storage-status small {
    color: var(--text-soft);
}

.storage-status--ok > span {
    background: var(--success-soft);
    color: var(--success);
}

.storage-status--error > span {
    background: var(--danger-soft);
    color: var(--danger);
}

.auth-footnote {
    display: flex;
    justify-content: center;
    gap: 0.35rem;
    margin-top: 1.4rem;
    color: var(--text-soft);
    font-size: 0.86rem;
    text-align: center;
}

/* Forms */
.stack-form {
    display: grid;
    gap: 1rem;
}

.form-grid {
    display: grid;
    gap: 1rem;
}

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

.form-grid--three {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.form-grid--four {
    grid-template-columns: 1fr 0.85fr 1.1fr 1.2fr;
}

.field {
    display: grid;
    align-content: start;
    gap: 0.42rem;
    min-width: 0;
}

.field--wide {
    grid-column: 1 / -1;
}

.field--empty {
    visibility: hidden;
}

.field > span {
    color: var(--text);
    font-size: 0.86rem;
    font-weight: 740;
}

.field small {
    color: var(--text-soft);
    font-size: 0.78rem;
}

.field input,
.field select,
.field textarea,
.compact-select select,
.search-field input {
    width: 100%;
    min-width: 0;
    border: 1px solid var(--border-strong);
    border-radius: 11px;
    outline: none;
    background: #fff;
    color: var(--text);
    transition: border-color 120ms ease, box-shadow 120ms ease, background 120ms ease;
}

.field input,
.field select,
.compact-select select,
.search-field input {
    height: 44px;
    padding: 0 0.78rem;
}

.field textarea {
    min-height: 84px;
    padding: 0.72rem 0.78rem;
    resize: vertical;
}

.field input:focus,
.field select:focus,
.field textarea:focus,
.compact-select select:focus,
.search-field input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(54, 93, 82, 0.12);
}

.field input::placeholder,
.field textarea::placeholder,
.search-field input::placeholder {
    color: #9aa39f;
}

.input-with-unit {
    position: relative;
}

.input-with-unit input {
    padding-right: 2.4rem;
}

.input-with-unit b {
    position: absolute;
    top: 50%;
    right: 0.8rem;
    color: var(--text-soft);
    font-size: 0.82rem;
    transform: translateY(-50%);
}

.form-submit-row {
    display: flex;
    justify-content: flex-end;
}

/* Notices */
.flash-region {
    display: grid;
    gap: 0.65rem;
}

.notice {
    padding: 0.82rem 1rem;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
}

.notice p {
    margin: 0.3rem 0 0;
}

.notice--success {
    border-color: #bcdcc8;
    background: var(--success-soft);
    color: #275f43;
}

.notice--error,
.notice--danger {
    border-color: #e6bdb9;
    background: var(--danger-soft);
    color: #7c3434;
}

.notice--dismissible {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.notice--dismissible button {
    width: 30px;
    height: 30px;
    flex: 0 0 30px;
    border: 0;
    border-radius: 50%;
    background: transparent;
    cursor: pointer;
    color: currentColor;
    font-size: 1.25rem;
    line-height: 1;
}

/* App header */
.app-header {
    position: sticky;
    z-index: 30;
    top: 0;
    border-bottom: 1px solid rgba(203, 210, 204, 0.78);
    background: rgba(255, 253, 248, 0.9);
    backdrop-filter: blur(16px);
}

.topbar {
    display: flex;
    min-height: 72px;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
}

.top-actions {
    display: flex;
    align-items: center;
    gap: 0.45rem;
}

.icon-button {
    display: inline-flex;
    min-height: 40px;
    align-items: center;
    gap: 0.42rem;
    padding: 0.5rem 0.7rem;
    border: 1px solid transparent;
    border-radius: 10px;
    background: transparent;
    cursor: pointer;
    color: var(--text-soft);
    font-size: 0.84rem;
    font-weight: 700;
}

.icon-button:hover {
    border-color: var(--border);
    background: var(--surface-strong);
    color: var(--primary-dark);
}

.icon-button svg {
    width: 19px;
    height: 19px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.icon-button--accent {
    background: var(--primary);
    color: #fff;
}

.icon-button--accent:hover {
    border-color: var(--primary-dark);
    background: var(--primary-dark);
    color: #fff;
}

.icon-button--quiet span {
    display: none;
}

/* Main dashboard */
.app-main {
    display: grid;
    gap: 1.25rem;
    padding-block: 28px 44px;
}

.profile-hero {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
    padding: 1.4rem 1.55rem;
    border: 1px solid rgba(203, 210, 204, 0.8);
    border-radius: var(--radius-lg);
    background:
        linear-gradient(110deg, rgba(255, 253, 248, 0.98), rgba(239, 245, 241, 0.95)),
        var(--surface);
    box-shadow: var(--shadow-sm);
}

.profile-identity {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.bird-avatar {
    display: grid;
    width: 68px;
    height: 68px;
    flex: 0 0 68px;
    border: 5px solid rgba(255, 255, 255, 0.8);
    border-radius: 22px;
    background: var(--accent-soft);
    color: #9b542f;
    font-size: 1.75rem;
    font-weight: 850;
    box-shadow: 0 8px 20px rgba(89, 67, 51, 0.1);
    place-items: center;
}

.profile-identity h1 {
    margin: 0;
    font-size: clamp(1.65rem, 4vw, 2.15rem);
    line-height: 1.1;
    letter-spacing: -0.03em;
}

.profile-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin: 0.45rem 0 0;
    color: var(--text-soft);
    font-size: 0.88rem;
}

.profile-quick-action {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.profile-quick-action p {
    max-width: 210px;
    margin: 0;
    color: var(--text-soft);
    font-size: 0.85rem;
    text-align: right;
}

.trend-alert {
    display: flex;
    align-items: flex-start;
    gap: 0.85rem;
    padding: 1rem 1.15rem;
    border: 1px solid #e8cc8f;
    border-radius: var(--radius-md);
    background: var(--warning-soft);
    color: #6d4b11;
}

.trend-alert__icon {
    display: grid;
    width: 30px;
    height: 30px;
    flex: 0 0 30px;
    border-radius: 50%;
    background: #e5b955;
    color: #523708;
    font-weight: 900;
    place-items: center;
}

.trend-alert p {
    margin: 0.25rem 0 0;
    font-size: 0.88rem;
}

.metric-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 1rem;
}

.metric-card {
    min-width: 0;
    padding: 1.05rem 1.15rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}

.metric-card--primary {
    border-color: #cbdcd4;
    background: linear-gradient(145deg, #365d52, #2c5046);
    color: #fff;
}

.metric-card__label {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.6rem;
}

.metric-card__label > span {
    font-size: 0.84rem;
    font-weight: 750;
}

.metric-card__label small {
    overflow: hidden;
    color: var(--text-soft);
    font-size: 0.72rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.metric-card--primary .metric-card__label small,
.metric-card--primary p {
    color: rgba(255, 255, 255, 0.72);
}

.metric-card__value {
    display: flex;
    align-items: baseline;
    gap: 0.35rem;
    margin-top: 0.42rem;
}

.metric-card__value strong {
    font-size: clamp(2rem, 4vw, 2.65rem);
    line-height: 1;
    letter-spacing: -0.05em;
}

.metric-card__value span {
    color: currentColor;
    font-size: 0.85rem;
    font-weight: 700;
    opacity: 0.7;
}

.metric-card__value--small strong {
    font-size: clamp(1.75rem, 3.4vw, 2.2rem);
}

.metric-card__value.is-up {
    color: #b05c33;
}

.metric-card__value.is-down {
    color: #4770a2;
}

.metric-card p {
    margin: 0.48rem 0 0;
    color: var(--text-soft);
    font-size: 0.77rem;
}

.panel {
    padding: 1.35rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}

.panel-header {
    margin-bottom: 1rem;
}

.panel-header--responsive {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1.5rem;
}

.panel-header h2 {
    margin: 0;
    font-size: 1.35rem;
    letter-spacing: -0.02em;
}

.panel-header p:last-child {
    margin: 0.28rem 0 0;
    color: var(--text-soft);
    font-size: 0.86rem;
}

/* Chart */
.chart-controls {
    display: flex;
    align-items: center;
    gap: 0.65rem;
}

.segmented-control {
    display: inline-flex;
    padding: 3px;
    border: 1px solid var(--border);
    border-radius: 11px;
    background: var(--surface-muted);
}

.segmented-control button {
    min-height: 34px;
    padding: 0.35rem 0.7rem;
    border: 0;
    border-radius: 8px;
    background: transparent;
    cursor: pointer;
    color: var(--text-soft);
    font-size: 0.76rem;
    font-weight: 740;
}

.segmented-control button:hover {
    color: var(--primary);
}

.segmented-control button.is-active {
    background: #fff;
    color: var(--primary-dark);
    box-shadow: 0 1px 5px rgba(32, 51, 45, 0.12);
}

.compact-select select {
    min-width: 128px;
    height: 40px;
    padding-right: 2rem;
    background: #fff;
    font-size: 0.8rem;
}

.chart-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 0.55rem 1rem;
    min-height: 1.5rem;
    margin-bottom: 0.35rem;
    color: var(--text-soft);
    font-size: 0.78rem;
}

.chart-summary strong {
    color: var(--text);
}

.chart-shell {
    position: relative;
    width: 100%;
    min-height: 360px;
    overflow: hidden;
    border-radius: 14px;
    background: linear-gradient(180deg, rgba(239, 244, 240, 0.58), rgba(255, 255, 255, 0.2));
}

.chart-loading,
.chart-empty {
    display: grid;
    min-height: 360px;
    padding: 2rem;
    color: var(--text-soft);
    text-align: center;
    place-items: center;
}

.weight-chart-svg {
    display: block;
    width: 100%;
    height: 360px;
    overflow: visible;
}

.chart-grid-line {
    stroke: #dfe5e0;
    stroke-width: 1;
    vector-effect: non-scaling-stroke;
}

.chart-axis-label {
    fill: #76837e;
    font-size: 11px;
    font-family: inherit;
}

.chart-normal-band {
    fill: rgba(54, 93, 82, 0.09);
}

.chart-normal-edge {
    stroke: rgba(54, 93, 82, 0.35);
    stroke-width: 1;
    stroke-dasharray: 4 5;
    vector-effect: non-scaling-stroke;
}

.chart-line {
    fill: none;
    stroke: var(--primary);
    stroke-width: 2.7;
    stroke-linecap: round;
    stroke-linejoin: round;
    vector-effect: non-scaling-stroke;
}

.chart-area {
    fill: url(#weightAreaGradient);
}

.chart-point {
    fill: #fff;
    stroke: var(--primary);
    stroke-width: 2.2;
    cursor: pointer;
    vector-effect: non-scaling-stroke;
}

.chart-point:hover,
.chart-point:focus {
    fill: var(--accent-soft);
    stroke: var(--accent);
    outline: none;
}

.chart-event-line {
    stroke: #d9dfda;
    stroke-width: 1;
    vector-effect: non-scaling-stroke;
}

.chart-event {
    fill: var(--accent);
    stroke: #fff;
    stroke-width: 1.5;
    cursor: pointer;
    vector-effect: non-scaling-stroke;
}

.chart-event--egg {
    fill: var(--egg);
}

.chart-event:hover,
.chart-event:focus {
    stroke: var(--text);
    outline: none;
}

.chart-event-label {
    fill: #87918d;
    font-size: 10px;
    font-family: inherit;
}

.chart-tooltip {
    position: absolute;
    z-index: 8;
    width: max-content;
    max-width: min(260px, calc(100vw - 48px));
    padding: 0.65rem 0.75rem;
    border: 1px solid rgba(203, 210, 204, 0.9);
    border-radius: 10px;
    background: rgba(32, 51, 45, 0.96);
    box-shadow: 0 8px 24px rgba(32, 51, 45, 0.2);
    color: #fff;
    font-size: 0.76rem;
    line-height: 1.45;
    pointer-events: none;
    transform: translate(-50%, calc(-100% - 10px));
}

.chart-tooltip strong,
.chart-tooltip span {
    display: block;
}

.chart-tooltip span {
    color: rgba(255, 255, 255, 0.78);
}

.chart-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem 1rem;
    margin-top: 0.65rem;
    color: var(--text-soft);
    font-size: 0.74rem;
}

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

.legend-line {
    width: 18px;
    height: 2px;
    border-radius: 10px;
    background: var(--primary);
}

.legend-event {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent);
}

.legend-event--egg {
    background: var(--egg);
}

.legend-band {
    width: 18px;
    height: 8px;
    border: 1px dashed rgba(54, 93, 82, 0.4);
    background: rgba(54, 93, 82, 0.1);
}

/* History */
.history-toolbar {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) auto auto auto;
    align-items: center;
    gap: 0.65rem;
    margin-bottom: 0.9rem;
}

.search-field {
    position: relative;
    display: block;
}

.search-field svg {
    position: absolute;
    top: 50%;
    left: 0.78rem;
    width: 18px;
    height: 18px;
    fill: none;
    stroke: var(--text-faint);
    stroke-width: 1.8;
    transform: translateY(-50%);
}

.search-field input {
    padding-left: 2.4rem;
}

.history-count {
    color: var(--text-soft);
    font-size: 0.78rem;
    white-space: nowrap;
}

.record-list {
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 14px;
}

.record-list__head,
.record-row {
    display: grid;
    grid-template-columns: 125px 90px 105px minmax(0, 1fr) 105px;
    gap: 0.85rem;
    align-items: center;
}

.record-list__head {
    min-height: 38px;
    padding: 0 0.85rem;
    border-bottom: 1px solid var(--border);
    background: var(--surface-muted);
    color: var(--text-soft);
    font-size: 0.7rem;
    font-weight: 750;
    letter-spacing: 0.03em;
}

.record-row {
    min-height: 82px;
    padding: 0.8rem 0.85rem;
    border-bottom: 1px solid var(--border);
    background: #fff;
}

.record-row:last-child {
    border-bottom: 0;
}

.record-row:hover {
    background: #fffefb;
}

.record-row[hidden] {
    display: none;
}

.record-cell {
    min-width: 0;
}

.record-cell--date {
    display: grid;
}

.record-cell--date strong {
    font-size: 0.84rem;
}

.record-cell--date span {
    color: var(--text-soft);
    font-size: 0.75rem;
}

.record-cell--weight {
    display: flex;
    align-items: baseline;
    gap: 0.2rem;
}

.record-cell--weight strong {
    font-size: 1.24rem;
    letter-spacing: -0.03em;
}

.record-cell--weight span {
    color: var(--text-soft);
    font-size: 0.72rem;
}

.record-cell--weight .record-no-weight {
    color: var(--text-soft);
    font-size: 0.8rem;
    letter-spacing: 0;
}

.context-badge {
    display: inline-flex;
    min-height: 25px;
    align-items: center;
    padding: 0.22rem 0.55rem;
    border-radius: 999px;
    background: var(--surface-strong);
    color: var(--primary-dark);
    font-size: 0.72rem;
    font-weight: 700;
    white-space: nowrap;
}

.record-cell--details {
    display: grid;
    gap: 0.35rem;
}

.record-cell--details p {
    margin: 0;
    overflow-wrap: anywhere;
    color: var(--text-soft);
    font-size: 0.78rem;
}

.record-cell--details p strong {
    color: var(--text);
}

.chip-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
}

.status-chip {
    display: inline-flex;
    min-height: 23px;
    align-items: center;
    padding: 0.18rem 0.48rem;
    border-radius: 999px;
    background: var(--accent-soft);
    color: #8e4b2d;
    font-size: 0.68rem;
    font-weight: 720;
}

.status-chip--egg {
    background: var(--egg-soft);
    color: #7d5b0f;
}

.status-chip--normal {
    background: var(--success-soft);
    color: #2d6849;
}

.status-chip--observation {
    background: #e6ebf4;
    color: #465f84;
}

.source-label {
    color: var(--text-faint);
    font-size: 0.68rem;
}

.record-cell--actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.45rem;
}

.row-action {
    padding: 0.28rem 0.2rem;
    border: 0;
    background: transparent;
    cursor: pointer;
    color: var(--primary);
    font-size: 0.75rem;
    font-weight: 720;
}

.row-action:hover {
    text-decoration: underline;
}

.row-action--danger {
    color: var(--danger);
}

.empty-state {
    padding: 2.6rem 1rem;
    color: var(--text-soft);
    text-align: center;
}

.empty-state strong {
    display: block;
    color: var(--text);
}

.empty-state p {
    margin: 0.3rem 0 0;
    font-size: 0.84rem;
}

.button--load-more {
    display: flex;
    margin: 0.9rem auto 0;
}

/* Footer */
.app-footer {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.8rem 0.3rem 0;
    color: var(--text-soft);
    font-size: 0.76rem;
}

.app-footer p {
    margin: 0;
}

.app-footer span {
    white-space: nowrap;
}

/* Dialogs */
.app-dialog {
    width: min(760px, calc(100vw - 32px));
    max-height: min(90vh, 900px);
    padding: 0;
    overflow: hidden;
    border: 1px solid rgba(203, 210, 204, 0.9);
    border-radius: 22px;
    background: var(--surface);
    box-shadow: var(--shadow-md);
    color: var(--text);
}

.app-dialog--wide {
    width: min(980px, calc(100vw - 32px));
}

.app-dialog::backdrop {
    background: rgba(24, 39, 34, 0.58);
    backdrop-filter: blur(4px);
}

.dialog-frame {
    max-height: min(90vh, 900px);
    overflow-y: auto;
}

.dialog-header {
    position: sticky;
    z-index: 5;
    top: 0;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    padding: 1.25rem 1.35rem 1rem;
    border-bottom: 1px solid var(--border);
    background: rgba(255, 253, 248, 0.96);
    backdrop-filter: blur(10px);
}

.dialog-header h2 {
    margin: 0;
    font-size: 1.35rem;
    letter-spacing: -0.02em;
}

.dialog-header p:last-child {
    margin: 0.28rem 0 0;
    color: var(--text-soft);
    font-size: 0.82rem;
}

.dialog-close {
    display: grid;
    width: 36px;
    height: 36px;
    flex: 0 0 36px;
    border: 1px solid var(--border);
    border-radius: 50%;
    background: #fff;
    cursor: pointer;
    color: var(--text-soft);
    font-size: 1.35rem;
    line-height: 1;
    place-items: center;
}

.dialog-close:hover {
    border-color: var(--border-strong);
    color: var(--text);
}

.record-form {
    display: grid;
}

.form-section {
    padding: 1.25rem 1.35rem;
    border-bottom: 1px solid var(--border);
}

.form-section__heading {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.form-section__heading > span {
    display: grid;
    width: 27px;
    height: 27px;
    flex: 0 0 27px;
    border-radius: 9px;
    background: var(--primary-soft);
    color: var(--primary-dark);
    font-size: 0.78rem;
    font-weight: 850;
    place-items: center;
}

.form-section__heading h3 {
    margin: 0;
    font-size: 1rem;
}

.form-section__heading p {
    margin: 0.18rem 0 0;
    color: var(--text-soft);
    font-size: 0.76rem;
}

.status-picker {
    display: flex;
    flex-wrap: wrap;
    gap: 0.55rem;
}

.status-option {
    position: relative;
    cursor: pointer;
}

.status-option input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.status-option span {
    display: inline-flex;
    min-height: 36px;
    align-items: center;
    padding: 0.45rem 0.72rem;
    border: 1px solid var(--border-strong);
    border-radius: 999px;
    background: #fff;
    color: var(--text-soft);
    font-size: 0.78rem;
    font-weight: 690;
    transition: border-color 120ms ease, background 120ms ease, color 120ms ease, box-shadow 120ms ease;
}

.status-option input:focus-visible + span {
    outline: 3px solid rgba(54, 93, 82, 0.18);
    outline-offset: 2px;
}

.status-option input:checked + span {
    border-color: var(--primary);
    background: var(--primary-soft);
    color: var(--primary-dark);
    box-shadow: inset 0 0 0 1px var(--primary);
}

.status-option input[value="egg"]:checked + span {
    border-color: #c18d1f;
    background: var(--egg-soft);
    color: #75540e;
    box-shadow: inset 0 0 0 1px #c18d1f;
}

.egg-count-field {
    max-width: 190px;
    margin-top: 0.9rem;
}

.egg-count-field[hidden] {
    display: none;
}

.dialog-actions {
    position: sticky;
    z-index: 5;
    bottom: 0;
    display: flex;
    justify-content: flex-end;
    gap: 0.65rem;
    padding: 1rem 1.35rem;
    background: rgba(255, 253, 248, 0.96);
    backdrop-filter: blur(10px);
}

.settings-stack {
    display: grid;
}

.settings-section {
    padding: 1.3rem 1.35rem;
    border-bottom: 1px solid var(--border);
}

.settings-section:last-child {
    border-bottom: 0;
}

.settings-section__heading {
    margin-bottom: 1rem;
}

.settings-section__heading h3 {
    margin: 0;
    font-size: 1rem;
}

.settings-section__heading p {
    margin: 0.22rem 0 0;
    color: var(--text-soft);
    font-size: 0.78rem;
}

.download-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.75rem;
}

.download-card {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.9rem;
    border: 1px solid var(--border);
    border-radius: 13px;
    background: var(--surface-muted);
    text-decoration: none;
}

.download-card:hover {
    border-color: var(--primary);
    background: var(--surface-strong);
}

.download-card svg {
    width: 27px;
    height: 27px;
    flex: 0 0 27px;
    fill: none;
    stroke: var(--primary);
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.download-card span {
    display: grid;
}

.download-card strong {
    font-size: 0.86rem;
}

.download-card small {
    color: var(--text-soft);
    font-size: 0.72rem;
}

.import-form {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-top: 0.8rem;
}

.file-drop {
    position: relative;
    display: flex;
    min-width: 0;
    flex: 1;
    align-items: center;
    gap: 0.75rem;
    padding: 0.85rem;
    border: 1px dashed var(--border-strong);
    border-radius: 13px;
    background: #fff;
    cursor: pointer;
}

.file-drop:hover {
    border-color: var(--primary);
    background: var(--surface-strong);
}

.file-drop svg {
    width: 27px;
    height: 27px;
    flex: 0 0 27px;
    fill: none;
    stroke: var(--primary);
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.file-drop span {
    display: grid;
    min-width: 0;
}

.file-drop strong {
    font-size: 0.84rem;
}

.file-drop small {
    color: var(--text-soft);
    font-size: 0.71rem;
}

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

.file-drop.has-file {
    border-style: solid;
    border-color: var(--primary);
    background: var(--primary-soft);
}

.storage-note {
    display: grid;
    margin-top: 0.8rem;
    padding: 0.75rem 0.85rem;
    border-radius: 10px;
    background: var(--success-soft);
    color: #2b6547;
    font-size: 0.75rem;
}

.storage-note--error {
    background: var(--danger-soft);
    color: #7c3434;
}

/* Focus */
:focus-visible {
    outline: 3px solid rgba(54, 93, 82, 0.26);
    outline-offset: 2px;
}

/* Responsive */
@media (max-width: 1000px) {
    .metric-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

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

    .record-list__head,
    .record-row {
        grid-template-columns: 112px 80px 95px minmax(0, 1fr) 92px;
        gap: 0.65rem;
    }
}

@media (max-width: 820px) {
    .topbar {
        min-height: 64px;
    }

    .top-actions .icon-button span {
        display: none;
    }

    .icon-button {
        width: 40px;
        justify-content: center;
        padding: 0;
    }

    .panel-header--responsive {
        display: grid;
    }

    .chart-controls {
        justify-content: space-between;
    }

    .history-toolbar {
        grid-template-columns: minmax(180px, 1fr) auto auto;
    }

    .history-count {
        grid-column: 1 / -1;
    }

    .record-list {
        overflow: visible;
        border: 0;
        border-radius: 0;
    }

    .record-list__head {
        display: none;
    }

    .record-row {
        position: relative;
        grid-template-columns: 1fr auto;
        gap: 0.55rem 1rem;
        min-height: 0;
        margin-bottom: 0.7rem;
        padding: 0.95rem;
        border: 1px solid var(--border);
        border-radius: 13px;
        box-shadow: 0 1px 3px rgba(32, 51, 45, 0.04);
    }

    .record-cell--date {
        grid-column: 1;
        grid-row: 1;
    }

    .record-cell--weight {
        grid-column: 2;
        grid-row: 1;
        justify-content: flex-end;
    }

    .record-cell--context {
        grid-column: 1 / -1;
        grid-row: 2;
    }

    .record-cell--details {
        grid-column: 1 / -1;
        grid-row: 3;
    }

    .record-cell--actions {
        grid-column: 1 / -1;
        grid-row: 4;
        justify-content: flex-start;
        padding-top: 0.25rem;
        border-top: 1px dashed var(--border);
    }

    .app-footer {
        display: grid;
    }
}

@media (max-width: 680px) {
    .container {
        width: min(100% - 24px, var(--container));
    }

    .auth-shell {
        padding: 16px 12px;
        align-items: start;
    }

    .auth-card {
        padding: 24px 18px;
        border-radius: 22px;
    }

    .auth-footnote {
        display: grid;
    }

    .form-grid--two,
    .form-grid--three,
    .form-grid--four {
        grid-template-columns: 1fr;
    }

    .field--empty {
        display: none;
    }

    .app-main {
        gap: 0.9rem;
        padding-block: 16px 30px;
    }

    .profile-hero {
        display: grid;
        padding: 1.1rem;
        border-radius: 19px;
    }

    .bird-avatar {
        width: 58px;
        height: 58px;
        flex-basis: 58px;
        border-radius: 18px;
        font-size: 1.45rem;
    }

    .profile-quick-action {
        justify-content: space-between;
        padding-top: 0.9rem;
        border-top: 1px solid var(--border);
    }

    .profile-quick-action p {
        text-align: left;
    }

    .metric-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0.7rem;
    }

    .metric-card {
        padding: 0.9rem;
    }

    .metric-card__label {
        display: grid;
        gap: 0.1rem;
    }

    .metric-card__value strong,
    .metric-card__value--small strong {
        font-size: 1.8rem;
    }

    .panel {
        padding: 1rem;
        border-radius: 18px;
    }

    .chart-controls {
        display: grid;
        justify-content: stretch;
    }

    .segmented-control {
        display: grid;
        grid-template-columns: repeat(4, 1fr);
    }

    .compact-select select {
        width: 100%;
    }

    .chart-shell,
    .chart-loading,
    .chart-empty {
        min-height: 320px;
    }

    .weight-chart-svg {
        height: 320px;
    }

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

    .search-field {
        grid-column: 1 / -1;
    }

    .app-dialog,
    .app-dialog--wide {
        width: 100vw;
        max-width: none;
        max-height: 94vh;
        margin: auto 0 0;
        border-width: 1px 0 0;
        border-radius: 22px 22px 0 0;
    }

    .dialog-frame {
        max-height: 94vh;
    }

    .dialog-header,
    .form-section,
    .settings-section,
    .dialog-actions {
        padding-inline: 1rem;
    }

    .dialog-header p:last-child {
        display: none;
    }

    .dialog-actions .button {
        flex: 1;
    }

    .download-grid {
        grid-template-columns: 1fr;
    }

    .import-form {
        display: grid;
    }

    .app-footer span {
        white-space: normal;
    }
}

@media (max-width: 430px) {
    .brand-lockup span:not(.brand-mark) {
        display: none;
    }

    .brand-mark {
        width: 40px;
        height: 40px;
        flex-basis: 40px;
    }

    .metric-grid {
        grid-template-columns: 1fr;
    }

    .metric-card__label {
        display: flex;
    }

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

    .search-field,
    .history-count {
        grid-column: auto;
    }

    .profile-quick-action {
        display: grid;
    }

    .profile-quick-action .button {
        width: 100%;
    }
}

@media (min-width: 681px) and (max-width: 980px) {
    .download-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@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;
    }
}

/* Quick entry and record photos */
.profile-action-buttons {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 0.55rem;
}

.record-photo-strip {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    margin-top: 0.1rem;
}

.record-photo {
    display: block;
    width: 72px;
    height: 72px;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 11px;
    background: var(--surface-muted);
    box-shadow: 0 2px 8px rgba(32, 51, 45, 0.08);
}

.record-photo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 160ms ease;
}

.record-photo:hover img,
.record-photo:focus-visible img {
    transform: scale(1.04);
}

.quick-page {
    min-height: 100vh;
}

.quick-main.container {
    display: grid;
    width: min(720px, calc(100% - 32px));
    gap: 1rem;
    padding-block: 24px 36px;
}

.quick-intro {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1.25rem;
    padding: 0.35rem 0.2rem;
}

.quick-intro h1 {
    margin: 0;
    font-size: clamp(2rem, 8vw, 3.15rem);
    line-height: 1;
    letter-spacing: -0.045em;
}

.quick-intro p:last-child {
    max-width: 520px;
    margin: 0.75rem 0 0;
    color: var(--text-soft);
    font-size: 0.9rem;
}

.quick-clock {
    display: grid;
    flex: 0 0 auto;
    justify-items: end;
    padding-bottom: 0.2rem;
    color: var(--text-soft);
}

.quick-clock strong {
    color: var(--primary-dark);
    font-size: 1.5rem;
    line-height: 1;
    letter-spacing: -0.04em;
}

.quick-clock span {
    margin-top: 0.25rem;
    font-size: 0.75rem;
}

.quick-card {
    overflow: hidden;
    border: 1px solid rgba(203, 210, 204, 0.9);
    border-radius: 24px;
    background: var(--surface);
    box-shadow: var(--shadow-md);
}

.quick-tabs {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.45rem;
    padding: 0.55rem;
    border-bottom: 1px solid var(--border);
    background: var(--surface-muted);
}

.quick-tab {
    display: inline-flex;
    min-height: 50px;
    align-items: center;
    justify-content: center;
    gap: 0.55rem;
    padding: 0.7rem 0.9rem;
    border: 1px solid transparent;
    border-radius: 14px;
    color: var(--text-soft);
    font-weight: 760;
    text-decoration: none;
}

.quick-tab:hover {
    background: #fff;
    color: var(--primary-dark);
}

.quick-tab.is-active {
    border-color: var(--border);
    background: #fff;
    color: var(--primary-dark);
    box-shadow: 0 2px 9px rgba(32, 51, 45, 0.07);
}

.quick-tab svg {
    width: 21px;
    height: 21px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.quick-panel {
    display: grid;
    gap: 1.4rem;
    padding: clamp(1.25rem, 5vw, 2.2rem);
}

.quick-panel__heading {
    text-align: center;
}

.quick-panel__heading h2 {
    margin: 0;
    font-size: 1.35rem;
    letter-spacing: -0.025em;
}

.quick-panel__heading p {
    margin: 0.45rem auto 0;
    color: var(--text-soft);
    font-size: 0.85rem;
}

.quick-form {
    display: grid;
    gap: 1rem;
    width: min(100%, 480px);
    margin-inline: auto;
}

.quick-weight-field {
    display: block;
}

.quick-weight-input-wrap {
    position: relative;
    display: block;
}

.quick-weight-input-wrap input {
    width: 100%;
    height: 104px;
    padding: 0 4.6rem 0 1.3rem;
    border: 2px solid var(--border-strong);
    border-radius: 20px;
    outline: none;
    background: #fff;
    color: var(--text);
    font-size: clamp(2.8rem, 12vw, 4.5rem);
    font-weight: 820;
    line-height: 1;
    letter-spacing: -0.06em;
    text-align: center;
    transition: border-color 120ms ease, box-shadow 120ms ease;
}

.quick-weight-input-wrap input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 5px rgba(54, 93, 82, 0.12);
}

.quick-weight-input-wrap input::placeholder {
    color: #c7ceca;
}

.quick-weight-input-wrap b {
    position: absolute;
    top: 50%;
    right: 1.35rem;
    color: var(--text-soft);
    font-size: 1.35rem;
    transform: translateY(-50%);
}

.quick-submit {
    min-height: 54px;
    border-radius: 15px;
    font-size: 1rem;
}

.quick-photo-picker {
    position: relative;
    display: grid;
    min-height: 260px;
    overflow: hidden;
    border: 2px dashed var(--border-strong);
    border-radius: 20px;
    background: var(--surface-muted);
    cursor: pointer;
    place-items: center;
    transition: border-color 120ms ease, background 120ms ease, box-shadow 120ms ease;
}

.quick-photo-picker:hover,
.quick-photo-picker:focus-within {
    border-color: var(--primary);
    background: var(--primary-soft);
    box-shadow: 0 0 0 4px rgba(54, 93, 82, 0.08);
}

.quick-photo-picker.has-file {
    border-style: solid;
    background: #fff;
}

.quick-photo-picker > input[type="file"] {
    position: absolute;
    z-index: 3;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.quick-photo-placeholder {
    display: grid;
    justify-items: center;
    gap: 0.45rem;
    padding: 1.4rem;
    text-align: center;
}

.quick-photo-placeholder svg {
    width: 56px;
    height: 56px;
    margin-bottom: 0.3rem;
    fill: none;
    stroke: var(--primary);
    stroke-width: 1.5;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.quick-photo-placeholder strong {
    font-size: 1.05rem;
}

.quick-photo-placeholder small {
    max-width: 330px;
    color: var(--text-soft);
    font-size: 0.75rem;
}

.quick-photo-preview {
    position: absolute;
    inset: 0;
    display: grid;
    align-content: end;
    overflow: hidden;
    background: #1f2d29;
}

.quick-photo-preview[hidden] {
    display: none;
}

.quick-photo-preview img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.quick-photo-preview::after {
    position: absolute;
    inset: 45% 0 0;
    background: linear-gradient(transparent, rgba(18, 29, 25, 0.88));
    content: "";
}

.quick-photo-preview strong,
.quick-photo-preview small {
    position: relative;
    z-index: 1;
    padding-inline: 1rem;
    overflow: hidden;
    color: #fff;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.quick-photo-preview strong {
    padding-bottom: 0.1rem;
}

.quick-photo-preview small {
    padding-bottom: 0.9rem;
    color: rgba(255, 255, 255, 0.76);
}

.quick-file-error {
    margin: -0.35rem 0 0;
    color: var(--danger);
    font-size: 0.82rem;
    font-weight: 700;
    text-align: center;
}

.quick-latest {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: baseline;
    gap: 0.15rem 0.75rem;
    width: min(100%, 480px);
    margin-inline: auto;
    padding: 0.9rem 1rem;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--surface-muted);
}

.quick-latest > span {
    color: var(--text-soft);
    font-size: 0.78rem;
}

.quick-latest > strong {
    font-size: 1.05rem;
}

.quick-latest > small {
    grid-column: 1 / -1;
    color: var(--text-faint);
    font-size: 0.72rem;
}

.quick-latest--photo {
    grid-template-columns: 1fr;
    align-items: start;
}

.quick-latest--photo a {
    display: block;
    margin-top: 0.35rem;
    overflow: hidden;
    border-radius: 11px;
    background: #e9edea;
}

.quick-latest--photo img {
    display: block;
    width: 100%;
    max-height: 210px;
    object-fit: cover;
}

.quick-secondary-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.7rem;
}

.quick-footer {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.75rem 0.25rem 0;
    color: var(--text-soft);
    font-size: 0.74rem;
}

.quick-back-link {
    display: block;
    margin-top: 1rem;
    color: var(--primary);
    font-size: 0.82rem;
    font-weight: 700;
    text-align: center;
    text-decoration: none;
}

.quick-back-link:hover {
    text-decoration: underline;
}

@media (max-width: 900px) {
    .profile-quick-action {
        align-items: flex-end;
        flex-direction: column;
    }
}

@media (max-width: 680px) {
    .quick-main.container {
        width: min(100% - 20px, 720px);
        padding-block: 15px 28px;
    }

    .quick-intro {
        align-items: flex-start;
    }

    .quick-intro p:last-child {
        font-size: 0.82rem;
    }

    .quick-card {
        border-radius: 20px;
    }

    .quick-panel {
        padding: 1.25rem 1rem 1.35rem;
    }

    .quick-weight-input-wrap input {
        height: 96px;
    }

    .quick-photo-picker {
        min-height: 230px;
    }

    .quick-secondary-actions {
        grid-template-columns: 1fr;
    }

    .quick-footer {
        display: grid;
        justify-content: start;
    }

    .profile-action-buttons {
        width: 100%;
        justify-content: stretch;
    }

    .profile-action-buttons .button {
        flex: 1;
    }
}

@media (max-width: 430px) {
    .quick-intro {
        display: grid;
    }

    .quick-clock {
        grid-auto-flow: column;
        align-items: baseline;
        justify-content: start;
        justify-items: start;
        gap: 0.5rem;
    }

    .quick-clock strong {
        font-size: 1.2rem;
    }

    .quick-clock span {
        margin: 0;
    }

    .quick-tab {
        min-height: 46px;
        padding-inline: 0.45rem;
        font-size: 0.88rem;
    }

    .quick-weight-input-wrap input {
        padding-right: 3.7rem;
        font-size: 3.2rem;
    }

    .quick-weight-input-wrap b {
        right: 1rem;
    }

    .profile-action-buttons {
        display: grid;
    }
}

@media (prefers-reduced-motion: reduce) {
    .record-photo img,
    .quick-photo-picker,
    .quick-weight-input-wrap input {
        transition: none;
    }
}
