/* ========================================
   Jogga Web App — Dark Theme
   ======================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
    /* Core palette */
    --color-primary: #6366f1;
    --color-primary-hover: #818cf8;
    --color-primary-subtle: rgba(99, 102, 241, 0.15);
    --color-primary-glow: rgba(99, 102, 241, 0.3);

    /* Surfaces */
    --color-bg: #0f0f13;
    --color-bg-secondary: #1a1a23;
    --color-bg-tertiary: #24243a;
    --color-bg-elevated: #1e1e2e;
    --color-bg-hover: #2a2a3e;

    /* Text */
    --color-text: #e4e4ed;
    --color-text-secondary: #8b8ba0;
    --color-text-tertiary: #5a5a72;
    --color-text-on-primary: #ffffff;

    /* Borders */
    --color-border: #2a2a3e;
    --color-border-subtle: #1f1f30;

    /* Semantic */
    --color-success: #34d399;
    --color-warning: #fbbf24;
    --color-error: #f87171;
    --color-error-subtle: rgba(248, 113, 113, 0.12);
    --color-strava: #FC4C02;

    /* Chat bubbles */
    --color-user-bubble: linear-gradient(135deg, #6366f1, #8b5cf6);
    --color-assistant-bubble: #1a1a23;

    /* Radii */
    --radius-bubble: 18px;
    --radius-card: 14px;
    --radius-input: 12px;
    --radius-sm: 8px;

    /* Layout */
    --max-chat-width: 800px;
    --journal-width: 380px;
    --toolbar-height: 56px;

    /* Typography */
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-medium: 0.25s ease;
}

/* Reset */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    height: 100%;
    font-family: var(--font-family);
    color: var(--color-text);
    background: var(--color-bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

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

::-webkit-scrollbar-track {
    background: transparent;
}

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

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

/* ========================================
   Screens
   ======================================== */

.screen {
    height: 100dvh;
    display: flex;
    flex-direction: column;
}

.screen.hidden {
    display: none;
}

/* ========================================
   Login Screen
   ======================================== */

.login-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 32px;
    gap: 48px;
    background: radial-gradient(ellipse at 50% 0%, rgba(99, 102, 241, 0.08) 0%, transparent 60%);
}

.login-branding {
    text-align: center;
}

.coach-avatar {
    display: inline-block;
    border-radius: 50%;
    background: #dddde8;
    object-fit: cover;
    object-position: center 15%;
    box-shadow: 0 4px 24px rgba(99, 102, 241, 0.25);
    border: 3px solid #dddde8;
}

.login-logo {
    width: 120px;
    height: 120px;
    margin-bottom: 16px;
}

.login-branding h1 {
    font-size: 42px;
    font-weight: 700;
    letter-spacing: -1px;
    background: linear-gradient(135deg, #e4e4ed, #8b8ba0);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.login-branding .subtitle {
    font-size: 16px;
    color: var(--color-text-secondary);
    margin-top: 8px;
    letter-spacing: 0.2px;
}

/* ========================================
   Questionnaire Screen
   ======================================== */

.questionnaire-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 48px 32px;
    max-width: 600px;
    margin: 0 auto;
    width: 100%;
    overflow-y: auto;
}

.questionnaire-branding {
    text-align: center;
    margin-bottom: 40px;
}

.questionnaire-logo {
    width: 100px;
    height: 100px;
    margin-bottom: 16px;
}

.questionnaire-branding h1 {
    font-size: 26px;
    font-weight: 700;
    letter-spacing: -0.3px;
}

.questionnaire-branding .subtitle {
    font-size: 15px;
    color: var(--color-text-secondary);
    margin-top: 10px;
    line-height: 1.5;
}

.questionnaire-content {
    width: 100%;
}

.questionnaire-progress {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 28px;
}

.questionnaire-progress-bar {
    flex: 1;
    height: 4px;
    background: var(--color-bg-tertiary);
    border-radius: 2px;
    overflow: hidden;
}

.questionnaire-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--color-primary), #8b5cf6);
    border-radius: 2px;
    transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.questionnaire-progress-text {
    font-size: 13px;
    color: var(--color-text-tertiary);
    white-space: nowrap;
    font-weight: 500;
}

.questionnaire-question h3 {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 20px;
    line-height: 1.4;
    letter-spacing: -0.2px;
}

.questionnaire-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 20px;
}

