:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #e0e7ff;
    --type-a-bg: #f5f3ff;
    --type-a-border: #c7d2fe;
    --type-a-text: #4338ca;
    --type-b-bg: #eff6ff;
    --type-b-border: #bfdbfe;
    --type-b-text: #1e40af;
    --hover-bg: #f1f5f9;
    --selected-bg: #818cf8;
    --selected-text: #ffffff;
    --bg: #f8fafc;
    --surface: #ffffff;
    --border: #e2e8f0;
    --border-light: #f1f5f9;
    --text: #1e293b;
    --text-light: #64748b;
    --text-muted: #94a3b8;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
    --clickable: #8b5cf6;
    --clickable-hover: #7c3aed;
    --clickable-bg: #f3e8ff;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
}

/* Navbar */
.navbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(10px);
    background: rgba(255, 255, 255, 0.95);
}

.nav-container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 0 24px;  /* Slightly reduced from 32px (better use of space) */
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 60px;  /* Slightly shorter */
}

.logo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;  /* Slightly lighter than 700 */
    font-size: 1.1rem;
}

.logo-icon {
    font-size: 1.3rem;
}

.badge {
    background: var(--primary);
    color: white;
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 500;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 20px;
}

.nav-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--text-light);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.2s ease;
    background: none;
    border: none;
    cursor: pointer;
    font-family: inherit;
    padding: 6px 8px;
    border-radius: 8px;
}

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

.nav-btn {
    background: none;
    border: none;
}

/* SVG icon sizing */
.nav-link svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

/* Container */
.container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 14px 32px;
    display: grid;
    grid-template-columns: 360px 1fr;
    gap: 32px;
}

/* Sidebar */
.sidebar {
    position: sticky;
    top: 60px;
    height: fit-content;
    max-height: calc(100vh - 100px);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

/* Sidebar Cards */
.sidebar-card {
    background: var(--surface);
    border-radius: 16px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    flex-shrink: 0; /* Prevent cards from shrinking */
}

.sidebar-card-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 20px 3px;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    user-select: none;
}

.sidebar-card-header span:first-child {
    font-size: 1.2rem;
}

.sidebar-card-header h3 {
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-light);
    margin: 0;
    flex: 1;
}

.collapse-icon {
    font-size: 0.7rem;
    transition: transform 0.2s;
    color: var(--text-light);
}

.collapsible .sidebar-card-body {
    display: block;
}

.collapsible.collapsed .sidebar-card-body {
    display: none;
}

.collapsible.collapsed .collapse-icon {
    transform: rotate(-90deg);
}

.sidebar-card-body {
    padding: 6px 10px;
}

/* Configuration */
.config-label {
    display: block;
    font-weight: 600;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-light);
    margin-bottom: 8px;
}

.config-select select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    font-family: inherit;
    font-size: 0.85rem;
    background: var(--surface);
    cursor: pointer;
    transition: all 0.2s;
}

.config-select select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

/* Search */
.search-box {
    padding: 6px 12px;
    border-bottom: 1px solid var(--border);
}

.search-box input {
    width: 100%;
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 0.85rem;
    transition: all 0.2s;
}

.search-box input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

/* Descriptor List */
.descriptor-list {
    padding: 4px 8px;
    max-height: 130px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

/* Expanded height class */
.descriptor-list.expanded {
    max-height: 270px;
}

.descriptor-item {
    padding: 6px 10px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s ease;
    border: 1px solid transparent;
    -webkit-tap-highlight-color: transparent;
}

.descriptor-item.type-a {
    background: var(--type-a-bg);
    border-left: 3px solid var(--type-a-border);
}

.descriptor-item.type-b {
    background: var(--type-b-bg);
    border-left: 3px solid var(--type-b-border);
}

/* Hover effect for unselected items - subtle background change */
.descriptor-item.type-a:hover:not(.active) {
    background: #e8e6f5;
    transform: translateX(2px);
}

.descriptor-item.type-b:hover:not(.active) {
    background: #e2eef9;
    transform: translateX(2px);
}

/* Selected item - subtle hover effect (just slight brightness change) */
.descriptor-item.active:hover {
    filter: brightness(0.97);
    transform: translateX(2px);
}

.descriptor-item.active {
    background: var(--selected-bg);
    color: var(--selected-text);
    border-left-color: var(--selected-text);
    box-shadow: var(--shadow-sm);
}

.descriptor-item .descriptor-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}

