/* Copyright 2026 Autopoetic Inc */

/* === 1. Variables & Reset === */
@import url('https://fonts.googleapis.com/css2?family=Nunito:ital,wght@0,200..1000;1,200..1000&display=swap');

:root {
    --color-bg: #FFFBF7;
    --color-bg-dark: #efefef;
    --color-border: #888;
    --color-text: #222;
    --color-text-muted: #444;
    --color-primary: #0056B3;
    --color-primary-hover: #007BFF;
    --color-disabled: #CCC;
    --color-success: #28A745;
    --color-error: #DC3545;
    --font-family: "Nunito", sans-serif;
    --font-size-xlg: 28px;
    --font-size-lg: 22px;
    --font-size-md: 18px;
    --font-size-sm: 14px;
    --line-height: 1.6;
    --space-unit: 10px;
    --space-sm: 10px;
    --space-md: 20px;
    --radius: 4px;
    --transition-fast: 0.3s ease-in;
    --shadow: 0 3px 2px -3px rgba(0, 0, 0, 0.25);
    --padding: 0.75em;

}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* === 2. Layout === */
body {
    font-optical-sizing: auto;
    font-family: var(--font-family);
    font-size: var(--font-size-lg);
    line-height: var(--line-height);
    color: var(--color-text);
    background: var(--color-bg);
    zoom: 1;
}

.container {
    max-width: 1024px;
    margin: 0 auto;
    padding: var(--space-md);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Full-width layout: remove the 1024px max-width and gutters so a page
   can span the entire viewport. Add `.full-width-page` to the <body>
   (via Jinja's {% block body_class %}) to opt in. Optionally add
   `.full-width-no-header` to also hide the header/logo/nav. */
.full-width-page .container {
    max-width: 100%;
    padding: 0;
}

.full-width-page main {
    flex: 1;
    overflow: hidden;
}

.full-width-page .breadcrumb {
    padding: 0 var(--space-sm);
    margin-bottom: 0;
}

.full-width-no-header .impersonation-banner,
.full-width-no-header header {
    display: none;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-md);
    padding-bottom: var(--space-sm);
}

#prototype-warning {
    text-align: center;
    padding: 4px;
    font-size: var(--font-size-sm);
}

.logo {
    display: block;
    max-width: 200px;
    margin-left: -0.65rem;
    width: 100%;
}

.logo img {
    min-width: 100%;
    width: 100%;
    cursor: pointer;
}

nav {
    align-items: center;
    gap: 4px;
}

.nav-main {
    align-items: center;
    gap: 12px;
    padding-bottom: var(--space-sm);
    margin-bottom: var(--space-sm);
}

.nav-main .nav-link {
    font-size: var(--font-size-lg);
    text-decoration: underline;
}

.nav-account {
    display: flex;
    align-items: center;
    gap: 12px;
    justify-content: flex-end;
}

.nav-user {
    font-size: var(--font-size-sm);
    color: var(--color-text-muted);
    white-space: nowrap;
}

.nav-link {
    font-size: var(--font-size-sm);
    color: var(--color-primary);
    text-decoration: none;
}

.nav-link:hover {
    color: var(--color-primary-hover);
}

button.nav-link {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
    font-family: inherit;
    font-size: var(--font-size-sm);
    color: var(--color-primary);
    text-decoration: none;
}

button.nav-link:hover {
    color: var(--color-primary-hover);
    cursor: pointer;
}

main {
    flex: 1;
}

footer {
    margin-top: var(--space-md);
    padding-top: var(--space-sm);
}

.footer-text {
    font-size: var(--font-size-sm);
    color: var(--color-text-muted);
}

footer .links li {
    font-size: var(--font-size-sm);
    display: inline;
}

footer .links .footer-sep {
    margin-left: 4px;
    color: var(--color-text-muted);
}

footer .links a {
    color: var(--color-text);
}

/* === 3. Typography & Utilities === */
h1, h2, h3, h4, h5, h6, h7, h8 {
    font-weight: normal;
}

.empty-state {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
    color: var(--color-text-muted);
    font-size: var(--font-size-lg);
    text-align: center;
}

.success-message {
    color: var(--color-success);
    font-size: var(--font-size-sm);
    margin-bottom: var(--space-sm);
}

.explainer {
    font-size: var(--font-size-sm);
    color: var(--color-text-muted);
    margin-bottom: var(--space-sm);
    line-height: 1.5;
}

.back-link {
    display: inline-block;
    margin-bottom: 0.5em;
    color: var(--color-text-muted);
    text-decoration: none;
    font-size: var(--font-size-sm);
}

.back-link:hover {
    color: var(--color-primary);
}

/* === 4. Buttons === */
.btn {
    padding: 10px 20px;
    background: var(--color-primary);
    color: white;
    border: none;
    border-radius: var(--radius);
    font-size: var(--font-size-sm);
    font-family: var(--font-family);
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
}

.btn:hover {
    background: var(--color-primary-hover);
}

.btn:disabled {
    background: var(--color-disabled);
    cursor: not-allowed;
}

.btn-secondary {
    background: var(--color-text-muted);
}