.questionnaire-option {
    display: block;
    width: 100%;
    text-align: left;
    padding: 14px 18px;
    border: 1.5px solid var(--color-border);
    border-radius: var(--radius-card);
    background: var(--color-bg-secondary);
    font-size: 15px;
    font-family: var(--font-family);
    color: var(--color-text);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.questionnaire-option:hover {
    border-color: var(--color-primary);
    background: var(--color-primary-subtle);
}

.questionnaire-option.selected {
    border-color: var(--color-primary);
    background: var(--color-primary-subtle);
    box-shadow: 0 0 0 1px var(--color-primary), inset 0 0 0 1px rgba(99, 102, 241, 0.1);
    font-weight: 500;
}

.questionnaire-freetext {
    margin-bottom: 8px;
}

.questionnaire-freetext textarea {
    width: 100%;
    resize: none;
    border: 1.5px solid var(--color-border);
    border-radius: var(--radius-input);
    padding: 12px 16px;
    font-family: var(--font-family);
    font-size: 14px;
    color: var(--color-text);
    background: var(--color-bg-secondary);
    outline: none;
    transition: border-color var(--transition-fast);
}

.questionnaire-freetext textarea:focus {
    border-color: var(--color-primary);
}

.questionnaire-freetext textarea::placeholder {
    color: var(--color-text-tertiary);
}

.questionnaire-nav {
    display: flex;
    justify-content: space-between;
    margin-top: 28px;
}

.questionnaire-loading {
    text-align: center;
    padding: 64px 24px;
    color: var(--color-text-secondary);
}

.questionnaire-loading-icon {
    width: 80px;
    height: 80px;
    margin-bottom: 20px;
    animation: pulse-glow 2s ease-in-out infinite;
}

@keyframes pulse-glow {
    0%, 100% { filter: drop-shadow(0 0 8px rgba(99, 102, 241, 0.2)); }
    50% { filter: drop-shadow(0 0 24px rgba(99, 102, 241, 0.5)); }
}

.questionnaire-loading h3 {
    font-size: 20px;
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: 10px;
}

.questionnaire-loading-subtitle {
    animation: pulse-text 1.8s ease-in-out infinite;
}

.questionnaire-loading-progress {
    width: 200px;
    height: 3px;
    background: var(--color-bg-tertiary);
    border-radius: 2px;
    margin: 20px auto 0;
    overflow: hidden;
}

.questionnaire-loading-progress-bar {
    height: 100%;
    width: 40%;
    background: linear-gradient(90deg, var(--color-primary), #8b5cf6);
    border-radius: 2px;
    animation: loading-slide 1.8s ease-in-out infinite;
}

@keyframes loading-slide {
    0% { transform: translateX(-100%); }
    50% { transform: translateX(250%); }
    100% { transform: translateX(-100%); }
}

.questionnaire-error {
    text-align: center;
    padding: 64px 24px;
    color: var(--color-error);
}

/* Inline loading (between questions) */
.questionnaire-loading-inline {
    text-align: center;
    padding: 24px 16px;
    color: var(--color-text-secondary);
    font-size: 14px;
    animation: pulse-text 1.8s ease-in-out infinite;
}

@keyframes pulse-text {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
}

/* Free-text row (textarea + voice button side by side) */
.questionnaire-freetext-row {
    display: flex;
    gap: 8px;
    align-items: flex-start;
}

.questionnaire-freetext-row textarea {
    flex: 1;
}

/* Number input */
.questionnaire-number-input {
    margin-bottom: 8px;
}

.questionnaire-number-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.questionnaire-number-field {
    flex: 1;
    max-width: 240px;
    border: 1.5px solid var(--color-border);
    border-radius: var(--radius-input);
    padding: 14px 18px;
    font-family: var(--font-family);
    font-size: 20px;
    font-weight: 600;
    color: var(--color-text);
    background: var(--color-bg-secondary);
    outline: none;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
    -moz-appearance: textfield;
}

.questionnaire-number-field::-webkit-outer-spin-button,
.questionnaire-number-field::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.questionnaire-number-field:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-subtle);
}

.questionnaire-number-field::placeholder {
    color: var(--color-text-tertiary);
    font-weight: 400;
    font-size: 15px;
}

.questionnaire-number-unit {
    font-size: 14px;
    color: var(--color-text-secondary);
    font-weight: 500;
    white-space: nowrap;
}

