:root {
    --bg: #f8f1ef;
    --panel: rgba(255, 249, 247, 0.82);
    --panel-strong: rgba(245, 224, 220, 0.92);
    --border: rgba(143, 45, 53, 0.24);
    --text: #4d2529;
    --muted: #7c5a5c;
    --accent: #8f2d35;
    --accent-soft: #e7c6c5;
    --user: #7b2730;
    --bot: #5e4547;
    --error: #a12430;
    --success: #7a3d45;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: Georgia, "Times New Roman", serif;
    color: var(--text);
    background-image:
        linear-gradient(rgba(248, 241, 239, 0.78), rgba(248, 241, 239, 0.92)),
        url("/static/background-physics-ver2.png");
    background-repeat: no-repeat;
    background-position: right top;
    background-size: 65% auto;
    background-attachment: scroll;
    background-color: var(--bg);
}

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

.site-footer {
    padding: 18px 24px 22px;
    color: var(--muted);
    font-size: 0.92rem;
    line-height: 1.5;
    text-align: center;
}

.site-footer a {
    font-weight: 700;
}

.flash-stack {
    position: fixed;
    top: 20px;
    right: 20px;
    display: grid;
    gap: 10px;
    z-index: 1000;
}

.flash {
    min-width: 240px;
    padding: 12px 16px;
    border-radius: 14px;
    border: 1px solid var(--border);
    background: white;
    box-shadow: 0 12px 30px rgba(43, 33, 24, 0.14);
}

.flash-error {
    border-color: #fecaca;
    color: var(--error);
}

.flash-success {
    border-color: #bbf7d0;
    color: var(--success);
}

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

.auth-card,
.panel {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 22px;
    box-shadow: 0 24px 60px rgba(78, 37, 41, 0.12);
    backdrop-filter: blur(10px);
}

.auth-card {
    width: min(100%, 460px);
    padding: 28px;
}

.auth-card-wide {
    width: min(100%, 620px);
}

.eyebrow {
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-size: 0.78rem;
    color: var(--accent);
    margin: 0 0 10px;
}

.auth-copy h1,
.sidebar h1 {
    margin: 0 0 8px;
}

.auth-copy p,
.sidebar-copy,
.hint,
.account-box span {
    color: var(--muted);
    line-height: 1.5;
}

.auth-form {
    display: grid;
    gap: 10px;
    margin-top: 22px;
}

label {
    font-weight: 700;
}

input,
textarea,
select,
button {
    font: inherit;
}

input,
textarea,
select {
    width: 100%;
    padding: 14px 16px;
    border-radius: 14px;
    border: 1px solid var(--border);
    background: white;
}

textarea {
    resize: vertical;
}

button {
    border: 0;
    border-radius: 14px;
    padding: 14px 18px;
    background: linear-gradient(135deg, var(--accent), #c2410c);
    color: white;
    cursor: pointer;
}

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

.secondary-button {
    background: white;
    color: var(--text);
    border: 1px solid var(--border);
}

.inline-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 48px;
    padding: 14px 18px;
    border-radius: 14px;
    text-decoration: none;
}

.auth-switch {
    margin-top: 18px;
}

.anonymous-code-fields {
    display: grid;
    gap: 10px;
    margin: 10px 0;
    padding: 18px;
    border: 1px solid var(--border);
    border-radius: 14px;
}

.anonymous-code-fields legend {
    padding: 0 8px;
    font-weight: 700;
}

.field-help {
    margin: 0 0 8px;
    color: var(--muted);
    line-height: 1.5;
}

.recovery-card {
    text-align: center;
}

.recovery-code {
    margin: 24px 0 14px;
    padding: 18px;
    border: 2px dashed var(--accent);
    border-radius: 14px;
    background: white;
    font-family: Consolas, "Courier New", monospace;
    font-size: clamp(1.15rem, 5vw, 1.65rem);
    font-weight: 700;
    letter-spacing: 0.08em;
    overflow-wrap: anywhere;
}

