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

:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --secondary: #8b5cf6;
    --accent: #ec4899;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;

    /* Dark mode colors */
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-card: #1e293b;
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;
    --border-color: #334155;
    --shadow: rgba(0, 0, 0, 0.3);
}

* {
    box-sizing: border-box;
}

body {
    font-family: "Inter", "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
    background: linear-gradient(180deg, var(--bg-primary) 0%, var(--bg-secondary) 60%);
    min-height: 100vh;
    margin: 0;
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    line-height: 1.5;
    padding: 20px;
}

/* Removed gradientShift animation */

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes pulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.05);
    }
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    animation: fadeIn 0.6s ease-out;
}

.card {
    background: var(--bg-card);
    border-radius: 18px;
    padding: 2rem;
    box-shadow: 0 30px 80px var(--shadow);
    margin-bottom: 2rem;
    border: none;
}

.card:hover {
    box-shadow: var(--shadow-xl);
    border-color: var(--border-hover);
}

.welcome-card {
    text-align: center;
    padding: 80px 40px;
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 24px;
    box-shadow: var(--shadow-xl);
    border: 1px solid var(--border-color);
    animation: fadeIn 0.8s ease-out;
}

h1 {
    background: linear-gradient(135deg, var(--accent) 0%, var(--primary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 16px;
    font-size: 3em;
    font-weight: 700;
    letter-spacing: -0.02em;
    animation: fadeIn 0.8s ease-out 0.2s both;
}

h2 {
    background: linear-gradient(135deg, var(--accent) 0%, var(--primary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 24px;
    font-weight: 600;
    font-size: 1.75em;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1.25em;
    margin-bottom: 40px;
    font-weight: 400;
    animation: fadeIn 0.8s ease-out 0.4s both;
}

.button-group {
    display: flex;
    gap: 16px;
    justify-content: center;
    flex-wrap: wrap;
    animation: fadeIn 0.8s ease-out 0.6s both;
}

button {
    font: inherit;
    border-radius: 999px;
    padding: 0.75rem 2rem;
    border: 1px solid var(--border-color);
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease, border-color 0.15s ease;
    height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    font-weight: 500;
    background: transparent;
    color: var(--text-primary);
    box-shadow: none;
}

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

.btn-primary,
button.primary {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
    box-shadow: 0 10px 25px rgba(37, 99, 235, 0.25);
}

.btn-primary:hover:not(:disabled),
button.primary:hover:not(:disabled) {
    transform: translateY(-1px);
    background: var(--primary-dark);
    box-shadow: 0 15px 30px rgba(37, 99, 235, 0.35);
}

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

.btn-secondary:hover:not(:disabled),
button.ghost:hover:not(:disabled) {
    background: var(--bg-card);
    border-color: var(--primary);
}

.btn-small,
button.small {
    height: 44px;
    padding: 0.5rem 1.25rem;
    font-size: 14px;
}

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

.btn-outline-primary:hover:not(:disabled) {
    background: rgba(37, 99, 235, 0.08);
    border-color: var(--primary);
}

.btn-outline-danger {
    border-color: #dc2626;
    color: #dc2626;
    background: transparent;
}

.btn-outline-danger:hover:not(:disabled) {
    background: rgba(220, 38, 38, 0.08);
    border-color: #dc2626;
}

.btn-danger {
    background: #dc2626;
    color: #fff;
    border-color: #dc2626;
    box-shadow: 0 10px 25px rgba(220, 38, 38, 0.25);
}

.btn-danger:hover:not(:disabled) {
    transform: translateY(-1px);
    background: #b91c1c;
    box-shadow: 0 15px 30px rgba(220, 38, 38, 0.35);
}

.btn-mode {
    background: transparent;
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    margin: 0;
    height: 36px;
    padding: 0 1rem;
    font-size: 14px;
    border-radius: 999px;
    box-shadow: none;
}

.btn-mode:hover:not(:disabled) {
    transform: translateY(-2px);
    border-color: var(--primary);
    background: rgba(37, 99, 235, 0.08);
}

.btn-mode.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
    box-shadow: 0 10px 25px rgba(37, 99, 235, 0.3);
}

.btn-mode.active:hover:not(:disabled) {
    background: var(--primary-dark);
    box-shadow: 0 15px 30px rgba(37, 99, 235, 0.4);
}

.form-group {
    margin-bottom: 24px;
}

label,
.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.4rem;
    color: var(--text-secondary);
    font-size: 14px;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
select,
.form-group input,
.form-group select {
    width: 100%;
    padding: 0.75rem 1rem;
    border-radius: 0.7rem;
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    color: var(--text-primary);
    font: inherit;
    font-size: 15px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--primary);
    border-radius: 4px;
}

input[type="checkbox"]:focus {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

input::placeholder {
    color: var(--text-muted);
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.error-message {
    color: #dc2626;
    margin-top: 1rem;
    padding: 0.75rem 1rem;
    background: rgba(220, 38, 38, 0.1);
    border-radius: 0.6rem;
    border-left: 3px solid #dc2626;
    font-size: 14px;
    line-height: 1.5;
}

.error-message:empty {
    display: none;
}

.hidden {
    display: none !important;
}

/* Modern Modal Dialog */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    animation: fadeIn 0.2s ease-out;
}

.modal-overlay.hidden {
    display: none;
}

.modal {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 32px;
    max-width: 500px;
    width: 90%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    animation: slideIn 0.3s ease-out;
}

.modal-kid-form {
    max-width: 600px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.modal-kid-form h2 {
    margin-bottom: 20px;
    flex-shrink: 0;
}

.modal-kid-form form {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    flex: 1;
    min-height: 0;
}

/* Form Tabs */
.form-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 24px;
    border-bottom: 2px solid var(--border-color);
    flex-shrink: 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE and Edge */
}

.form-tabs::-webkit-scrollbar {
    display: none; /* Chrome, Safari, Opera */
}

.form-tab {
    background: transparent;
    border: none;
    padding: 10px 16px;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 500;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    transition: all 0.2s ease;
    white-space: nowrap;
    flex-shrink: 0;
    position: relative;
    border-radius: 8px 8px 0 0;
}

.form-tab:hover {
    color: var(--text-primary);
    background: rgba(99, 102, 241, 0.05);
}

.form-tab.active {
    color: var(--primary);
    background: rgba(99, 102, 241, 0.1);
    border-bottom-color: var(--primary);
    font-weight: 600;
}

/* Tab Content */
.form-tab-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 8px;
    margin-right: -8px;
    min-height: 0;
}

.form-tab-content::-webkit-scrollbar {
    width: 6px;
}

.form-tab-content::-webkit-scrollbar-track {
    background: transparent;
}

.form-tab-content::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

.tab-pane {
    display: none;
}

.tab-pane.active {
    display: block;
    animation: fadeIn 0.2s ease-out;
}

/* Form Actions */
.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
    flex-shrink: 0;
}

textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    border-radius: 0.7rem;
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    color: var(--text-primary);
    font: inherit;
    font-size: 15px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    resize: vertical;
    font-family: inherit;
}

