:root {
    color-scheme: light;
    --bg: #f7f8fa;
    --panel: #ffffff;
    --text: #18202a;
    --muted: #667085;
    --line: #d9dee7;
    --accent: #1f6feb;
    --accent-strong: #1554b8;
    --danger: #b42318;
    --success: #067647;
    --shadow: 0 12px 28px rgba(24, 32, 42, 0.08);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
}

button,
input,
textarea {
    font: inherit;
}

button {
    cursor: pointer;
}

button:disabled,
textarea:disabled {
    cursor: not-allowed;
    opacity: 0.65;
}

.entry {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}

.entry-panel {
    width: min(420px, 100%);
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
    padding: 24px;
}

h1,
h2,
p {
    margin-top: 0;
}

h1 {
    font-size: 28px;
    line-height: 1.2;
}

h2 {
    font-size: 18px;
}

label {
    display: grid;
    gap: 6px;
    margin: 14px 0;
    font-weight: 600;
}

input,
textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 10px 12px;
    background: #fff;
    color: var(--text);
}

textarea {
    resize: vertical;
}

.check {
    grid-template-columns: 18px 1fr;
    align-items: center;
    font-weight: 500;
}

.check input {
    width: 18px;
}

.primary,
.secondary,
.text-button,
.nav-item {
    border: 0;
    border-radius: 6px;
    min-height: 38px;
}

.primary {
    width: 100%;
    background: var(--accent);
    color: #fff;
    font-weight: 700;
    padding: 10px 14px;
}

.primary:hover {
    background: var(--accent-strong);
}

.secondary {
    background: #eef4ff;
    color: var(--accent-strong);
    padding: 8px 12px;
    font-weight: 700;
}

.text-button {
    background: transparent;
    color: var(--accent);
    padding: 6px 0;
    text-align: left;
}

.segmented {
    display: grid;
    grid-template-columns: 1fr 1fr;
    border: 1px solid var(--line);
    border-radius: 7px;
    overflow: hidden;
    margin-bottom: 18px;
}

.segmented button {
    border: 0;
    padding: 9px 12px;
    background: #fff;
}

.segmented button[aria-selected="true"] {
    background: var(--text);
    color: #fff;
}

.app-shell {
    display: grid;
    grid-template-columns: 250px 1fr;
    min-height: 100vh;
}

.sidebar {
    background: #111827;
    color: #fff;
    padding: 20px;
    display: grid;
    grid-template-rows: auto 1fr auto;
    gap: 22px;
}

.brand {
    color: #fff;
    text-decoration: none;
    font-size: 22px;
    font-weight: 800;
}

.nav-list {
    display: grid;
    align-content: start;
    gap: 6px;
}

.nav-item {
    width: 100%;
    background: transparent;
    color: #d1d5db;
    text-align: left;
    padding: 10px 12px;
}

.nav-item[aria-current="page"],
.nav-item:hover {
    background: #243042;
    color: #fff;
}

.sidebar-user {
    border-top: 1px solid rgba(255, 255, 255, 0.16);
    padding-top: 14px;
    display: grid;
    gap: 6px;
}

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

.view {
    max-width: 1040px;
    margin: 0 auto;
}

.view.narrow {
    max-width: 620px;
}

.view-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-bottom: 18px;
}

.view-header h1 {
    margin: 0;
}

.notice,
.empty,
.muted {
    color: var(--muted);
}

.error {
    color: var(--danger);
}

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

.list-item,
.user-row,
.thread-item,
.direct-chat-panel,
.thread-list,
.comments-region,
.assistant-messages {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
}

.list-item {
    padding: 16px;
    margin-bottom: 12px;
}

.list-item a,
.user-row {
    color: var(--accent);
    text-decoration: none;
}

.toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 20px;
}

.toolbar-field {
    display: grid;
    gap: 4px;
    margin: 0;
    font-weight: 600;
}

.toolbar-field span {
    font-size: 13px;
    color: var(--muted);
}

.toolbar-field select {
    min-width: 180px;
}

.feed-layout {
    display: grid;
    grid-template-columns: minmax(260px, 340px) minmax(0, 1fr);
    gap: 18px;
}

.feed-sidebar,
.feed-main {
    display: grid;
    gap: 18px;
    min-width: 0;
}