.primary-link-button {
    display: inline-flex;
    justify-content: center;
    margin-top: 18px;
    padding: 14px 18px;
    border-radius: 14px;
    background: linear-gradient(135deg, var(--accent), #c2410c);
    color: white;
    text-decoration: none;
}

.admin-page {
    align-items: start;
}

.admin-card {
    width: min(100%, 960px);
}

.admin-navigation {
    position: relative;
    margin-top: 18px;
    display: flex;
    justify-content: flex-start;
    align-items: center;
    gap: 10px;
}

.admin-nav-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    min-height: 46px;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: rgba(255, 252, 251, 0.9);
    color: var(--text);
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
    transition: border-color 140ms ease, background 140ms ease, transform 140ms ease;
}

.admin-nav-button:hover {
    transform: translateY(-1px);
    border-color: rgba(143, 45, 53, 0.48);
    background: var(--panel-strong);
}

.admin-nav-button svg,
.admin-home-icon svg {
    width: 22px;
    height: 22px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.admin-menu {
    position: relative;
}

.admin-menu summary {
    list-style: none;
}

.admin-menu summary::-webkit-details-marker {
    display: none;
}

.admin-menu[open] > summary {
    border-color: var(--accent);
    background: var(--panel-strong);
    color: var(--accent);
}

.admin-menu-panel {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    z-index: 20;
    width: min(310px, calc(100vw - 48px));
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: rgba(255, 252, 251, 0.98);
    box-shadow: 0 18px 42px rgba(78, 37, 41, 0.18);
    backdrop-filter: blur(12px);
}

.admin-menu-panel a,
.admin-menu-panel button {
    display: flex;
    align-items: center;
    width: 100%;
    min-height: 45px;
    padding: 11px 14px;
    border: 0;
    border-bottom: 1px solid var(--border);
    border-radius: 0;
    background: transparent;
    color: var(--text);
    font-weight: 400;
    text-align: left;
    text-decoration: none;
}

.admin-menu-panel a:hover,
.admin-menu-panel button:hover,
.admin-menu-panel a[aria-current="page"] {
    background: var(--panel-strong);
    color: var(--accent);
}

.admin-menu-panel a[aria-current="page"] {
    font-weight: 700;
}

.admin-menu-panel form,
.admin-menu-panel form button {
    margin: 0;
}

.admin-menu-panel form button {
    border-bottom: 0;
    color: var(--error);
}

.admin-page-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 14px;
}

.admin-home-card {
    width: min(100%, 900px);
}

.admin-home-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    margin-top: 24px;
}

.admin-home-tile {
    display: flex;
    align-items: center;
    gap: 16px;
    min-height: 126px;
    padding: 20px;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: rgba(255, 252, 251, 0.74);
    color: var(--text);
    text-decoration: none;
    transition: border-color 160ms ease, background 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.admin-home-tile:hover {
    transform: translateY(-2px);
    border-color: rgba(143, 45, 53, 0.52);
    background: rgba(255, 252, 251, 0.96);
    box-shadow: 0 12px 28px rgba(78, 37, 41, 0.1);
}

.admin-home-icon {
    flex: 0 0 48px;
    width: 48px;
    height: 48px;
    display: grid;
    place-items: center;
    border-radius: 14px;
    background: var(--panel-strong);
    color: var(--accent);
}

.admin-home-icon svg {
    width: 26px;
    height: 26px;
}

.admin-home-tile > span:last-child {
    display: grid;
    gap: 6px;
}

.admin-home-tile strong {
    font-size: 1.08rem;
}

.admin-home-tile small {
    color: var(--muted);
    font-size: 0.94rem;
    line-height: 1.4;
}

.admin-events {
    display: grid;
    gap: 18px;
    margin-top: 22px;
}

.admin-task-management {
    gap: 28px;
}

.admin-task-intro {
    padding: 18px;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: rgba(255, 252, 251, 0.72);
}

.admin-task-form {
    display: grid;
    gap: 12px;
    margin-top: 14px;
}

.admin-task-form label {
    display: grid;
    gap: 6px;
}

.admin-task-form input[type="number"] {
    max-width: 160px;
}

.admin-task-form .admin-checkbox {
    display: flex;
    align-items: center;
    gap: 9px;
}

.admin-checkbox input[type="checkbox"] {
    width: auto;
    padding: 0;
    accent-color: var(--accent);
}

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

.admin-task-entry {
    border: 1px solid var(--border);
    border-radius: 14px;
    background: rgba(255, 252, 251, 0.72);
    overflow: hidden;
}

.admin-task-entry summary {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    cursor: pointer;
}

.admin-task-entry summary > span:first-child {
    display: grid;
    gap: 3px;
}

.admin-task-entry summary > span:first-child span {
    color: var(--muted);
    font-size: 0.92rem;
}

.admin-task-entry .admin-task-form {
    padding: 0 16px 16px;
}

.admin-task-delete-form {
    padding: 0 16px 16px;
}

.danger-button {
    background: var(--error);
}

.danger-button:hover {
    background: #7c1d28;
}

.admin-task-id {
    margin: 0;
    color: var(--muted);
    overflow-wrap: anywhere;
}

.admin-task-status {
    flex: 0 0 auto;
    border-radius: 999px;
    padding: 5px 10px;
    font-size: 0.86rem;
    font-weight: 700;
}

.admin-task-status.is-active {
    background: rgba(66, 112, 82, 0.16);
    color: #356345;
}

.admin-task-status.is-archived {
    background: rgba(122, 61, 69, 0.12);
    color: var(--error);
}

.admin-event-card {
    border: 1px solid var(--border);
    border-radius: 18px;
    background: rgba(255, 252, 251, 0.72);
    padding: 18px;
}

.admin-event-meta {
    display: grid;
    gap: 4px;
    margin-bottom: 12px;
}

.admin-event-details {
    margin: 0 0 14px;
    color: var(--muted);
    line-height: 1.5;
}

.admin-chat-preview {
    display: grid;
    gap: 10px;
    margin-bottom: 16px;
}

.admin-chat-messages {
    display: grid;
    gap: 10px;
}

.admin-chat-message {
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.58);
}