.btn-secondary:hover {
    background: var(--color-text);
}

.btn-ghost {
    background: transparent;
    color: var(--color-primary);
    border: 1px solid var(--color-primary);
}

.btn-ghost:hover {
    background: transparent;
}

/* Size modifier: a less-tall, compact button for inline use (list rows,
 * toolbars). Composes with any variant: `btn btn-ghost btn-thin`. */
.btn-thin {
    font-size: 0.75rem;
    padding: 4px 10px;
    line-height: 1.4;
}

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

.btn-danger:hover {
    background: #C82333;
}

.btn-action {
    font-size: 0.75rem;
    background: transparent;
    color: var(--color-text-muted);
    border-radius: var(--radius);
    cursor: pointer;
    font-family: var(--font-family);
    border: none;
    text-decoration: underline;
}

.btn-action:hover {
    color: var(--color-text);
}

.delete-btn {
    background: none;
    border: none;
    font-size: 0.5em;
    cursor: pointer;
    padding: 0.25em 0.25em 0.25em 2em;
    color: #888;
    opacity: 0.5;
    filter: grayscale(100%);
}

.delete-btn:hover {
    opacity: 1.0;
    filter: grayscale(0%);
    color: red;
}

.btn-publish,
.btn-unpublish,
.btn-published-url,
.btn-export {
    font-size: 0.75rem;
}

.btn-publish,
.btn-unpublish,
.btn-export {
    color: var(--color-text-muted);
    background: none;
    border: none;
    cursor: pointer;
}

.btn-publish:hover,
.btn-unpublish:hover,
.btn-export:hover {
    color: var(--color-text);
}

.btn-published-url {
    background: none;
    border: none;
    cursor: pointer;
    white-space: nowrap;
    text-decoration: underline;
}

.btn-publish:hover,
.btn-unpublish:hover,
.btn-update-publish:hover,
.btn-copy-link:hover,
.btn-export:hover {
    color: var(--color-text);
}

.btn-published-link {
    text-decoration: none;
}

.btn-published-link:hover {
    text-decoration: underline;
}

/* === 5. Forms === */
.form-group {
    margin-bottom: 12px;
}

.form-group label {
    display: block;
    font-size: var(--font-size-md);
    margin-bottom: 4px;
    color: var(--color-text-muted);
}

input[type="email"],
input[type="password"],
input[type="text"],
textarea {
    width: 100%;
    padding: var(--space-sm);
    background-color: white;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-size: var(--font-size-md);
    font-family: var(--font-family);
    resize: vertical;
    outline: none;
    box-shadow: none;
    -webkit-box-shadow: none;
}

input[type="email"]:focus,
input[type="password"]:focus,
input[type="text"]:focus,
textarea:focus {
    border: 1px solid blue;
}

.preamble-processing {
    color: var(--color-text-muted);
    font-style: italic;
    font-size: var(--font-size-sm);
    margin-bottom: 0.5em;
}

