/* RN4 application components. Shared design values live in ui-tokens.css. */


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

body {
    min-height: 100vh;
    font-family: var(--font-ui);
    background: var(--page);
    line-height: 1.6;
    color: var(--dark);
}

.container {
    margin: 0 auto;
    max-width: 1440px;
    padding: 32px;
}

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--surface);
    color: var(--dark);
    padding: 24px 28px;
    border: 1px solid var(--light-gray);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-card);
    gap: 24px;
    flex-wrap: wrap;
    margin-bottom: 24px;
}

.header-left {
    display: flex;
    flex-direction: column;
}

.header h1 {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 0;
    font-size: clamp(1.2rem, 2vw, 1.6rem);
    font-weight: 650;
    letter-spacing: -.035em;
    line-height: 1.3;
}

.header-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    background: var(--secondary);
    color: var(--primary);
    width: 42px;
    height: 42px;
    border-radius: 12px;
    flex-shrink: 0;
}

.header-subtitle {
    opacity: 1;
    color: var(--gray);
    font-size: .85rem;
    margin-top: 8px;
}

.new-case-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color .18s ease, border-color .18s ease, box-shadow .18s ease;
    border: 1px solid var(--light-gray);
    border-radius: var(--radius-control);
    font-size: .85rem;
    padding: 10px 14px;
    min-height: 44px;
    background: var(--primary);
    border-color: var(--primary);
    color: var(--on-primary);
}

.new-case-btn:hover {
    transform: none;
    border-color: var(--brand-border);
    box-shadow: none;
    background: var(--primary-dark);
    color: var(--on-primary);
}

.dev-mode-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color .18s ease, border-color .18s ease, box-shadow .18s ease;
    background: var(--surface);
    color: var(--dark);
    border: 1px solid var(--light-gray);
    border-radius: var(--radius-control);
    font-size: .85rem;
    padding: 10px 14px;
    min-height: 44px;
}

.dev-mode-btn:hover {
    background: var(--secondary);
    border-color: var(--brand-border);
    box-shadow: none;
}

.dev-mode-btn.active {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.6);
}

/* Dev Mode Panel */
.dev-panel {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--page);
    z-index: 1000;
}

.dev-panel.active {
    display: flex;
    flex-direction: column;
}

.dev-panel-content {
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100%;
}

.dev-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 28px;
    color: var(--dark);
    flex-shrink: 0;
    background: var(--surface-soft);
    box-shadow: none;
}

.dev-panel-header h2 {
    margin: 0;
    font-size: 1.3rem;
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
}

.dev-panel-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: var(--on-primary);
    width: 40px;
    height: 40px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color .18s ease, border-color .18s ease, box-shadow .18s ease;
}

.dev-panel-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.05);
}

.dev-panel-body {
    display: grid;
    grid-template-columns: 240px 1fr 5px 1fr;
    flex: 1;
    overflow: hidden;
    background: var(--page);
}

/* Custom scrollbar styling for dev panel */
.dev-main::-webkit-scrollbar,
.dev-sidebar::-webkit-scrollbar,
.ai-chat-messages::-webkit-scrollbar {
    width: 8px;
}

.dev-main::-webkit-scrollbar-track,
.dev-sidebar::-webkit-scrollbar-track,
.ai-chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.dev-main::-webkit-scrollbar-thumb,
.dev-sidebar::-webkit-scrollbar-thumb,
.ai-chat-messages::-webkit-scrollbar-thumb {
    background: var(--light-gray);
    border-radius: 4px;
}

.dev-main::-webkit-scrollbar-thumb:hover,
.dev-sidebar::-webkit-scrollbar-thumb:hover,
.ai-chat-messages::-webkit-scrollbar-thumb:hover {
    background: var(--gray);
}

.dev-sidebar {
    background: var(--surface);
    border-right: 1px solid var(--light-gray);
    padding: 24px 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    overflow-y: auto;
}

.dev-sidebar-header {
    padding: 0 8px 16px 8px;
    margin-bottom: 8px;
    border-bottom: 1px solid var(--light-gray);
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--gray);
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.dev-main {
    padding: 24px 28px;
    overflow-y: auto;
    min-width: 0;
}

/* Right section: AI chat + form side by side */
.dev-right-section {
    display: flex;
    flex-direction: row;
    border-left: 1px solid var(--light-gray);
    background: var(--page);
    overflow: hidden;
}

/* Resizable divider between main and right section */
.dev-resizer {
    width: 5px;
    cursor: col-resize;
    background: transparent;
    flex-shrink: 0;
    transition: background 0.2s;
    position: relative;
}

.dev-resizer:hover,
.dev-resizer.dragging {
    background: var(--primary);
}

.dev-resizer::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 3px;
    height: 40px;
    background: var(--light-gray);
    border-radius: 2px;
}

.dev-resizer:hover::after,
.dev-resizer.dragging::after {
    background: var(--primary);
}

/* AI chat panel inside right section */
.ai-assistant-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--surface);
    min-width: 280px;
}

/* Vertical resizer between AI and form panels */
.dev-inner-resizer {
    width: 5px;
    cursor: col-resize;
    background: transparent;
    flex-shrink: 0;
    transition: background 0.2s;
    position: relative;
}

.dev-inner-resizer:hover,
.dev-inner-resizer.dragging {
    background: var(--primary);
}

.dev-inner-resizer::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 3px;
    height: 40px;
    background: var(--light-gray);
    border-radius: 2px;
}

.dev-inner-resizer:hover::after,
.dev-inner-resizer.dragging::after {
    background: var(--primary);
}

/* Inline case/drug form panel - hidden when not active */
.case-form-panel {
    display: none;
    flex-shrink: 0;
    width: 0;
    overflow: hidden;
    transition: width 0.3s ease;
    background: var(--surface);
    flex-direction: column;
}

.case-form-panel.active {
    display: flex;
    width: 400px;
    overflow-y: auto;
}

.case-form-panel .dev-form-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 20px;
    background: var(--primary);
    color: var(--dark);
    flex-shrink: 0;
}

.case-form-panel .dev-form-header h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
}

.case-form-panel .dev-form-body {
    padding: 16px 20px;
    flex: 1;
    overflow-y: auto;
}

.case-form-panel .dev-form-group {
    margin-bottom: 12px;
}

.case-form-panel .dev-form-group:last-of-type {
    margin-bottom: 0;
}

.case-form-panel .dev-form-group label {
    font-size: 0.82rem;
    color: var(--gray);
    font-weight: 600;
    display: block;
    margin-bottom: 4px;
}

.case-form-panel .dev-form-group input,
.case-form-panel .dev-form-group textarea,
.case-form-panel .dev-form-group select {
    padding: 8px 12px;
    border: 1.5px solid var(--light-gray);
    border-radius: 8px;
    font-size: 0.9rem;
    width: 100%;
    transition: border-color 0.2s;
}

.case-form-panel .dev-form-group input:focus,
.case-form-panel .dev-form-group textarea:focus,
.case-form-panel .dev-form-group select:focus {
    outline: none;
    border-color: var(--primary);
}

.case-form-panel .dev-form-actions {
    display: flex;
    gap: 10px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--surface-soft);
}

.case-form-panel .dev-form-actions .cancel {
    flex: 1;
    padding: 10px;
    background: var(--surface-soft);
    color: var(--gray);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
}

.case-form-panel .dev-form-actions .save {
    flex: 1;
    padding: 10px;
    background: var(--primary);
    color: var(--on-primary);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
}

.dev-sidebar-item {
    padding: 12px 16px;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 500;
    color: var(--gray);
    transition: background-color .18s ease, border-color .18s ease, box-shadow .18s ease;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.95rem;
    position: relative;
}

.dev-sidebar-item:hover {
    background: var(--surface-soft);
    color: var(--dark);
}

.dev-sidebar-item.active {
    background: var(--primary);
    color: var(--on-primary);
    box-shadow: 0 4px 12px rgba(35, 74, 66, 0.08);
}

.dev-sidebar-item.active::before {
    content: '';
    position: absolute;
    left: -16px;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 60%;
    background: var(--primary);
    border-radius: 0 2px 2px 0;
}

.dev-sidebar-item .icon-emoji {
    font-size: 1.2rem;
}

.dev-section {
    display: none;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

.dev-section.active {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

.dev-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 14px;
    border-bottom: 2px solid var(--light-gray);
    flex-shrink: 0;
}

.dev-section-header h3 {
    margin: 0;
    font-size: 1.35rem;
    color: var(--dark);
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}

.dev-add-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 11px 20px;
    border: none;
    cursor: pointer;
    transition: background-color .18s ease, border-color .18s ease, box-shadow .18s ease;
    background: var(--primary);
    color: var(--on-primary);
    border-radius: var(--radius-control);
    box-shadow: none;
    font-weight: 600;
    font-size: .9rem;
    min-height: 44px;
}

