:root {
    --bg: #f8f8fb;
    --surface: #ffffff;
    --surface-strong: #ffffff;
    --text: #152338;
    --muted: #647086;
    --line: rgba(106, 112, 190, 0.18);
    --accent: #7347c7;
    --accent-strong: #4d8ed7;
    --accent-soft: #e9f4ff;
    --gold: #9ad9f2;
    --danger: #bd4c6d;
    --shadow: 0 18px 42px rgba(54, 65, 128, 0.12);
    --radius: 16px;
    --radius-small: 12px;
}

* {
    box-sizing: border-box;
}

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

body {
    min-height: 100vh;
    margin: 0;
    color: var(--text);
    font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
    background:
        linear-gradient(135deg, rgba(126, 210, 235, 0.26), transparent 34%),
        linear-gradient(315deg, rgba(127, 73, 209, 0.18), transparent 32%),
        var(--bg);
}

a {
    color: inherit;
}

button,
input,
textarea {
    font: inherit;
}

.app-shell,
.auth-shell {
    width: min(100%, 760px);
    margin: 0 auto;
    padding: max(18px, env(safe-area-inset-top)) 14px 36px;
}

.app-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin: 6px 0 18px;
}

.app-header > div:first-child::before,
.brand-panel::before {
    content: "";
    display: block;
    width: 54px;
    height: 54px;
    margin: 0 0 8px;
    background: url("icon.png") center / contain no-repeat;
}

.eyebrow {
    margin: 0 0 6px;
    color: var(--accent);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0;
    text-transform: uppercase;
}

h1 {
    margin: 0;
    font-size: 34px;
    line-height: 1.02;
}

h2 {
    margin: 0;
    font-size: 18px;
    line-height: 1.22;
}

p {
    line-height: 1.45;
}

.brand-panel {
    min-height: 34vh;
    display: grid;
    align-content: end;
    padding: 24px 0;
}

.brand-panel h1 {
    max-width: 620px;
    font-size: 42px;
}

.brand-panel p:last-child {
    max-width: 520px;
    margin: 14px 0 0;
    color: var(--muted);
    font-size: 17px;
}

.auth-card,
.quick-add {
    background: rgba(255, 255, 255, 0.88);
    border: 1px solid rgba(255, 255, 255, 0.72);
    border-radius: var(--radius-small);
    box-shadow: var(--shadow);
    padding: 14px;
    backdrop-filter: blur(16px);
}

:focus-visible {
    outline: 3px solid rgba(77, 142, 215, 0.42);
    outline-offset: 3px;
}

.auth-card,
.quick-add,
.remember-item {
    border-radius: var(--radius);
}

button,
.primary,
.top-nav a {
    transition: transform 0.16s ease, box-shadow 0.16s ease, background-color 0.16s ease;
}

button:active,
.primary:active,
.top-nav a:active {
    transform: scale(0.98);
}

@media (max-width: 640px) {
    body:not(.auth-body) {
        padding-bottom: calc(82px + env(safe-area-inset-bottom));
    }

    .top-nav {
        position: fixed;
        z-index: 100;
        right: 10px;
        bottom: max(10px, env(safe-area-inset-bottom));
        left: 10px;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        margin: 0;
        padding: 8px;
        border: 1px solid var(--line);
        border-radius: 18px;
        background: rgba(255, 255, 255, 0.94);
        box-shadow: 0 14px 38px rgba(35, 42, 91, 0.2);
        backdrop-filter: blur(18px);
    }

    .top-nav a {
        min-width: 0;
        padding-inline: 8px;
        font-size: 12px;
    }

    .brand-panel {
        min-height: 28vh;
    }

    .brand-panel h1 {
        font-size: clamp(32px, 10vw, 42px);
    }
}

.maintenance-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
}

.maintenance-card {
    width: min(100%, 560px);
    padding: 24px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: rgba(255, 255, 255, 0.9);
    box-shadow: var(--shadow);
    backdrop-filter: blur(18px);
}

.maintenance-card h1 { margin-bottom: 12px; }
.maintenance-card p { color: var(--muted); }
.maintenance-card .primary { width: 100%; }

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