/* Text input */
.questionnaire-text-input {
    margin-bottom: 8px;
}

.questionnaire-text-row {
    display: flex;
    gap: 8px;
    align-items: flex-start;
}

.questionnaire-text-field {
    flex: 1;
    resize: none;
    border: 1.5px solid var(--color-border);
    border-radius: var(--radius-input);
    padding: 14px 18px;
    font-family: var(--font-family);
    font-size: 15px;
    color: var(--color-text);
    background: var(--color-bg-secondary);
    outline: none;
    line-height: 1.5;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.questionnaire-text-field:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-subtle);
}

.questionnaire-text-field::placeholder {
    color: var(--color-text-tertiary);
}

/* Voice button */
.btn-voice {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border: 1.5px solid var(--color-border);
    border-radius: var(--radius-input);
    background: var(--color-bg-secondary);
    color: var(--color-text-secondary);
    cursor: pointer;
    flex-shrink: 0;
    transition: all var(--transition-fast);
}

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

.btn-voice.recording {
    border-color: var(--color-error);
    color: var(--color-error);
    background: var(--color-error-subtle);
    animation: recording-pulse 1.5s ease-in-out infinite;
}

@keyframes recording-pulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(248, 113, 113, 0.3);
    }
    50% {
        box-shadow: 0 0 0 8px rgba(248, 113, 113, 0);
    }
}

/* ========================================
   Buttons
   ======================================== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 32px;
    border: none;
    border-radius: var(--radius-input);
    font-size: 15px;
    font-weight: 600;
    font-family: var(--font-family);
    cursor: pointer;
    transition: all var(--transition-fast);
    letter-spacing: 0.1px;
}

.btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.btn-primary {
    background: linear-gradient(135deg, var(--color-primary), #8b5cf6);
    color: white;
    box-shadow: 0 2px 12px rgba(99, 102, 241, 0.3);
}

.btn-primary:hover:not(:disabled) {
    box-shadow: 0 4px 20px rgba(99, 102, 241, 0.45);
    transform: translateY(-1px);
}

.btn-primary:active:not(:disabled) {
    transform: translateY(0);
}

.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--color-text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-icon:hover {
    background: var(--color-bg-tertiary);
    color: var(--color-text);
}

.btn-text {
    border: none;
    background: transparent;
    color: var(--color-text-secondary);
    font-size: 13px;
    font-weight: 500;
    font-family: var(--font-family);
    cursor: pointer;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

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

.btn-secondary {
    background: var(--color-bg-tertiary);
    color: var(--color-text);
    border: 1px solid var(--color-border);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--color-bg-hover);
    border-color: var(--color-text-tertiary);
}

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

.btn-danger-text:hover {
    background: var(--color-error-subtle);
    color: var(--color-error);
}

/* ========================================
   Toolbar
   ======================================== */

.toolbar {
    display: flex;
    align-items: center;
    height: var(--toolbar-height);
    padding: 0 12px;
    border-bottom: 1px solid var(--color-border);
    background: var(--color-bg-secondary);
    flex-shrink: 0;
    gap: 4px;
    backdrop-filter: blur(12px);
}