.dev-add-btn:hover {
    transform: none;
    background: var(--primary-dark);
    box-shadow: none;
}

.dev-add-btn .plus-icon {
    font-size: 1.2rem;
    font-weight: 400;
    line-height: 1;
}

.dev-add-btn.sct-add-btn {
    background: var(--primary);
    box-shadow: 0 2px 8px rgba(35, 74, 66, 0.08);
}

.dev-add-btn.sct-add-btn:hover {
    box-shadow: 0 4px 14px rgba(35, 74, 66, 0.08);
}

.dev-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 18px;
}

.dev-empty-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 60px 20px;
    color: var(--gray);
    background: var(--surface);
    border: 2px dashed var(--light-gray);
    border-radius: 16px;
}

.dev-empty-state .empty-icon {
    font-size: 3rem;
    margin-bottom: 12px;
    opacity: 0.5;
}

.dev-empty-state .empty-title {
    font-size: 1.1rem;
    color: var(--gray);
    margin-bottom: 6px;
    font-weight: 500;
}

.dev-empty-state .empty-desc {
    font-size: 0.9rem;
    color: var(--gray);
}

/* Reference Database Styles */
.ref-instructions-block {
    background: var(--surface);
    border: 2px solid var(--light-gray);
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 20px;
}
.ref-block-header {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    color: var(--dark);
    margin-bottom: 12px;
    font-size: 1rem;
}
.ref-edit-btn {
    margin-left: auto;
    background: var(--surface-soft);
    border: 1px solid var(--light-gray);
    border-radius: 8px;
    padding: 4px 12px;
    font-size: 0.85rem;
    cursor: pointer;
    color: var(--gray);
}
.ref-edit-btn:hover {
    background: var(--light-gray);
}
.ref-instructions-text {
    color: var(--gray);
    font-size: 0.9rem;
    line-height: 1.6;
}
.ref-scale-block {
    background: var(--surface);
    border: 2px solid var(--light-gray);
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 20px;
}
.ref-scale-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
}
.ref-scale-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: var(--page);
    border-radius: 10px;
    font-size: 0.9rem;
}
.ref-scale-label {
    font-weight: 700;
    font-size: 1rem;
    min-width: 30px;
    text-align: center;
}
.ref-scale-label.positive { color: var(--success); }
.ref-scale-label.neutral { color: var(--gray); }
.ref-scale-label.negative { color: var(--danger); }
.ref-questions-header {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    color: var(--dark);
    margin-bottom: 16px;
    font-size: 1rem;
}
.ref-question-card {
    background: var(--surface);
    border: 2px solid var(--light-gray);
    border-radius: 16px;
    padding: 20px;
    transition: background-color .18s ease, border-color .18s ease, box-shadow .18s ease;
}
.ref-question-card:hover {
    border-color: var(--success);
    box-shadow: 0 4px 16px rgba(5, 150, 105, 0.12);
    transform: none;
}
.ref-question-card .q-number {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--success);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}
.ref-question-card .q-considering {
    font-weight: 600;
    color: var(--dark);
    margin-bottom: 6px;
    font-size: 0.95rem;
}
.ref-question-card .q-new-info {
    font-size: 0.85rem;
    color: var(--gray);
    margin-bottom: 12px;
    line-height: 1.5;
}
.ref-question-card .q-score {
    display: inline-block;
    font-weight: 700;
    font-size: 1rem;
    padding: 3px 10px;
    border-radius: 8px;
    margin-bottom: 12px;
}
.ref-question-card .q-score.positive { background: var(--secondary); color: var(--success); }
.ref-question-card .q-score.neutral { background: var(--surface-soft); color: var(--gray); }
.ref-question-card .q-score.negative { background: var(--danger-soft); color: var(--danger); }
.ref-question-card .q-rationale {
    font-size: 0.85rem;
    color: var(--gray);
    line-height: 1.5;
    margin-bottom: 12px;
}
.ref-question-card .q-actions {
    display: flex;
    gap: 8px;
}
.ref-question-card .q-actions button {
    padding: 5px 12px;
    border-radius: 8px;
    font-size: 0.8rem;
    cursor: pointer;
    border: none;
    font-weight: 500;
    transition: background-color .18s ease, border-color .18s ease, box-shadow .18s ease;
}
.ref-question-card .q-actions .edit-btn {
    background: var(--secondary);
    color: var(--primary);
}
.ref-question-card .q-actions .edit-btn:hover { background: var(--secondary); }
.ref-question-card .q-actions .delete-btn {
    background: var(--danger-soft);
    color: var(--danger);
}
.ref-question-card .q-actions .delete-btn:hover { background: var(--danger-soft); }
.ref-score-note {
    font-size: 0.8rem;
    color: var(--gray);
    margin-top: 12px;
    font-style: italic;
}

.dev-card {
    background: var(--surface);
    border: 1px solid var(--light-gray);
    border-radius: 14px;
    padding: 18px;
    transition: background-color .18s ease, border-color .18s ease, box-shadow .18s ease;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.dev-card:hover {
    transform: none;
    border-color: var(--brand-border);
    box-shadow: var(--shadow-card);
}

.dev-card-title {
    font-weight: 600;
    color: var(--dark);
    font-size: 1.05rem;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.dev-card-meta {
    font-size: 0.85rem;
    color: var(--gray);
    padding: 6px 10px;
    background: var(--page);
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    width: fit-content;
}

.dev-card-desc {
    font-size: 0.9rem;
    color: var(--gray);
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    flex: 1;
}

.dev-card-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.dev-card-tag {
    font-size: 0.75rem;
    padding: 3px 8px;
    background: var(--secondary);
    color: var(--primary-dark);
    border-radius: 6px;
    font-weight: 500;
}

.dev-card-actions {
    display: flex;
    gap: 8px;
    margin-top: 4px;
    padding-top: 12px;
    border-top: 1px solid var(--surface-soft);
}

.dev-card-btn {
    flex: 1;
    padding: 9px 12px;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: background-color .18s ease, border-color .18s ease, box-shadow .18s ease;
    border: none;
}

.dev-card-btn.edit {
    background: var(--surface-soft);
    color: var(--gray);
}

.dev-card-btn.edit:hover {
    background: var(--light-gray);
    color: var(--dark);
}

.dev-card-btn.ai {
    background: var(--secondary);
    color: var(--success);
}

.dev-card-btn.ai:hover {
    background: var(--secondary);
}

.dev-card-btn.delete {
    background: var(--danger-soft);
    color: var(--danger);
}

.dev-card-btn.delete:hover {
    background: var(--danger-soft);
}

/* Form Modal */
.dev-form-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.65);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 1100;
    justify-content: center;
    align-items: center;
    padding: 20px;
    animation: modalFadeIn 0.2s ease;
}

.dev-form-modal.active {
    display: flex;
}

@keyframes modalFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes modalSlideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.dev-form-content {
    background: var(--surface);
    border-radius: 16px;
    width: 90%;
    max-width: 680px;
    max-height: 88vh;
    overflow-y: auto;
    animation: modalSlideUp 0.3s ease;
    box-shadow: var(--shadow-float);
}

.dev-form-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 24px;
    color: var(--dark);
    position: sticky;
    top: 0;
    z-index: 1;
    background: var(--surface-soft);
    box-shadow: none;
}

.dev-form-header h3 {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.dev-form-body {
    padding: 24px;
}

.dev-form-group {
    margin-bottom: 18px;
}

.dev-form-group label {
    display: block;
    font-weight: 600;
    color: var(--dark);
    margin-bottom: 6px;
    font-size: 0.9rem;
}

.dev-form-group input,
.dev-form-group textarea,
.dev-form-group select {
    width: 100%;
    padding: 11px 14px;
    border: 1.5px solid var(--light-gray);
    border-radius: 10px;
    font-size: 0.95rem;
    font-family: inherit;
    transition: background-color .18s ease, border-color .18s ease, box-shadow .18s ease;
    background: var(--page);
}

.dev-form-group input:focus,
.dev-form-group textarea:focus,
.dev-form-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(35, 74, 66, 0.08);
    background: var(--surface);
}

.dev-form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--surface-soft);
}

.dev-form-actions button {
    padding: 10px 22px;
    border-radius: 10px;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background-color .18s ease, border-color .18s ease, box-shadow .18s ease;
    border: none;
}

.dev-form-actions button.cancel {
    background: var(--surface-soft);
    color: var(--gray);
}

.dev-form-actions button.cancel:hover {
    background: var(--light-gray);
}

