:root {
    --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --page-bg: #f5f4f2;
    --surface: #fff;
    --border: #e2dfda;
    --border-strong: #cfcac2;
    --text: #22201d;
    --text-muted: #77716a;
    --accent: #0073e6;
    --radius: 10px;
    --shadow: 0 1px 2px rgba(28, 25, 23, 0.04);
    --shadow-lifted: 0 6px 18px rgba(28, 25, 23, 0.1);
    --star: #e0a32e;
    --star-empty: #d7d2ca;
}

body {
    font-family: var(--font-sans);
}

/* Site navigation shared by all sub-apps */

.site-nav {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    padding: 0.75rem 1.25rem;
    background-color: var(--surface);
    border-bottom: 1px solid var(--border);
    font-size: 0.9375rem;
}

.site-nav a {
    color: var(--text-muted);
    text-decoration: none;
}

.site-nav a:hover {
    color: var(--text);
    text-decoration: underline;
}

.site-nav-home {
    font-weight: 600;
    color: var(--text) !important;
}

/* Main page */

body:has(.page) {
    margin: 0;
    background-color: var(--page-bg);
    color: var(--text);
}

.page {
    max-width: 34rem;
    margin: 0 auto;
    padding: clamp(2rem, 6vw, 4rem) 1.25rem 3rem;
    line-height: 1.5;
}

.page h1 {
    margin: 0 0 1.75rem;
    font-size: clamp(1.75rem, 1.4rem + 1.4vw, 2.25rem);
    font-weight: 600;
    letter-spacing: -0.02em;
}

.user-list ul,
.app-list ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 0.625rem;
}

.user-list li,
.app-list li {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.9em 1.15em;
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.user-list li:hover,
.app-list li:hover {
    border-color: var(--border-strong);
    box-shadow: var(--shadow-lifted);
    transform: translateY(-1px);
}

.user-list li:has(a:focus-visible) {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.user-list a,
.app-list a {
    color: inherit;
    font-size: 1.0625rem;
    font-weight: 500;
    text-decoration: none;
}

/* Makes the whole row clickable, not just the name. */
.user-list a::after,
.app-list a::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: var(--radius);
}

.user-list a:focus-visible {
    outline: none;
}

.user-list li span {
    margin-left: auto;
    color: var(--text-muted);
    font-size: 0.8125rem;
}

.auth-links {
    margin-top: 2rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--border);
    font-size: 0.9375rem;
    color: var(--text-muted);
}

.auth-links a,
.auth-links .link-button {
    color: var(--text-muted);
    text-decoration: none;
}

.auth-links a:hover,
.auth-links .link-button:hover {
    color: var(--text);
    text-decoration: underline;
}

.logout-form {
    display: inline;
}

.link-button {
    font: inherit;
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
}

@media (prefers-reduced-motion: reduce) {
    .user-list li {
        transition: none;
    }

    .user-list li:hover {
        transform: none;
    }
}

.wishlist-page {
    max-width: 72rem;
}

.wishlist-heading {
    max-width: 34rem;
    margin: 0 auto 2rem;
    overflow-wrap: anywhere;
}