textarea:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-20px) scale(0.95);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal h3 {
    margin: 0 0 16px 0;
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
}

.modal p {
    margin: 0 0 24px 0;
    color: var(--text-secondary);
    font-size: 15px;
    line-height: 1.5;
}

.modal-input {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 15px;
    background: var(--bg-dark);
    color: var(--text-primary);
    margin-bottom: 24px;
    font-family: inherit;
}

.modal-input:focus {
    outline: none;
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.modal-buttons {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

.modal-buttons button {
    min-width: 100px;
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 32px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
}

.header h1 {
    font-size: 28px;
    font-weight: 600;
    margin: 0;
}

.header h2 {
    font-size: 22px;
    font-weight: 600;
    margin: 0;
}

.kid-item {
    display: flex;
    flex-direction: column;
    padding: 1rem 1.5rem;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    transition: all 0.3s ease;
    margin-bottom: 1rem;
    background: var(--bg-card);
}


.kid-item.expanded {
    background: var(--bg-primary);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.kid-history-expanded {
    width: 100%;
    animation: slideDown 0.3s ease-out;
    overflow: hidden;
}

@keyframes slideDown {
    from {
        opacity: 0;
        max-height: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        max-height: 2000px;
        transform: translateY(0);
    }
}

.kid-item:hover {
    border-color: #2563eb;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.15);
}

.kid-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.badge {
    background: linear-gradient(135deg, var(--danger) 0%, #dc2626 100%);
    color: white;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    margin-left: 12px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.conversation-item {
    margin-bottom: 32px;
    padding: 24px;
    border: 2px solid var(--border-color);
    border-radius: 16px;
    background: var(--bg-card);
    transition: all 0.3s ease;
    animation: fadeIn 0.4s ease-out;
}

.conversation-item:hover {
    border-color: var(--accent);
    box-shadow: var(--shadow-md);
}

.messages {
    margin-top: 20px;
}

.message {
    display: block;
    width: fit-content;
    padding: 0.875rem 1.125rem;
    margin-bottom: 0.75rem;
    border-radius: 1rem;
    max-width: 80%;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    word-break: break-word;
    color: var(--text-primary);
    font-size: 15px;
    line-height: 1.5;
    animation: fadeIn 0.2s ease-out;
}

.message ol,
.message ul {
    margin: 0.75rem 0;
    padding-left: 1.75rem;
    padding-right: 0.5rem;
}

.message ol {
    list-style-type: decimal;
}

.message ul {
    list-style-type: disc;
}

.message li {
    margin: 0.5rem 0;
    line-height: 1.6;
    padding-left: 0.5rem;
}

.message ol li,
.message ul li {
    white-space: normal;
}

.message.user {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.3) 0%, rgba(139, 92, 246, 0.3) 100%);
    margin-left: auto;
    text-align: right;
    border-bottom-right-radius: 4px;
    border: 1px solid rgba(99, 102, 241, 0.2);
}

.message.assistant {
    background: linear-gradient(135deg, rgba(236, 72, 153, 0.2) 0%, rgba(139, 92, 246, 0.2) 100%);
    margin-right: auto;
    border-bottom-left-radius: 4px;
    border: 1px solid rgba(236, 72, 153, 0.2);
}

.message.system {
    background: rgba(148, 163, 184, 0.1);
    margin: 0 auto;
    text-align: center;
    font-style: italic;
    max-width: 100%;
    color: var(--text-muted);
    border: 1px solid var(--border-color);
}

.message.typing {
    display: inline-flex;
    gap: 6px;
    align-items: center;
    padding: 0.75rem 1rem;
    min-width: 56px;
}


.typing-dot {
    width: 6px;
    height: 6px;
    border-radius: 999px;
    background: var(--text-muted);
    opacity: 0.6;
    animation: typingPulse 1.2s infinite ease-in-out;
}

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

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

@keyframes typingPulse {

    0%,
    80%,
    100% {
        transform: scale(0.85);
        opacity: 0.4;
    }

    40% {
        transform: scale(1);
        opacity: 1;
    }
}

.blocked {
    color: var(--danger);
    font-weight: 600;
    display: block;
    margin-top: 8px;
    font-size: 0.9em;
}

/* Chat UI */
.chat-container {
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 24px;
    box-shadow: var(--shadow-xl);
    display: flex;
    flex-direction: column;
    height: calc(100vh - 40px);
    max-height: 900px;
    border: 1px solid var(--border-color);
    overflow: hidden;
    animation: fadeIn 0.6s ease-out;
}

.chat-header {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    align-items: center;
    padding: 16px 24px;
    border-bottom: 2px solid var(--border-color);
    background: rgba(30, 41, 59, 0.8);
    gap: 1rem;
}

.chat-header-left {
    display: flex;
    justify-content: flex-start;
    align-items: center;
}

.chat-header-center {
    display: flex;
    justify-content: center;
    align-items: center;
}

.chat-header-right {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 10px;
}

.chat-header h1 {
    font-size: 1.75em;
    margin: 0;
}

.mode-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
    padding: 3rem 1.5rem;
}

.mode-buttons-header {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    background: var(--bg-darker);
    scroll-behavior: smooth;
}

.chat-messages::-webkit-scrollbar {
    width: 8px;
}

.chat-messages::-webkit-scrollbar-track {
    background: var(--bg-card);
    border-radius: 10px;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, var(--accent) 0%, var(--primary) 100%);
    border-radius: 10px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: var(--accent);
}

.chat-input-area {
    padding: 24px 32px;
    border-top: 2px solid var(--border-color);
    background: var(--bg-card);
    backdrop-filter: blur(10px);
}

.current-mode {
    margin-bottom: 12px;
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.current-mode span {
    font-weight: 700;
    color: var(--accent);
}

#chatForm {
    display: flex;
    gap: 12px;
}

#messageInput {
    flex: 1;
    padding: 0 20px;
    height: 52px;
    border: 2px solid var(--border-color);
    border-radius: 16px;
    font-size: 16px;
    font-family: inherit;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background: var(--bg-card-hover);
    color: var(--text-primary);
}