.dev-form-actions button.save {
    background: var(--primary);
    color: var(--on-primary);
    box-shadow: 0 2px 8px rgba(35, 74, 66, 0.08);
}

.dev-form-actions button.save:hover {
    transform: none;
    box-shadow: 0 4px 14px rgba(35, 74, 66, 0.08);
}

/* ─── Auth Styles ────────────────────────────────────────────────────────── */
#auth-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: background-color .18s ease, border-color .18s ease, box-shadow .18s ease;
    background: var(--page);
    padding: 24px;
    overflow-y: auto;
}

#auth-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.auth-card {
    background: var(--surface);
    width: 100%;
    text-align: center;
    max-width: 440px;
    padding: 36px;
    border: 1px solid var(--light-gray);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-float);
    margin: auto;
}

.auth-logo {
    font-size: 3rem;
    margin-bottom: 20px;
    display: grid;
    place-items: center;
    width: 56px;
    height: 56px;
    background: var(--secondary);
    color: var(--primary);
    border-radius: 16px;
    margin: 0 auto 24px;
}

.auth-card h2 {
    margin-bottom: 8px;
    color: var(--dark);
    font-size: 1.65rem;
    font-weight: 650;
    letter-spacing: -.035em;
}

.auth-subtitle {
    color: var(--gray);
    margin-bottom: 30px;
    font-size: .85rem;
}

.auth-tabs {
    display: flex;
    border-radius: 12px;
    margin-bottom: 25px;
    background: var(--surface-soft);
    border: 1px solid var(--light-gray);
    padding: 4px;
}

.auth-tab {
    flex: 1;
    padding: 10px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: background-color .18s ease, border-color .18s ease, box-shadow .18s ease;
    color: var(--gray);
    border: 0;
    font: inherit;
    font-size: .9rem;
    background: transparent;
    min-height: 44px;
}

.auth-tab.active {
    background: var(--surface);
    color: var(--primary);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.auth-form {
    display: none;
}

.auth-form.active {
    display: block;
}

.auth-form-group {
    text-align: left;
    margin-bottom: 18px;
}

.auth-form-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--dark);
}

.auth-form-group input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--light-gray);
    border-radius: 10px;
    font-size: 1rem;
    transition: background-color .18s ease, border-color .18s ease, box-shadow .18s ease;
    border-width: 1px;
    background: var(--surface);
    font: inherit;
    min-height: 48px;
}

.auth-form-group input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(35, 74, 66, 0.08);
}

.auth-btn {
    width: 100%;
    padding: 14px;
    border: none;
    cursor: pointer;
    transition: background-color .18s ease, border-color .18s ease, box-shadow .18s ease;
    margin-top: 10px;
    background: var(--primary);
    color: var(--on-primary);
    border-radius: var(--radius-control);
    box-shadow: none;
    font-weight: 600;
    font-size: .9rem;
    min-height: 44px;
}

.auth-btn:hover {
    transform: none;
    background: var(--primary-dark);
    box-shadow: none;
}

#auth-error {
    color: var(--danger);
    font-size: 0.9rem;
    margin-top: 15px;
    min-height: 1.4em;
}

#main-app {
    display: none;
}

#main-app.visible {
    display: block;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.9rem;
    color: var(--gray);
    background: var(--surface-soft);
    padding: 6px 12px;
    border-radius: var(--radius-control);
}

.logout-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    transition: opacity 0.2s;
    color: var(--gray);
    min-height: 36px;
    min-width: 36px;
    justify-content: center;
    opacity: 1;
}

.logout-btn:hover {
    opacity: 1;
}

.dev-form-group textarea {
    min-height: 100px;
    resize: vertical;
}

.dev-form-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--light-gray);
}

.dev-form-actions button {
    flex: 1;
    padding: 14px 20px;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color .18s ease, border-color .18s ease, box-shadow .18s ease;
    border: none;
}

.dev-form-actions .cancel {
    background: var(--surface-soft);
    color: var(--gray);
}

.dev-form-actions .cancel:hover {
    background: var(--light-gray);
}

.dev-form-actions .save {
    background: var(--primary);
    color: var(--on-primary);
}

.dev-form-actions .save:hover {
    background: var(--primary-dark);
}

/* Blood Test Entry Styles in Dev Form */
.blood-test-entry {
    background: var(--page);
    border: 1px solid var(--light-gray);
    border-radius: 8px;
    padding: 10px;
    margin-bottom: 8px;
}

.blood-test-entry-grid input {
    font-size: 0.85rem;
    padding: 8px 10px;
}

/* AI Assistant Panel - scoped for dev-right-section */
#devRightSection .ai-assistant-panel,
.ai-assistant-panel {
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border: none;
    border-radius: 0;
    height: 100%;
    overflow: hidden;
}

.ai-assistant-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 18px;
    color: var(--dark);
    flex-shrink: 0;
    background: var(--surface-soft);
    box-shadow: none;
}

.ai-assistant-header h3 {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.ai-assistant-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 14px;
    overflow: hidden;
    background: var(--page);
}

.ai-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    background: var(--surface);
    border: 1px solid var(--light-gray);
    border-radius: 12px;
    margin-bottom: 12px;
}

.ai-message {
    margin-bottom: 10px;
    padding: 10px 14px;
    border-radius: 12px;
    line-height: 1.5;
    font-size: 0.92rem;
    word-wrap: break-word;
}

.ai-message:last-child {
    margin-bottom: 0;
}

.ai-message.user {
    background: var(--primary);
    color: var(--on-primary);
    margin-left: 20px;
    border-bottom-right-radius: 4px;
}

.ai-message.assistant {
    background: var(--secondary);
    border: 1px solid var(--secondary);
    color: var(--dark);
    margin-right: 20px;
    border-bottom-left-radius: 4px;
}

.ai-message.typing {
    display: flex;
    align-items: center;
    gap: 4px;
    background: var(--secondary);
    border: 1px solid var(--secondary);
    margin-right: 20px;
}

.ai-message.typing::after {
    content: '';
    display: inline-block;
    width: 8px;
    height: 8px;
    background: var(--primary);
    border-radius: 50%;
    animation: typing-bounce 1s infinite;
}

@keyframes typing-bounce {
    0%, 100% { transform: translateY(0); opacity: 0.4; }
    50% { transform: translateY(-4px); opacity: 1; }
}

.ai-input-area {
    display: flex;
    gap: 8px;
    align-items: flex-start;
    flex-shrink: 0;
}

.ai-input-area textarea {
    flex: 1;
    padding: 11px 14px;
    border: 1.5px solid var(--light-gray);
    border-radius: 10px;
    font-size: 0.92rem;
    font-family: inherit;
    resize: none;
    min-height: 44px;
    max-height: 120px;
    transition: background-color .18s ease, border-color .18s ease, box-shadow .18s ease;
    background: var(--surface);
}

.ai-input-area textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(35, 74, 66, 0.08);
}

.ai-send-btn {
    padding: 11px 18px;
    border: none;
    cursor: pointer;
    transition: background-color .18s ease, border-color .18s ease, box-shadow .18s ease;
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
    background: var(--primary);
    color: var(--on-primary);
    border-radius: var(--radius-control);
    box-shadow: none;
    font-weight: 600;
    font-size: .9rem;
    min-height: 44px;
}

.ai-send-btn:hover {
    transform: none;
    background: var(--primary-dark);
    box-shadow: none;
}

.ai-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.ai-clear-btn {
    background: rgba(255,255,255,0.2);
    border: none;
    color: var(--on-primary);
    padding: 5px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.82rem;
    transition: background 0.2s;
}

.ai-clear-btn:hover {
    background: rgba(255,255,255,0.3);
}

.ai-code-block {
    background: var(--surface-soft);
    color: var(--dark);
    padding: 12px 16px;
    border-radius: 8px;
    margin: 10px 0;
    font-size: 0.85rem;
    overflow-x: auto;
    max-height: 300px;
    font-family: 'SF Mono', Monaco, Consolas, monospace;
    white-space: pre-wrap;
}

.ai-code-inline {
    background: var(--surface-soft);
    color: var(--primary);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.9em;
    font-family: 'SF Mono', Monaco, Consolas, monospace;
}

.ai-context-info {
    padding: 10px 14px;
    background: var(--secondary);
    border-left: 3px solid var(--primary);
    border-radius: 8px;
    margin-bottom: 12px;
    font-size: 0.85rem;
    color: var(--primary-dark);
    line-height: 1.5;
}

/* Main Layout */
.main-content {
    display: grid;
    grid-template-columns: minmax(340px, 1fr) minmax(0, 1.4fr);
    gap: 24px;
    align-items: start;
}