.preamble-failed {
    color: var(--color-error, #c0392b);
    font-size: var(--font-size-sm);
    margin-bottom: 0.5em;
}

.preamble-textarea,
.preamble-textarea-disabled {
    width: 100%;
    font-family: var(--font-family);
    height: 20em;
}

/* === 6. Errors === */
.errors {
    list-style: none;
    margin-bottom: 12px;
    padding: var(--space-sm);
    background: #FFF0F0;
    border: 1px solid var(--color-error);
    border-radius: var(--radius);
}

.errors li {
    font-size: var(--font-size-sm);
    color: var(--color-error);
}

/* === 7. Breadcrumbs === */
.breadcrumb {
    font-size: var(--font-size-sm);
    color: var(--color-text-muted);
    margin-bottom: var(--space-sm);
    padding: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.breadcrumb a {
    color: var(--color-primary);
    text-decoration: none;
}

.breadcrumb a:hover {
    color: var(--color-primary-hover);
    text-decoration: underline;
}

.breadcrumb-separator {
    color: var(--color-text-muted);
}

.breadcrumb span:last-child {
    max-width: 200px;
    display: inline-block;
    vertical-align: bottom;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* === 8. Pagination === */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: var(--space-md);
    margin: var(--space-md) 0;
}

.pagination-link {
    font-size: var(--font-size-sm);
    color: var(--color-primary);
    text-decoration: none;
}

.pagination-link:hover {
    color: var(--color-primary-hover);
}

.pagination-info {
    font-size: var(--font-size-sm);
    color: var(--color-text-muted);
}

/* === 9. Usage Bar === */
.usage-summary {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.usage-bar-container {
    flex: 1;
    max-width: 120px;
    height: 4px;
    background: var(--color-bg-dark);
    border-radius: 2px;
    overflow: hidden;
}

.usage-bar {
    height: 100%;
    background: var(--color-primary);
    border-radius: 2px;
    transition: width 0.3s ease;
}

.usage-bar-over {
    background: var(--color-error);
}

.usage-text {
    font-size: var(--font-size-sm);
    color: var(--color-text-muted);
    white-space: nowrap;
}

/* === 10. Spinner === */
.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid #aaa;
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    vertical-align: middle;
    margin-right: 6px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* === 11. Agent Browsing === */
.agents-list {
    margin: 0 auto;
}

.agent-search-form {
    margin-bottom: var(--space-md);
    display: none;
}

.agent-search-input {
    width: 100%;
    padding: 8px 12px;
    font-size: var(--font-size-md);
    font-family: var(--font-family);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: white;
    outline: none;
}

.agent-search-input:focus {
    border-color: var(--color-primary);
}

.agent-items {
    list-style: none;
    padding: 0;
}

.agent-card {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 16px 0;
    gap: 16px;
    font-size: 14px;
}

.agent-card + .agent-card {
    border-top: 1px solid var(--color-border);
}

.agent-card-main {
    flex: 1;
    min-width: 0;
}

.agent-card-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 4px;
}

.agent-display-name {
    font-size: var(--font-size-md);
    font-weight: 700;
}

.agent-meta {
    font-size: var(--font-size-sm);
    color: var(--color-text-muted);
    margin-bottom: 6px;
}

.agent-meta .agent-version {
    margin-left: 8px;
}

.agent-perspectives {
    margin-bottom: 0.5em;
}

.agent-description {
    color: var(--color-text-muted);
    font-size: var(--font-size-sm);
    margin: 0 0 0.5em 0;
    line-height: 1.4;
}

.agent-perspectives-emoji {
    margin-bottom: 6px;
    font-size: var(--font-size-md);
}

.agent-perspectives-emoji .agent-emoji {
    margin-right: 4px;
}

.agent-tags {
    display: none;
    flex-wrap: wrap;
    font-size: 14px;
}

.agent-tag {
    display: inline;
}

.agent-tag + .agent-tag::before {
    content: ", ";
}

.agent-card-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex-shrink: 0;
}

.agent-card-actions .btn {
    font-size: var(--font-size-sm);
    text-align: center;
    white-space: nowrap;
}

/* === 12. Agent Detail === */
.agent-detail {
    margin: 0 auto;
}

.agent-detail h1 {
    font-size: var(--font-size-xlg);
    margin-bottom: var(--space-sm);
}

.agent-detail-header {
    margin-bottom: var(--space-md);
}

.agent-detail-title-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-sm);
}

.agent-detail-title-row .btn {
    flex-shrink: 0;
}

.agent-detail-meta {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.agent-detail-id {
    font-size: var(--font-size-sm);
    color: var(--color-text-muted);
}

.agent-detail-id code {
    font-family: monospace;
    font-size: 0.85em;
}

.agent-detail .agent-tags {
    margin-bottom: var(--space-md);
}

.agent-detail-perspectives {
    margin-top: var(--space-md);
}

.agent-detail-perspectives h2 {
    font-size: var(--font-size-md);
    font-weight: 700;
    margin-bottom: var(--space-md);
}

.perspective-section {
    display: flex;
    align-items: flex-start;
    gap: 0;
    margin-bottom: 12px;
    overflow: hidden;
}

.perspective-emoji-column {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6em;
    padding: 0px 10px 0px 10px;
}

.perspective-content {
    flex: 1;
    min-width: 0;
    padding: 4px 8px 8px 8px;
}

.perspective-header {
    margin-bottom: 6px;
}

.perspective-emoji-large {
    display: none;
}

.perspective-display-name {
    font-size: var(--font-size-md);
    font-weight: 700;
}

.perspective-role-badge {
    font-size: 0.65rem;
    color: var(--color-text-muted);
    background: var(--color-bg-dark);
    padding: 2px 6px;
    border-radius: 10px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.perspective-description {
    font-size: var(--font-size-sm);
    color: var(--color-text-muted);
    line-height: 1.5;
    margin: 0;
}

/* === 13. Tier Bar === */
.tier-bar {
    display: block;
    gap: 3px;
    align-items: center;
    margin-bottom: 0.5em;
}

.tier-segment {
    display: inline-flex;
    width: 20px;
    height: 8px;
    background: var(--color-bg-dark);
    border-radius: 2px;
}

.tier-filled {
    background: var(--color-primary);
}

.tier-label {
    font-size: 0.7rem;
    color: var(--color-text-muted);
    margin-left: 6px;
}

.tier-bar-label {
    font-size: 14px;
}

/* === 14. Projects === */
.project-items {
    list-style: none;
    padding: 0;
}

.project-item {
    border: 1px solid #aaa;
    background-color: white;
    margin: 1em 0;
    padding: var(--padding);
    border-radius: var(--radius);
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: var(--space-sm);
    box-shadow: var(--shadow);
}

.project-breadcrumb {
    font-size: var(--font-size-md);
    min-width: 0;
}

.project-breadcrumb-link {
    text-decoration: none;
    color: var(--color-primary);
}

.project-breadcrumb-link:hover {
    color: var(--color-primary-hover);
    text-decoration: underline;
}

.project-meta {
    font-size: var(--font-size-sm);
    color: var(--color-text-muted);
    text-align: right;
    white-space: nowrap;
}

.project-detail {
    width: 100%;
    margin-top: 2em;
}

.project-detail h1 {
    margin-bottom: var(--space-md);
}

.project-detail h2 {
    font-size: var(--font-size-md);
    margin-bottom: var(--space-sm);
}

.project-detail .form-section {
    margin-bottom: var(--space-md);
}

.project-detail .danger-zone {
    background: #FFF0F0;
    padding: var(--space-md);
    border: 1px solid var(--color-error);
    border-radius: var(--radius);
}

.project-detail .danger-zone h2 {
    color: var(--color-error);
}

.project-detail .danger-zone p {
    font-size: var(--font-size-sm);
    color: var(--color-text-muted);
    margin-bottom: var(--space-sm);
}

.project-members {
    width: 100%;
    margin-top: 2em;
}

.project-members h2 {
    font-size: var(--font-size-md);
    margin-bottom: var(--space-sm);
}

.project-members .form-section {
    margin-bottom: var(--space-md);
}

.members-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: var(--space-md);
}

.members-table th,
.members-table td {
    text-align: left;
    padding: var(--space-sm) var(--space-md);
    border-bottom: 1px solid var(--color-border);
}

.members-table th {
    font-weight: var(--font-weight-semibold);
    color: var(--color-text-muted);
    font-size: var(--font-size-sm);
}

.members-table td:last-child {
    text-align: right;
}

.invitations {
    width: 100%;
    margin-top: 2em;
}

.invitations h1 {
    margin-bottom: var(--space-md);
}

.invitations-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: var(--space-md);
}