.toolbar-title {
    flex: 1;
    text-align: center;
    font-size: 16px;
    font-weight: 700;
    letter-spacing: -0.3px;
    background: linear-gradient(135deg, var(--color-primary), #a78bfa);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ========================================
   Content Area
   ======================================== */

.content-area {
    flex: 1;
    display: flex;
    min-height: 0;
}

/* ========================================
   Chat Area
   ======================================== */

.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 24px 16px;
    display: flex;
    flex-direction: column;
}

.messages-container .messages-inner {
    max-width: var(--max-chat-width);
    width: 100%;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Welcome message */
.welcome-message {
    text-align: center;
    padding: 80px 24px 48px;
    color: var(--color-text-secondary);
}

.welcome-message .welcome-logo {
    width: 100px;
    height: 100px;
    margin-bottom: 20px;
}

.welcome-message h2 {
    font-size: 24px;
    font-weight: 700;
    color: var(--color-text);
    margin-bottom: 10px;
    letter-spacing: -0.3px;
}

.welcome-message p {
    font-size: 15px;
    line-height: 1.6;
    color: var(--color-text-secondary);
}

.archive-note {
    font-size: 13px;
    color: var(--color-text-tertiary);
    margin-top: 16px;
    padding: 8px 16px;
    background: var(--color-bg-secondary);
    border-radius: var(--radius-sm);
    display: inline-block;
}

/* ========================================
   Message Bubbles
   ======================================== */

.message {
    display: flex;
    flex-direction: column;
    max-width: 72%;
    animation: message-in 0.25s ease-out;
}

@keyframes message-in {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

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

.message-bubble {
    padding: 12px 16px;
    border-radius: var(--radius-bubble);
    line-height: 1.55;
    font-size: 15px;
    word-wrap: break-word;
    white-space: pre-wrap;
}

.message.user .message-bubble {
    background: var(--color-user-bubble);
    color: white;
    border-bottom-right-radius: 6px;
    box-shadow: 0 2px 12px rgba(99, 102, 241, 0.25);
}

.message.assistant .message-bubble {
    background: var(--color-assistant-bubble);
    color: var(--color-text);
    border-bottom-left-radius: 6px;
    border: 1px solid var(--color-border);
    white-space: normal;
}

/* Markdown rendered content in assistant messages */
.message.assistant strong { font-weight: 600; }
.message.assistant em { font-style: italic; }
.message.assistant ul, .message.assistant ol { margin: 8px 0; padding-left: 20px; }
.message.assistant li { margin: 4px 0; }
.message.assistant h3, .message.assistant h4, .message.assistant h5, .message.assistant h6 { font-size: 1em; font-weight: 600; margin: 12px 0 6px; }
.message.assistant p { margin: 6px 0; }
.message.assistant p:first-child { margin-top: 0; }
.message.assistant p:last-child { margin-bottom: 0; }
.message.assistant blockquote {
    border-left: 3px solid var(--color-border);
    margin: 8px 0;
    padding: 4px 12px;
    color: var(--color-text-secondary);
}
.message.assistant hr {
    border: none;
    border-top: 1px solid var(--color-border);
    margin: 12px 0;
}

.message-time {
    font-size: 11px;
    color: var(--color-text-tertiary);
    margin-top: 6px;
    padding: 0 4px;
}

/* ========================================
   Typing Indicator
   ======================================== */

.typing-indicator {
    padding: 0 16px 12px;
}

.typing-indicator.hidden {
    display: none;
}

.typing-bubble {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 12px 16px;
    background: var(--color-assistant-bubble);
    border-radius: var(--radius-bubble);
    border-bottom-left-radius: 6px;
    border: 1px solid var(--color-border);
}

.typing-bubble span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--color-primary);
    animation: typing-bounce 1.4s ease-in-out infinite;
}

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

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

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

/* ========================================
   Input Bar
   ======================================== */

/* Input area wrapper (context tags + input bar) */
.input-area {
    flex-shrink: 0;
    border-top: 1px solid var(--color-border);
    background: var(--color-bg);
}

/* Context tags */
.context-tags {
    display: flex;
    gap: 6px;
    padding: 8px 16px 0;
    flex-wrap: wrap;
}

.context-tags:empty {
    display: none;
}

.context-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    font-size: 11px;
    font-weight: 500;
    color: var(--color-text-tertiary);
    background: var(--color-bg-secondary);
    border: 1px solid var(--color-border-subtle);
    border-radius: 12px;
    line-height: 1.4;
}

.context-tag svg {
    flex-shrink: 0;
    opacity: 0.7;
}

.input-bar {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    padding: 12px 16px 16px;
    background: var(--color-bg);
    flex-shrink: 0;
}

.input-bar textarea {
    flex: 1;
    resize: none;
    border: 1.5px solid var(--color-border);
    border-radius: var(--radius-input);
    padding: 11px 16px;
    font-family: var(--font-family);
    font-size: 15px;
    line-height: 1.5;
    color: var(--color-text);
    background: var(--color-bg-secondary);
    outline: none;
    max-height: 120px;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.input-bar textarea:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-subtle);
}

.input-bar textarea::placeholder {
    color: var(--color-text-tertiary);
}

.btn-send {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border: none;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--color-primary), #8b5cf6);
    color: white;
    cursor: pointer;
    flex-shrink: 0;
    transition: all var(--transition-fast);
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}

.btn-send:hover:not(:disabled) {
    box-shadow: 0 4px 16px rgba(99, 102, 241, 0.45);
    transform: translateY(-1px);
}

