:root {
    --green: #69a244;
    --green-dark: #4c7a2f;
    --bark: #6d4c33;
    --sky: #eaf4fb;
    --paper: #ffffff;
    --ink: #2e3830;
    --muted: #6b7a6e;
    --danger: #c0392b;
    --radius: 14px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    color: var(--ink);
    background: linear-gradient(180deg, var(--sky) 0%, #f4f9ef 100%);
    min-height: 100vh;
}

h1 {
    font-size: 1.6rem;
}

h2 {
    font-size: 1.15rem;
    margin-top: 0;
}

h3 {
    font-size: 1rem;
}

a {
    color: var(--green-dark);
}

code {
    background: #f0f0e8;
    padding: 2px 6px;
    border-radius: 6px;
    font-size: 0.85em;
    word-break: break-all;
}

/* layout */
.page {
    max-width: 860px;
    margin: 0 auto;
    padding: 16px;
}

.centered-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 16px;
}

.card {
    background: var(--paper);
    border-radius: var(--radius);
    box-shadow: 0 2px 10px rgba(46, 56, 48, 0.08);
    padding: 20px;
    margin-bottom: 18px;
}

.narrow {
    width: 100%;
    max-width: 420px;
}

.two-cols {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

/* top bar */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px 16px;
    background: var(--green-dark);
}

.topbar .brand {
    color: #fff;
    font-weight: 700;
    text-decoration: none;
    font-size: 1.1rem;
}

.topbar .links {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
}

.topbar .links a {
    color: #eaf4e2;
    text-decoration: none;
}

.topbar .links a:hover {
    text-decoration: underline;
}

.topbar .who {
    color: #cfe6bd;
    font-size: 0.9rem;
}

.bell {
    position: relative;
}

.badge {
    display: inline-block;
    background: #e67e22;
    color: #fff;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 700;
    padding: 1px 7px;
    margin-left: 3px;
    vertical-align: top;
}

/* forms */
label {
    display: block;
    margin: 12px 0 4px;
    font-weight: 600;
    font-size: 0.92rem;
}

label.checkbox {
    font-weight: 400;
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 8px 0;
}

input:not([type="checkbox"]):not([type="color"]), textarea, select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #cfd8cc;
    border-radius: 10px;
    font: inherit;
    background: #fbfdf9;
}

input:focus, textarea:focus {
    outline: 2px solid var(--green);
    border-color: var(--green);
}

button, .button {
    display: inline-block;
    font: inherit;
    border: 1px solid #cfd8cc;
    background: #fff;
    color: var(--ink);
    border-radius: 10px;
    padding: 9px 16px;
    margin-top: 10px;
    cursor: pointer;
    text-decoration: none;
}

button.primary, .button.primary {
    background: var(--green);
    border-color: var(--green);
    color: #fff;
    font-weight: 600;
}

button.primary:hover, .button.primary:hover {
    background: var(--green-dark);
}

button.danger {
    background: #fff;
    color: var(--danger);
    border-color: var(--danger);
}

button.danger:hover {
    background: var(--danger);
    color: #fff;
}

.small-btn {
    padding: 5px 12px;
    font-size: 0.88rem;
    margin-top: 0;
}

.linklike {
    border: none;
    background: none;
    color: #eaf4e2;
    padding: 0;
    margin: 0;
    cursor: pointer;
    text-decoration: underline;
    font: inherit;
}

main .linklike {
    color: var(--muted);
}

.inline {
    display: inline;
}

.row-form {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    flex-wrap: wrap;
}

.row-form > div {
    flex: 1;
    min-width: 160px;
}

.row-form input {
    width: auto;
    min-width: 180px;
}

.row-form button {
    margin-top: 0;
}

/* text helpers */
.muted {
    color: var(--muted);
}

.small {
    font-size: 0.85rem;
}

.preserve {
    white-space: pre-wrap;
}

.actions {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

/* flash */
.flash {
    border-radius: 10px;
    padding: 10px 14px;
    margin: 10px 0;
}

.flash.error {
    background: #fdecea;
    color: var(--danger);
    border: 1px solid #f5b7b1;
}

.flash.ok {
    background: #eafaf1;
    color: #1e8449;
    border: 1px solid #a9dfbf;
}

/* tables */
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
}

th {
    text-align: left;
    color: var(--muted);
    font-size: 0.85rem;
    border-bottom: 2px solid #e6ece3;
}

td, th {
    padding: 8px 6px;
    vertical-align: middle;
}

tr + tr td {
    border-top: 1px solid #eef2ea;
}

/* tiles (friends, kids) */
.tile-row {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.tile {
    background: #f6faf2;
    border: 1px solid #dfe9d7;
    border-radius: var(--radius);
    padding: 14px;
    min-width: 150px;
    text-decoration: none;
    color: var(--ink);
    display: flex;
    flex-direction: column;
    gap: 6px;
}

a.tile:hover {
    border-color: var(--green);
}

.tile-name {
    font-weight: 700;
    font-size: 1.05rem;
}

.approval {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
    border-top: 1px solid #eef2ea;
    padding: 6px 0;
}

.approval:first-of-type {
    border-top: none;
}

.notification {
    padding: 8px 10px;
    border-radius: 8px;
    display: flex;
    gap: 10px;
    align-items: baseline;
    flex-wrap: wrap;
}

.notification.new {
    background: #f2f9ea;
    font-weight: 600;
}

/* chat */
.chat-page {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 60px);
}

.chat-box {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.chat-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 6px;
    text-decoration: none;
    color: var(--ink);
    border-top: 1px solid #eef2ea;
}

.chat-row:first-of-type {
    border-top: none;
}

.chat-row:hover .tile-name {
    color: var(--green-dark);
}

.chat-row .muted {
    margin-left: auto;
}