.invitations-table th,
.invitations-table td {
    text-align: left;
    padding: var(--space-sm) var(--space-md);
    border-bottom: 1px solid var(--color-border);
}

.invitations-table th {
    font-weight: var(--font-weight-semibold);
    color: var(--color-text-muted);
    font-size: var(--font-size-sm);
}

.invitation-actions {
    display: flex;
    gap: var(--space-sm);
    justify-content: flex-end;
}

.api-keys {
    width: 100%;
    margin-top: 2em;
}

.api-keys .form-section {
    margin-bottom: var(--space-md);
}

.api-keys .danger-zone {
    background: #FFF0F0;
    padding: var(--space-md);
    border: 1px solid var(--color-error);
    border-radius: var(--radius);
}

.api-keys .danger-zone h2 {
    color: var(--color-error);
}

.api-keys .danger-zone p {
    font-size: var(--font-size-sm);
    color: var(--color-text-muted);
    margin-bottom: var(--space-sm);
}

.api-key-display {
    display: block;
    padding: var(--space-sm) var(--space-md);
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-family: monospace;
    font-size: 0.9em;
    word-break: break-all;
    user-select: all;
}

.api-key-reveal {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.api-key-reveal .btn-copy {
    align-self: flex-start;
}

.api-key-warning {
    font-size: var(--font-size-sm);
    color: var(--color-warning, #B45309);
    margin: var(--space-xs) 0 0 0;
}

.api-key-textarea {
    width: 100%;
    font-family: monospace;
    font-size: 0.85em;
    padding: var(--space-sm);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    resize: vertical;
}

.mono-input {
    font-family: monospace;
    font-size: 0.9em;
}

.code-example {
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: var(--space-md);
    overflow-x: auto;
    font-size: var(--font-size-sm);
}

.code-example code {
    font-family: monospace;
    white-space: pre;
}

.access-token-result {
    margin-top: var(--space-md);
}

.btn-copy {
    margin-top: var(--space-xs);
}

.btn-sm {
    font-size: var(--font-size-sm);
    padding: var(--space-xs) var(--space-sm);
}

.api-key-cell {
    font-size: var(--font-size-sm);
    word-break: break-all;
}

.api-key-actions {
    display: flex;
    gap: var(--space-xs);
    justify-content: flex-end;
}

.token-form-row td {
    padding-top: var(--space-sm) !important;
}

.token-gen-form {
    display: flex;
    gap: var(--space-sm);
    align-items: flex-end;
    flex-wrap: wrap;
}

.token-gen-form .form-group {
    flex: 1;
    min-width: 200px;
}

.empty-state {
    color: var(--color-text-muted);
    font-size: var(--font-size-sm);
}
    width: 100%;
}

.project-create h1 {
    margin-bottom: var(--space-md);
}

.delete-dialog {
    margin-top: var(--space-sm);
    padding: var(--space-sm);
    border: 1px solid var(--color-error);
    border-radius: var(--radius);
    background: white;
}

.delete-dialog p {
    font-size: var(--font-size-sm);
    margin-bottom: var(--space-sm);
}

.delete-dialog input[type="text"] {
    margin-bottom: var(--space-sm);
}

/* === 15. Conversation List === */
.list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-md);
}

.list-header h1 {
    font-size: 22px;
}

.list-header-actions {
    display: flex;
    gap: var(--space-sm);
    align-items: center;
}

.conversation-items {
    list-style: none;
}

