:root {
    --ios-bg: #f2f2f7;
    --ios-card: #ffffff;
    --ios-text: #000000;
    --ios-text-secondary: #6d6d72;
    --ios-text-tertiary: #c7c7cc;
    --ios-separator: rgba(60, 60, 67, 0.29);
    --ios-blue: #007aff;
    --ios-red: #ff3b30;
    --ios-bar-bg: rgba(249, 249, 249, 0.82);
    --ios-bar-border: rgba(60, 60, 67, 0.29);
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

@media (prefers-color-scheme: dark) {
    :root {
        --ios-bg: #000000;
        --ios-card: #1c1c1e;
        --ios-text: #ffffff;
        --ios-text-secondary: #98989d;
        --ios-text-tertiary: #48484a;
        --ios-separator: rgba(84, 84, 88, 0.6);
        --ios-blue: #0a84ff;
        --ios-red: #ff453a;
        --ios-bar-bg: rgba(28, 28, 30, 0.78);
        --ios-bar-border: rgba(84, 84, 88, 0.6);
    }
}

* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html {
    background: var(--ios-bg);
}

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
    background: var(--ios-bg);
    color: var(--ios-text);
    line-height: 1.4;
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--ios-blue);
    text-decoration: none;
}

/* ---------- Navigatiebalk (top) ---------- */

.ios-navbar {
    position: sticky;
    top: 0;
    z-index: 20;
    background: var(--ios-bar-bg);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    border-bottom: 0.5px solid var(--ios-bar-border);
    padding-top: var(--safe-top);
}

.ios-navbar-inner {
    max-width: 720px;
    margin: 0 auto;
    height: 44px;
    display: flex;
    align-items: center;
}

.ios-navbar-side {
    flex: 1 1 0;
    display: flex;
    align-items: center;
    min-width: 0;
}

.ios-navbar-side--left {
    justify-content: flex-start;
    padding-left: 4px;
}

.ios-navbar-title {
    flex: 2 1 0;
    text-align: center;
    font-size: 1.05rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding: 0 0.3rem;
}

.ios-back {
    display: flex;
    align-items: center;
    color: var(--ios-blue);
    font-size: 1rem;
    gap: 2px;
    padding: 0.4rem 0.3rem 0.4rem 0;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ios-back-chevron {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
    margin-right: -4px;
}

/* ---------- Tabbalk (bottom) ---------- */

.ios-tabbar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 20;
    display: flex;
    background: var(--ios-bar-bg);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    border-top: 0.5px solid var(--ios-bar-border);
    padding-bottom: var(--safe-bottom);
}

.ios-tab {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 7px 2px 5px;
    color: var(--ios-text-secondary);
}

.ios-tab-icon {
    width: 25px;
    height: 25px;
}

.ios-tab-label {
    font-size: 0.62rem;
    font-weight: 500;
    letter-spacing: 0.01em;
    white-space: nowrap;
}

.ios-tab.active {
    color: var(--ios-blue);
}

/* ---------- Layout ---------- */

.container {
    max-width: 720px;
    margin: 0 auto;
    padding: 0.6rem 1rem calc(78px + var(--safe-bottom));
    min-height: 100vh;
}

.ios-page-title,
.container > h1 {
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin: 0.5rem 0.1rem 1rem;
}

.container h2 {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--ios-text-secondary);
    margin: 1.6rem 0.9rem 0.5rem;
}

.categorie-groep h2 {
    margin-top: 0;
}

.uitleg {
    color: var(--ios-text-secondary);
    margin: 0 0.9rem 0.9rem;
    font-size: 0.88rem;
}

.ios-flash {
    background: var(--ios-card);
    background: color-mix(in srgb, var(--ios-blue) 12%, var(--ios-card));
    color: var(--ios-blue);
    padding: 0.7rem 0.9rem;
    border-radius: 12px;
    margin: 0 0 1rem;
    font-size: 0.9rem;
    font-weight: 500;
}

/* ---------- Gegroepeerde kaart / lijst (iOS Settings-stijl) ---------- */

.ios-card {
    background: var(--ios-card);
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 1.1rem;
    box-shadow: 0 0 0 0.5px var(--ios-separator);
}

.ios-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.ios-list-row {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 44px;
    padding: 0 16px;
    gap: 10px;
}

.ios-list-row:not(:last-child)::after,
.ios-form-row:not(:last-child)::after {
    content: "";
    position: absolute;
    left: 16px;
    right: 0;
    bottom: 0;
    height: 0.5px;
    background: var(--ios-separator);
}

.ios-row-link {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 0;
    min-width: 0;
    color: var(--ios-text);
}

