:root {
    color-scheme: light;
    --bg: #f5f7f8;
    --panel: #ffffff;
    --ink: #1f2933;
    --muted: #62717f;
    --line: #d9e1e7;
    --accent: #14736f;
    --accent-dark: #0f5754;
    --danger: #b42318;
    --warning: #9a6700;
    --success: #18794e;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    line-height: 1.5;
    min-width: 320px;
}

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

button,
.button-link {
    border: 0;
    border-radius: 6px;
    background: var(--accent);
    color: #fff;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    padding: 0 14px;
    font: inherit;
    font-weight: 700;
    text-decoration: none;
    white-space: nowrap;
}

button:hover,
.button-link:hover {
    background: var(--accent-dark);
}

button:disabled {
    background: #c7d1d8;
    color: #5d6b76;
    cursor: not-allowed;
}

button:disabled:hover {
    background: #c7d1d8;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 6px;
    color: var(--ink);
    font: inherit;
    padding: 10px 12px;
    min-height: 44px;
}

textarea {
    resize: vertical;
}

label {
    display: grid;
    gap: 6px;
    font-weight: 700;
}

code {
    background: #e8edf1;
    border-radius: 4px;
    padding: 2px 5px;
}

.topbar {
    align-items: center;
    background: #fff;
    border-bottom: 1px solid var(--line);
    display: flex;
    justify-content: space-between;
    min-height: 64px;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 5;
}

.brand {
    color: var(--ink);
    font-size: 20px;
    font-weight: 800;
    text-decoration: none;
}

.topbar nav {
    align-items: center;
    display: flex;
    gap: 12px;
    min-width: 0;
}

.topbar form {
    margin: 0;
}

.topbar form button {
    background: #3b4854;
}

.shell {
    margin: 0 auto;
    max-width: 1180px;
    padding: 28px 20px 48px;
    width: 100%;
}

.auth-panel,
.content-panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 1px 2px rgba(31, 41, 51, 0.05);
}

.auth-panel {
    margin: 48px auto 0;
    max-width: 440px;
    padding: 28px;
}

.content-panel {
    min-width: 0;
    padding: 22px;
}

.content-panel.narrow {
    max-width: 640px;
}

h1,
h2 {
    margin: 0;
    line-height: 1.15;
}

h1 {
    font-size: 30px;
}

h2 {
    font-size: 20px;
}

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

.compact {
    gap: 10px;
}

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

.flash,
.status {
    border-radius: 6px;
    margin: 0 0 16px;
    padding: 10px 12px;
}

.flash-error,
.status.error {
    background: #ffebe9;
    color: var(--danger);
}

.flash-success,
.status.success {
    background: #dafbe1;
    color: var(--success);
}

.flash-warning {
    background: #fff8c5;
    color: var(--warning);
}

.status {
    background: #eef3f5;
    color: var(--muted);
    margin-top: 14px;
}

.page-title,
.panel-heading,
.friend-title,
.item-row,
.actions {
    align-items: center;
    display: flex;
    gap: 12px;
}

.page-title,
.panel-heading,
.friend-title,
.item-row {
    justify-content: space-between;
}

.page-title {
    margin-bottom: 22px;
}

.page-title > div,
.panel-heading h2,
.friend-title > div,
.item-row > div {
    min-width: 0;
}

.dashboard {
    display: grid;
    gap: 22px;
}

.grid {
    display: grid;
    gap: 22px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.inline-form {
    display: grid;
    gap: 10px;
    grid-template-columns: minmax(0, 1fr) auto;
    margin-top: 16px;
}

.details dl,
.friend-body dl,
.meta-list {
    display: grid;
    gap: 8px 12px;
    grid-template-columns: 110px minmax(0, 1fr);
}

dt {
    color: var(--muted);
    font-weight: 700;
}

dd {
    margin: 0;
    overflow-wrap: anywhere;
}

.member-list,
.friend-list {
    display: grid;
    gap: 10px;
    margin-top: 14px;
}

.fronter-stack {
    display: grid;
    gap: 8px;
}

.fronter-row {
    align-items: center;
    display: grid;
    gap: 12px;
    grid-template-columns: 52px minmax(0, 1fr);
    min-width: 0;
}

.fronter-row strong {
    display: block;
}

.fronter-row span {
    color: var(--muted);
    display: block;
    font-size: 14px;
    overflow-wrap: anywhere;
}

.avatar {
    aspect-ratio: 1;
    background: #e8edf1;
    border: 1px solid var(--line);
    border-radius: 8px;
    display: inline-grid;
    height: 52px;
    object-fit: cover;
    place-items: center;
    width: 52px;
}

.avatar-fallback {
    color: var(--accent-dark);
    font-weight: 800;
}

.item-row,
.friend-card {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px;
    min-width: 0;
}

.item-row span,
.friend-title span {
    color: var(--muted);
    display: block;
    font-size: 14px;
    overflow-wrap: anywhere;
}

.actions button,
.friend-title button {
    background: #3b4854;
    min-height: 34px;
    padding: 0 10px;
}

.actions button:first-child {
    background: var(--accent);
}

.actions button:last-child,
.friend-title button {
    background: var(--danger);
}

.meta-list {
    margin: 18px 0 0;
}

.actions form {
    margin: 0;
}

.message-card {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px;
}

.message-card strong,
.message-card span {
    display: block;
}

.message-card span {
    color: var(--muted);
    font-size: 14px;
}

.message-card p {
    margin: 10px 0 0;
    overflow-wrap: anywhere;
}

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

@media (max-width: 760px) {
    .page-title,
    .panel-heading,
    .friend-title,
    .item-row {
        align-items: stretch;
        flex-direction: column;
    }

    .actions {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .inline-form,
    .details dl,
    .friend-body dl,
    .meta-list {
        grid-template-columns: 1fr;
    }

    .page-title .button-link,
    .panel-heading button,
    .friend-title button,
    .inline-form button,
    .actions button {
        width: 100%;
    }
}

@media (max-width: 560px) {
    .topbar {
        align-items: stretch;
        flex-direction: column;
        gap: 10px;
        padding: 12px 14px;
        position: static;
    }

    .brand {
        text-align: center;
    }

    .topbar nav {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
        width: 100%;
    }

    .topbar nav a,
    .topbar nav button,
    .topbar nav form {
        width: 100%;
    }

    .topbar nav a,
    .topbar nav button {
        min-height: 42px;
        padding: 0 10px;
    }

    .shell {
        padding: 18px 12px 32px;
    }

    .auth-panel {
        margin-top: 18px;
        padding: 18px;
    }

    .content-panel {
        padding: 16px;
    }

    h1 {
        font-size: 24px;
    }

    h2 {
        font-size: 18px;
    }

    .dashboard {
        gap: 14px;
    }

    .grid {
        gap: 14px;
    }

    .actions {
        grid-template-columns: 1fr;
    }

    .flash,
    .status {
        overflow-wrap: anywhere;
    }

    .fronter-row {
        grid-template-columns: 44px minmax(0, 1fr);
    }

    .avatar {
        height: 44px;
        width: 44px;
    }
}

@media (max-width: 380px) {
    .topbar nav {
        grid-template-columns: 1fr;
    }
}