.admin-chat-message span {
    color: var(--muted);
    font-size: 0.86rem;
    font-weight: 700;
}

.admin-chat-message p {
    margin: 5px 0 0;
    line-height: 1.5;
    overflow-wrap: anywhere;
    white-space: pre-wrap;
}

.admin-feedback-form {
    display: grid;
    gap: 10px;
}

.admin-feedback-form textarea {
    width: 100%;
    padding: 14px 16px;
    border-radius: 14px;
    border: 1px solid var(--border);
    background: white;
    font: inherit;
    resize: vertical;
}

.admin-feedback-state {
    border: 1px solid rgba(122, 61, 69, 0.24);
    border-radius: 14px;
    background: rgba(122, 61, 69, 0.08);
    padding: 12px 14px;
}

.admin-feedback-state p {
    margin: 8px 0;
}

.admin-rating-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 14px;
}

.admin-rating-card {
    display: grid;
    gap: 12px;
}

.rating-stat-row,
.rating-distribution {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 14px;
}

.rating-stat-row {
    color: var(--text);
}

.rating-distribution span {
    min-width: 48px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: rgba(255, 252, 251, 0.7);
    padding: 6px 10px;
    text-align: center;
}

.admin-section-title {
    margin: 8px 0 12px;
    font-size: 1.2rem;
}

.admin-section-heading {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.admin-download-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.admin-table-wrap {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: rgba(255, 252, 251, 0.72);
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 620px;
}

.admin-table th,
.admin-table td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    vertical-align: top;
}

.admin-table th {
    color: var(--accent);
}

.admin-table tr:last-child td {
    border-bottom: 0;
}

.admin-table thead th {
    background: rgba(255, 252, 251, 0.96);
}

.admin-table td span {
    display: block;
    margin-top: 4px;
    color: var(--muted);
    font-size: 0.92rem;
}

.admin-budget-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 14px;
}

.admin-budget-stat {
    display: grid;
    gap: 6px;
}

.admin-budget-stat span,
.admin-budget-stat small {
    color: var(--muted);
}

.admin-budget-stat strong {
    font-size: 1.45rem;
}

.admin-budget-table {
    min-width: 820px;
}

.budget-cell {
    display: grid;
    gap: 5px;
    min-width: 170px;
}

.budget-cell small {
    color: var(--muted);
}

.admin-usage-meter {
    width: 100%;
    height: 8px;
    overflow: hidden;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: rgba(255, 252, 251, 0.74);
}

.admin-usage-meter span {
    display: block;
    height: 100%;
    margin: 0;
    background: var(--accent);
}

.admin-week-list {
    display: grid;
    gap: 10px;
}