.wishlist-add {
    padding: 1.5rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.wishlist-add h2 {
    margin: 0 0 1.25rem;
    font-size: 1.25rem;
    font-weight: 600;
}

.wishlist-add .modal-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.wishlist-add label {
    display: block;
    font-weight: 500;
}

.wishlist-add .modal-form-input {
    display: block;
    min-width: 0;
    margin: .4rem 0 0;
    padding: .65rem .75rem;
    border: 1px solid var(--border-strong);
    border-radius: 5px;
    font: inherit;
    background: var(--surface);
    color: var(--text);
}

.wishlist-add .modal-form-button {
    min-height: 2.75rem;
    padding: .6rem 1rem;
    font: inherit;
    font-weight: 500;
    background: #0067ce;
    border-radius: 6px;
}

.wishlist-add .modal-form-button:hover {
    background: #005bb5;
}

.wishlist-add :is(input, button):focus-visible {
    outline: 3px solid var(--accent);
    outline-offset: 3px;
}

.wishlist {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 1em;
    padding: 1em;
}

/* Media query for larger screens */
@media (min-width: 600px) {
    .wishlist {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    }
}

@media (min-width: 900px) {
    .wishlist {
        grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    }
}

@media (min-width: 1200px) {
    .wishlist {
        grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    }
}

.wishlist-item {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    background-color: #f0f0f0;
    border: 1px solid #ccc;
    padding: 1.5em;
    text-align: center;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    position: relative;
}

.wishlist-item-img {
    max-width: 100%;
    height: 80%;
    object-fit: contain;
    border-radius: 8px;
    margin-bottom: 1em;
}

.wishlist-item-info {
    height: 20%;
}

.wishlist-item-name {
    font-size: 1.2em;
    margin: 0.5em 0;
}

.wishlist-item-notes {
    font-size: 1em;
    color: #333;
    min-height: 1.5em;
    margin: 0.5em 0;
}

.wishlist-item-remove,
.wishlist-item-modify {
    position: absolute;
    top: 10px;
    color: white;
    border: none;
    border-radius: 5px;
    padding: 0.5em;
    display: none;
    cursor: pointer;
    transition: background-color 0.3s, transform 0.2s;
}

.wishlist-item-remove {
    right: 10px;
    background-color: red;
}

.wishlist-item-remove:hover {
    background-color: darkred;
    transform: scale(1.05);
}

.wishlist-item-remove:active {
    background-color: darkred;
    transform: scale(0.95);
}

.wishlist-item-modify {
    right: 100px;
    /* Adjust as needed for spacing */
    background-color: blue;
}

.wishlist-item-modify:hover {
    background-color: darkblue;
    transform: scale(1.05);
}

.wishlist-item-modify:active {
    background-color: darkblue;
    transform: scale(0.95);
}

.wishlist-item:hover .wishlist-item-remove,
.wishlist-item:focus .wishlist-item-remove,
.wishlist-item:hover .wishlist-item-modify,
.wishlist-item:focus .wishlist-item-modify {
    display: block;
}

@media (hover: none) {

    .wishlist-item-remove,
    .wishlist-item-modify {
        display: block;
    }
}

.modal {
    position: fixed;
    z-index: 1;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgb(0, 0, 0);
    background-color: rgba(0, 0, 0, 0.4);
}

.modal-content {
    position: relative;
    background-color: #fefefe;
    margin: 15% auto;
    padding: 20px;
    border: 1px solid #888;
    width: 80%;
    max-width: 500px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

/* Close Button */
.modal-close {
    color: #aaa;
    font-size: 2em;
    font-weight: bold;
    position: absolute;
    top: 2px;
    right: 12px;
}

.modal-close:hover,
.modal-close:focus {
    color: black;
    text-decoration: none;
    cursor: pointer;
}

.modal-form-label {
    display: block;
    margin: 10px 0 5px;
}

.modal-form-label:first-child {
    margin-top: 2em;
}

.modal-form-input {
    width: 100%;
    padding: 8px;
    margin: 5px 0 10px;
    box-sizing: border-box;
}

.modal-form-button {
    padding: 0.5em 1em;
    background-color: #0073e6;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
}

.modal-form-button:hover {
    background-color: #005bb5;
}
/* Auth Styles */
.auth-form-container {
    max-width: 400px;
    margin: 50px auto;
    padding: 20px;
    background: #f9f9f9;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    text-align: center;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 20px;
}

.auth-form label {
    text-align: left;
    display: block;
    font-weight: bold;
    margin-bottom: 5px;
}

.auth-form input {
    width: 100%;
    padding: 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-sizing: border-box;
}

/* The invited address is fixed: it comes from the invitation, not the form. */
.auth-form input[readonly] {
    background: #eee;
    color: #555;
    cursor: not-allowed;
}

.auth-form button {
    padding: 10px;
    background-color: #007bff;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
}

.auth-form button:hover {
    background-color: #0056b3;
}

.error {
    color: red;
    background: #ffe6e6;
    padding: 10px;
    border-radius: 4px;
    margin-bottom: 15px;
}

/* Eating-out restaurant management */

.restaurants-page {
    max-width: 48rem;
}

.restaurants-page .muted {
    color: var(--text-muted);
    font-size: 0.9375rem;
}

.restaurants-page .eyebrow {
    margin: 0 0 .3rem;
    color: var(--text-muted);
    font-size: .875rem;
}

.restaurants-heading, .restaurant-card-heading, .restaurant-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}

.restaurants-heading h1 {
    margin: 0;
}

.restaurants-heading {
    margin-bottom: 1.25rem;
}

.restaurants-page .button {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    min-height: 2.75rem;
    box-sizing: border-box;
    padding: .6rem 1rem;
    border: 1px solid var(--border-strong);
    border-radius: 6px;
    font: inherit;
    font-size: .9375rem;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
}

.restaurants-page .primary {
    color: white;
    background: #0067ce;
    border-color: #0067ce;
}

.restaurants-page .secondary {
    color: var(--text);
    background: var(--surface);
}

.restaurants-page .danger {
    background: #b42318;
    border-color: #b42318;
    color: white;
}

.restaurants-page .danger-outline {
    color: #b42318;
    background: var(--surface);
}

.restaurants-page .button:hover {
    filter: brightness(.94);
}

.restaurants-page .button:disabled {
    opacity: .5;
    cursor: not-allowed;
}

.restaurants-page :is(a, button, input):focus-visible {
    outline: 3px solid var(--accent);
    outline-offset: 3px;
}

.restaurant-list {
    list-style: none;
    padding: 0;
    display: grid;
    gap: 1rem;
    margin-top: 1.5rem;
}

.restaurant-card, .restaurant-empty, .restaurant-form {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    overflow-wrap: anywhere;
}

.restaurant-card h2, .restaurant-empty h2 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
}