.card,
.stacked-form,
.location-editor,
.location-detail,
.tag-selection {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.card,
.location-editor,
.location-detail {
    padding: 16px;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 12px;
}

.stacked-form {
    padding: 16px;
    display: grid;
    gap: 12px;
}

.stacked-form label {
    margin: 0;
}

.stacked-form .toolbar {
    margin-bottom: 0;
}

.inline-form {
    display: flex;
    gap: 10px;
    align-items: center;
    margin: 0;
}

.inline-form input {
    flex: 1 1 auto;
}

.tag-selection {
    padding: 16px;
}

.tag-section + .tag-section {
    margin-top: 14px;
}

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

.tag-row,
.tag-pill-button {
    width: 100%;
    border: 1px solid var(--line);
    background: #f8fafc;
    color: var(--text);
    border-radius: 999px;
    padding: 8px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    text-align: left;
}

.tag-row:hover,
.tag-pill-button:hover {
    border-color: var(--accent);
    color: var(--accent-strong);
}

.tag-row.selected,
.tag-pill.selected .tag-pill-button {
    background: #e8f1ff;
    border-color: #b9d4ff;
}

.tag-row small,
.tag-pill-button small {
    color: var(--muted);
    white-space: nowrap;
}

.tag-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.tag-pill {
    display: inline-flex;
    align-items: stretch;
    gap: 4px;
}

.tag-pill-button {
    width: auto;
    min-height: 34px;
}

.tag-remove {
    border: 1px solid var(--line);
    border-radius: 999px;
    background: #fff;
    color: var(--danger);
    min-width: 34px;
    padding: 0 10px;
}

.feed-list {
    display: grid;
    gap: 12px;
}

.feed-footer {
    display: flex;
    justify-content: center;
}

.location-card-header {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: flex-start;
}

.location-card-header h2 {
    margin-bottom: 4px;
}

.meta-line {
    display: grid;
    gap: 4px;
    justify-items: end;
    color: var(--muted);
    font-size: 13px;
}

.tag-search-suggestions {
    display: grid;
    gap: 8px;
}

.location-detail h2,
.location-editor h2,
.card h2 {
    margin-bottom: 12px;
}

.user-list {
    display: grid;
    gap: 8px;
}

.user-row {
    display: block;
    padding: 12px 14px;
}

.direct-chat-layout {
    display: grid;
    grid-template-columns: minmax(220px, 300px) minmax(0, 1fr);
    gap: 16px;
}

.thread-list {
    padding: 8px;
}

.thread-item {
    width: 100%;
    display: grid;
    gap: 4px;
    padding: 10px;
    background: transparent;
    text-align: left;
}

.thread-item:hover {
    background: #f3f6fb;
}

.thread-item span {
    color: var(--muted);
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.direct-chat-panel,
.comments-region,
.assistant-messages {
    padding: 16px;
}

.direct-chat-messages,
.assistant-messages {
    display: grid;
    gap: 10px;
    min-height: 240px;
    align-content: start;
}

.direct-chat-message,
.assistant-message {
    max-width: 76%;
    padding: 10px 12px;
    border-radius: 8px;
    background: #eef2f7;
}

.direct-chat-message.mine,
.assistant-message.mine {
    justify-self: end;
    background: #dbeafe;
}

.direct-chat-message time {
    display: block;
    margin-top: 4px;
    font-size: 12px;
    color: var(--muted);
}

.message-form {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 110px;
    gap: 10px;
    margin-top: 12px;
}

.message-form .primary {
    width: auto;
}

.comment-composer,
.comment-reply-form {
    display: grid;
    gap: 10px;
    margin-bottom: 16px;
}

.comment-list {
    display: grid;
    gap: 14px;
}

.comment {
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fff;
    padding: 14px;
}

.comment[data-comment-depth="1"],
.comment[data-comment-depth="2"],
.comment[data-comment-depth="3"] {
    margin-left: 18px;
    background: #fbfcfe;
}

.comment-header {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: flex-start;
    margin-bottom: 10px;
}

.comment-author {
    display: grid;
    gap: 3px;
}

.comment-author a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 700;
}

.comment-meta,
.comment-vote-state,
.comment-reply-count {
    color: var(--muted);
    font-size: 13px;
}

.comment-scorebox {
    display: grid;
    justify-items: end;
    gap: 2px;
    min-width: 70px;
}

.comment-text {
    margin: 0 0 12px;
    white-space: normal;
}

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

.comment-vote-button.active {
    background: #dbeafe;
}

.comment-vote-clear {
    padding-inline: 0;
}

.comment-replies {
    display: grid;
    gap: 12px;
    margin: 14px 0 16px;
}

.comment-reply-form {
    margin: 0 0 4px 18px;
}

.comment-reply-status {
    margin: 0 0 8px;
}

.profile-comment-list {
    display: grid;
    gap: 12px;
}

.profile-comment {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    padding: 12px 14px;
}

.profile-comment-meta {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 10px;
    color: var(--muted);
    font-size: 13px;
    margin-bottom: 8px;
}

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

    .sidebar {
        position: static;
        grid-template-rows: auto auto auto;
    }

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

    .content {
        padding: 18px;
    }

    .view-header,
    .feed-layout,
    .direct-chat-layout,
    .message-form {
        grid-template-columns: 1fr;
        display: grid;
    }

    .card-header,
    .location-card-header {
        grid-template-columns: 1fr;
        display: grid;
    }

    .comment-header,
    .profile-comment-meta {
        grid-template-columns: 1fr;
        display: grid;
    }

    .comment-reply-form {
        margin-left: 0;
    }

    .direct-chat-message,
    .assistant-message {
        max-width: 100%;
    }
}