.descriptor-item strong {
    font-size: 0.8rem;
    font-weight: 600;
    line-height: 1.3;
}

.descriptor-item .descriptor-meta {
    font-size: 0.6rem;
    font-weight: 400;
    white-space: nowrap;
    flex-shrink: 0;
    opacity: 0.6;
}

.descriptor-item.type-a .descriptor-meta {
    color: var(--type-a-text);
}

.descriptor-item.type-b .descriptor-meta {
    color: var(--type-b-text);
}

.descriptor-item.active .descriptor-meta {
    color: var(--selected-text);
    opacity: 0.75;
}

/* Remove the click flash/scale effect */
.descriptor-item:active {
    transform: scale(0.99);
}

/* Main Content */
.main-content {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.main-card {
    background: var(--surface);
    border-radius: 16px;
    border: 1px solid var(--border);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.main-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
}

.main-card-header h2 {
    font-size: 1rem;
    font-weight: 600;
    margin: 0;
}

.descriptor-title {
    display: flex;
    align-items: center;
    gap: 12px;
}

.main-card-body {
    padding: 24px;
}

/* Buttons */
.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    padding: 8px 16px;
    border-radius: 10px;
    font-size: 0.8rem;
    cursor: pointer;
    font-family: inherit;
    color: var(--text);
    transition: all 0.2s;
    font-weight: 500;
}

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

.output-card .btn-outline {
    background: #3b3b4f;
    border-color: #5a5a7a;
    color: #e2e8f0;
}

.output-card .btn-outline:hover {
    background: #6b7280;
    border-color: #8b92a0;
    color: white;
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}

.btn-small {
    background: var(--bg);
    border: 1px dashed var(--border);
    padding: 10px 16px;
    border-radius: 10px;
    font-size: 0.8rem;
    cursor: pointer;
    font-family: inherit;
    color: var(--primary);
    font-weight: 500;
    transition: all 0.2s;
    width: 100%;
}

.btn-small:hover {
    background: var(--primary-light);
    border-color: var(--primary);
    border-style: solid;
}

.btn-text {
    background: transparent;
    border: none;
    color: var(--primary);
    font-size: 0.8rem;
    cursor: pointer;
    font-family: inherit;
    font-weight: 500;
    transition: all 0.2s;
}

.btn-text:hover {
    color: var(--primary-dark);
    text-decoration: underline;
}

.clinical-note-preview {
    background: var(--bg);
    border-radius: 10px;
    padding: 8px 12px;
    margin-bottom: 6px;
}

.clinical-note-preview small {
    color: var(--text-muted);
    display: block;
    margin-bottom: 8px;
    font-size: 0.7rem;
}

#clinicalNotePreview {
    font-size: 0.8rem;
    font-family: 'Monaco', 'Courier New', monospace;
    color: var(--text);
    line-height: 1.4;
    white-space: normal;
    word-break: break-word;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

#clinicalNoteDatePreview {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 8px;
    padding-left: 4px;
}

/* Editor Sections */
.editor-section {
    margin-bottom: 28px;
}

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

.editor-label {
    display: block;
    font-weight: 600;
    font-size: 0.8rem;
    margin-bottom: 8px;
    color: var(--text);
}

.editor-input,
.editor-textarea,
.clinical-textarea,
.raw-textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 10px;
    font-family: 'Monaco', 'Courier New', monospace;
    font-size: 0.85rem;
    line-height: 1.5;
    transition: all 0.2s;
    background: var(--surface);
}

.editor-input:focus,
.editor-textarea:focus,
.clinical-textarea:focus,
.raw-textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.editor-textarea {
    resize: vertical;
}

