:root {
    color-scheme: light;
    --bg: #f6f8fb;
    --surface: #ffffff;
    --surface-soft: #eef4f5;
    --surface-raised: #ffffff;
    --ink: #162027;
    --muted: #5f6f7a;
    --line: #dbe4ea;
    --line-strong: #c4d0d8;
    --primary: #126b68;
    --primary-strong: #0a5553;
    --primary-soft: #e5f4f1;
    --primary-ink: #ffffff;
    --accent: #df6b52;
    --accent-soft: #fff0ec;
    --sky: #356dff;
    --sky-soft: #edf3ff;
    --warning: #9a6a00;
    --warning-soft: #fff6da;
    --danger: #b23a3a;
    --danger-soft: #fff0ef;
    --success: #23764f;
    --success-soft: #e9f7ef;
    --focus-ring: rgba(18, 107, 104, 0.18);
    --shadow: 0 18px 44px rgba(31, 50, 61, 0.11);
    --shadow-soft: 0 10px 24px rgba(31, 50, 61, 0.08);
    --radius-card: 8px;
    --radius-control: 10px;
    --radius-pill: 999px;
}

:root[data-theme="dark"] {
    color-scheme: dark;
    --bg: #11171b;
    --surface: #182126;
    --surface-soft: #202b31;
    --surface-raised: #1d282e;
    --ink: #eef5f7;
    --muted: #a7b5bd;
    --line: #2c3b43;
    --line-strong: #41535d;
    --primary: #62c7be;
    --primary-strong: #8ce1d8;
    --primary-soft: #173533;
    --primary-ink: #071312;
    --accent: #ff957c;
    --accent-soft: #3a241f;
    --sky: #8aa8ff;
    --sky-soft: #1b2746;
    --warning: #f0cb63;
    --warning-soft: #332a12;
    --danger: #ff9c9c;
    --danger-soft: #351f20;
    --success: #89d8ad;
    --success-soft: #183527;
    --focus-ring: rgba(98, 199, 190, 0.24);
    --shadow: 0 18px 50px rgba(0, 0, 0, 0.32);
    --shadow-soft: 0 10px 28px rgba(0, 0, 0, 0.24);
}

* {
    box-sizing: border-box;
}