/* Cards */
.card {
    background: var(--surface);
    overflow: hidden;
    border: 1px solid var(--light-gray);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-card);
}

.card-header {
    border-bottom: 1px solid var(--light-gray);
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--surface);
    padding: 20px 24px;
    min-height: 76px;
}

.card-header h2 {
    font-weight: 600;
    color: var(--dark);
    font-size: 1rem;
}

.card-header .icon {
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--secondary);
    color: var(--primary);
    width: 34px;
    height: 34px;
    font-size: 1rem;
}

.card-body {
    padding: 24px;
}

/* Scenario Section */
.scenario-section {
    position: sticky;
    top: 20px;
    align-self: start;
    min-width: 0;
}

.scenario-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border-radius: 20px;
    font-weight: 600;
    margin-bottom: 16px;
    background: var(--secondary);
    color: var(--primary-dark);
    font-size: .75rem;
    padding: 6px 12px;
    animation: none;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.02); }
}

.scenario-text {
    color: var(--dark);
    margin-bottom: 24px;
    border-radius: 12px;
    background: var(--surface);
    border-left: 3px solid var(--brand-border);
    font-size: var(--font-reading);
    font-weight: 400;
    padding: 20px;
    line-height: var(--leading-reading);
    letter-spacing: .025em;
    text-wrap: pretty;
}

.patient-info {
    display: grid;
    gap: 0;
    border: 1px solid var(--light-gray);
    border-radius: var(--radius-control);
    overflow: hidden;
}

.info-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    background: var(--surface);
    padding: 11px 14px;
    border-radius: 0;
    border-bottom: 1px solid var(--light-gray);
}

.info-item .label {
    color: var(--gray);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-size: .73rem;
    min-width: 78px;
    padding-top: 2px;
}

.info-item .value {
    font-weight: 500;
    color: var(--dark);
}

/* Hidden sections */
.hidden-section {
    display: none;
}

.reveal-btn {
    width: 100%;
    padding: 12px 16px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color .18s ease, border-color .18s ease, box-shadow .18s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 12px;
    background: var(--surface);
    color: var(--primary-dark);
    border: 1px solid var(--brand-border);
    min-height: 44px;
    border-radius: var(--radius-control);
}

.reveal-btn:hover {
    transform: none;
    background: var(--secondary);
    box-shadow: none;
}

.reveal-btn.revealed {
    cursor: default;
    background: var(--success-soft);
    color: var(--success);
    border-color: var(--brand-border);
}

.reveal-btn.revealed:hover {
    transform: none;
    box-shadow: none;
}

.vital-signs {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-top: 16px;
}

/* Blood Test Report Styles */
.blood-test-section {
    margin-bottom: 8px;
}

.blood-test-btn {
    width: 100%;
    padding: 10px 16px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: background-color .18s ease, border-color .18s ease, box-shadow .18s ease;
    background: var(--surface);
    color: var(--primary-dark);
    border: 1px solid var(--brand-border);
    min-height: 44px;
    border-radius: var(--radius-control);
}

.blood-test-btn:hover {
    transform: none;
    background: var(--secondary);
    box-shadow: none;
}

.blood-test-btn.revealed {
    cursor: default;
    background: var(--success-soft);
    color: var(--success);
    border-color: var(--brand-border);
}

.blood-test-btn.revealed:hover {
    transform: none;
    box-shadow: none;
}

.blood-test-table {
    width: 100%;
    margin-top: 8px;
    border-collapse: collapse;
    font-size: 0.75rem;
    background: var(--surface);
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.blood-test-table th {
    background: var(--danger);
    color: var(--on-primary);
    padding: 8px 6px;
    text-align: left;
    font-weight: 600;
    font-size: 0.75rem;
}

.blood-test-table td {
    padding: 6px;
    border-bottom: 1px solid var(--surface-soft);
}

.blood-test-table tr:last-child td {
    border-bottom: none;
}

.blood-test-table tr:nth-child(even) {
    background: var(--page);
}

.blood-test-category {
    font-weight: 600;
    color: var(--gray);
    background: var(--surface-soft) !important;
}

.blood-test-result {
    font-weight: 600;
}

.blood-test-result.high {
    color: var(--danger);
}

.blood-test-result.low {
    color: var(--primary);
}

.blood-test-result.normal {
    color: var(--success);
}

.blood-test-range {
    color: var(--gray);
    font-size: 0.75rem;
}

.blood-test-flag {
    display: inline-block;
    padding: 1px 4px;
    border-radius: 3px;
    font-size: 0.65rem;
    font-weight: 600;
    margin-left: 4px;
}

.blood-test-flag.high {
    background: var(--danger-soft);
    color: var(--danger);
}

.blood-test-flag.low {
    background: var(--secondary);
    color: var(--primary);
}

.vital-item {
    background: var(--surface);
    border: 2px solid var(--light-gray);
    border-radius: 10px;
    padding: 12px;
    text-align: center;
    transition: background-color .18s ease, border-color .18s ease, box-shadow .18s ease;
    border-width: 1px;
}

.vital-item:hover {
    border-color: var(--primary);
    transform: none;
}

.vital-item.warning {
    border-color: var(--warning);
    background: var(--warning-soft);
}

.vital-item .vital-label {
    font-size: 0.75rem;
    color: var(--gray);
    text-transform: uppercase;
}

.vital-item .vital-value {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--dark);
    margin-top: 4px;
}

.vital-item.warning .vital-value {
    color: var(--warning);
}

/* Symptom Tags */
.symptoms-section {
    margin-top: 20px;
}

.symptoms-title {
    font-size: 0.85rem;
    color: var(--gray);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 10px;
}

.symptom-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.symptom-tag {
    padding: 8px 14px;
    background: var(--secondary);
    border: 2px dashed var(--light-gray);
    border-radius: 20px;
    font-size: 0.85rem;
    color: var(--gray);
    opacity: 0.5;
    transition: background-color .18s ease, border-color .18s ease, box-shadow .18s ease;
    border-width: 1px;
}

.symptom-tag.discovered {
    opacity: 1;
    background: var(--warning-soft);
    border: 2px solid var(--warning);
    color: var(--dark);
    animation: discoverPulse 0.5s ease;
    border-width: 1px;
}

@keyframes discoverPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

.symptom-tag.discovered::before {
    content: '✓ ';
}

/* Personality Section */
.personality-section {
    margin-top: 16px;
}

.personality-title {
    font-size: 0.85rem;
    color: var(--gray);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 10px;
}

.personality-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.personality-tag {
    padding: 8px 14px;
    background: var(--secondary);
    border: 2px solid var(--brand-border);
    border-radius: 20px;
    font-size: 0.85rem;
    color: var(--primary-dark);
    border-width: 1px;
}

.symptom-tag.unknown {
    background: var(--secondary);
    border: 2px dashed var(--light-gray);
    color: var(--gray);
    font-style: italic;
}

/* Assignment Section */
.assignment-section {
    margin-top: 20px;
}

.assignment-card {
    border-radius: 12px;
    background: var(--secondary);
    border: 1px solid var(--brand-border);
    padding: 16px;
}

.assignment-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.assignment-number {
    width: 28px;
    height: 28px;
    color: var(--on-primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.9rem;
    background: var(--primary);
}

.assignment-title {
    font-weight: 600;
    color: var(--dark);
}

.assignment-instruction {
    color: var(--gray);
    font-size: .85rem;
    line-height: 1.7;
}

/* Chat Messages */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    padding: 24px;
    gap: 20px;
    background: var(--surface);
}