#chatForm .btn-primary {
    height: 52px;
    padding: 0 24px;
}

#messageInput::placeholder {
    color: var(--text-muted);
}

#messageInput:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.2);
}

#messageInput:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.blocked-message {
    padding: 16px 20px;
    background: rgba(245, 158, 11, 0.2);
    border: 2px solid var(--warning);
    border-radius: 16px;
    margin: 12px 24px;
    color: #fbbf24;
    font-weight: 600;
    animation: slideIn 0.3s ease-out;
    box-shadow: var(--shadow-sm);
}

/* Color Picker */
.color-picker-container {
    position: relative;
    display: inline-block;
}

.color-picker-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid var(--border-color);
    cursor: pointer;
    transition: all 0.15s ease;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
}

.color-picker-btn svg {
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

.color-picker-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(37, 99, 235, 0.35);
}

.color-picker-popup {
    position: absolute;
    top: 50px;
    right: 0;
    background: var(--bg-card);
    border: 2px solid var(--border-color);
    border-radius: 16px;
    padding: 20px;
    box-shadow: var(--shadow-xl);
    min-width: 300px;
    animation: fadeIn 0.2s ease-out;
    z-index: 1000;
}

.color-picker-popup h3 {
    color: var(--text-primary);
    margin: 0 0 16px 0;
    font-size: 13px;
    font-weight: 600;
    text-align: center;
}