html {
    width: 100%;
    overflow-x: hidden;
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    width: 100%;
    min-height: 100vh;
    overflow-x: hidden;
    color: var(--ink);
    background: linear-gradient(180deg, var(--bg) 0%, #eef3f6 100%);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    letter-spacing: 0;
}

:root[data-theme="dark"] body {
    background: linear-gradient(180deg, #11171b 0%, #0c1013 100%);
}

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

button {
    border: 0;
    cursor: pointer;
    touch-action: manipulation;
}

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

button:active {
    transform: translateY(0);
}

button:disabled,
input:disabled,
select:disabled,
textarea:disabled {
    cursor: not-allowed;
    opacity: 0.55;
}

.shell {
    width: min(1180px, calc(100% - 32px));
    margin: 0 auto;
    padding: 28px 0;
}

.auth-view {
    min-height: calc(100vh - 56px);
    display: grid;
    grid-template-columns: minmax(0, 1.08fr) minmax(320px, 430px);
    gap: 40px;
    align-items: center;
}

.auth-story {
    display: grid;
    gap: 70px;
}

.brand-lockup {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    width: fit-content;
    color: var(--ink);
    text-decoration: none;
}

.brand-mark {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    border-radius: 8px;
    color: var(--primary-ink);
    background: var(--primary-strong) url("assets/care2u-icon.png") center / cover no-repeat;
    font-size: 0.88rem;
    font-weight: 900;
    letter-spacing: 0;
    box-shadow: 0 12px 22px rgba(18, 107, 104, 0.22);
    overflow: hidden;
    text-indent: -999px;
}

:root[data-theme="dark"] .brand-mark {
    box-shadow: none;
}

.brand-lockup strong {
    display: block;
    font-size: 1.05rem;
    line-height: 1.1;
}

.brand-lockup small {
    display: block;
    margin-top: 2px;
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 700;
}

.hero h1,
.workspace-head h1 {
    margin: 0;
    max-width: 740px;
    color: var(--ink);
    font-weight: 820;
    letter-spacing: 0;
}

.hero h1 {
    font-size: 4.7rem;
    line-height: 0.98;
}

.workspace-head h1 {
    font-size: 2.35rem;
    line-height: 1.04;
}

.hero p {
    max-width: 610px;
    margin: 18px 0 0;
    color: var(--muted);
    font-size: 1.1rem;
    line-height: 1.7;
}

.eyebrow {
    margin: 0 0 8px;
    color: var(--primary-strong);
    font-weight: 850;
    text-transform: uppercase;
    letter-spacing: 0;
    font-size: 0.76rem;
}

.trust-strip {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 24px;
}

.trust-strip span,
.identity span,
.pill {
    width: fit-content;
    border-radius: var(--radius-pill);
    padding: 7px 11px;
    color: var(--primary-strong);
    background: var(--primary-soft);
    border: 1px solid rgba(18, 107, 104, 0.16);
    font-size: 0.78rem;
    font-weight: 850;
}

.trust-strip span:nth-child(2) {
    color: var(--sky);
    background: var(--sky-soft);
    border-color: rgba(53, 109, 255, 0.2);
}

.trust-strip span:nth-child(3) {
    color: var(--accent);
    background: var(--accent-soft);
    border-color: rgba(223, 107, 82, 0.24);
}

.auth-panel,
.panel,
.sidebar,
.context-bar {
    border: 1px solid var(--line);
    background: var(--surface);
    box-shadow: var(--shadow-soft);
    border-radius: var(--radius-card);
}

.auth-panel {
    padding: 24px;
    box-shadow: var(--shadow);
}

.auth-panel-head {
    margin-bottom: 18px;
}

.auth-panel h2,
.panel h2 {
    margin: 0;
    font-size: 1.18rem;
    line-height: 1.25;
}

.tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
    margin-bottom: 18px;
    border-radius: 8px;
    padding: 4px;
    background: var(--surface-soft);
    border: 1px solid var(--line);
}

.tab,
.ghost,
.secondary,
.icon-button {
    min-height: 44px;
    border-radius: var(--radius-control);
    background: var(--surface-raised);
    color: var(--ink);
    border: 1px solid var(--line);
    padding: 0 14px;
    font-weight: 780;
    box-shadow: none;
    transition: transform 160ms ease, border-color 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

.tab {
    background: transparent;
    border-color: transparent;
}

.tab.active {
    background: var(--surface-raised);
    color: var(--ink);
    border-color: var(--line);
    box-shadow: 0 4px 10px rgba(31, 50, 61, 0.07);
}

.primary {
    min-height: 48px;
    border-radius: var(--radius-control);
    background: var(--primary-strong);
    color: var(--primary-ink);
    padding: 0 18px;
    font-weight: 850;
    box-shadow: 0 14px 24px rgba(18, 107, 104, 0.19);
    transition: transform 160ms ease, box-shadow 160ms ease, filter 160ms ease;
}

.secondary {
    color: var(--primary-strong);
    background: var(--primary-soft);
    border-color: rgba(18, 107, 104, 0.2);
}

.ghost {
    background: transparent;
}

.primary:hover,
.secondary:hover,
.ghost:hover,
.icon-button:hover,
.nav-item:hover,
.quick-action:hover {
    box-shadow: var(--shadow-soft);
}

.utility-bar {
    width: fit-content;
    display: flex;
    gap: 8px;
    margin-top: 24px;
    padding: 0;
}

.icon-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.icon-button.is-ready {
    border-color: var(--primary);
    background: var(--primary-soft);
}

.auth-form,
.stack {
    display: grid;
    gap: 14px;
}

label {
    display: grid;
    gap: 7px;
    color: var(--muted);
    font-size: 0.92rem;
    font-weight: 760;
}

input,
select,
textarea {
    width: 100%;
    min-height: 48px;
    border: 1px solid var(--line);
    border-radius: var(--radius-control);
    background: var(--surface-raised);
    color: var(--ink);
    padding: 13px 14px;
    outline: none;
    font-size: 16px;
    transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

textarea {
    resize: vertical;
    min-height: 190px;
    line-height: 1.55;
}

input:focus,
select:focus,
textarea:focus,
button:focus-visible {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px var(--focus-ring);
}

.hint,
small,
.muted {
    color: var(--muted);
}

.hint {
    margin: 0;
    line-height: 1.45;
}

.hidden {
    display: none !important;
}

.app-view {
    min-height: calc(100vh - 56px);
}

.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
    padding: 10px 0;
}

.topbar-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    flex: 0 0 auto;
}

.utility-anchor .utility-bar {
    margin: 0;
}

.app-layout {
    display: grid;
    grid-template-columns: 260px minmax(0, 1fr);
    gap: 18px;
    align-items: start;
}

.sidebar {
    position: sticky;
    top: 18px;
    display: grid;
    gap: 18px;
    padding: 14px;
}

.identity {
    display: grid;
    gap: 7px;
    padding: 12px;
    border-bottom: 1px solid var(--line);
}

.identity strong {
    overflow-wrap: anywhere;
}

.section-nav {
    display: grid;
    gap: 6px;
}

.nav-item {
    display: grid;
    grid-template-columns: 32px 1fr auto;
    align-items: center;
    gap: 10px;
    min-height: 46px;
    border-radius: var(--radius-control);
    padding: 7px 10px;
    color: var(--muted);
    background: transparent;
    border: 1px solid transparent;
    font-weight: 820;
    text-align: left;
    transition: transform 160ms ease, background 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.nav-item.is-active {
    color: var(--ink);
    background: var(--surface-soft);
    border-color: var(--line);
}

.nav-icon {
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    border-radius: 9px;
    color: var(--primary-strong);
    background: var(--primary-soft);
    font-size: 0.78rem;
    font-weight: 900;
}

.nav-item:nth-child(2) .nav-icon {
    color: var(--sky);
    background: var(--sky-soft);
}

.nav-item:nth-child(3) .nav-icon {
    color: var(--warning);
    background: var(--warning-soft);
}

.nav-item:nth-child(4) .nav-icon {
    color: var(--accent);
    background: var(--accent-soft);
}

.nav-item small {
    min-width: 26px;
    padding: 3px 7px;
    border-radius: var(--radius-pill);
    color: var(--muted);
    background: var(--surface-raised);
    border: 1px solid var(--line);
    text-align: center;
    font-size: 0.76rem;
}

.workspace {
    display: grid;
    gap: 16px;
    min-width: 0;
}

.workspace-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    padding: 4px 2px 2px;
}

.workspace-head p:last-child {
    max-width: 660px;
    margin: 10px 0 0;
    line-height: 1.55;
}

.context-bar {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 12px;
    align-items: end;
    padding: 12px;
}

.view-screen {
    display: none;
    min-width: 0;
}

.view-screen.is-active {
    display: grid;
    gap: 16px;
}

.panel {
    padding: 18px;
}

.panel-title {
    margin-bottom: 16px;
}

.plant-panel {
    display: grid;
    gap: 18px;
    overflow: hidden;
}

.plant-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(260px, 350px);
    gap: 18px;
    align-items: start;
}