.btn-send:disabled {
    background: var(--color-bg-tertiary);
    color: var(--color-text-tertiary);
    cursor: not-allowed;
    box-shadow: none;
}

/* ========================================
   Panel shared styles
   ======================================== */

.journal-panel,
.strava-panel,
.calendar-panel {
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    background: var(--color-bg-secondary);
    overflow: hidden;
    border-right: 1px solid var(--color-border);
}

.journal-panel.hidden,
.strava-panel.hidden,
.calendar-panel.hidden {
    display: none;
}

/* ========================================
   Journal Panel
   ======================================== */

.journal-panel {
    width: var(--journal-width);
}

.journal-header {
    display: flex;
    align-items: center;
    padding: 14px 16px;
    border-bottom: 1px solid var(--color-border);
    flex-shrink: 0;
}

.journal-header h2 {
    flex: 1;
    font-size: 16px;
    font-weight: 600;
    letter-spacing: -0.2px;
}

.journal-header-actions {
    display: flex;
    gap: 2px;
}

.journal-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

/* Journal Sections */
.journal-section {
    background: var(--color-bg-elevated);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-card);
    padding: 16px;
    margin-bottom: 12px;
}

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

.journal-section-title {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--color-primary);
    margin-bottom: 12px;
}

.journal-row {
    display: flex;
    align-items: baseline;
    gap: 8px;
    padding: 3px 0;
    font-size: 14px;
}

.journal-row-label {
    color: var(--color-text-secondary);
    width: 80px;
    flex-shrink: 0;
    font-size: 13px;
}

.journal-row-value {
    color: var(--color-text);
    font-weight: 500;
}

.journal-row-icon {
    flex-shrink: 0;
    width: 20px;
    text-align: center;
}

.journal-detail {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    padding: 3px 0;
}

.journal-detail-icon {
    flex-shrink: 0;
}

/* HR Zone bars */
.hr-zone-bars {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.hr-zone-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
}

.hr-zone-label {
    width: 50px;
    flex-shrink: 0;
    font-weight: 600;
    font-size: 12px;
}

.hr-zone-bar {
    flex: 1;
    height: 6px;
    border-radius: 3px;
}

.hr-zone-value {
    width: 90px;
    flex-shrink: 0;
    text-align: right;
    font-size: 12px;
    color: var(--color-text-secondary);
    font-weight: 500;
}

/* Run entries */
.run-entry {
    padding: 10px 0;
    border-bottom: 1px solid var(--color-border-subtle);
}

.run-entry:last-child {
    border-bottom: none;
}

.run-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.run-type {
    font-size: 14px;
    font-weight: 600;
}

.run-date {
    font-size: 12px;
    color: var(--color-text-tertiary);
}

.run-stats {
    font-size: 13px;
    color: var(--color-text-secondary);
    margin-top: 3px;
}

.run-fitness {
    font-size: 12px;
    color: var(--color-success);
    margin-top: 3px;
    font-weight: 500;
}

/* Scheduled run entries */
.scheduled-entry {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
}

.scheduled-info {
    display: flex;
    flex-direction: column;
}

.scheduled-type {
    font-size: 14px;
    font-weight: 600;
}

.scheduled-distance {
    font-size: 12px;
    color: var(--color-text-tertiary);
}

.scheduled-date {
    font-size: 12px;
    color: var(--color-text-tertiary);
}

/* Insight entries */
.insight-entry {
    display: flex;
    gap: 8px;
    padding: 5px 0;
    align-items: flex-start;
}

.insight-icon {
    flex-shrink: 0;
    font-size: 13px;
}

.insight-text {
    font-size: 13px;
    line-height: 1.5;
    color: var(--color-text-secondary);
}