.clinical-textarea {
    font-family: inherit;
    min-height: 200px;
    resize: vertical;
}

.raw-textarea {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 0.8rem;
    line-height: 1.5;
    background: #fffbeb;
    border-color: #fde68a;
    font-family: 'Monaco', 'Courier New', monospace;
    resize: vertical;
}

/* Threshold Rows */
.thresholds-header {
    display: grid;
    grid-template-columns: 1.5fr 2.5fr auto;
    gap: 12px;
    padding: 10px 12px;
    background: var(--bg);
    border-radius: 10px;
    margin-bottom: 8px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-light);
    border: 1px solid var(--border);
}

.date-label {
    grid-column: 1;
}

.value-label {
    grid-column: 2;
}

.action-label {
    grid-column: 3;
    width: 40px;
}

.threshold-rows {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 12px;
}

.threshold-row {
    display: grid;
    grid-template-columns: 1.5fr 2.5fr auto;
    gap: 12px;
    padding: 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    transition: all 0.2s;
}

.threshold-row:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-sm);
}

.threshold-date input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.85rem;
    font-family: inherit;
    background: var(--surface);
}

.threshold-date input:focus {
    outline: none;
    border-color: var(--primary);
}

.threshold-value-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.threshold-condition {
    flex-shrink: 0;
    width: 70px;
}

.threshold-condition select {
    width: 100%;
    padding: 10px 6px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.85rem;
    font-family: inherit;
    background: var(--surface);
    cursor: pointer;
    text-align: center;
}

.threshold-condition select:focus {
    outline: none;
    border-color: var(--primary);
}

.threshold-value {
    flex: 1;
    min-width: 0;
}

.threshold-value input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.85rem;
    font-family: inherit;
    background: var(--surface);
}

.threshold-value input:focus {
    outline: none;
    border-color: var(--primary);
}

.threshold-units {
    flex: 1;
    min-width: 0;
}

.threshold-units input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.85rem;
    font-family: inherit;
    background: var(--surface);
}

.threshold-units input:focus {
    outline: none;
    border-color: var(--primary);
}

.threshold-remove {
    display: flex;
    align-items: center;
    justify-content: center;
}

.remove-row {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.2rem;
    padding: 8px;
    border-radius: 8px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.remove-row:hover {
    background: #fee2e2;
    color: #dc2626;
}

/* Date section */
.date-section {
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-light);
}

.date-section.hidden {
    display: none;
}

.help-text {
    display: block;
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 6px;
    line-height: 1.4;
}

/* Alert */
.alert {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border-radius: 12px;
    margin-bottom: 24px;
    font-size: 0.85rem;
}

.alert-info {
    background: var(--primary-light);
    border: 1px solid #c7d2fe;
    color: #3730a3;
}

.alert span {
    font-size: 1rem;
}

/* Raw toggle */
.raw-toggle {
    text-align: center;
    margin: 24px 0 12px 0;
    padding: 0;
}

#toggleRawPreview {
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 16px;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-light);
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

#toggleRawPreview:hover {
    background: var(--bg);
    border-color: var(--primary);
    color: var(--primary);
}

/* Raw Preview Container */
#rawPreview {
    margin-top: 12px;
    padding: 0;
}

/* Output Card */
.output-card {
    background: #1e1e2e;
}

.output-card .main-card-header {
    background: #2a2a3a;
    border-bottom-color: #3a3a4a;
}

.output-card .main-card-header h2 {
    color: #e2e8f0;
}

.output-container {
    padding: 0;
}

.code-block {
    background: #1e1e2e;
    color: #e2e8f0;
    padding: 24px;
    margin: 0;
    font-family: 'Monaco', 'Courier New', monospace;
    font-size: 0.75rem;
    line-height: 1.6;
    white-space: pre-wrap;
    word-wrap: break-word;
    max-height: 500px;
    overflow-y: auto;
}

/* Modals */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