.plant-card {
    display: flex;
    align-items: center;
    gap: 16px;
    min-width: 0;
}

.plant-card h2 {
    margin: 0 0 6px;
    font-size: 1.35rem;
}

.plant-card p:last-child {
    margin: 0;
    line-height: 1.55;
}

.plant-visual {
    position: relative;
    display: grid;
    place-items: end center;
    flex: 0 0 108px;
    width: 108px;
    height: 120px;
    border-radius: var(--radius-card);
    background: linear-gradient(180deg, var(--primary-soft), var(--sky-soft));
    border: 1px solid var(--line);
    overflow: hidden;
}

.plant-visual::after {
    content: "";
    position: absolute;
    bottom: 14px;
    width: 58px;
    height: 30px;
    border-radius: 0 0 14px 14px;
    background: var(--accent-soft);
    border: 1px solid var(--line-strong);
}

.plant-sprout {
    position: relative;
    z-index: 1;
    width: 8px;
    height: 44px;
    margin-bottom: 34px;
    border-radius: 999px;
    background: var(--primary);
    transform-origin: bottom center;
}

.plant-sprout::before,
.plant-sprout::after {
    content: "";
    position: absolute;
    bottom: 20px;
    width: 28px;
    height: 18px;
    border-radius: 999px 999px 999px 0;
    background: var(--primary);
}

.plant-sprout::before {
    right: 4px;
    transform: rotate(-34deg);
}

.plant-sprout::after {
    left: 4px;
    transform: scaleX(-1) rotate(-34deg);
}

.needs-water .plant-sprout {
    height: 30px;
    opacity: 0.72;
}

.plant-growing .plant-sprout {
    height: 48px;
}

.plant-leafy .plant-sprout,
.plant-bloom .plant-sprout {
    height: 58px;
}

.plant-bloom .plant-sprout::before,
.plant-bloom .plant-sprout::after {
    background: var(--success);
}