.color-options {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 10px;
}

.color-option {
    padding: 0;
    background: transparent;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-sm);
    position: relative;
}

.color-option:hover {
    box-shadow: var(--shadow-md);
    border-color: rgba(255, 255, 255, 0.3);
}

.color-option.selected {
    border-color: var(--text-primary);
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.3);
}

.color-option.selected::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-size: 18px;
    font-weight: bold;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.color-custom {
    margin-top: 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    font-size: 13px;
    color: var(--text-secondary);
}

#customColor {
    width: 42px;
    height: 32px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 0;
    background: transparent;
    cursor: pointer;
}

/* Loading animation */
@keyframes shimmer {
    0% {
        background-position: -1000px 0;
    }

    100% {
        background-position: 1000px 0;
    }
}

.loading {
    background: linear-gradient(90deg, #1e293b 25%, #334155 50%, #1e293b 75%);
    background-size: 1000px 100%;
    animation: shimmer 2s infinite;
}

@media (max-width: 768px) {
    body {
        padding: 12px;
    }

    .container {
        padding: 0;
    }

    .welcome-card {
        padding: 60px 24px;
    }

    h1 {
        font-size: 2em;
    }

    .card {
        padding: 24px;
        border-radius: 16px;
    }

    .kid-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .kid-actions {
        width: 100%;
        margin-top: 12px;
    }

    .chat-container {
        height: calc(100vh - 24px);
        border-radius: 16px;
    }

    .chat-header {
        grid-template-columns: 1fr;
        gap: 12px;
        padding: 16px 20px;
    }

    .chat-header-left,
    .chat-header-center,
    .chat-header-right {
        justify-content: center;
    }

    .chat-header-center {
        order: 2;
    }

    .chat-header-right {
        order: 3;
    }

    .mode-buttons {
        padding: 40px 20px;
    }

    .btn-mode {
        width: 100%;
        max-width: 300px;
    }

    .message {
        max-width: 90%;
    }

    .color-picker-container {
        top: 10px;
        right: 10px;
    }

    .color-picker-popup {
        right: -20px;
        min-width: 260px;
    }

    /* Responsive modal */
    .modal-kid-form {
        max-width: 95%;
        max-height: 95vh;
        padding: 16px;
    }

    .modal-kid-form h2 {
        font-size: 20px;
        margin-bottom: 16px;
    }

    .form-tabs {
        gap: 2px;
        margin-bottom: 16px;
        margin-left: -4px;
        margin-right: -4px;
        padding: 0 4px;
    }

    .form-tab {
        padding: 8px 12px;
        font-size: 13px;
        min-width: auto;
    }

    .form-group {
        margin-bottom: 20px;
    }

    .form-actions {
        flex-direction: column;
        gap: 8px;
    }

    .form-actions button {
        width: 100%;
    }

    /* Parent Panel Mobile Optimizations */
    .header {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }

    .header-actions {
        display: flex;
        flex-direction: column;
        width: 100%;
        gap: 8px;
    }

    .header-actions button {
        width: 100%;
    }

    .header h1 {
        font-size: 24px;
    }

    /* Mobile-friendly conversations table - convert to cards */
    .conversations-table-container {
        overflow-x: visible;
    }

    .conversations-table-container table {
        display: none;
    }

    .conversations-card-view {
        display: block;
    }

    .conversation-card {
        background: var(--bg-card);
        border: 1px solid var(--border-color);
        border-radius: 12px;
        padding: 16px;
        margin-bottom: 12px;
        cursor: pointer;
        transition: all 0.2s ease;
    }

    .conversation-card:active {
        background: var(--bg-primary);
        transform: scale(0.98);
    }

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

    .conversation-card-title {
        font-weight: 600;
        color: var(--text-primary);
        font-size: 16px;
        flex: 1;
        margin-right: 8px;
    }

    .conversation-card-meta {
        display: flex;
        flex-wrap: wrap;
        gap: 12px;
        font-size: 13px;
        color: var(--text-secondary);
        margin-bottom: 12px;
    }

    .conversation-card-meta-item {
        display: flex;
        align-items: center;
        gap: 4px;
    }

    .conversation-card-actions {
        display: flex;
        gap: 8px;
    }

    .conversation-card-actions button {
        flex: 1;
    }

    /* Conversation preview modal mobile */
    .modal {
        max-width: 95vw !important;
        max-height: 95vh !important;
        margin: 2.5vh auto;
    }

    #conversationPreviewTitle {
        font-size: 16px !important;
        line-height: 1.3 !important;
        margin-bottom: 12px !important;
    }

    #conversationPreviewContent {
        max-height: calc(95vh - 120px) !important;
        padding: 12px !important;
    }

    /* User messages - keep constrained on mobile */
    #conversationPreviewContent .message-user .message-bubble {
        max-width: 85% !important;
    }

    /* Bot messages (assistant) - allow to grow wider on mobile for longer content */
    #conversationPreviewContent .message-assistant .message-bubble {
        max-width: 95% !important;
    }

    /* Button groups stack on mobile */
    div[style*="display: flex"][style*="gap"] {
        flex-wrap: wrap;
    }

    /* Kid item mobile */
    .kid-item {
        padding: 12px;
    }

    .kid-item > div:first-child {
        flex-direction: column;
        gap: 12px;
    }

    .kid-item .kid-actions {
        flex-direction: column;
        width: 100%;
    }

    .kid-item .kid-actions button {
        width: 100%;
    }

    .kid-history-expanded {
        margin-top: 12px;
    }

    /* Stats cards mobile */
    .stats-grid {
        grid-template-columns: 1fr !important;
    }

    /* Activity chart mobile */
    .activity-chart {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
}