.conversation-item {
    display: flex;
    align-items: center;
    border: 1px solid #aaa;
    background-color: white;
    margin: 1em 0;
    padding: var(--padding);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.conversation-link {
    flex: 1;
    text-decoration: none;
    color: var(--color-text);
    display: flex;
    justify-content: space-between;
    align-items: baseline;
}

.conversation-link:hover .conversation-title {
    color: var(--color-primary);
}

.conversation-title {
    font-size: var(--font-size-md);
    max-width: 80ch;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conversation-meta {
    font-size: var(--font-size-sm);
    color: var(--color-text-muted);
}

/* === 16. Auth === */
.auth-form {
    max-width: 640px;
    margin: 0 auto;
}

.auth-form h1 {
    margin-bottom: var(--space-md);
}

.auth-form .btn {
    display: block;
    width: 100%;
}

.auth-form .btn + .plan-description {
    margin-top: 1em;
}

.auth-form #sign-up-description {
    margin-bottom: 1em;
}

.auth-form form {
    margin-bottom: 2em;
    padding: 2em;
    border: 1px solid gray;
    background-color: white;
    border-radius: 4px;
}

.auth-form hr {
    margin: 2em 0;
    border-top-width: 2px;
    border-top-style: dashed;
}

#sign-up-or-log-in.auth-form form {
    background-color: transparent;
    border: none;
    padding: 0;
}

#sign-up-or-log-in.auth-form form .buttons {
    display: flex;
}

#sign-up-or-log-in.auth-form form .buttons > * {
    display: flex;
}

#sign-up-direct-page p, #sign-up-direct-page form label, #sign-up-direct-page form input{
    margin-bottom: 1em;
}

/* === 17. Settings === */
.settings-form {
    max-width: 500px;
    margin: 60px auto;
}

.settings-form h1 {
    margin-bottom: var(--space-md);
}

.settings-form h2 {
    margin-bottom: var(--space-sm);
    font-weight: normal;
}

.settings-form hr {
    border: none;
    border-top: 1px solid var(--color-border);
    margin: var(--space-md) 0;
}

.settings-billing p {
    color: var(--color-text-muted);
    font-size: var(--font-size-sm);
    margin-bottom: var(--space-sm);
}

/* === 18. Error Page === */
.error-page {
    text-align: center;
    padding: 60px 0;
}

.error-page h1 {
    margin-bottom: var(--space-md);
}

.error-page p {
    margin-bottom: var(--space-md);
    color: var(--color-text-muted);
}

/* === 19. Admin === */
.admin-customers {
    width: 100%;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    margin: var(--space-md) 0;
    font-size: 0.75em;
}

.admin-table th {
    text-align: left;
    padding: 8px 12px;
    border-bottom: 2px solid var(--color-border);
    font-weight: normal;
    color: var(--color-text-muted);
}

.admin-table th a {
    color: var(--color-text-muted);
    text-decoration: none;
}

.admin-table th a:hover {
    color: var(--color-primary);
}

.admin-table td {
    padding: 4px 8px;
    border-bottom: 1px solid var(--color-border);
    line-height: 1.4;
}

.admin-row:hover {
    background-color: var(--color-bg-dark);
}

.admin-cell-number {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.admin-cell-date {
    white-space: nowrap;
    color: var(--color-text-muted);
}

.admin-status {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 3px;
    font-size: 12px;
    text-transform: capitalize;
}

.admin-status-active {
    background-color: #d4edda;
    color: #155724;
}

.admin-status-trialing {
    background-color: #cce5ff;
    color: #004085;
}

.admin-status-past_due,
.admin-status-unpaid,
.admin-status-canceled {
    background-color: #f8d7da;
    color: #721c24;
}

.admin-status-none {
    background-color: var(--color-bg-dark);
    color: var(--color-text-muted);
}

.admin-uuid-link {
    color: var(--color-primary);
    text-decoration: none;
    font-family: var(--font-mono, monospace);
}

.admin-uuid-link:hover {
    text-decoration: underline;
}

.admin-detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px 24px;
    margin: var(--space-md) 0;
}