.modal-container {
    position: relative;
    background: var(--surface);
    border-radius: 20px;
    width: 90%;
    max-width: 800px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
    animation: modalSlideIn 0.3s ease;
}

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

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    background: var(--bg);
    border-radius: 20px 20px 0 0;
}

.modal-header h3 {
    font-size: 1rem;
    font-weight: 600;
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-light);
    padding: 0 8px;
    line-height: 1;
}

.modal-close:hover {
    color: var(--text);
}

.modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 10px 20px;
    border-top: 1px solid var(--border);
    background: var(--bg);
    border-radius: 0 0 20px 20px;
}

.modal-footer .btn-primary {
    background: var(--primary);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 10px;
    font-weight: 500;
    cursor: pointer;
}

.modal-footer .btn-primary:hover {
    background: var(--primary-dark);
}

/* Template Editor */
.template-editor {
    width: 100%;
    min-height: 300px;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 12px;
    font-family: 'Monaco', 'Courier New', monospace;
    font-size: 0.8rem;
    line-height: 1.6;
    resize: vertical;
    background: var(--surface);
}

.template-editor:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

/* Treatment Logic Modal - Shorter text fields */
#treatmentResponseEditor,
#intentionToTreatEditor {
    min-height: 120px;
    max-height: 180px;
}

/* Clickable Placeholder Styling */
.placeholder-legend {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px 16px;
    margin-bottom: 16px;
}

.placeholder-legend span {
    display: block;
    font-size: 0.8rem;
    margin-bottom: 8px;
    color: var(--text);
}

.legend-list {
    margin: 0;
    padding-left: 20px;
    font-size: 0.75rem;
}

.legend-list li {
    margin-bottom: 4px;
    color: var(--text-light);
}

.legend-list code {
    background: #fffbeb;
    padding: 2px 6px;
    border-radius: 6px;
    font-family: monospace;
    font-size: 0.7rem;
    color: #f59e0b;
    font-weight: 600;
    border: 1px solid #fcd34d;
    cursor: pointer;
    transition: all 0.2s;
}

.legend-list code:hover {
    background: #f59e0b;
    color: white;
    border-color: #f59e0b;
}

/* Clickable placeholder in template editor */
.template-editor {
    cursor: text;
}

/* Make placeholder text stand out in the editor */
.template-editor::-webkit-input-placeholder {
    color: var(--text-muted);
}

/* Edit template button */
#editTemplateBtn {
    background: #f59e0b;
    border: none;
    border-radius: 10px;
    padding: 8px;
    font-size: 0.8rem;
    font-weight: 600;
    color: white;
    cursor: pointer;
    transition: all 0.2s ease;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-shadow: 0 1px 1px rgba(0, 0, 0, 0.1);
    letter-spacing: 0.3px;
    margin-top: 8px;
}

#editTemplateBtn:hover {
    background: #d97706;
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

#editTemplateBtn:active {
    transform: translateY(0);
}

/* Clinical Note Button */
.btn-clinical-note {
    background: #0d9488;
    border: none;
    border-radius: 10px;
    padding: 8px;
    font-size: 0.8rem;
    font-weight: 600;
    color: white;
    cursor: pointer;
    transition: all 0.2s ease;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-shadow: 0 1px 1px rgba(0, 0, 0, 0.1);
    letter-spacing: 0.3px;
    margin-top: 8px;
}

.btn-clinical-note:hover {
    background: #0f766e;
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-clinical-note:active {
    transform: translateY(0);
}

/* Download Button - Green (export/save action) */
#downloadPromptBtn {
    background: var(--primary);  /* #6366f1 - same as your theme */
    border: none;
    border-radius: 10px;
    padding: 8px;
    font-size: 0.8rem;
    font-weight: 600;
    color: white;
    cursor: pointer;
    transition: all 0.2s ease;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-shadow: 0 1px 1px rgba(0, 0, 0, 0.1);
    letter-spacing: 0.3px;
}

#downloadPromptBtn:hover {
    background: var(--primary-dark);  /* #4f46e5 */
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