/* Desktop: show table, hide cards */
@media (min-width: 769px) {
    .conversations-card-view {
        display: none;
    }
}

/* Test Chat Modal */
.modal-test-chat {
    max-width: 800px;
    max-height: 95vh;
    height: 95vh;
    display: flex;
    flex-direction: column;
    padding: 0;
    overflow: hidden;
}

.test-chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 2px solid var(--border-color);
    flex-shrink: 0;
}

.test-chat-header h2 {
    margin: 0;
    font-size: 20px;
}

.test-chat-container {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.test-chat-modes {
    display: flex;
    gap: 8px;
    padding: 16px 24px;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
    justify-content: center;
    flex-wrap: wrap;
}

.test-mode-btn {
    min-width: 100px;
}

.test-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    background: var(--bg-primary);
    min-height: 0;
}

.test-chat-messages::-webkit-scrollbar {
    width: 8px;
}

.test-chat-messages::-webkit-scrollbar-track {
    background: var(--bg-card);
    border-radius: 10px;
}

.test-chat-messages::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 10px;
}

.test-message {
    display: block;
    width: fit-content;
    padding: 0.875rem 1.125rem;
    margin-bottom: 0.75rem;
    border-radius: 1rem;
    max-width: 80%;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    word-break: break-word;
    color: var(--text-primary);
    font-size: 15px;
    line-height: 1.5;
    animation: fadeIn 0.2s ease-out;
}