.admin-detail-label {
    color: var(--color-text-muted);
    font-size: 0.75em;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.admin-detail-value {
    font-size: 0.75em;
}

.admin-detail-section {
    margin: var(--space-lg) 0;
}

.admin-detail-section h3 {
    margin-bottom: var(--space-sm);
    font-size: 0.85em;
    color: var(--color-text-muted);
}

.impersonation-banner {
    background: var(--color-warning, #f59e0b);
    color: #000;
    padding: 0.5rem 1rem;
    text-align: center;
    font-size: 0.85em;
    font-family: var(--font-mono, monospace);
}

.btn-impersonate {
    font-size: 0.75em;
    padding: 2px 8px;
    background: var(--color-primary);
    color: #fff;
    border: none;
    border-radius: 3px;
    cursor: pointer;
}

.btn-impersonate:hover {
    opacity: 0.85;
}

.btn-knowledge-dump {
    font-size: 0.75em;
    padding: 2px 8px;
    background: var(--color-secondary, #666);
    color: #fff;
    border: none;
    border-radius: 3px;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
    margin-left: 4px;
}

.btn-knowledge-dump:hover {
    opacity: 0.85;
}

.btn-edit-flags {
    font-size: 0.75em;
    padding: 2px 8px;
    background: var(--color-secondary, #666);
    color: #fff;
    border: none;
    border-radius: 3px;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
    margin-left: 4px;
}

.btn-edit-flags:hover {
    opacity: 0.85;
}

.admin-feature-flags-form {
    margin-top: var(--space-md);
}

.admin-json-editor {
    width: 100%;
    min-height: 240px;
    font-family: var(--font-mono, monospace);
    font-size: 0.8em;
    padding: 12px;
    border: 1px solid var(--color-border);
    border-radius: 4px;
    background: var(--color-bg);
    color: var(--color-text);
    resize: vertical;
    tab-size: 2;
}

.admin-json-editor:focus {
    outline: 2px solid var(--color-primary);
    border-color: var(--color-primary);
}

.admin-form-actions {
    margin-top: var(--space-sm);
}

.btn-save-flags {
    font-size: 0.85em;
    padding: 6px 16px;
    background: var(--color-primary);
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

.btn-save-flags:hover {
    opacity: 0.85;
}

.admin-detail-hint {
    font-size: 0.75em;
    color: var(--color-text-muted);
    margin-bottom: var(--space-sm);
}

.success-message {
    color: #155724;
    background: #d4edda;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 0.85em;
}

.btn-stop-impersonating {
    font-size: 0.85em;
    padding: 2px 12px;
    background: #000;
    color: #fff;
    border: none;
    border-radius: 3px;
    cursor: pointer;
}

.btn-stop-impersonating:hover {
    opacity: 0.85;
}

/* === 20. Chat Components === */
#conversation-page {
    display: flex;
    flex-direction: column;
    min-height: 60vh;
    margin-top: 2em;
}

#conversation-page .messages {
    flex: 1;
    padding-bottom: var(--space-md);
    display: flex;
    flex-direction: column;
}

#conversation-page .empty-state {
    padding: 40px 0;
}

#conversation-page .message {
    padding: 2px 0;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    animation: fadeIn 0.3s ease-in;
    margin-bottom: 16px;
}

#conversation-page .user-message {
    justify-content: flex-end;
    flex-wrap: wrap;
}

#conversation-page .user-message .message-body {
    font-family: var(--font-family);
    background: white;
    border: 1px solid #aaa;
    padding: 1em 1.3em;
    border-radius: var(--radius);
    max-width: 80%;
    font-size: var(--font-size-md);
    text-align: justify;
    white-space: pre-wrap;
    line-height: var(--line-height);
    overflow: hidden;
    box-shadow: var(--shadow);
}

#conversation-page .user-message .message-actions {
    flex-basis: 100%;
    justify-content: flex-end;
    margin: -0.3em 0;
}

#conversation-page .message-timestamp {
    display: block;
    font-size: var(--font-size-sm);
    color: var(--color-text-muted);
    margin-top: 4px;
    margin-bottom: 4px;
}

#conversation-page .agent-response .message-timestamp {
    margin-bottom: 8px;
}

#conversation-page .agent-message .message-body {
    font-size: var(--font-size-md);
    line-height: var(--line-height);
    text-align: justify;
    overflow: hidden;
}

#conversation-page .user-message > *,
#conversation-page .agent-message .agent-response > * {
  position: relative;
  z-index: 2;
}



#conversation-page .md-pending {
    visibility: hidden;
}

#conversation-page .agent-message .message-body p:first-child {
    margin-top: 0;
}

#conversation-page .agent-message .message-body p:last-child {
    margin-bottom: 0;
}

#conversation-page .agent-message .perspective-text ul,
#conversation-page .agent-message .perspective-text ol,
#conversation-page .agent-message .perspective-text p,
#conversation-page .agent-message .message-body ul,
#conversation-page .agent-message .message-body ol,
#conversation-page .agent-message .message-body p {
    margin: 1em 0;
}

#conversation-page .agent-message .perspective-text li,
#conversation-page .agent-message .message-body li {
    margin: 0.5em 0;
}

#conversation-page .agent-message .perspective-text ul,
#conversation-page .agent-message .perspective-text ol,
#conversation-page .agent-message .message-body ul,
#conversation-page .agent-message .message-body ol {
    padding-left: 1.5em;
}

#conversation-page .agent-message .message-body code {
    font-family: monospace;
    font-size: 0.9em;
    background: var(--color-bg-dark);
    padding: 0.15em 0.3em;
    border-radius: 3px;
}

#conversation-page .agent-message .message-body pre {
    background: var(--color-bg-dark);
    padding: 0.75em 1em;
    border-radius: var(--radius);
    overflow-x: auto;
    margin: 0.5em 0;
}

#conversation-page .agent-message .message-body pre code {
    background: none;
    padding: 0;
    border-radius: 0;
}

#conversation-page .agent-message .message-body blockquote {
    border-left: 3px solid var(--color-border);
    padding-left: 0.75em;
    margin: 0.5em 0;
    color: var(--color-text-muted);
}

#conversation-page .agent-message .message-body h1,
#conversation-page .agent-message .message-body h2,
#conversation-page .agent-message .message-body h3,
#conversation-page .agent-message .message-body h4 {
    margin: 0.75em 0 0.25em;
    font-weight: 700;
}