.message {
    max-width: 85%;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.message.user {
    align-self: flex-end;
}

.message.assistant {
    align-self: flex-start;
}

.message-bubble {
    padding: 14px 18px;
    line-height: 1.7;
    font-size: .95rem;
    border-radius: 14px;
}

.message.user .message-bubble {
    border-bottom-right-radius: 4px;
    background: var(--secondary);
    color: var(--dark);
    border: 1px solid var(--brand-border);
}

.message.assistant .message-bubble {
    border-bottom-left-radius: 4px;
    background: var(--surface-soft);
    color: var(--dark);
    border: 1px solid var(--light-gray);
}

.message.assistant.patient .message-bubble {
    border-color: var(--warning);
    background: var(--surface-soft);
    color: var(--dark);
    border: 1px solid var(--light-gray);
}

.message-time {
    font-size: 0.7rem;
    color: var(--gray);
    margin-top: 6px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.message.user .message-time {
    justify-content: flex-end;
}

.patient-label {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: var(--warning);
    color: var(--on-primary);
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.7rem;
    font-weight: 600;
}

.nurse-label {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: var(--primary);
    color: var(--on-primary);
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.7rem;
    font-weight: 600;
}

/* Chat Input */
.chat-input-container {
    border-top: 1px solid var(--light-gray);
    padding: 20px 24px;
    background: var(--surface-soft);
}

.input-wrapper {
    display: flex;
    gap: 8px;
    align-items: center;
}

.chat-input {
    flex: 1;
    border-radius: 12px;
    font-size: 1rem;
    font-family: inherit;
    transition: background-color .18s ease, border-color .18s ease, box-shadow .18s ease;
    resize: none;
    min-height: 50px;
    max-height: 120px;
    padding: 12px 14px;
    border: 1px solid var(--light-gray);
    min-width: 0;
}

.chat-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(35, 74, 66, 0.08);
}

.chat-input::placeholder {
    color: var(--gray);
}

.send-btn {
    padding: 14px 24px;
    background: var(--primary);
    color: var(--on-primary);
    border: none;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color .18s ease, border-color .18s ease, box-shadow .18s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.send-btn:hover {
    transform: none;
    box-shadow: 0 6px 20px rgba(35, 74, 66, 0.08);
}

.send-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.action-phase-btn {
    width: 100%;
    margin-top: 12px;
    padding: 14px 20px;
    border: none;
    cursor: pointer;
    transition: background-color .18s ease, border-color .18s ease, box-shadow .18s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: var(--primary);
    color: var(--on-primary);
    border-radius: var(--radius-control);
    box-shadow: none;
    font-weight: 600;
    font-size: .9rem;
    min-height: 44px;
}

.action-phase-btn:hover {
    transform: none;
    background: var(--primary-dark);
    box-shadow: none;
}

.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 14px 18px;
    background: var(--surface);
    border: 2px solid var(--light-gray);
    border-radius: 16px;
    width: fit-content;
}

.typing-dot {
    width: 8px;
    height: 8px;
    background: var(--gray);
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-6px); }
}

/* Loading State */
.loading {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--gray);
    padding: 10px;
}

.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--light-gray);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Error Toast */
.toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--danger);
    color: var(--on-primary);
    padding: 14px 24px;
    border-radius: 10px;
    font-weight: 500;
    box-shadow: 0 10px 40px rgba(239, 68, 68, 0.3);
    transition: transform 0.3s ease;
    z-index: 1000;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--secondary);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: var(--light-gray);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--gray);
}

/* Responsive */
@media (max-width: 900px) {
    .main-content {
        grid-template-columns: 1fr;
    }

    .scenario-section {
        position: static;
    }

    .right-section {
        height: 60vh;
        min-height: 400px;
    }

    .action-content-wrapper {
        grid-template-columns: 1fr !important;
    }
}

/* Action Phase Styles - Two Column Layout */
.action-content-wrapper {
    display: grid;
    grid-template-columns: 1fr 1.2fr;
    gap: 0;
    flex: 1;
    overflow: hidden;
}

.action-input-column {
    display: flex;
    flex-direction: column;
    padding: 20px;
    border-right: 2px solid var(--secondary);
    overflow-y: auto;
    border-color: var(--light-gray);
}

.action-input-card {
    background: var(--surface);
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 16px;
}

.action-input-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    color: var(--primary-dark);
    margin-bottom: 12px;
    font-size: 1rem;
}

.action-main-textarea {
    width: 100%;
    padding: 16px;
    border: 2px solid var(--secondary);
    border-radius: 12px;
    font-size: 1rem;
    font-family: inherit;
    resize: vertical;
    min-height: 150px;
    transition: background-color .18s ease, border-color .18s ease, box-shadow .18s ease;
}

.action-main-textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(35, 74, 66, 0.08);
}

.action-main-submit {
    margin-top: 16px;
    width: 100%;
    padding: 14px 24px;
    border: none;
    cursor: pointer;
    transition: background-color .18s ease, border-color .18s ease, box-shadow .18s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: var(--primary);
    color: var(--on-primary);
    border-radius: var(--radius-control);
    box-shadow: none;
    font-weight: 600;
    font-size: .9rem;
    min-height: 44px;
}

.action-main-submit:hover {
    transform: none;
    background: var(--primary-dark);
    box-shadow: none;
}

.action-main-submit:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.action-quick-section {
    margin-top: 20px;
}

.action-quick-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--primary-dark);
    margin-bottom: 12px;
}

.action-quick-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}

.action-quick-btn {
    padding: 12px 14px;
    background: var(--secondary);
    border: 1px solid var(--brand-border);
    border-radius: 12px;
    font-size: 0.85rem;
    color: var(--primary-dark);
    cursor: pointer;
    transition: background-color .18s ease, border-color .18s ease, box-shadow .18s ease;
    text-align: left;
}

.action-quick-btn:hover {
    background: var(--secondary);
    transform: none;
}

.action-finish-btn {
    width: 100%;
    padding: 14px 24px;
    border: none;
    cursor: pointer;
    transition: background-color .18s ease, border-color .18s ease, box-shadow .18s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: var(--primary);
    color: var(--on-primary);
    border-radius: var(--radius-control);
    box-shadow: none;
    font-weight: 600;
    font-size: .9rem;
    min-height: 44px;
}

.action-finish-btn:hover {
    transform: none;
    background: var(--primary-dark);
    box-shadow: none;
}

/* Records Column */
.action-records-column {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.action-records-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 20px;
    border-bottom: 2px solid var(--secondary);
    font-weight: 600;
    color: var(--primary-dark);
    border-color: var(--light-gray);
    background: var(--surface-soft);
    border-bottom-width: 1px;
}

.action-records-count {
    margin-left: auto;
    font-size: 0.85rem;
    color: var(--gray);
    font-weight: normal;
}

.action-records-list {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.action-record-item {
    background: var(--surface);
    border: 1px solid var(--secondary);
    border-radius: 16px;
    padding: 20px;
}

.action-record-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
}

.action-record-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 600;
    background: var(--secondary);
    color: var(--primary-dark);
}

.action-record-time {
    font-size: 0.85rem;
    color: var(--gray);
}

.action-record-content {
    color: var(--dark);
    line-height: 1.7;
    margin-bottom: 16px;
    font-size: 1rem;
    white-space: pre-wrap;
}

.action-record-feedback {
    padding-top: 16px;
    border-top: 1px dashed var(--brand-border);
}

.action-record-feedback-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--primary-dark);
    margin-bottom: 10px;
}

.action-record-feedback-content {
    color: var(--dark);
    font-size: var(--font-reading);
    line-height: var(--leading-reading);
    padding: 16px;
    background: var(--secondary);
    border-radius: 12px;
    white-space: pre-wrap;
}

.feedback-section {
    margin-bottom: 16px;
}

.feedback-section:last-child {
    margin-bottom: 0;
}

.feedback-section-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--primary-dark);
    margin-bottom: 10px;
}

.feedback-section-content {
    color: var(--dark);
    font-size: var(--font-reading);
    line-height: var(--leading-reading);
    padding: 14px;
    background: var(--secondary);
    border-radius: 10px;
    white-space: pre-wrap;
}

/* Right Section Layout */
.right-section {
    display: flex;
    flex-direction: column;
    height: calc(100dvh - 205px);
    min-height: 640px;
    min-width: 0;
}

.right-section #assessmentSection {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.right-section #actionSection {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.right-section .card-header {
    background: var(--surface);
    padding: 18px 24px;
    border-bottom: 1px solid var(--light-gray);
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.right-section .card-header h2 {
    font-size: 1.1rem;
    color: var(--primary-dark);
    font-weight: 600;
}

.right-section .chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.right-section .chat-input-container {
    padding: 20px;
    background: var(--surface);
    border-top: 1px solid var(--light-gray);
    flex-shrink: 0;
}

.phase-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    margin-left: auto;
}

.phase-badge.assessment {
    background: #14b8a6;
    color: var(--on-primary);
}

.phase-badge.action {
    background: var(--primary);
    color: var(--on-primary);
}

.typing-indicator.action-typing {
    background: var(--secondary);
    border-color: var(--brand-border);
}

/* SCT Score Selector */
.sct-score-grid {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

.sct-score-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.sct-score-btn {
    width: 100%;
    aspect-ratio: 1;
    border: 2px solid var(--light-gray);
    border-radius: 12px;
    background: var(--surface);
    color: var(--gray);
    font-size: 1.05rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color .18s ease, border-color .18s ease, box-shadow .18s ease;
    min-height: 52px;
}

.sct-score-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--secondary);
    transform: none;
    box-shadow: 0 4px 12px rgba(35, 74, 66, 0.08);
}