.msg {
    max-width: 75%;
    padding: 10px 14px;
    border-radius: 16px;
}

.msg.mine {
    align-self: flex-end;
    background: #dcefcd;
    border-bottom-right-radius: 4px;
}

.msg.theirs {
    align-self: flex-start;
    background: #f0f2f7;
    border-bottom-left-radius: 4px;
}

.msg.flagged-msg {
    outline: 2px solid #e67e22;
}

.msg-meta {
    font-size: 0.8rem;
    color: var(--muted);
    display: flex;
    gap: 8px;
    align-items: baseline;
    margin-bottom: 2px;
}

.msg-body {
    white-space: pre-wrap;
    word-break: break-word;
}

.send-bar {
    display: flex;
    gap: 10px;
    margin-top: 4px;
}

.send-bar input {
    flex: 1;
}

.send-bar button {
    margin-top: 0;
}

.conn-status {
    font-size: 0.7em;
    color: #bbb;
    vertical-align: middle;
}

.conn-status.online {
    color: #2ecc71;
}

.profile-hero h1 {
    margin: 6px 0 0;
}

/* modes: same house, different rooms */
.topbar-camp {
    background: #31456e;
}

.topbar-lodge {
    background: var(--bark);
}

.mode-treehouse {
    font-size: 1.08rem;
}

/* treehouse home: big faces, tap to chat */
.treehouse-home h1 {
    text-align: center;
    margin-top: 24px;
}

.center {
    text-align: center;
}

.no-margin {
    margin: 4px 0;
}

ul.plain {
    list-style: none;
    margin: 6px 0;
    padding: 0;
}

.face-grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 26px;
    margin: 26px 0;
}

.face {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    color: var(--ink);
    width: 120px;
}

.face-emoji {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 104px;
    height: 104px;
    border-radius: 50%;
    font-size: 3.2rem;
    box-shadow: 0 3px 10px rgba(46, 56, 48, 0.18);
    transition: transform 0.12s ease;
}

.face:hover .face-emoji {
    transform: scale(1.08);
}

.face-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    font-size: 0.95rem;
    padding: 3px 10px;
    border: 2px solid #fff;
}

.face-name {
    font-weight: 700;
    font-size: 1.1rem;
    text-align: center;
}

.card.soft {
    background: #fbfdf8;
    box-shadow: none;
    border: 1px dashed #d5e2cc;
}

details.card.soft summary {
    cursor: pointer;
    font-weight: 600;
}

/* small round avatars in lists and chat headers */
.avatar-sm {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 1.35rem;
    vertical-align: middle;
    flex: none;
}

.hero-avatar {
    width: 84px;
    height: 84px;
    font-size: 2.6rem;
    margin-top: 4px;
}

/* avatar picker on the profile edit page */
.avatar-picker {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 4px 0 8px;
}

.avatar-option input {
    position: absolute;
    opacity: 0;
    width: 0;
}

.avatar-face {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    font-size: 1.7rem;
    background: #f2f6ee;
    border: 3px solid transparent;
    cursor: pointer;
}

.avatar-option input:checked + .avatar-face {
    border-color: var(--green);
    background: #e2f2d6;
}

.avatar-option input:focus-visible + .avatar-face {
    outline: 2px solid var(--green-dark);
}

/* real profile pictures fill their circle */
.face-img, .avatar-img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    display: block;
}

.group-face {
    background: #8d99ae;
}

.big-avatar {
    width: 72px;
    height: 72px;
}

.avatar-xs {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    font-size: 0.9rem;
    flex: none;
}

.member-chips {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin: -4px 0 8px;
}

.member-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 0.88rem;
    color: var(--muted);
}

.member-picker {
    display: flex;
    gap: 4px 18px;
    flex-wrap: wrap;
    margin: 8px 0;
}

.member-picker .checkbox {
    margin: 2px 0;
}

/* the kids' door */
.knock-box {
    background: #f2f9ea;
    border: 2px dashed var(--green);
    border-radius: var(--radius);
    padding: 14px 16px;
    margin: 14px 0;
}

.knock-box h2 {
    margin: 0 0 4px;
    font-size: 1.05rem;
}

.knock-door {
    font-size: 4rem;
    margin: 18px 0;
    animation: knock-bounce 1.6s ease-in-out infinite;
}

@keyframes knock-bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-7px); }
}

.knock-card {
    border: 2px solid var(--green);
}

.knock-code {
    font-size: 3rem;
    font-weight: 800;
    letter-spacing: 0.35em;
    padding-left: 0.35em; /* visually re-center despite letter-spacing */
    color: var(--green-dark);
    margin: 10px 0 0;
}

.push-controls {
    display: flex;
    gap: 10px;
    align-items: center;
    justify-content: inherit;
    flex-wrap: wrap;
}

.ios-install-hint {
    background: #fff8e6;
    border: 1px dashed #e0c060;
    border-radius: 10px;
    padding: 10px 14px;
    color: #7a6120;
    font-size: 0.9rem;
    max-width: 460px;
}

.nowrap {
    white-space: nowrap;
}

input.code-input {
    width: 5.5em !important;
    text-align: center;
    font-size: 1.1rem;
    letter-spacing: 0.25em;
}

.guardian-chip {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    background: #f2f6ee;
    border: 1px solid #dfe9d7;
    border-radius: 999px;
    padding: 2px 10px;
    margin: 2px 6px 2px 0;
    font-size: 0.9rem;
}

td select {
    width: auto;
    padding: 6px 10px;
    border: 1px solid #cfd8cc;
    border-radius: 10px;
    font: inherit;
    background: #fbfdf9;
}

@media (max-width: 600px) {
    .two-cols {
        grid-template-columns: 1fr;
    }

    .msg {
        max-width: 90%;
    }
}