#conversation-page .individual-perspective .perspective-text.md-pending {
    visibility: hidden;
}

#conversation-page .individual-perspective .perspective-text p:first-child {
    margin-top: 0;
}

#conversation-page .individual-perspective .perspective-text p:last-child {
    margin-bottom: 0;
}

#conversation-page .agent-response {
    width: 100%;
}

#conversation-page .agent-display-name {
    display: block;
    color: var(--color-text-muted);
    margin-bottom: 4px;
}

/* === 20a. Thinking Block === */
#conversation-page .thinking-block {
    margin-bottom: 12px;
}

#conversation-page .thinking-block summary {
    font-size: var(--font-size-sm);
    color: var(--color-text-muted);
    cursor: pointer;
    user-select: none;
}

#conversation-page .perspectives {
    margin-top: 8px;
    padding: 12px;
    border-radius: var(--radius);
}

#conversation-page .perspective {
    margin-bottom: 15px;
    font-size: var(--font-size-md);
    line-height: 1.4;
    text-align: justify;
    display: flex;
}

#conversation-page .perspective:last-child {
    margin-bottom: 0;
}

#conversation-page .perspective-name {
    font-weight: 700;
    margin-right: 8px;
    text-transform: capitalize;
}

#conversation-page .perspective-statement {
    display: inline-block;
    font-size: var(--font-size-md);
}

#conversation-page .individual-perspective {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 1em;
    padding-right: 1em;
}

#conversation-page .individual-perspective .perspective-emoji {
    margin-right: 0.25em;
    font-size: 1em;
    display: inline-block;
    position: relative;
    top: -3px;
    flex-shrink: 0;
    line-height: var(--line-height);
}

#conversation-page .perspective-emoji-hidden {
    visibility: hidden;
}

#conversation-page .individual-perspective .perspective-text {
    flex: 1;
    font-size: var(--font-size-md);
    line-height: var(--line-height);
    text-align: justify;
}

#conversation-page .individual-perspective + .message-body {
    margin-top: 0;
}

#conversation-page .perspective-divider {
    color: var(--color-text-muted);
    font-size: var(--font-size-md);
    user-select: none;
}

/* === 20b. Contribution Bar === */
#conversation-page .contribution-bar {
    margin-top: 12px;
    margin-bottom: 0;
}

#conversation-page .contribution-segments {
    display: flex;
    height: 6px;
    overflow: hidden;
}

#conversation-page .contribution-segments .segment {
    height: 100%;
    min-width: 1px;
    transition: width 0.3s ease;
}

#conversation-page .contribution-labels {
    position: relative;
    height: 22px;
    margin-top: 2px;
}

#conversation-page .contribution-labels .label {
    position: absolute;
    transform: translateX(-50%);
    font-size: 14px;
    line-height: 22px;
}

@media print {
    #conversation-page .contribution-segments .segment {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
}

/* === 20c. Steering Visualization === */
#conversation-page .steering-viz {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    position: relative;
    z-index: 1 !important;
}

#conversation-page .steering-viz .contribution-bar {
    width: 100%;
    min-width: 0;
}

#conversation-page .sv-container {
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    width: 100%;
    max-height: 50vh;
    max-width: 70vh;
}

#conversation-page .sv-canvas {
    cursor: pointer;
    width: 100%;
    height: auto;
    aspect-ratio: 1 / 1;
}

#sv-fullscreen-overlay {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    background: rgb(255, 251, 247, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
}

.sv-fullscreen-canvas {
    width: min(80vw, 80vh);
    height: min(80vw, 80vh);
}

.sv-download-buttons {
    position: absolute;
    top: 16px;
    right: 16px;
    display: flex;
    gap: 12px;
    z-index: 10002;
}

.sv-download-btn {
    background: none;
    color: #000;
    border: none;
    padding: 0;
    font-size: 14px;
    font-weight: 400;
    font-family: inherit;
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 2px;
    opacity: 0.7;
    transition: opacity 0.15s;
}

.sv-download-btn:hover {
    opacity: 1;
}

/* === 20d. Message Actions === */
#conversation-page .message-actions {
    display: flex;
    gap: 8px;
    margin-top: 4px;
    align-items: center;
}

#conversation-page .message-actions form {
    display: inline;
}

#conversation-page .publish-info {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 2px;
    flex-wrap: wrap;
}

/* === 20e. Chat Input === */
#conversation-page .chat-input {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: flex-end;
}

#conversation-page .chat-input textarea {
    flex: 1;
    min-width: 0;
    resize: none;
    overflow-y: auto;
    max-height: 40vh;
}

#conversation-page .chat-input-footer {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    flex-basis: 100%;
    gap: 12px;
    width: 100%;
    max-width: 100%;
    overflow: visible;
}

#conversation-page .chat-input-meta {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

#conversation-page .agent-select {
    padding: 6px 10px;
    font-size: var(--font-size-sm);
    font-family: var(--font-family);
    color: var(--color-text-muted);
    background: white;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23333' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 30px;
    margin-bottom: 2px;
    visibility: hidden;
}