.admin-week-card {
    border: 1px solid var(--border);
    border-radius: 14px;
    background: rgba(255, 252, 251, 0.72);
    overflow: hidden;
}

.admin-week-card summary {
    display: grid;
    grid-template-columns: minmax(180px, 1.35fr) repeat(4, minmax(120px, 1fr));
    gap: 12px;
    align-items: center;
    cursor: pointer;
    padding: 14px 16px;
}

.admin-week-card summary::marker {
    color: var(--accent);
}

.admin-week-card summary span {
    display: grid;
    gap: 3px;
}

.admin-week-card summary small {
    color: var(--muted);
}

.admin-week-card[open] summary {
    border-bottom: 1px solid var(--border);
    background: rgba(245, 224, 220, 0.36);
}

.admin-week-day-table {
    border: 0;
    border-radius: 0;
    background: transparent;
}

.admin-event-filter {
    display: flex;
    align-items: end;
    gap: 10px;
    flex-wrap: wrap;
    margin: 0 0 12px;
}

.admin-event-filter label {
    display: grid;
    gap: 6px;
    color: var(--accent);
    font-weight: 700;
}

.admin-event-filter input {
    min-width: min(280px, 100%);
    min-height: 44px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: white;
    color: var(--text);
    font: inherit;
}

.admin-event-filter span {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    color: var(--muted);
}

.admin-usage-event-scroll {
    max-height: calc(50 * 52px + 52px);
    overflow: auto;
}

.admin-usage-event-scroll thead th {
    position: sticky;
    top: 0;
    z-index: 1;
}

@media (min-width: 1160px) {
    .admin-card {
        width: min(100%, 1180px);
    }
}

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

    .admin-week-card summary {
        grid-template-columns: 1fr 1fr;
    }
}

.page-header {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px 24px 0;
}

.page-header h1 {
    margin: 0;
    font-size: clamp(1.9rem, 3vw, 2.6rem);
    letter-spacing: 0.04em;
    color: var(--accent);
}

.layout {
    width: calc(100% - 24px);
    margin: 0 auto;
    min-height: calc(100vh - 88px);
    padding: 18px 18px 24px 18px;
    display: grid;
    grid-template-columns: minmax(360px, max-content) minmax(0, 1fr);
    gap: 22px;
    align-items: center;
}

.layout > * {
    min-width: 0;
}

.sidebar,
.chat-shell {
    padding: 22px;
    min-width: 0;
}

.sidebar {
    position: sticky;
    top: 18px;
    width: max-content;
    max-width: 460px;
}

.sidebar-top {
    display: flex;
    align-items: start;
    justify-content: space-between;
    gap: 16px;
}

.sidebar-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.notification-bell {
    position: relative;
    width: 48px;
    height: 48px;
    flex: 0 0 48px;
    display: inline-grid;
    place-items: center;
    padding: 0;
    border: 1px solid var(--border);
    background: white;
    color: var(--text);
}

.notification-bell.has-notifications {
    border-color: rgba(161, 36, 48, 0.46);
    box-shadow: 0 0 0 3px rgba(161, 36, 48, 0.08);
}

.notification-bell:hover:not(:disabled) {
    background: var(--panel-strong);
}

.notification-bell-icon {
    font-size: 1.35rem;
    line-height: 1;
}

.notification-count {
    position: absolute;
    top: -7px;
    right: -7px;
    min-width: 23px;
    height: 23px;
    padding: 0 5px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 2px solid white;
    border-radius: 999px;
    background: var(--error);
    color: white;
    font-family: Arial, sans-serif;
    font-size: 0.72rem;
    font-weight: 700;
    line-height: 1;
}

.notification-count[hidden] {
    display: none;
}

.account-box {
    margin: 18px 0;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: rgba(255, 250, 249, 0.6);
    display: grid;
    gap: 6px;
}

.account-box strong {
    overflow-wrap: anywhere;
}

.mode-switch {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin: 16px 0 18px;
}

.mode-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: rgba(255, 252, 251, 0.82);
    color: var(--text);
    text-decoration: none;
    text-align: center;
}

.mode-link.active {
    background: var(--panel-strong);
    border-color: var(--accent);
    color: var(--accent);
    font-weight: 700;
}

.usage-meter {
    height: 9px;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: rgba(255, 252, 251, 0.88);
}