.plant-bloom::before {
    content: "";
    position: absolute;
    top: 30px;
    width: 18px;
    height: 18px;
    border-radius: 999px;
    background: var(--accent);
    z-index: 2;
}

.checkin-form {
    display: grid;
    gap: 12px;
    padding: 14px;
    border-radius: var(--radius-card);
    background: var(--surface-soft);
    border: 1px solid var(--line);
}

input[type="range"] {
    padding: 0;
    min-height: 28px;
    accent-color: var(--primary);
    box-shadow: none;
}

.checkin-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    border: 1px solid var(--line);
    border-radius: var(--radius-card);
    overflow: hidden;
}

.checkin-stats > div {
    min-width: 0;
    padding: 14px;
    background: var(--surface-soft);
}

.checkin-stats > div + div {
    border-left: 1px solid var(--line);
}

.checkin-stats strong {
    display: block;
    font-size: 1.15rem;
    line-height: 1.2;
}

.checkin-history {
    display: grid;
    gap: 8px;
}

.checkin-row {
    display: grid;
    grid-template-columns: minmax(130px, 0.7fr) 1fr;
    gap: 12px;
    padding: 13px;
    border: 1px solid var(--line);
    border-radius: var(--radius-card);
    background: var(--surface-raised);
}

.score-bars {
    display: grid;
    gap: 7px;
}

.score-line {
    display: grid;
    grid-template-columns: 58px 1fr 20px;
    align-items: center;
    gap: 8px;
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 760;
}

.score-line i {
    height: 8px;
    border-radius: 999px;
    background: var(--surface-soft);
    overflow: hidden;
}

.score-line b {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: var(--primary);
}

.score-line em {
    color: var(--ink);
    font-style: normal;
    text-align: right;
}

.quick-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.quick-action {
    display: grid;
    gap: 8px;
    min-height: 116px;
    padding: 16px;
    border-radius: var(--radius-card);
    color: var(--ink);
    background: var(--surface);
    border: 1px solid var(--line);
    text-align: left;
    transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
}

.quick-action span {
    color: var(--primary-strong);
    font-size: 0.82rem;
    font-weight: 850;
    text-transform: uppercase;
}

.quick-action:nth-child(2) span {
    color: var(--sky);
}

.quick-action:nth-child(3) span {
    color: var(--accent);
}

.quick-action strong {
    font-size: 1rem;
    line-height: 1.35;
}

.split-view {
    display: grid;
    grid-template-columns: minmax(280px, 0.78fr) minmax(0, 1.22fr);
    gap: 16px;
    align-items: start;
}

.split-view-narrow {
    grid-template-columns: minmax(260px, 0.62fr) minmax(0, 1.38fr);
}

.diary-layout {
    grid-template-columns: minmax(260px, 0.58fr) minmax(0, 1.42fr);
}

.app-view.is-professional .split-view,
.app-view.is-professional .split-view-narrow,
.app-view.is-professional .plant-layout {
    grid-template-columns: 1fr;
}

.composer-panel {
    align-self: start;
}

.composer-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    cursor: pointer;
    list-style: none;
}

.composer-summary::-webkit-details-marker {
    display: none;
}

.composer-summary .eyebrow {
    display: block;
}

.composer-summary strong {
    display: block;
    font-size: 1.18rem;
    line-height: 1.25;
}

.summary-hint {
    flex: 0 0 auto;
    border-radius: var(--radius-pill);
    padding: 7px 11px;
    color: var(--primary-strong);
    background: var(--primary-soft);
    border: 1px solid rgba(18, 107, 104, 0.16);
    font-size: 0.78rem;
    font-weight: 850;
}

.composer-panel form {
    margin-top: 16px;
}

.diary-title {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(210px, 280px);
    gap: 14px;
    align-items: end;
}

.diary-controls {
    display: grid;
    grid-template-columns: 1fr 0.72fr;
    gap: 8px;
}

.search-label {
    gap: 6px;
}

.diary-controls small {
    grid-column: 1 / -1;
}

.pager {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 10px;
    margin-top: 12px;
}

.pager small {
    text-align: center;
}

.session-form {
    display: grid;
    grid-template-columns: 1.15fr 96px minmax(140px, 1fr) auto;
    gap: 12px;
    align-items: end;
}

.list,
.thoughts {
    display: grid;
    gap: 10px;
}

.roomy {
    margin-top: 14px;
}

