:root {
    --border: #d0d3d8;
    --border-strong: #6b7280;
    --text: #111827;
    --text-muted: #6b7280;
    --bg: #ffffff;
    --bg-soft: #f5f6f8;
    --accent: #1d4e89;
    --accent-hover: #163d6d;
    --blocked: #e5e7eb;
    --taken: #fef3c7;
    --taken-border: #f59e0b;
    --open-hover: #dbeafe;
    --error: #b91c1c;
    --success: #047857;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: var(--text);
    background: var(--bg);
    -webkit-text-size-adjust: 100%;
}

.top-bar {
    padding: 16px 16px 8px;
    text-align: center;
    border-bottom: 1px solid var(--border);
}
.top-bar h1 {
    margin: 0 0 6px;
    font-size: 20px;
    font-weight: 700;
}
.instructions {
    margin: 0;
    font-size: 14px;
    color: var(--text-muted);
    line-height: 1.4;
    white-space: pre-wrap;
}

.month-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 16px;
    background: var(--bg-soft);
    position: sticky;
    top: 0;
    z-index: 10;
    border-bottom: 1px solid var(--border);
}
.month-nav h2 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    min-width: 160px;
    text-align: center;
}
.nav-btn {
    width: 44px;
    height: 44px;
    font-size: 22px;
    background: white;
    border: 1px solid var(--border-strong);
    border-radius: 6px;
    cursor: pointer;
    color: var(--text);
    line-height: 1;
}
.nav-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}
.print-btn {
    margin-left: auto;
    padding: 8px 14px;
    font-size: 14px;
    font-weight: 600;
    background: white;
    border: 1px solid var(--border-strong);
    border-radius: 6px;
    cursor: pointer;
    height: 44px;
}

main {
    padding: 12px;
    max-width: 1000px;
    margin: 0 auto;
}

.loading {
    padding: 40px 20px;
    text-align: center;
    color: var(--text-muted);
}

/* --- Calendar grid --- */
.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
}
.dow-header {
    text-align: center;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    padding: 6px 0;
    letter-spacing: 0.5px;
}
.cell {
    border: 1px solid var(--border);
    border-radius: 6px;
    min-height: 68px;
    padding: 4px 6px;
    display: flex;
    flex-direction: column;
    background: white;
    position: relative;
    overflow: hidden;
}
.cell.empty-cell {
    border: none;
    background: transparent;
}
.cell .date-num {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    line-height: 1;
    margin-bottom: 2px;
}
.cell.past {
    background: var(--bg-soft);
    color: var(--text-muted);
}
.cell.past .date-num { color: var(--text-muted); }

/* Open date — tappable */
.cell.open {
    cursor: pointer;
    border-color: var(--border-strong);
}
.cell.open:hover, .cell.open:focus {
    background: var(--open-hover);
    outline: none;
}
.cell.open .sign-up-hint {
    font-size: 12px;
    color: var(--accent);
    font-weight: 600;
    margin-top: auto;
}

/* Taken (has a meal) */
.cell.taken {
    background: var(--taken);
    border-color: var(--taken-border);
}
.cell.taken .meal-name {
    font-size: 13px;
    font-weight: 600;
    line-height: 1.2;
    color: var(--text);
    word-break: break-word;
}
.cell.taken .meal-phone {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
    line-height: 1.2;
}

/* Blocked (P-day or explicitly blocked) */
.cell.blocked {
    background: var(--blocked);
    color: var(--text-muted);
    background-image:
      linear-gradient(to top right,
        transparent calc(50% - 0.5px), rgba(107,114,128,0.55) calc(50% - 0.5px),
        rgba(107,114,128,0.55) calc(50% + 0.5px), transparent calc(50% + 0.5px)),
      linear-gradient(to top left,
        transparent calc(50% - 0.5px), rgba(107,114,128,0.55) calc(50% - 0.5px),
        rgba(107,114,128,0.55) calc(50% + 0.5px), transparent calc(50% + 0.5px));
}
.cell.blocked .date-num { color: var(--text-muted); }
.cell.blocked .block-reason {
    font-size: 10px;
    color: var(--text-muted);
    margin-top: auto;
    text-align: right;
}

.admin-contact {
    margin: 24px 0 12px;
    text-align: center;
    font-size: 13px;
    color: var(--text-muted);
}

/* --- Modal --- */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    z-index: 100;
}
.modal[hidden] { display: none; }
.modal-card {
    background: white;
    border-radius: 10px;
    width: 100%;
    max-width: 400px;
    padding: 20px;
    position: relative;
}
.modal-close {
    position: absolute;
    top: 8px; right: 8px;
    width: 36px; height: 36px;
    font-size: 22px;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
}
.modal-card h3 {
    margin: 0 0 16px;
    padding-right: 30px;
    font-size: 18px;
}
.modal-card label {
    display: block;
    margin-bottom: 12px;
    font-size: 13px;
    color: var(--text-muted);
    position: relative;
}
.modal-card input {
    display: block;
    width: 100%;
    padding: 10px 12px;
    margin-top: 4px;
    border: 1px solid var(--border-strong);
    border-radius: 6px;
    font-size: 16px; /* 16px+ prevents iOS zoom */
    font-family: inherit;
    color: var(--text);
}
.modal-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 20px;
}
.modal-actions button {
    padding: 10px 18px;
    font-size: 15px;
    font-weight: 600;
    border-radius: 6px;
    cursor: pointer;
    border: 1px solid var(--border-strong);
}
#modal-cancel { background: white; color: var(--text); }
#signup-submit {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}
#signup-submit:hover { background: var(--accent-hover); }
#signup-submit:disabled { opacity: 0.6; cursor: not-allowed; }

.error {
    margin-top: 12px;
    color: var(--error);
    font-size: 14px;
}
.success {
    color: var(--success);
}

.suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin: 2px 0 0;
    padding: 4px 0;
    background: white;
    border: 1px solid var(--border-strong);
    border-radius: 6px;
    list-style: none;
    max-height: 180px;
    overflow-y: auto;
    z-index: 5;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}
.suggestions li {
    padding: 8px 12px;
    cursor: pointer;
    font-size: 15px;
    color: var(--text);
}
.suggestions li:hover, .suggestions li[aria-selected="true"] {
    background: var(--open-hover);
}

/* --- Wider screens --- */
@media (min-width: 640px) {
    .top-bar h1 { font-size: 24px; }
    .cell { min-height: 90px; }
    .cell .date-num { font-size: 14px; }
}