.sct-score-btn.selected {
    background: var(--primary);
    border-color: var(--primary);
    color: var(--on-primary);
    box-shadow: 0 4px 14px rgba(35, 74, 66, 0.08);
    transform: none;
}

.sct-score-btn.correct {
    background: var(--success);
    border-color: var(--success);
    color: var(--on-primary);
    box-shadow: 0 4px 12px rgba(35, 74, 66, 0.08);
}

.sct-score-btn.wrong {
    background: var(--danger);
    border-color: var(--danger);
    color: var(--on-primary);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

.sct-score-btn.dimmed {
    opacity: 0.3;
    cursor: default;
    transform: none !important;
    box-shadow: none !important;
}

.sct-score-meaning {
    font-size: 0.68rem;
    color: var(--gray);
    text-align: center;
    line-height: 1.3;
    font-weight: 500;
}

.sct-score-btn.selected .sct-score-meaning {
    color: var(--on-primary);
}

.sct-score-btn.wrong .sct-score-meaning,
.sct-score-btn.correct .sct-score-meaning {
    color: var(--on-primary);
}

.sct-submit-btn {
    width: 100%;
    padding: 14px;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 16px;
    transition: background-color .18s ease, border-color .18s ease, box-shadow .18s ease;
    background: var(--primary);
    color: var(--on-primary);
    border-radius: var(--radius-control);
    box-shadow: none;
    font-weight: 600;
    font-size: .9rem;
    min-height: 44px;
}

.sct-submit-btn:hover {
    transform: none;
    background: var(--primary-dark);
    box-shadow: none;
}

.sct-submit-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.sct-feedback-card {
    background: var(--page);
    border: 1px solid var(--light-gray);
    border-radius: 12px;
    padding: 16px;
    margin-top: 12px;
}

.sct-feedback-header {
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 8px;
}

.sct-feedback-header.correct { color: var(--success); }
.sct-feedback-header.wrong   { color: var(--danger); }

.sct-next-btn {
    width: 100%;
    padding: 12px;
    border: none;
    cursor: pointer;
    margin-top: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: background-color .18s ease, border-color .18s ease, box-shadow .18s ease;
    background: var(--primary);
    color: var(--on-primary);
    border-radius: var(--radius-control);
    box-shadow: none;
    font-weight: 600;
    font-size: .9rem;
    min-height: 44px;
}

.sct-next-btn:hover {
    transform: none;
    background: var(--primary-dark);
    box-shadow: none;
}

/* Medication Phase Styles */
.medication-phase-btn {
    width: 100%;
    margin-top: 12px;
    padding: 14px 20px;
    background: var(--primary);
    color: var(--on-primary);
    border: none;
    border-radius: 12px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color .18s ease, border-color .18s ease, box-shadow .18s ease;
    display: none;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.medication-phase-btn:hover {
    transform: none;
    box-shadow: 0 6px 20px rgba(35, 74, 66, 0.08);
}

.medication-phase-btn.visible {
    display: flex;
}

.phase-badge.medication {
    background: var(--primary);
    color: var(--on-primary);
}

.phase-badge.completed {
    background: var(--success);
    color: var(--on-primary);
}

/* Medication Phase Styles */
.right-section #medSection {
    display: none;
    flex-direction: column;
    height: 100%;
}

.med-content-wrapper {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
}

.med-drug-list {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

.med-form-container {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

.med-drug-card {
    background: var(--surface);
    border: 2px solid var(--light-gray);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 12px;
    cursor: pointer;
    transition: background-color .18s ease, border-color .18s ease, box-shadow .18s ease;
    display: block;
}

.med-drug-card:hover {
    border-color: var(--primary);
    box-shadow: 0 4px 12px rgba(35, 74, 66, 0.08);
    transform: none;
}

.med-drug-card.selected {
    border-color: var(--primary);
    background: var(--secondary);
}

.med-drug-name {
    font-weight: 600;
    color: var(--dark);
    margin-bottom: 6px;
    font-size: 1rem;
}

.med-drug-use {
    font-size: 0.85rem;
    color: var(--gray);
    margin-bottom: 8px;
}

.med-drug-detail {
    font-size: 0.8rem;
    color: var(--gray);
}

.med-submit-btn {
    width: 100%;
    padding: 16px 24px;
    border: none;
    cursor: pointer;
    transition: background-color .18s ease, border-color .18s ease, box-shadow .18s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: var(--primary);
    color: var(--on-primary);
    border-radius: var(--radius-control);
    box-shadow: none;
    font-weight: 600;
    font-size: .9rem;
    min-height: 44px;
}

.med-submit-btn:hover {
    transform: none;
    background: var(--primary-dark);
    box-shadow: none;
}

.med-submit-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.med-step-card {
    background: var(--surface);
    border-radius: 16px;
    padding: 24px;
    margin-bottom: 16px;
}

.med-step-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.med-step-number {
    width: 32px;
    height: 32px;
    background: var(--primary);
    color: var(--on-primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.9rem;
}

.med-step-title {
    font-weight: 600;
    color: var(--dark);
    font-size: 1.1rem;
}

.med-step-content {
    padding-left: 44px;
}

.med-reason-textarea {
    width: 100%;
    padding: 14px;
    border: 2px solid var(--light-gray);
    border-radius: 10px;
    font-size: 0.95rem;
    font-family: inherit;
    resize: vertical;
    min-height: 100px;
    transition: background-color .18s ease, border-color .18s ease, box-shadow .18s ease;
}

.med-reason-textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(35, 74, 66, 0.08);
}

.med-dosage-section {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px dashed var(--light-gray);
}

.med-dosage-label {
    font-size: 0.85rem;
    color: var(--gray);
    margin-bottom: 8px;
}

.med-dosage-input {
    width: 100%;
    padding: 14px;
    border: 2px solid var(--light-gray);
    border-radius: 10px;
    font-size: 0.95rem;
    font-family: inherit;
    transition: background-color .18s ease, border-color .18s ease, box-shadow .18s ease;
}

.med-dosage-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(35, 74, 66, 0.08);
}

.med-evaluation-card {
    background: var(--surface);
    border: 2px solid var(--success);
    border-radius: 16px;
    padding: 24px;
    margin-top: 16px;
    border-width: 1px;
}

.med-evaluation-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.med-evaluation-badge {
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 600;
    background: var(--success-soft);
    color: var(--success);
}

.med-evaluation-content {
    color: var(--dark);
    line-height: var(--leading-reading);
    font-size: var(--font-reading);
    white-space: normal;
    flex: 1;
}

.med-back-btn {
    background: var(--surface-soft);
    border: 1px solid var(--light-gray);
    color: var(--gray);
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background-color .18s ease, border-color .18s ease, box-shadow .18s ease;
}

.med-back-btn:hover {
    background: var(--light-gray);
    color: var(--gray);
}

.med-complete-btn {
    width: 100%;
    padding: 16px 24px;
    border: none;
    cursor: pointer;
    transition: background-color .18s ease, border-color .18s ease, box-shadow .18s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 16px;
    background: var(--primary);
    color: var(--on-primary);
    border-radius: var(--radius-control);
    box-shadow: none;
    font-weight: 600;
    font-size: .9rem;
    min-height: 44px;
}

.med-complete-btn:hover {
    transform: none;
    background: var(--primary-dark);
    box-shadow: none;
}

.typing-indicator.med-typing {
    background: var(--secondary);
    border-color: var(--brand-border);
}

/* ─── ASR Voice Input ─────────────────────────────────────── */
.asr-btn {
    flex-shrink: 0;
    width: 38px;
    height: 38px;
    border-radius: 8px;
    border: none;
    background: var(--surface-soft);
    color: var(--gray);
    cursor: pointer;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, color 0.2s;
    margin-left: 8px;
}
.asr-btn:hover {
    background: var(--light-gray);
    color: var(--dark);
}
.asr-btn.recording {
    background: var(--danger-soft);
    color: var(--danger);
    animation: asr-pulse 1.2s ease-in-out infinite;
}
.asr-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    animation: none;
}
@keyframes asr-pulse {
    0%, 100% { transform: scale(1); }
    50%       { transform: scale(1.12); }
}
.asr-status {
    font-size: 0.78rem;
    color: var(--danger);
    margin-left: 6px;
    white-space: nowrap;
}
.asr-input-row {
    display: flex;
    align-items: flex-start;
    gap: 0;
}
/* Override input-wrapper for chat input to handle flex layout */
.input-wrapper {
    display: flex;
    gap: 8px;
    align-items: center;
}
.input-wrapper textarea {
    flex: 1;
}
/* AI input area: ensure flex layout includes asr-btn */
.ai-input-area {
    display: flex;
    gap: 8px;
    align-items: flex-start;
}
.ai-input-area textarea {
    flex: 1;
}
/* PASS pre-test: a separate step before any patient information. */
#heart-screen {
    background: var(--page);
    color: var(--dark);
    min-height: 100vh;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
#heart-skip-error { color: var(--danger); padding: 12px 4vw; }
#heart-skip-error:empty { display: none; }
#heart-frame { display: block; width: 100%; height: 100dvh; border: 0; }

#pretest-screen { max-width: 1400px; margin: auto; padding: 32px 20px; }
#pretest-screen[hidden] { display: none; }
.pretest-card { background: var(--surface); border: 1px solid var(--light-gray);  overflow: hidden;
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-card);
}
.pretest-header {   display: flex; justify-content: space-between; gap: 20px; align-items: start;
    background: var(--surface);
    color: var(--dark);
    border-bottom: 1px solid var(--light-gray);
    padding: 28px 32px;
}
.pretest-header h1 { font-size: 1.7rem; margin: 8px 0;
    font-weight: 650;
    letter-spacing: -.03em;
}
.pretest-header p { line-height: 1.6; max-width: 780px;
    color: var(--gray);
    font-size: .9rem;
}
.pretest-body { padding: 28px 32px; }
.pretest-key { display: flex; flex-wrap: wrap; gap: 10px; margin: 16px 0 24px; }
.pretest-key span { background: var(--secondary); border-radius: 8px; padding: 10px 12px; font-size: .85rem; line-height: 1.5; flex: 1 1 170px;
    border: 1px solid var(--brand-border);
}
.pretest-table { width: 100%; border-collapse: collapse; font-size: .92rem; line-height: 1.65; }
.pretest-table th { background: var(--surface-soft); text-align: left; padding: 14px; }
.pretest-table td { padding: 20px 14px; vertical-align: top; border-bottom: 1px solid var(--light-gray); }
.pretest-table td:first-child { font-weight: 700; color: var(--primary-dark); min-width: 120px; }
.pretest-table td:nth-child(2), .pretest-table td:nth-child(3) { width: 31%; }
.pretest-options { display: flex; gap: 6px; border: 0; }
.pretest-options label { position: relative; cursor: pointer; }
.pretest-options input { position: absolute; opacity: 0; width: 100%; height: 100%; cursor: pointer; }
.pretest-options span { display: grid; place-items: center; min-width: 42px; min-height: 44px; border: 1px solid var(--gray); border-radius: 8px; font-weight: 700; }
.pretest-options input:checked + span { background: var(--primary-dark); border-color: var(--primary-dark); color: var(--on-primary); }
.pretest-options input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: 3px; }
.pretest-footer { display: flex; justify-content: space-between; align-items: center; gap: 20px; margin-top: 24px; }
.pretest-submit { padding: 14px 22px; border: 0; border-radius: 10px; background: var(--primary-dark); color: var(--on-primary); font: inherit; font-weight: 700; cursor: pointer; }
.pretest-submit:disabled { opacity: .55; cursor: not-allowed; }
#pretest-error { color: var(--danger); margin-top: 16px; }
.pretest-sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
@media (max-width: 900px) {
    .pretest-header, .pretest-body { padding: 20px; }
    .pretest-table thead { display: none; }
    .pretest-table, .pretest-table tbody, .pretest-table tr, .pretest-table td { display: block; width: 100% !important; }
    .pretest-table tr { border: 1px solid var(--light-gray); border-radius: 12px; margin-bottom: 16px; overflow: hidden; }
    .pretest-table td { padding: 12px 16px; border: 0; }
    .pretest-table td::before { content: attr(data-label); display: block; font-weight: 700; font-size: .8rem; color: var(--gray); margin-bottom: 5px; }
    .pretest-footer { align-items: stretch; flex-direction: column; }
}

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