.test-message ol,
.test-message ul {
    margin: 0.75rem 0;
    padding-left: 1.75rem;
    padding-right: 0.5rem;
}

.test-message ol {
    list-style-type: decimal;
}

.test-message ul {
    list-style-type: disc;
}

.test-message li {
    margin: 0.5rem 0;
    line-height: 1.6;
    padding-left: 0.5rem;
}

.test-message ol li,
.test-message ul li {
    white-space: normal;
}

.test-message-user {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.3) 0%, rgba(139, 92, 246, 0.3) 100%);
    margin-left: auto;
    text-align: right;
    border-bottom-right-radius: 4px;
    border: 1px solid rgba(99, 102, 241, 0.2);
}

.test-message-assistant {
    background: linear-gradient(135deg, rgba(236, 72, 153, 0.2) 0%, rgba(139, 92, 246, 0.2) 100%);
    margin-right: auto;
    border-bottom-left-radius: 4px;
    border: 1px solid rgba(236, 72, 153, 0.2);
}

.test-message-system {
    background: rgba(148, 163, 184, 0.1);
    margin: 0 auto;
    text-align: center;
    font-style: italic;
    max-width: 100%;
    color: var(--text-muted);
    border: 1px solid var(--border-color);
}

.test-message code {
    background: rgba(0, 0, 0, 0.2);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
}

.test-message a {
    color: var(--primary);
    text-decoration: underline;
}

.test-message a:hover {
    color: var(--primary-dark);
}

.test-message strong {
    font-weight: 600;
}

.test-message em {
    font-style: italic;
}

.test-chat-input-area {
    padding: 16px 24px;
    border-top: 2px solid var(--border-color);
    background: var(--bg-card);
    flex-shrink: 0;
}

.test-chat-input-area form {
    display: flex;
    gap: 12px;
}

.test-chat-input-area #testMessageInput {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid var(--border-color);
    border-radius: 12px;
    background: var(--bg-card);
    color: var(--text-primary);
    font-size: 15px;
    font-family: inherit;
}

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

@media (max-width: 768px) {
    .modal-test-chat {
        max-width: 95%;
        max-height: 95vh;
        height: 95vh;
    }

    .test-chat-header {
        padding: 16px;
    }

    .test-chat-header h2 {
        font-size: 18px;
    }

    .test-chat-modes {
        padding: 12px 16px;
    }

    .test-mode-btn {
        padding: 8px 12px;
        font-size: 13px;
        min-width: auto;
    }

    .test-chat-messages {
        padding: 16px;
    }

    .test-message {
        max-width: 90%;
        font-size: 14px;
    }

    .test-chat-input-area {
        padding: 12px 16px;
    }

    .test-chat-input-area form {
        flex-direction: column;
    }

    .test-chat-input-area #testMessageInput {
        width: 100%;
    }
}

/* Remove global transitions to prevent jank */
/* Specific elements that need transitions have them defined */