#downloadPromptBtn:active {
    transform: translateY(0);
}

/* Reset button styling (keep consistent) */
#resetDescriptorBtn {
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text);
}

#resetDescriptorBtn:hover {
    background: var(--border);
    border-color: var(--text-light);
}

/* Toast */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--surface);
    padding: 12px 20px;
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    border-left: 3px solid var(--primary);
    font-size: 0.85rem;
    animation: slideIn 0.2s ease;
    z-index: 1000;
    font-weight: 500;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

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

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

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

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

/* ============================================ */
/* MOBILE RESPONSIVE STYLES */
/* ============================================ */

/* Small phones (portrait) */
@media (max-width: 640px) {
    .nav-container {
        padding: 0 16px;
        height: 56px;
    }
    
    .logo {
        font-size: 1rem;
        gap: 8px;
    }
    
    .logo-icon {
        font-size: 1.25rem;
    }
    
    .container {
        padding: 16px;
        grid-template-columns: 1fr;
        gap: 16px;
    }
    
    .sidebar {
        position: static;
        max-height: none;
        gap: 14px;
    }
    
    .main-card-header {
        flex-direction: column;
        gap: 12px;
        align-items: flex-start;
        padding: 14px 16px;
    }
    
    .main-card-body {
        padding: 16px;
    }
    
    .code-block {
        padding: 16px;
        font-size: 0.7rem;
        max-height: 300px;
    }

    .modal-container {
        width: 95%;
        max-height: 90vh;
    }
    
    .template-editor {
        min-height: 250px;
        font-size: 0.75rem;
    }

    .toast {
        bottom: 16px;
        right: 16px;
        left: 16px;
        text-align: center;
    }
    
    #treatmentResponseEditor,
    #intentionToTreatEditor {
        min-height: 100px;
    }
}

/* Tablets and small desktops */
@media (max-width: 1024px) and (min-width: 641px) {
    .container {
        grid-template-columns: 300px 1fr;
        gap: 24px;
        padding: 24px;
    }
    
    .main-card-body {
        padding: 20px;
    }
}

/* Threshold rows - mobile friendly */
@media (max-width: 768px) {
    .thresholds-header {
        display: none;
    }
    
    .threshold-row {
        grid-template-columns: 1fr;
        gap: 10px;
        padding: 14px;
    }
    
    .threshold-value-row {
        flex-wrap: wrap;
        gap: 8px;
    }
    
    .threshold-condition {
        width: 100%;
    }
    
    .threshold-condition select {
        width: 100%;
        padding: 10px;
    }
    
    .threshold-value {
        flex: 1;
    }
    
    .threshold-units {
        flex: 1;
    }
    
    .threshold-remove {
        justify-content: flex-end;
        margin-top: 4px;
    }
    
    .remove-row {
        width: 40px;
        height: 40px;
    }
}

/* Touch-friendly tap targets */
@media (hover: none) and (pointer: coarse) {
    .descriptor-item,
    .btn-outline,
    .btn-small,
    .btn-text,
    .remove-row,
    .config-select select,
    .sidebar-card-header {
        cursor: default;
        -webkit-tap-highlight-color: transparent;
    }
    
    .descriptor-item:active {
        background: var(--hover-bg);
        transform: scale(0.98);
    }
    
    .btn-outline:active,
    .btn-small:active {
        transform: scale(0.97);
    }
    
    .descriptor-item,
    .btn-outline,
    .btn-small,
    .remove-row {
        min-height: 44px;
    }
}

/* Landscape mode on phones */
@media (max-width: 896px) and (orientation: landscape) {
    .container {
        gap: 16px;
    }
    
    .sidebar {
        max-height: 400px;
    }
    
    .code-block {
        max-height: 250px;
    }
}

/* Large desktops */
@media (min-width: 1600px) {
    .container {
        padding: 40px;
        gap: 40px;
    }
    
    .main-card-header {
        padding: 20px 28px;
    }
    
    .main-card-body {
        padding: 28px;
    }
}