.usage-meter span {
    display: block;
    width: 0;
    height: 100%;
    background: linear-gradient(135deg, var(--accent), #c2410c);
    transition: width 180ms ease;
}

.conversation-sidebar-header {
    display: grid;
    gap: 10px;
    margin-bottom: 12px;
}

.conversation-sidebar-header .sidebar-copy {
    margin: 0;
}

.conversation-meta {
    display: block;
    margin-top: 6px;
    color: var(--muted);
    font-size: 0.92rem;
}

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

.task-list-scroll {
    max-height: min(680px, calc(100vh - 330px));
    overflow-y: auto;
    padding-right: 8px;
    scrollbar-gutter: stable;
}

.task-item {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: rgba(255, 253, 252, 0.78);
    padding: 14px;
    transition: transform 140ms ease, border-color 140ms ease, background 140ms ease;
}

.task-item:hover {
    transform: translateX(2px);
    border-color: rgba(143, 45, 53, 0.48);
}

.task-item.active {
    background: var(--panel-strong);
    border-color: var(--accent);
}

.task-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.task-title-button,
.task-question-button {
    text-align: left;
    background: transparent;
    border: 0;
    border-radius: 8px;
    color: var(--text);
    padding: 0;
}

.task-title-button {
    min-width: 0;
    font-weight: 700;
}

.task-question-button {
    display: block;
    width: 100%;
    margin-top: 6px;
    color: var(--text);
    line-height: 1.45;
}

.task-rating {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 6px;
}

.rating-point {
    width: 17px;
    height: 17px;
    padding: 0;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: rgba(255, 253, 252, 0.86);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    transition: background 140ms ease, border-color 140ms ease, color 140ms ease, transform 140ms ease;
}

.rating-point:hover {
    transform: translateY(-1px);
    border-color: rgba(143, 45, 53, 0.48);
}

.rating-point.is-selected {
    background: var(--accent-soft);
    border-color: var(--accent);
}

.rating-point.is-current {
    background: var(--accent);
}

.task-banner {
    margin-bottom: 16px;
    padding: 16px;
    border-radius: 16px;
    border: 1px solid var(--border);
    background: linear-gradient(135deg, rgba(251, 240, 237, 0.92), rgba(235, 204, 204, 0.9));
}

.task-banner strong {
    display: block;
    margin-bottom: 6px;
}

.task-banner-content {
    display: flex;
    align-items: center;
    gap: 16px;
}

.task-description {
    flex: 1 1 0;
    min-width: 0;
    line-height: 1.5;
}

.task-image {
    display: block;
    flex: 0 1 auto;
    width: auto;
    max-width: 45%;
    margin: 0;
    border: 1px solid var(--border);
    border-radius: 12px;
    object-fit: contain;
    background: rgba(255, 252, 251, 0.7);
}

.editable-conversation-title {
    display: block;
    width: 100%;
    margin: 0 0 6px;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: var(--text);
    font-weight: 700;
    text-align: left;
    overflow-wrap: anywhere;
}

.editable-conversation-title:hover {
    color: var(--accent);
}

.conversation-title-input {
    width: 100%;
    min-width: 0;
    margin: 0 0 6px;
    padding: 8px 10px;
    border-radius: 10px;
    font-weight: 700;
}

.task-item .conversation-title-input {
    margin: 6px 0 0;
}

.conversation-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}