.item,
.thought,
.empty-state {
    border: 1px solid var(--line);
    background: var(--surface-raised);
    border-radius: var(--radius-card);
    padding: 14px;
    min-width: 0;
}

.item {
    display: grid;
    gap: 6px;
}

.item strong,
.thought strong {
    display: block;
    overflow-wrap: anywhere;
}

.item span {
    overflow-wrap: anywhere;
}

.item-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 8px;
}

.danger {
    min-height: 40px;
    border-radius: var(--radius-control);
    padding: 0 13px;
    font-weight: 850;
    color: var(--danger);
    background: var(--danger-soft);
    border: 1px solid rgba(178, 58, 58, 0.24);
}

.thought {
    border-left: 4px solid var(--accent);
    background: linear-gradient(90deg, var(--accent-soft), var(--surface-raised) 36%);
}

.thought header {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
}

.thought header div {
    min-width: 0;
}

.thought p {
    margin: 0;
    color: var(--ink);
    line-height: 1.55;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.empty-state {
    color: var(--muted);
    line-height: 1.5;
    background: var(--surface-soft);
}

.requires-link.is-disabled {
    position: relative;
}

.requires-link.is-disabled::after {
    content: "Necesitas un vinculo activo para usar esta accion.";
    display: block;
    margin-top: 8px;
    color: var(--muted);
    font-size: 0.84rem;
    line-height: 1.35;
}

.install-sheet {
    position: fixed;
    inset: 0;
    z-index: 60;
    display: grid;
    place-items: end center;
    padding: 18px;
    background: rgba(13, 21, 26, 0.34);
}

:root[data-theme="dark"] .install-sheet {
    background: rgba(0, 0, 0, 0.58);
}

.install-card {
    position: relative;
    width: min(420px, 100%);
    border: 1px solid var(--line);
    border-radius: var(--radius-card);
    padding: 22px;
    color: var(--ink);
    background: var(--surface);
    box-shadow: var(--shadow);
}

.install-card h2 {
    margin: 0 0 8px;
}

.install-card p:last-child {
    margin-bottom: 0;
    color: var(--muted);
    line-height: 1.5;
}

.sheet-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-control);
    color: var(--ink);
    background: var(--surface-soft);
    border: 1px solid var(--line);
    font-size: 1.1rem;
    font-weight: 850;
}

.toast-region {
    position: fixed;
    right: max(18px, env(safe-area-inset-right));
    bottom: max(18px, env(safe-area-inset-bottom));
    z-index: 80;
    display: grid;
    gap: 10px;
    width: min(420px, calc(100% - 28px));
    pointer-events: none;
}

.toast {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 12px;
    min-height: 58px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius-card);
    color: var(--ink);
    background: var(--surface);
    box-shadow: var(--shadow);
    pointer-events: auto;
    transform: translateY(12px) scale(0.98);
    opacity: 0;
    transition: transform 220ms ease, opacity 220ms ease;
}

.toast.is-visible {
    transform: translateY(0) scale(1);
    opacity: 1;
}

.toast.is-leaving {
    transform: translateY(8px) scale(0.98);
    opacity: 0;
}

.toast-success {
    border-color: rgba(35, 118, 79, 0.28);
    background: var(--success-soft);
}

.toast-error {
    border-color: rgba(178, 58, 58, 0.28);
    background: var(--danger-soft);
}

.toast-icon {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: var(--radius-control);
    color: var(--success);
    background: var(--surface-raised);
    border: 1px solid currentColor;
    font-size: 0.74rem;
    font-weight: 900;
}

.toast-error .toast-icon {
    color: var(--danger);
}

.toast-text {
    min-width: 0;
    color: var(--ink);
    font-size: 0.95rem;
    font-weight: 760;
    line-height: 1.35;
}

.toast-close {
    width: 34px;
    height: 34px;
    border-radius: var(--radius-control);
    color: var(--muted);
    background: var(--surface-raised);
    border: 1px solid var(--line);
    font-size: 1rem;
    font-weight: 900;
}