.ios-row-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.ios-row-title {
    font-size: 1rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ios-row-subtitle {
    font-size: 0.82rem;
    color: var(--ios-text-secondary);
    margin-top: 1px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ios-row-value {
    font-size: 0.92rem;
    color: var(--ios-text-secondary);
    white-space: nowrap;
    flex-shrink: 0;
}

.ios-chevron {
    color: var(--ios-text-tertiary);
    font-size: 1.2rem;
    flex-shrink: 0;
}

.ios-row-delete {
    flex-shrink: 0;
}

.ios-delete-link {
    background: none;
    border: none;
    color: var(--ios-red);
    font-size: 0.92rem;
    padding: 10px 0 10px 4px;
    cursor: pointer;
    font-family: inherit;
}

.ios-empty {
    padding: 0.9rem 16px;
    color: var(--ios-text-secondary);
    font-size: 0.92rem;
}

.ios-empty a {
    font-weight: 500;
}

/* ---------- Formulier-rijen (invoervelden in een ios-list) ---------- */

.ios-form-row {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 44px;
    padding: 0 16px;
    gap: 12px;
}

.ios-row-label {
    font-size: 1rem;
    color: var(--ios-text);
    flex-shrink: 0;
}

.ios-row-input {
    flex: 1;
    min-width: 0;
    border: none;
    background: transparent;
    color: var(--ios-text);
    font-size: 1rem;
    text-align: right;
    padding: 11px 0;
    font-family: inherit;
}

.ios-row-input::placeholder {
    color: var(--ios-text-tertiary);
}

select.ios-row-input {
    text-align-last: right;
    -webkit-appearance: none;
    appearance: none;
    direction: rtl;
}

select.ios-row-input option {
    direction: ltr;
}

.ios-row-input:focus,
.ios-row-input:focus-visible {
    outline: none;
}

/* ---------- Knoppen ---------- */

.ios-button {
    display: block;
    width: 100%;
    border: none;
    background: var(--ios-blue);
    color: #fff;
    font-size: 1.05rem;
    font-weight: 600;
    padding: 0.85rem 1rem;
    border-radius: 12px;
    cursor: pointer;
    font-family: inherit;
    margin-bottom: 1.1rem;
}

.ios-button:active {
    opacity: 0.75;
}

.ios-button-secondary {
    display: inline-block;
    background: transparent;
    color: var(--ios-blue);
    border: none;
    font-size: 0.95rem;
    font-weight: 500;
    padding: 0.6rem 0.2rem;
    cursor: pointer;
    font-family: inherit;
}

.ios-button-danger {
    background: var(--ios-card);
    color: var(--ios-red);
    box-shadow: 0 0 0 0.5px var(--ios-separator);
}

/* ---------- Boodschappenlijst: gerechten aanvinken ---------- */

.ios-select-row .ios-row-link {
    cursor: pointer;
}

.ios-native-checkbox {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

.ios-checkmark {
    color: var(--ios-blue);
    font-size: 1.1rem;
    font-weight: 700;
    opacity: 0;
    flex-shrink: 0;
}

.ios-native-checkbox:checked ~ .ios-checkmark {
    opacity: 1;
}

/* ---------- Boodschappenlijst: producten afvinken ---------- */

.categorie-groep {
    margin-bottom: 1.1rem;
}

.categorie-groep .ios-card {
    margin-bottom: 0;
}

.lijst-item {
    position: relative;
}

.ios-todo-label {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 44px;
    padding: 9px 0;
    cursor: pointer;
    min-width: 0;
}

.ios-todo-circle {
    width: 23px;
    height: 23px;
    border-radius: 50%;
    border: 2px solid var(--ios-text-tertiary);
    flex-shrink: 0;
    position: relative;
    background: transparent;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.ios-todo-circle::after {
    content: "";
    position: absolute;
    left: 50%;
    top: 46%;
    width: 5px;
    height: 9px;
    border-right: 2px solid #fff;
    border-bottom: 2px solid #fff;
    transform: translate(-50%, -50%) rotate(45deg);
    opacity: 0;
}

.ios-native-checkbox:checked ~ .ios-todo-circle {
    background: var(--ios-blue);
    border-color: var(--ios-blue);
}

.ios-native-checkbox:checked ~ .ios-todo-circle::after {
    opacity: 1;
}

.item-tekst {
    font-size: 1rem;
    min-width: 0;
    overflow-wrap: anywhere;
}

.lijst-item.afgevinkt {
    color: var(--ios-text-secondary);
}

.lijst-item.afgevinkt .item-tekst {
    text-decoration: line-through;
    text-decoration-color: var(--ios-text-tertiary);
}

@media (max-width: 480px) {
    .ios-row-title,
    .ios-row-subtitle {
        white-space: normal;
    }
}