.info-item:last-child {
    border-bottom: 0;
}

.auth-note {
    font-size: .78rem;
    color: var(--gray);
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--light-gray);
}

/* Shared interaction rules. Hidden/state classes above remain authoritative. */
button, input, textarea, select { font-family: var(--font-ui); }
button { touch-action: manipulation; }
button:disabled { cursor: not-allowed; }
button:focus-visible, a:focus-visible, textarea:focus-visible, input:focus-visible,
select:focus-visible, [tabindex]:focus-visible {
    outline: 3px solid var(--focus); outline-offset: 3px;
}
textarea, input, select { accent-color: var(--primary); }
textarea::placeholder, input::placeholder { color: var(--gray); opacity: 1; }
.header-icon svg, .auth-logo svg { width: 28px; height: 28px; }
.phase-badge.assessment, .phase-badge.action, .phase-badge.medication, .phase-badge.sct {
    background: var(--secondary); color: var(--primary-dark);
    border: 1px solid var(--brand-border); font-size: .78rem;
}
.card-header.phase-heading { background: var(--surface); color: var(--dark); }
.card-header.phase-heading h2 { color: var(--dark); }
.card-header.phase-heading .icon { background: var(--secondary); }
.auth-tab.active { background: var(--surface); color: var(--primary-dark); }
#heart-screen { font-family: var(--font-ui); }
@media (max-width: 1100px) {
    .header { align-items: flex-start; }
    .header-actions { width: 100%; }
    .main-content { grid-template-columns: minmax(280px, .85fr) minmax(0, 1.2fr); }
    .action-content-wrapper { grid-template-columns: 1fr; overflow-y: auto; }
    .action-input-column, .action-records-column { overflow: visible; }
    .action-input-column { border-right: 0; border-bottom: 1px solid var(--light-gray); }
    .action-records-list { overflow: visible; }
}
@media (max-width: 900px) {
    .container { padding: 20px; }
    .main-content { grid-template-columns: minmax(0, 1fr); }
    .scenario-section { position: static; }
    .right-section { height: auto; min-height: 640px; }
    .right-section #assessmentSection { min-height: 640px; }
    .chat-messages { max-height: 60dvh; min-height: 280px; }
    .dev-panel-body { grid-template-columns: 180px minmax(0, 1fr); overflow-y: auto; }
    .dev-main { min-width: 0; }
    .dev-resizer { display: none; }
    .dev-right-section { grid-column: 2; min-height: 420px; }
}
@media (max-width: 540px) {
    .container, #pretest-screen { padding: 16px; }
    .header { padding: 20px; gap: 18px; }
    .header h1 { font-size: 1.15rem; gap: 10px; }
    .header-subtitle { font-size: .78rem; }
    .header-actions { gap: 8px; }
    .user-info { margin-right: auto; }
    .dev-mode-btn { order: 4; width: 100%; justify-content: center; }
    .card-body, .card-header, .chat-messages, .chat-input-container { padding: 18px; }
    .auth-card { padding: 28px 24px; }
    .auth-card h2 { font-size: 1.4rem; }
    .input-wrapper { flex-wrap: wrap; }
    .input-wrapper textarea { flex-basis: 100%; }
    .input-wrapper .send-btn { flex: 1; }
    .asr-btn { margin-left: 0; min-width: 44px; min-height: 44px; }
    .message { max-width: 95%; }
    .action-input-column, .action-input-card { padding: 16px; }
    .action-quick-grid, .med-drug-grid { grid-template-columns: 1fr; }
    .med-step-content { padding-left: 0; }
    .pretest-header { flex-wrap: wrap; }
    .dev-panel-header { padding: 14px 18px; }
    .dev-panel-body { display: flex; flex-direction: column; }
    .dev-sidebar { width: 100%; flex-shrink: 0; }
    .dev-sidebar-header { display: none; }
    .dev-sidebar-item { padding: 10px 16px; }
    .dev-main { overflow: visible; padding: 18px; flex-shrink: 0; }
    .dev-right-section { min-height: 480px; flex-shrink: 0; }
    .dev-form-content { width: 100%; max-height: 90dvh; }
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
}

.patient-label, .nurse-label { background: var(--secondary); color: var(--primary-dark); }
.blood-test-table th { background: var(--surface-soft); color: var(--dark); }
.pretest-options input { top: 0; left: 0; }
@media (max-width: 900px) {
    .med-content-wrapper { min-height: 600px; }
}

.toast { max-width: calc(100vw - 32px); box-shadow: var(--shadow-float); }
.toast[data-tone="success"] { background: var(--primary-dark); }
#auth-overlay.hidden { visibility: hidden; }