@media (max-width: 980px) {
    .auth-view,
    .app-layout,
    .split-view,
    .split-view-narrow,
    .diary-layout,
    .plant-layout,
    .quick-grid {
        grid-template-columns: 1fr;
    }

    .auth-view {
        align-items: start;
        gap: 24px;
        min-height: auto;
    }

    .auth-story {
        gap: 44px;
        padding-top: 10px;
    }

    .hero h1 {
        font-size: 3.4rem;
        line-height: 1.02;
    }

    .sidebar {
        position: static;
    }

    .section-nav {
        grid-template-columns: repeat(4, minmax(0, 1fr));
        overflow-x: auto;
        padding-bottom: 2px;
    }

    .nav-item {
        grid-template-columns: 1fr;
        justify-items: center;
        min-width: 102px;
        text-align: center;
    }

    .nav-item small {
        display: none;
    }

    .session-form {
        grid-template-columns: 1fr 100px;
    }

    .session-form label:nth-child(3),
    .session-form button {
        grid-column: 1 / -1;
    }

    .diary-title {
        grid-template-columns: 1fr;
    }

    .diary-controls {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    .shell {
        width: 100%;
        padding: 12px 10px calc(112px + env(safe-area-inset-bottom));
    }

    .auth-story {
        gap: 30px;
    }

    .hero h1 {
        font-size: 2.55rem;
    }

    .hero p {
        font-size: 1rem;
        line-height: 1.6;
    }

    .utility-bar,
    .topbar-actions,
    .context-bar,
    .session-form,
    .checkin-row {
        grid-template-columns: 1fr;
    }

    .utility-bar {
        width: 100%;
    }

    .icon-button {
        flex: 1;
        min-height: 50px;
    }

    .auth-panel,
    .panel,
    .sidebar,
    .context-bar {
        box-shadow: none;
    }

    .auth-panel,
    .sidebar,
    .panel {
        padding: 14px;
    }

    .sidebar {
        gap: 0;
    }

    .identity {
        border-bottom: 0;
    }

    .section-nav {
        position: fixed;
        left: 10px;
        right: 10px;
        bottom: max(10px, env(safe-area-inset-bottom));
        z-index: 70;
        display: grid;
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: 4px;
        padding: 8px;
        overflow: visible;
        border: 1px solid var(--line);
        border-radius: var(--radius-card);
        background: var(--surface);
        background: color-mix(in srgb, var(--surface) 94%, transparent);
        box-shadow: var(--shadow);
        backdrop-filter: blur(18px);
    }

    .nav-item {
        grid-template-columns: 1fr;
        justify-items: center;
        gap: 4px;
        min-width: 0;
        min-height: 58px;
        padding: 6px 4px;
        border-radius: var(--radius-card);
        text-align: center;
        font-size: 0.78rem;
    }

    .nav-item.is-active {
        background: var(--primary-soft);
        border-color: rgba(18, 107, 104, 0.22);
    }

    .nav-icon {
        width: 28px;
        height: 28px;
        border-radius: var(--radius-card);
        font-size: 0.72rem;
    }

    .app-header {
        align-items: flex-start;
        flex-wrap: wrap;
        margin-bottom: 10px;
    }

    .topbar-actions {
        width: 100%;
        display: grid;
        gap: 8px;
    }

    .topbar-actions .utility-bar {
        width: 100%;
        margin: 0;
    }

    .ghost {
        min-height: 50px;
    }

    .workspace,
    .view-screen,
    .app-layout {
        gap: 12px;
    }

    .workspace-head h1 {
        font-size: 1.8rem;
    }

    .context-bar {
        position: sticky;
        top: 8px;
        z-index: 5;
        padding: 10px;
    }

    .plant-card {
        align-items: flex-start;
    }

    .plant-visual {
        flex-basis: 86px;
        width: 86px;
        height: 96px;
    }

    .checkin-stats {
        grid-template-columns: 1fr;
    }

    .checkin-stats > div + div {
        border-left: 0;
        border-top: 1px solid var(--line);
    }

    .primary,
    .secondary,
    .danger,
    .session-form button,
    .context-bar button {
        width: 100%;
        min-height: 52px;
    }

    input,
    select,
    textarea {
        min-height: 52px;
        padding: 14px 15px;
    }

    textarea {
        min-height: 220px;
    }

    .thought header {
        display: grid;
        gap: 5px;
    }

    .thought header small {
        font-size: 0.78rem;
    }

    .toast-region {
        left: 10px;
        right: 10px;
        bottom: calc(92px + env(safe-area-inset-bottom));
        width: auto;
    }
}

@media (max-width: 390px) {
    .shell {
        padding-inline: 8px;
    }

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

    .hero h1 {
        font-size: 2.2rem;
    }

    .section-nav {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

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

    .toast,
    .toast.is-visible,
    .toast.is-leaving {
        transform: none;
    }
}