#conversation-page .agent-select:focus {
    outline: none;
    border-color: var(--color-primary);
}

#conversation-page .agent-label {
    font-size: 0.75rem;
    color: var(--color-text-muted);
    margin-bottom: 2px;
}

#conversation-page .hide-perspectives-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.75rem;
    color: var(--color-text-muted);
    cursor: pointer;
    margin-top: 4px;
    user-select: none;
}

#conversation-page .knowledge-access-group {
    display: flex;
    align-items: center;
    gap: 8px;
    border: none;
    padding: 0 0 6px 0px;
    font-size: 0.75rem;
    color: var(--color-text-muted);
}

#conversation-page .knowledge-access-group legend {
    display: flex;
    font-size: 0.75rem;
    color: var(--color-text-muted);
    padding: 0;
    margin-right: 2px;
}

#conversation-page .knowledge-access-label {
    display: flex;
    align-items: center;
    gap: 3px;
    cursor: pointer;
    user-select: none;
}

#conversation-page .knowledge-access-group.knowledge-agent-selected .knowledge-access-label[data-value="none"] {
    display: none;
}

#conversation-page .hide-perspectives-toggle input[type="checkbox"] {
    margin: 0;
    cursor: pointer;
}

/* === 20f. Status Bar === */
#conversation-page .status-bar {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    margin-bottom: 8px;
}

#conversation-page .status-bar .status {
    margin-bottom: 0;
    flex: 0 0 auto;
}

#conversation-page .status {
    font-size: var(--font-size-sm);
    color: var(--color-text-muted);
    margin-bottom: 8px;
}

#conversation-page .status.connected {
    color: var(--color-success);
}

#conversation-page .status.disconnected {
    color: var(--color-error);
}

/* === 20g. File Upload === */
#conversation-page .btn-upload {
    background: transparent;
    cursor: pointer;
    border: none;
    font-size: 0.75rem;
    font-family: var(--font-family);
    color: var(--color-text-muted);
    margin-left: auto;
    white-space: nowrap;
    text-decoration: underline;
}

#conversation-page .btn-upload:hover {
    color: var(--color-text);
}

#conversation-page .btn-upload:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

#conversation-page .file-input {
    display: none;
}

#conversation-page .attachment-list {
    flex-basis: 100%;
    margin-top: -4px;
    margin-bottom: 4px;
}

#conversation-page .attachment-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: var(--color-primary);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 10px 20px;
    font-size: var(--font-size-sm);
    color: #ffffff;
}

#conversation-page .attachment-remove {
    background: transparent;
    border: none;
    cursor: pointer;
    color: white;
    font-size: var(--font-size-md);
    padding: 0 2px;
    position: relative;
    right: -7px;
    line-height: 1;
}

#conversation-page #agent-select {
    max-width: 100%;
    overflow: hidden;
}

/* === 21. Animation === */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-5px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.animate-in {
    animation: fadeIn 0.3s ease-in;
}

/* === 22. Responsive === */
@media only screen and (max-width: 1020px) {
    #conversation-page .user-message {
        justify-content: flex-start;
        width: 100%;
    }

    input[type="email"],
    input[type="password"],
    input[type="text"],
    textarea,
    #conversation-page .user-message .message-body,
    #conversation-page .agent-message .message-body,
    #conversation-page .individual-perspective .perspective-text,
    .conversation-title {
        font-size: 0.73em;
    }

    #conversation-page .user-message .message-body {
        width: 100%;
        max-width: 100%;
    }

    #conversation-page .chat-input {
        flex-direction: column;
        align-items: stretch;
    }

    #conversation-page .chat-input textarea {
        width: 100%;
    }

    #conversation-page .chat-input-footer {
        flex-direction: column-reverse;
        align-items: stretch;
    }

    #conversation-page .chat-input #send-btn {
        width: 100%;
    }

    #conversation-page .individual-perspective {
        padding-right: 0.5em;
    }

    .agent-card {
        flex-direction: column;
        align-items: stretch;
        text-align: left;
    }

    .agent-card-main {
        width: 100%;
    }

    .agent-card-actions {
        flex-direction: row;
        width: 100%;
        margin-top: 12px;
    }

    .agent-card-actions .btn {
        flex: 1;
        display: block;
        text-align: center;
    }

    #conversation-page .sv-container {
        overflow: hidden;
    }

    #conversation-page .sv-container .sv-canvas {
        scale: 1.1;
        margin: -3vh 0;
    }

    .sv-fullscreen-canvas {
        width: 120vw !important;
        height: 120vw !important;
    }

    .project-item {
        flex-direction: column;
        align-items: flex-start;
    }

    .project-meta {
        text-align: left;
    }
}

/* === 23. Theme Toggle === */
.theme-toggle {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    font-family: inherit;
    font-size: var(--font-size-sm);
    color: var(--color-primary);
    text-decoration: none;
}

.theme-toggle:hover {
    color: var(--color-primary-hover);
}

/* === 20h. Ask page === */
.ask-explainer {
    font-size: 0.875rem;
    color: var(--color-text-muted);
    margin: 0 0 12px 0;
}