/* Long clinical explanations need reading contrast, not muted metadata styling. */
.clinical-feedback-text {
    color: var(--dark);
    font-size: var(--font-reading);
    line-height: var(--leading-reading);
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    max-width: 68ch;
}
.feedback-section-content, .action-record-feedback-content {
    overflow-wrap: anywhere;
}
.med-evaluation-content { min-width: 0; }
.info-item .label, .vital-item .vital-label {
    font-size: .8125rem;
    font-weight: 600;
    color: var(--gray);
}
.assignment-instruction, .med-drug-use, .med-drug-detail {
    color: var(--gray);
    font-size: .9375rem;
    line-height: 1.7;
}
.message-bubble { font-size: 1rem; line-height: 1.8; }
.message-time { font-size: .8125rem; }
.med-summary-bar { line-height: 1.7; }

/* Reading comfort: keep clinical content large and regular, with clear labels. */
#main-app { font-size: 18px; }
.message-bubble {
    font-size: var(--font-reading);
    font-weight: 400;
    line-height: var(--leading-reading);
    letter-spacing: .015em;
    max-width: 60ch;
}
.clinical-feedback-text, .feedback-section-content, .action-record-feedback-content {
    font-weight: 400;
    letter-spacing: .015em;
}
.info-item .label, .vital-item .vital-label {
    font-size: .9375rem;
    font-weight: 500;
}
.info-item .value { font-size: 1.125rem; font-weight: 400; }
.assignment-instruction, .med-drug-use, .med-drug-detail {
    font-size: 1.0625rem;
    line-height: 1.8;
}
.chat-input { font-size: 1.125rem; line-height: 1.6; }
.card-header h2, .right-section .card-header h2 { font-size: 1.125rem; }
@media (max-width: 540px) {
    .scenario-text { padding: 18px; }
    .info-item .label { min-width: 72px; }
}

/* One teal accent with neutral sage surfaces throughout the light workspace. */
input, textarea, select { color: var(--dark); background-color: var(--surface); }
.header { background: var(--primary-dark); color: var(--on-primary); border-color: var(--primary-dark); }
.header-subtitle { color: var(--on-primary); opacity: .88; }
.header .new-case-btn { background: var(--secondary); color: var(--primary-dark); border-color: var(--brand-border); }
.header .new-case-btn:hover { background: var(--surface); color: var(--primary-dark); }
.scenario-section .card { background: var(--case-surface); }
.scenario-section .card-header { background: var(--case-heading); border-color: var(--light-gray); }
.scenario-section .card-header .icon { background: var(--secondary); }
.scenario-text { background: var(--secondary); border-left-color: var(--primary); }
.patient-info { border-color: var(--light-gray); }
.info-item { background: var(--surface); border-bottom-color: var(--light-gray); }
.info-item:nth-child(even) { background: var(--surface-soft); }
.assignment-card { background: var(--task-surface); border-color: var(--light-gray); }
.assignment-number { background: var(--primary); }
.right-section #assessmentSection .card-header { background: var(--chat-heading); border-bottom-color: var(--light-gray); }
.chat-messages { background: var(--chat-surface); }
.message.assistant .message-bubble, .message.assistant.patient .message-bubble {
    background: var(--surface); border-color: var(--light-gray);
}
.message.user .message-bubble { background: var(--secondary); border-color: var(--brand-border); }
.right-section .chat-input-container { background: var(--surface-soft); border-top-color: var(--light-gray); }
#actionSection .card-header { background: var(--task-heading); border-bottom-color: var(--light-gray); }
.action-content-wrapper { background: var(--surface-soft); }
.action-records-header { background: var(--task-surface); }
#medSection .card-header { background: var(--secondary); border-bottom-color: var(--light-gray); }
.med-content-wrapper { background: var(--surface-soft); }
.med-evaluation-card { background: var(--surface); }
.pretest-header { background: var(--chat-heading); }
.pretest-key span { background: var(--surface-soft); border-color: var(--light-gray); }
.pretest-table th { background: var(--surface-soft); }
.pretest-table tbody tr:nth-child(even) { background: var(--surface-soft); }
.auth-card { border-top: 5px solid var(--primary); }
.auth-tabs { background: var(--secondary); }
.auth-tab.active { background: var(--surface); }
.dev-sidebar { background: var(--secondary); }
.dev-panel-header, .dev-form-header, .ai-assistant-header {
    background: var(--primary-dark); color: var(--on-primary);
}
.dev-panel-close, .ai-clear-btn { color: var(--on-primary); background: rgba(255,255,255,.12); }
.dev-main { background: var(--surface-soft); }
.dev-mode-btn.active { background: var(--secondary); border-color: var(--brand-border); }
.toast[data-tone="success"] { color: var(--on-primary); }

/* Clear zones and compact details give the light workspace a visual rhythm. */
.section-heading { display: grid; gap: 3px; }
.section-kicker {
    font-size: .6875rem; font-weight: 650; letter-spacing: .1em;
    text-transform: uppercase; color: var(--gray);
}
.scenario-section .card-header, #assessmentSection .card-header { min-height: 90px; padding: 20px 24px; }
.patient-info {
    display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1px; border: 1px solid var(--light-gray); background: var(--light-gray);
}
.patient-info .info-item {
    display: flex; flex-direction: column; gap: 4px;
    padding: 12px 16px; border: 0; background: var(--surface);
}
.patient-info .info-item:first-child {
    grid-column: 1 / -1; background: var(--secondary);
    flex-direction: row; align-items: center; gap: 18px;
}
.patient-info .label { min-width: 0; font-size: .75rem; letter-spacing: .04em; }
.patient-info .value { font-size: 1.0625rem; }
.patient-info .info-item:first-child .value { font-weight: 600; }
.scenario-section .reveal-btn { background: transparent; border-color: var(--light-gray); }
.scenario-section .reveal-btn:hover { background: var(--secondary); }
.assignment-card { border-left: 3px solid var(--primary); }
.chat-messages { padding: 28px; }
.message-bubble { box-shadow: 0 2px 4px rgba(37, 66, 63, .035); }
.right-section .chat-input-container { padding: 20px 24px; }
.chat-input-container .action-phase-btn { margin-top: 20px; }
@media (max-width: 540px) {
    .chat-messages { padding: 18px; }
    .right-section .chat-input-container { padding: 18px; }
    .patient-info .info-item { padding: 12px 14px; }
}

/* Developer student records */
.data-filters { display:flex; gap:16px; flex-wrap:wrap; margin:20px 0; }
.data-filters label { display:flex; flex-direction:column; gap:6px; color:var(--dark); }
.data-filters input, .data-filters select { padding:10px; border:1px solid var(--light-gray); border-radius:8px; background:var(--surface); color:var(--dark); max-width:100%; }
.data-summary { display:grid; grid-template-columns:repeat(auto-fit,minmax(150px,1fr)); gap:12px; }
.data-summary > div { padding:16px; background:var(--surface-soft); border-radius:10px; }
.data-summary span, .data-summary strong { display:block; }
.data-summary strong { margin-top:8px; font-size:1.15rem; }
.data-table-wrap { overflow-x:auto; max-width:100%; margin:14px 0 24px; }
.data-table-wrap table { width:100%; border-collapse:collapse; text-align:left; }
.data-table-wrap th, .data-table-wrap td { padding:12px; border-bottom:1px solid var(--light-gray); vertical-align:top; overflow-wrap:anywhere; min-width:95px; white-space:pre-wrap; }
.data-table-wrap th { background:var(--surface-soft); }
.data-link { background:var(--primary); color:var(--on-primary); border:0; border-radius:8px; padding:8px 12px; cursor:pointer; }
.data-payload { white-space:pre-wrap; overflow-wrap:anywhere; font:inherit; background:var(--surface-soft); padding:16px; }
#devDataSection { min-width:0; color:var(--dark); }
#devDataSection h4 { margin-top:24px; }
.dev-panel-body.student-data-view { grid-template-columns:220px minmax(0,1fr) !important; }
.student-data-view > #devResizer, .student-data-view > #devRightSection { display:none; }
@media (max-width:768px) { .dev-panel-body.student-data-view { grid-template-columns:160px minmax(0,1fr) !important; } }
/* Keep added learning columns readable; smaller screens scroll the table. */
.data-table-wrap th { white-space:nowrap; overflow-wrap:normal; }
.data-table-wrap td { min-width:130px; max-width:420px; }
#studentDataDetail { scroll-margin-top:24px; }

.pretest-header-actions { display:flex; flex-wrap:wrap; align-items:center; gap:10px; flex-shrink:0; }
@media (max-width:768px) {
    .pretest-header { flex-wrap:wrap; }
    .pretest-header-actions { width:100%; }
}

.data-toolbar { display:flex; flex-wrap:wrap; gap:10px; }
.data-remove-all { padding:10px 16px; background:var(--danger); color:var(--on-primary); border:0; border-radius:var(--radius-control); font:inherit; cursor:pointer; }
.data-remove-all:disabled { opacity:.55; cursor:not-allowed; }