.restaurant-rating {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    font-size: .875rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.restaurant-links {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: .5rem 1.25rem;
    padding: 0;
}

.restaurants-page a:not(.button) {
    color: #0067ce;
    text-underline-offset: .2em;
}

/* A card's own title stays quiet; the whole card is the obvious target. */
.restaurants-page .restaurant-card h2 a {
    color: inherit;
    text-decoration: none;
}

.restaurants-page .restaurant-card h2 a:hover {
    text-decoration: underline;
}

.restaurant-actions {
    justify-content: flex-start;
    margin-top: 1.25rem;
    gap: .75rem;
}

.restaurant-empty {
    margin-top: 2rem;
    text-align: center;
    padding: 3rem 1.5rem;
}

.restaurant-empty p {
    color: var(--text-muted);
}

.restaurants-page .back-link {
    display: inline-block;
    margin-bottom: 1.5rem;
}

.restaurant-form label {
    display: block;
    margin-bottom: .4rem;
    font-weight: 500;
}

.restaurant-form input {
    width: 100%;
    box-sizing: border-box;
    min-width: 0;
    padding: .65rem .75rem;
    border: 1px solid var(--border-strong);
    border-radius: 5px;
    font: inherit;
    background: var(--surface);
    color: var(--text);
}

.restaurant-form fieldset {
    min-width: 0;
    border: 0;
    padding: 0;
    margin: 1.75rem 0;
}

.restaurant-form legend {
    padding: 0;
    font-weight: 600;
}

.coordinate-fields {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.restaurant-link-fields {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: .75rem;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.restaurant-link-fields .remove-link {
    grid-column: 1 / -1;
    justify-self: start;
}

.restaurants-page .error {
    color: #9c231b;
}

.restaurants-page .error p {
    margin-top: 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;
}

@media (max-width: 480px) {
    .coordinate-fields, .restaurant-link-fields {
        grid-template-columns: 1fr;
    }
    .restaurant-card, .restaurant-form {
        padding: 1rem;
    }
    .restaurants-heading {
        align-items: flex-start;
    }
}

.eating-out-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1.25rem;
    margin: 1.5rem 0;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.eating-out-nav a {
    padding: 0.4rem 0;
}

.eating-out-nav a[aria-current="page"] {
    font-weight: 600;
    text-decoration-thickness: 2px;
}

.want-list-filter {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.want-list-filter select {
    min-width: 0;
    max-width: 100%;
    padding: 0.65rem;
    border: 1px solid var(--border-strong);
    border-radius: 6px;
    font: inherit;
    background: var(--surface);
    color: var(--text);
}

.want-list-filter select:focus-visible {
    outline: 3px solid var(--accent);
    outline-offset: 3px;
}

.wanting-users {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem 0.75rem;
    margin: 1rem 0;
}

.want-control {
    margin-top: 1rem;
}

/* Eating-out reviews. Scores are stored 1-10 and shown as five stars. */

/* Five outlined stars with a gold copy clipped to the score. No letter
   spacing, so the clip width is an exact fraction of the five glyphs. */
.stars {
    position: relative;
    display: inline-block;
    font-size: 1.0625rem;
    line-height: 1;
    letter-spacing: normal;
    white-space: nowrap;
    color: var(--star-empty);
}

.stars::before {
    content: "\2605\2605\2605\2605\2605";
}

.stars-fill {
    position: absolute;
    inset: 0 auto 0 0;
    overflow: hidden;
    color: var(--star);
}

.stars-fill::before {
    content: "\2605\2605\2605\2605\2605";
}

.rating-value {
    font-variant-numeric: tabular-nums;
}

.reviews-heading {
    margin: 2rem 0 1rem;
}

.review-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    gap: 1rem;
}

.review-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem 1.5rem;
    box-shadow: var(--shadow);
    overflow-wrap: anywhere;
}

.review-card-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}

.review-card-heading h3 {
    margin: 0 0 .25rem;
    font-size: 1.0625rem;
}

.review-card-heading p {
    margin: 0;
}

.review-notes {
    margin: 1rem 0 0;
    white-space: pre-line;
}

.category-averages {
    list-style: none;
    padding: 0;
    margin: 1rem 0 0;
    display: grid;
    grid-template-columns: max-content max-content max-content;
    align-items: center;
    gap: .35rem .75rem;
    font-size: .9375rem;
    color: var(--text-muted);
}

.category-averages li {
    display: grid;
    grid-column: 1 / -1;
    grid-template-columns: subgrid;
    align-items: center;
}

/* Ten radios drawn as five stars. The row is reversed so that the checked
   input can fill every lower half through a sibling selector. */
.star-field {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: .25rem 1.25rem;
}

.star-input {
    --star-size: 2rem;
    display: flex;
    flex-direction: row-reverse;
    justify-content: flex-end;
}

.star-input input {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: 0;
    padding: 0;
    opacity: 0;
}

.star-input label {
    position: relative;
    display: block;
    width: calc(var(--star-size) / 2);
    height: var(--star-size);
    margin: 0;
    overflow: hidden;
    color: var(--star-empty);
    cursor: pointer;
}

.star-input label::before {
    content: "\2605";
    position: absolute;
    top: 0;
    width: var(--star-size);
    font-size: var(--star-size);
    line-height: 1;
    text-align: center;
}

.star-input label.left::before {
    left: 0;
}

.star-input label.right::before {
    left: calc(var(--star-size) / -2);
}

.star-input input:checked ~ label {
    color: var(--star);
}

/* While pointing at the row, the hovered value replaces the stored one. */
.star-input:hover input:checked ~ label {
    color: var(--star-empty);
}

.star-input:hover label:hover,
.star-input:hover label:hover ~ label {
    color: var(--star);
}

.restaurants-page .star-input input:focus-visible {
    outline: none;
}

.star-input input:focus-visible + label::before {
    outline: 3px solid var(--accent);
    outline-offset: 2px;
}

.star-clear, .repeat-visit {
    display: flex;
    align-items: center;
    gap: .5rem;
}

.star-clear label, .repeat-visit label {
    margin: 0;
    font-weight: 400;
}

.restaurant-form .star-clear input, .restaurant-form .repeat-visit input {
    width: auto;
    min-height: 1.25rem;
}

.repeat-visit {
    margin: 1.75rem 0;
}

.review-form textarea {
    width: 100%;
    box-sizing: border-box;
    min-width: 0;
    padding: .65rem .75rem;
    border: 1px solid var(--border-strong);
    border-radius: 5px;
    font: inherit;
    background: var(--surface);
    color: var(--text);
    resize: vertical;
}

.restaurants-page .review-form textarea:focus-visible {
    outline: 3px solid var(--accent);
    outline-offset: 3px;
}

@media (max-width: 480px) {
    .review-card {
        padding: 1rem;
    }
    .star-input {
        --star-size: 2.25rem;
    }
}


.admin-page {
    max-width: 48rem;
}

.admin-page .muted {
    color: var(--text-muted);
    font-size: 0.9375rem;
}

.admin-page .eyebrow {
    margin: 0 0 .3rem;
    color: var(--text-muted);
    font-size: .875rem;
}

.admin-heading {
    margin-bottom: 1.25rem;
}

.admin-heading h1 {
    margin: 0;
}

.admin-page .button {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    min-height: 2.75rem;
    box-sizing: border-box;
    padding: .6rem 1rem;
    border: 1px solid var(--border-strong);
    border-radius: 6px;
    font: inherit;
    font-size: .9375rem;
    font-weight: 500;
    cursor: pointer;
}

.admin-page .primary {
    color: white;
    background: #0067ce;
    border-color: #0067ce;
}

.admin-page .secondary {
    color: var(--text);
    background: var(--surface);
}

.admin-page .button:hover {
    filter: brightness(.94);
}

.admin-page :is(a, button, input):focus-visible {
    outline: 3px solid var(--accent);
    outline-offset: 3px;
}

.admin-notice, .admin-invite, .invitation-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    overflow-wrap: anywhere;
}