.top-nav {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 8px;
    margin: 0 0 16px;
}

.top-nav a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 46px;
    padding: 10px 14px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.64);
    border: 1px solid var(--line);
    color: var(--muted);
    text-decoration: none;
    font-weight: 800;
    font-size: 14px;
}

.top-nav a.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #ffffff;
}

.stack {
    display: grid;
    gap: 12px;
}

label {
    display: grid;
    gap: 7px;
    color: var(--muted);
    font-size: 14px;
    font-weight: 700;
}

input,
textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface-strong);
    color: var(--text);
    outline: none;
    padding: 15px 16px;
    font-size: 17px;
}

textarea {
    resize: vertical;
}

input:focus,
textarea:focus {
    border-color: rgba(115, 71, 199, 0.42);
    box-shadow: 0 0 0 4px rgba(107, 163, 224, 0.16);
}

button {
    min-height: 54px;
    border: 0;
    border-radius: 8px;
    background: #ecf4fb;
    color: var(--text);
    font-weight: 800;
    cursor: pointer;
}

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

.tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 14px;
}

.tab-button {
    min-height: 46px;
    background: transparent;
    border: 1px solid var(--line);
    color: var(--muted);
}

.tab-button.active {
    background: var(--accent-soft);
    border-color: rgba(106, 112, 190, 0.24);
    color: var(--accent);
}

.hidden {
    display: none;
}

.status {
    margin: 12px 0;
    padding: 12px 14px;
    border-radius: 8px;
    background: var(--accent-soft);
    border: 1px solid rgba(106, 112, 190, 0.18);
    color: var(--accent);
    font-weight: 800;
}

.status.error {
    background: rgba(182, 64, 50, 0.10);
    border-color: rgba(182, 64, 50, 0.18);
    color: var(--danger);
}

.icon-action,
.delete-button {
    width: 44px;
    min-height: 44px;
    padding: 0;
    border-radius: 8px;
    background: var(--surface);
    border: 1px solid var(--line);
    box-shadow: none;
}

.icon-action {
    font-size: 22px;
    transform: rotate(45deg);
}

.header-actions {
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

.header-actions form {
    margin: 0;
}

.settings-action,
.logout-action {
    text-decoration: none;
    transform: rotate(45deg);
}

.header-actions .icon-action {
    transform: rotate(45deg);
}

.settings-action.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fffaf0;
}

.logout-action[data-icon="logout"] {
    position: relative;
    font-size: 0;
}

.settings-action {
    font-size: 0;
    position: relative;
}

.settings-action::before {
    content: "⚙";
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    font-size: 20px;
    line-height: 1;
    transform: rotate(-45deg);
}

.logout-action[data-icon="logout"]::before {
    content: "";
    position: absolute;
    left: 50%;
    top: 50%;
    width: 24px;
    height: 24px;
    background: currentColor;
    transform: translate(-50%, -50%) rotate(-45deg);
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M5 3h9a2 2 0 0 1 2 2v3h-2V5H5v14h9v-3h2v3a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2Zm10.6 5.4L17 7l5 5-5 5-1.4-1.4 2.6-2.6H9v-2h9.2l-2.6-2.6Z'/%3E%3C/svg%3E") center / contain no-repeat;
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M5 3h9a2 2 0 0 1 2 2v3h-2V5H5v14h9v-3h2v3a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2Zm10.6 5.4L17 7l5 5-5 5-1.4-1.4 2.6-2.6H9v-2h9.2l-2.6-2.6Z'/%3E%3C/svg%3E") center / contain no-repeat;
}

.logout-action[data-icon="logout"] span {
    display: none;
}

.tag-strip {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 16px 0;
    scrollbar-width: none;
}

.tag-strip::-webkit-scrollbar {
    display: none;
}

.tag-strip a,
.item-tags a {
    display: inline-flex;
    align-items: center;
    min-height: 36px;
    padding: 8px 12px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.72);
    border: 1px solid var(--line);
    color: var(--accent);
    text-decoration: none;
    font-size: 14px;
    font-weight: 800;
    white-space: nowrap;
}

.tag-strip a.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fffaf0;
}

.remember-list {
    display: grid;
    gap: 10px;
}