.conversation-list {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.conversation-tab {
    background: rgba(255, 252, 251, 0.88);
    color: var(--text);
    border: 1px solid var(--border);
    padding: 10px 14px;
}

.conversation-tab.active {
    background: var(--panel-strong);
    border-color: var(--accent);
    color: var(--accent);
}

.chat-window {
    width: 100%;
    min-width: 0;
    min-height: 420px;
    max-height: 60vh;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: rgba(255, 252, 251, 0.68);
    padding: 16px;
    margin-bottom: 16px;
}

.chat-shell-toolbar {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.chat-shell-toolbar .task-banner {
    flex: 1;
}

.fullscreen-button {
    flex: 0 0 auto;
    white-space: nowrap;
}

.message {
    margin-bottom: 12px;
    max-width: 100%;
    border: 1px solid transparent;
    border-radius: 16px;
    padding: 11px 14px;
    line-height: 1.55;
}

.message h2,
.message h3,
.message h4 {
    margin: 12px 0 6px;
    line-height: 1.25;
}

.message p {
    margin: 0 0 10px;
}

.message code {
    border: 1px solid rgba(143, 45, 53, 0.18);
    border-radius: 6px;
    background: rgba(255, 252, 251, 0.86);
    padding: 1px 5px;
    font-family: Consolas, "Courier New", monospace;
    font-size: 0.92em;
}

.message mjx-container {
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
}

.message mjx-container[display="true"] {
    margin: 10px 0;
    padding-bottom: 2px;
}

.markdown-code-block {
    margin: 10px 0;
    overflow-x: auto;
    border: 1px solid rgba(143, 45, 53, 0.2);
    border-radius: 10px;
    background: #2f2527;
    color: #fff7f2;
    padding: 12px;
}

.markdown-code-block span {
    display: block;
    margin-bottom: 8px;
    color: #e7c6c5;
    font-size: 0.82rem;
    text-transform: uppercase;
}

.markdown-code-block code {
    display: block;
    border: 0;
    border-radius: 0;
    background: transparent;
    padding: 0;
    white-space: pre;
    color: inherit;
}

.user {
    color: var(--user);
    background: rgba(231, 198, 197, 0.52);
    border-color: rgba(143, 45, 53, 0.28);
}

.bot {
    color: var(--bot);
    background: rgba(255, 253, 252, 0.78);
    border-color: rgba(124, 90, 92, 0.2);
}

.pending-message {
    display: flex;
    align-items: baseline;
    gap: 6px;
}

.pending-status {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--muted);
}

.typing-dots {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.typing-dots span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    animation: typing-dot 1.2s infinite ease-in-out;
}

.typing-dots span:nth-child(2) {
    animation-delay: 0.15s;
}

.typing-dots span:nth-child(3) {
    animation-delay: 0.3s;
}

.pending-timer {
    min-width: 36px;
    font-variant-numeric: tabular-nums;
    color: var(--accent);
}

@keyframes typing-dot {
    0%,
    80%,
    100% {
        opacity: 0.32;
        transform: translateY(0);
    }

    40% {
        opacity: 1;
        transform: translateY(-3px);
    }
}

.event-message {
    color: var(--error);
    background: rgba(161, 36, 48, 0.08);
    border: 1px solid rgba(161, 36, 48, 0.22);
    border-radius: 14px;
    padding: 10px 12px;
}

.aha-event-message {
    color: #356345;
    background: rgba(66, 112, 82, 0.1);
    border-color: rgba(53, 99, 69, 0.24);
}

.disclaimer-message {
    color: var(--muted);
    background: rgba(143, 45, 53, 0.08);
    border: 1px solid rgba(143, 45, 53, 0.2);
    border-radius: 14px;
    padding: 10px 12px;
}

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

.composer {
    display: flex;
    align-items: stretch;
    gap: 12px;
    min-width: 0;
    width: 100%;
}

.composer > * {
    min-width: 0;
}

.upload-control {
    display: grid;
    grid-template-columns: auto minmax(150px, 220px);
    align-items: stretch;
    gap: 8px;
}

.upload-control input[type="file"] {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    clip-path: inset(50%);
}

.upload-control label {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 52px;
    padding: 14px 18px;
    cursor: pointer;
}

.upload-control input[type="file"]:disabled + label {
    opacity: 0.65;
    cursor: not-allowed;
}

.upload-control span {
    display: flex;
    align-items: center;
    min-height: 52px;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: rgba(255, 253, 252, 0.72);
    color: var(--muted);
    font-size: 0.92rem;
    line-height: 1.25;
    overflow-wrap: anywhere;
}

.upload-control .upload-dropzone {
    border-style: dashed;
    cursor: copy;
    transition: border-color 0.16s ease, background 0.16s ease;
}

.upload-control .upload-dropzone.is-dragging {
    border-color: var(--accent);
    background: rgba(231, 198, 197, 0.54);
    color: var(--accent);
}

.upload-control input[type="file"]:disabled ~ .upload-dropzone {
    opacity: 0.65;
    cursor: not-allowed;
}

.chat-actions {
    margin-top: 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.mistrust-row {
    display: flex;
    justify-content: flex-start;
    gap: 10px;
    flex-wrap: nowrap;
}

.print-button {
    margin-left: auto;
    padding: 10px 14px;
}

.aha-button {
    background: rgba(66, 112, 82, 0.13);
    color: #356345;
    border: 2px solid rgba(53, 99, 69, 0.82);
    border-radius: 14px;
    padding: 10px 14px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.aha-button:has(.aha-rating-point:not(:disabled)):hover {
    background: rgba(66, 112, 82, 0.22);
}

.aha-label {
    font-weight: 700;
}

.aha-rating {
    display: flex;
    align-items: center;
    gap: 5px;
}

.aha-rating-point {
    width: 17px;
    height: 17px;
    padding: 0;
    border-radius: 999px;
    border: 1px solid rgba(53, 99, 69, 0.82);
    background: rgba(255, 253, 252, 0.86);
    transition: background 140ms ease, border-color 140ms ease, transform 140ms ease;
}

.aha-rating-point:hover:not(:disabled) {
    transform: translateY(-1px);
    border-color: #356345;
}

.aha-rating-point.is-selected {
    background: rgba(66, 112, 82, 0.38);
}

.aha-rating-point.is-current {
    background: #356345;
}

.mistrust-button {
    background: rgba(161, 36, 48, 0.12);
    color: var(--error);
    border: 2px solid var(--error);
    padding: 10px 14px;
}

.mistrust-button:hover:not(:disabled) {
    background: rgba(161, 36, 48, 0.2);
}

.challenge-button {
    background: rgba(174, 126, 24, 0.14);
    color: #79570f;
    border: 2px solid #a87818;
    padding: 10px 14px;
}

.challenge-button:hover:not(:disabled) {
    background: rgba(174, 126, 24, 0.24);
}

.admin-feedback-message.notification-target {
    outline: 3px solid rgba(161, 36, 48, 0.28);
    outline-offset: 3px;
    animation: notification-target-pulse 1.4s ease-out;
}

@keyframes notification-target-pulse {
    0% {
        transform: scale(0.985);
        box-shadow: 0 0 0 0 rgba(161, 36, 48, 0.28);
    }
    100% {
        transform: scale(1);
        box-shadow: 0 0 0 12px rgba(161, 36, 48, 0);
    }
}

@media (prefers-reduced-motion: reduce) {
    .admin-feedback-message.notification-target {
        animation: none;
    }
}

.composer input,
.composer textarea {
    flex: 1;
    background: rgba(255, 253, 252, 0.84);
}

.chat-shell {
    width: 100%;
    max-width: none;
    align-self: center;
}

@media (min-width: 901px) {
    .task-layout {
        grid-template-columns: minmax(360px, max-content) minmax(0, 1fr);
        justify-content: stretch;
    }

    .task-layout .chat-shell {
        width: 100%;
        max-width: none;
    }
}

#free-chat-shell:fullscreen {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: none;
    height: 100%;
    padding: 24px;
    border: 0;
    border-radius: 0;
    background: var(--bg);
}

#free-chat-shell:fullscreen .chat-window {
    flex: 1;
    min-height: 0;
    max-height: none;
}

@media (max-width: 900px) {
    .layout {
        grid-template-columns: minmax(0, 1fr);
        width: 100%;
        padding: 16px;
    }

    .sidebar {
        position: static;
        margin-left: 0;
        width: 100%;
        max-width: 100%;
    }

    .chat-shell {
        width: 100%;
    }

    .chat-shell-toolbar {
        align-items: stretch;
        flex-direction: column;
    }

    .fullscreen-button {
        width: 100%;
    }
}

@media (max-width: 640px) {
    .layout,
    .auth-page {
        padding: 16px;
    }

    .page-header {
        padding: 16px 16px 0;
    }

    .composer,
    .sidebar-top {
        flex-direction: column;
    }

    .sidebar-actions {
        width: 100%;
        justify-content: flex-end;
    }

    .conversation-bar {
        align-items: stretch;
        flex-direction: column;
    }

    .task-rating {
        flex-wrap: wrap;
    }

    .mistrust-row {
        justify-content: stretch;
        flex-direction: column;
    }

    .chat-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .aha-button,
    .challenge-button,
    .mistrust-button,
    .conversation-tab,
    #print-button,
    #new-conversation-button,
    #new-free-conversation-button {
        width: 100%;
    }

    .upload-control {
        grid-template-columns: 1fr;
    }
}