.admin-notice {
    border-left: 4px solid #b42318;
}

.admin-notice h2, .admin-invite h2, .admin-invitations h2 {
    margin: 0 0 .5rem;
    font-size: 1.25rem;
    font-weight: 600;
}

.admin-notice ul {
    margin: .5rem 0 0;
    padding-left: 1.25rem;
    color: var(--text-muted);
}

.admin-invite {
    margin-top: 1.25rem;
}

.admin-invite-fields {
    display: flex;
    align-items: end;
    gap: .75rem;
    flex-wrap: wrap;
    margin: 0;
    padding: 0;
    border: 0;
}

.admin-invite-fields:disabled {
    opacity: .55;
}

.admin-invite-fields label {
    flex-basis: 100%;
    font-weight: 500;
    font-size: .9375rem;
}

.admin-invite-fields input {
    flex: 1 1 18rem;
    min-width: 0;
    min-height: 2.75rem;
    box-sizing: border-box;
    padding: .6rem .75rem;
    border: 1px solid var(--border-strong);
    border-radius: 5px;
    font: inherit;
    background: var(--surface);
    color: var(--text);
}

.admin-invitations {
    margin-top: 2rem;
}

.invitation-list {
    list-style: none;
    padding: 0;
    display: grid;
    gap: 1rem;
    margin: 1rem 0 0;
}

.invitation-card-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}

.invitation-card h3 {
    margin: 0;
    font-size: 1.125rem;
    font-weight: 600;
}

.invitation-card p {
    margin: .4rem 0 0;
}

.invitation-status {
    border-radius: 999px;
    padding: .2rem .7rem;
    font-size: .8125rem;
    font-weight: 500;
    white-space: nowrap;
    border: 1px solid var(--border-strong);
    color: var(--text-muted);
    background: var(--page-bg);
}

.invitation-status-sent {
    color: #05603a;
    background: #ecfdf3;
    border-color: #abefc6;
}

.invitation-status-undelivered {
    color: #b42318;
    background: #fef3f2;
    border-color: #fecdca;
}

.invitation-status-accepted {
    color: #175cd3;
    background: #eff8ff;
    border-color: #b2ddff;
}

.admin-page .invitation-error {
    margin-top: .75rem;
}

.invitation-resend {
    margin-top: 1rem;
}