.remember-item {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: start;
    gap: 12px;
    padding: 13px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.78);
    border: 1px solid rgba(34, 90, 72, 0.12);
    box-shadow: 0 10px 26px rgba(29, 48, 42, 0.08);
}

.remember-item.done {
    opacity: 0.64;
}

.remember-item.done h2 {
    text-decoration: line-through;
}

.check-button {
    position: relative;
    width: 30px;
    min-height: 30px;
    margin-top: 1px;
    border-radius: 999px;
    border: 2px solid rgba(34, 90, 72, 0.42);
    background: transparent;
    box-shadow: none;
}

.check-button.checked {
    background: var(--accent);
    border-color: var(--accent);
}

.check-button.checked::after {
    content: "";
    position: absolute;
    left: 9px;
    top: 4px;
    width: 7px;
    height: 14px;
    border-right: 3px solid #fff;
    border-bottom: 3px solid #fff;
    transform: rotate(42deg);
}

.item-content {
    display: grid;
    gap: 7px;
    min-width: 0;
}

.item-content p {
    margin: 0;
    color: var(--muted);
    word-break: break-word;
}

.item-dates {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 10px;
}

.item-date {
    color: rgba(104, 116, 111, 0.72);
    font-size: 12px;
    line-height: 1.2;
}

.due-date {
    color: var(--accent-strong);
    font-weight: 800;
}

.due-date.due-now {
    color: var(--accent);
}

/* Two primary destinations with a lighter secondary add action. */
.top-nav:has(.nav-add) {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.top-nav .nav-add {
    grid-column: 1 / -1;
    min-height: 40px;
    background: rgba(233, 244, 255, 0.72);
    border-color: rgba(77, 142, 215, 0.2);
    color: var(--accent);
    font-weight: 700;
}

.top-nav .nav-add.active {
    background: rgba(115, 71, 199, 0.13);
    border-color: rgba(115, 71, 199, 0.3);
    color: var(--accent);
}

/* MemMark mobile design refresh */
.auth-card,
.quick-add,
.remember-item { border-radius: var(--radius); }

@media (max-width: 640px) {
    body:not(.auth-body) { padding-bottom: calc(86px + env(safe-area-inset-bottom)); }
    .top-nav {
        position: fixed; z-index: 100; right: 10px;
        bottom: max(10px, env(safe-area-inset-bottom)); left: 10px;
        margin: 0; padding: 8px; border: 1px solid var(--line);
        border-radius: 18px; background: rgba(255, 255, 255, 0.94);
        box-shadow: 0 14px 38px rgba(35, 42, 91, 0.2);
        backdrop-filter: blur(18px);
    }

    .top-nav a {
        min-width: 0;
        padding-inline: 7px;
        font-size: 12px;
    }
}

.item-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.item-tags a {
    min-height: 30px;
    padding: 5px 9px;
    font-size: 12px;
    background: var(--accent-soft);
}

.delete-button {
    min-height: 34px;
    width: 34px;
    color: var(--danger);
    font-size: 24px;
    line-height: 1;
}

.empty {
    margin: 18px 0;
    color: var(--muted);
    text-align: center;
}

@media (min-width: 680px) {
    .quick-add:not(.add-page-form) .stack {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 180px;
    }

    .quick-add:not(.add-page-form) textarea,
    .quick-add:not(.add-page-form) button {
        grid-column: auto;
    }
}

@media (max-width: 430px) {
    .app-shell,
    .auth-shell {
        padding-left: 12px;
        padding-right: 12px;
    }

    h1 {
        font-size: 30px;
    }

    .brand-panel h1 {
        font-size: 36px;
    }
}

/* Logo theme lock */
.top-nav a.active,
.tag-strip a.active,
button.primary,
.check-button.checked,
.settings-action.active {
    color: #ffffff;
}

.remember-item {
    border-color: rgba(106, 112, 190, 0.14);
}

.check-button {
    border-color: rgba(77, 142, 215, 0.48);
}

.due-date {
    color: var(--accent-strong);
}

.item-date {
    color: rgba(100, 112, 134, 0.78);
}

.due-date.due-now {
    color: var(--accent);
}