/* Insight date badge */
.insight-date-badge {
    display: inline-block;
    font-size: 10px;
    font-weight: 600;
    color: var(--color-primary-hover);
    background: var(--color-primary-subtle);
    padding: 1px 6px;
    border-radius: 4px;
    margin-right: 4px;
    vertical-align: middle;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

/* Injury-related insight highlighting */
.insight-entry.insight-injury {
    background: var(--color-error-subtle);
    border-radius: var(--radius-sm);
    padding: 5px 6px;
    margin: 2px -6px;
}

.insight-entry.insight-injury .insight-icon {
    color: var(--color-warning);
}

/* Hidden insights for expand/collapse */
.insight-hidden {
    display: none !important;
}

/* Show all button for insights */
.insight-show-all {
    display: block;
    width: 100%;
    text-align: center;
    margin-top: 8px;
    font-size: 12px;
    color: var(--color-primary);
}

/* Journal empty state */
.journal-empty {
    text-align: center;
    padding: 48px 24px;
    color: var(--color-text-secondary);
}

.journal-empty-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.journal-empty h3 {
    font-size: 17px;
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: 8px;
}

.journal-empty p {
    font-size: 14px;
    line-height: 1.5;
    margin-bottom: 20px;
}

/* Journal loading */
.journal-loading {
    display: flex;
    justify-content: center;
    padding: 40px;
    color: var(--color-text-secondary);
}

/* ========================================
   Strava Panel
   ======================================== */

.strava-panel {
    width: var(--journal-width);
}

.strava-header {
    display: flex;
    align-items: center;
    padding: 14px 16px;
    border-bottom: 1px solid var(--color-border);
    flex-shrink: 0;
}

.strava-header h2 {
    flex: 1;
    font-size: 16px;
    font-weight: 600;
    letter-spacing: -0.2px;
}

.strava-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

/* Strava empty / connect state */
.strava-empty {
    text-align: center;
    padding: 48px 24px;
    color: var(--color-text-secondary);
}

.strava-empty-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.strava-empty h3 {
    font-size: 17px;
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: 8px;
}

.strava-empty p {
    font-size: 14px;
    line-height: 1.5;
    margin-bottom: 20px;
}

.strava-connect-btn {
    background: linear-gradient(135deg, #FC4C02, #ff6a33);
    color: white;
    text-decoration: none;
    padding: 12px 28px;
    font-size: 15px;
    box-shadow: 0 2px 12px rgba(252, 76, 2, 0.3);
}

.strava-connect-btn:hover {
    box-shadow: 0 4px 20px rgba(252, 76, 2, 0.45);
}

/* Strava actions bar */
.strava-actions {
    display: flex;
    gap: 8px;
}

.strava-sync-btn {
    flex: 1;
    background: var(--color-bg-elevated);
    color: var(--color-text);
    border: 1px solid var(--color-border);
    padding: 10px 16px;
    font-size: 14px;
}

.strava-sync-btn:hover:not(:disabled) {
    background: var(--color-bg-hover);
}

.strava-analyze-btn {
    flex: 1;
    font-size: 14px;
    padding: 10px 16px;
}

/* Activity cards */
.strava-activity-list {
    margin-top: 12px;
}

.strava-activity-card {
    background: var(--color-bg-elevated);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-card);
    padding: 14px 16px;
    margin-bottom: 8px;
}

.strava-activity-card:last-child {
    margin-bottom: 0;
}

.strava-activity-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.strava-activity-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--color-text);
}

.strava-activity-date {
    font-size: 12px;
    color: var(--color-text-tertiary);
}

.strava-activity-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    font-size: 13px;
    color: var(--color-text-secondary);
}

.strava-hr {
    color: var(--color-strava);
}

.strava-elev {
    color: var(--color-text-secondary);
}

.strava-empty-hint {
    text-align: center;
    padding: 24px 16px;
    color: var(--color-text-tertiary);
    font-size: 14px;
}

/* Strava detail rows */
.strava-splits,
.strava-efforts {
    font-size: 12px;
    color: var(--color-text-secondary);
    margin-top: 6px;
    line-height: 1.6;
}

.strava-detail-label {
    font-weight: 600;
    color: var(--color-text);
}

/* ========================================
   Calendar Panel
   ======================================== */

.calendar-panel {
    width: 480px;
}

.calendar-header {
    display: flex;
    align-items: center;
    padding: 14px 16px;
    border-bottom: 1px solid var(--color-border);
    flex-shrink: 0;
}

.calendar-header h2 {
    flex: 1;
    font-size: 16px;
    font-weight: 600;
    letter-spacing: -0.2px;
}

.calendar-header-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

.date-override-input {
    font-family: var(--font-family);
    font-size: 12px;
    padding: 5px 10px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-bg-elevated);
    color: var(--color-text);
    color-scheme: dark;
    transition: border-color var(--transition-fast);
}

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

.btn-small {
    font-size: 11px;
    padding: 5px 10px;
}

.calendar-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

.calendar-loading {
    display: flex;
    justify-content: center;
    padding: 40px;
    color: var(--color-text-secondary);
}

/* Calendar nav */
.calendar-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.calendar-month-label {
    font-size: 16px;
    font-weight: 600;
    letter-spacing: -0.2px;
}

/* Calendar grid */
.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 3px;
}

.calendar-day-header {
    text-align: center;
    font-size: 11px;
    font-weight: 600;
    color: var(--color-text-tertiary);
    padding: 4px 0 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.calendar-cell {
    min-height: 72px;
    border: 1px solid var(--color-border-subtle);
    border-radius: var(--radius-sm);
    padding: 4px;
    font-size: 12px;
    background: var(--color-bg-elevated);
    display: flex;
    flex-direction: column;
    gap: 2px;
    transition: background var(--transition-fast);
}

.calendar-cell.empty {
    border: none;
    background: transparent;
}

.calendar-cell.today {
    border-color: var(--color-primary);
    background: var(--color-primary-subtle);
    box-shadow: 0 0 0 1px var(--color-primary);
}

.calendar-day-num {
    font-size: 12px;
    font-weight: 500;
    color: var(--color-text-tertiary);
    margin-bottom: 2px;
}

.calendar-cell.today .calendar-day-num {
    color: var(--color-primary-hover);
    font-weight: 700;
}

/* Calendar events */
.calendar-event {
    padding: 2px 5px;
    border-radius: 4px;
    font-size: 10px;
    line-height: 1.3;
    display: flex;
    align-items: center;
    gap: 3px;
    overflow: hidden;
}

.calendar-event.completed {
    opacity: 0.6;
}

.calendar-event-type {
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.calendar-event-dist {
    font-weight: 400;
    white-space: nowrap;
}

.calendar-event-check {
    margin-left: auto;
    font-size: 10px;
}

/* Rest day icon (zero-distance runs) */
.calendar-event-rest-icon {
    font-size: 9px;
    flex-shrink: 0;
}

/* Race day event styling */
.calendar-event.race-day {
    font-weight: 700;
    border-left-width: 4px !important;
}

.calendar-event-race-icon {
    margin-left: auto;
    font-size: 10px;
    flex-shrink: 0;
}

/* Race day cell styling */
.calendar-cell.race-day-cell {
    border-color: #fbbf24;
    box-shadow: 0 0 0 1px #fbbf24, inset 0 0 8px rgba(251, 191, 36, 0.08);
    background: rgba(251, 191, 36, 0.06);
}

.calendar-cell.race-day-cell .calendar-day-num {
    color: #fcd34d;
    font-weight: 700;
}

/* Schedule gap styling */
.calendar-cell.schedule-gap {
    background: rgba(148, 163, 184, 0.04);
    border-style: dashed;
    border-color: var(--color-border-subtle);
}

.calendar-gap-label {
    font-size: 8px;
    color: var(--color-text-tertiary);
    text-align: center;
    opacity: 0.7;
    font-style: italic;
    padding-top: 2px;
}

/* Calendar legend */
.calendar-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid var(--color-border);
}

.calendar-legend-item {
    font-size: 11px;
    padding: 3px 10px;
    border-radius: 6px;
    font-weight: 500;
}

/* ========================================
   Error Toast
   ======================================== */

.error-toast {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: white;
    padding: 12px 24px;
    border-radius: var(--radius-input);
    font-size: 14px;
    font-weight: 500;
    z-index: 200;
    animation: toast-in 0.3s ease;
    max-width: 90%;
    text-align: center;
    box-shadow: 0 4px 20px rgba(239, 68, 68, 0.3);
}

@keyframes toast-in {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

/* ========================================
   Responsive - Mobile
   ======================================== */

@media (max-width: 768px) {
    .message {
        max-width: 88%;
    }

    .journal-panel,
    .strava-panel,
    .calendar-panel {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        z-index: 100;
        border-right: none;
    }

    .calendar-grid {
        font-size: 0.7rem;
    }

    .calendar-event-type {
        font-size: 0.55rem;
    }

    .calendar-event-dist {
        font-size: 0.5rem;
    }

    .input-area {
        padding-bottom: max(0px, calc(env(safe-area-inset-bottom) - 16px));
    }

    .toolbar {
        padding: 0 8px;
    }

    .btn-danger-text {
        font-size: 11px;
        padding: 4px 8px;
    }
}
