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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    min-height: 100vh;
    color: #fff;
}

.app-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 10px 15px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 15px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    margin-bottom: 10px;
}

.title-section h1 {
    font-size: 20px;
    font-weight: 600;
}

.config-section {
    display: flex;
    align-items: center;
    gap: 15px;
}

.config-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.config-item label {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.7);
}

.config-item input {
    width: 200px;
    padding: 6px 10px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    font-size: 13px;
}

.config-item select {
    padding: 6px 10px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    font-size: 13px;
}

.config-item select option {
    background: #2a2a4a;
    color: #fff;
}

.config-small {
    width: auto;
}

.connection-info {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #ff4757;
}

.status-dot.connected {
    background: #2ed573;
}

.mobile-nav {
    display: none;
}

.main-wrapper {
    display: flex;
    gap: 15px;
    flex: 1;
    min-height: 0;
    align-items: stretch;
}

.main-wrapper.reversed {
    flex-direction: row-reverse;
}

.sidebar {
    width: 180px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.mode-tabs {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 15px;
}

.mode-tab {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 14px;
}

.mode-tab:hover {
    background: rgba(255, 255, 255, 0.1);
}

.mode-tab.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-color: transparent;
    color: #fff;
}

.stats-panel {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    padding: 12px;
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.stats-section {
    padding: 8px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.stats-section:last-child {
    border-bottom: none;
}

.stats-title {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.5);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stats-content {
    font-size: 15px;
    color: #fff;
    font-weight: 500;
}

.status-value {
    font-size: 13px;
    line-height: 1.4;
    color: rgba(255, 255, 255, 0.8);
    word-break: break-word;
    min-height: 32px;
}

.status-value.success { color: #2ed573; }
.status-value.error { color: #ff4757; }
.status-value.warning { color: #ffa502; }

.token-row {
    display: flex;
    gap: 15px;
}

.token-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.token-label {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.5);
}

.token-value {
    font-size: 14px;
    color: #fff;
    font-weight: 600;
}

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.practice-panel {
    display: none;
    flex-direction: column;
    gap: 10px;
    flex: 1;
}

.practice-panel.active {
    display: flex;
}

.card-display {
    background: rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    padding: 20px;
    height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.card-placeholder {
    color: rgba(255, 255, 255, 0.4);
    text-align: center;
}

.card-content {
    width: 100%;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.card-prompt {
    font-size: 20px;
    font-weight: 500;
    margin-bottom: 10px;
    text-align: center;
}

.hint-row {
    display: flex;
    align-items: center;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

.card-keywords {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}

.keyword-tag {
    padding: 4px 12px;
    background: rgba(102, 126, 234, 0.3);
    border-radius: 15px;
    font-size: 14px;
    color: #a8b4ff;
}

.btn-hint {
    padding: 6px 14px;
    background: rgba(255, 193, 7, 0.2);
    border: 1px solid rgba(255, 193, 7, 0.4);
    border-radius: 18px;
    color: #ffc107;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-hint:hover:not(:disabled) {
    background: rgba(255, 193, 7, 0.3);
}

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

.speak-btn-card {
    position: absolute;
    top: -5px;
    right: 0;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s ease;
}

.speak-btn-card:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}

.question-content {
    text-align: center;
    width: 100%;
}

.question-prompt-text {
    font-size: 16px;
    color: rgba(255, 255, 255, 0.7);
    margin-bottom: 8px;
}

.question-text {
    font-size: 22px;
    font-weight: 600;
    color: #f5576c;
}

.question-hint {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.5);
    margin-top: 8px;
}

.action-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
    padding: 5px 0;
}

.btn {
    padding: 10px 24px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 6px;
}

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

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.btn-record {
    background: linear-gradient(135deg, #f5576c 0%, #f093fb 100%);
    color: #fff;
}

.btn-record:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(245, 87, 108, 0.4);
}

.btn-record.recording {
    animation: pulse 1s infinite;
}

.btn-small {
    padding: 4px 10px;
    font-size: 12px;
}

.btn-layout {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    color: rgba(255, 255, 255, 0.7);
}

.btn-layout:hover {
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
}

.btn-result {
    display: none;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #fff;
    padding: 10px 16px;
}

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

.result-panel {
    display: none;
}

.result-section {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 15px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.result-row {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 8px;
}

.result-label {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.6);
    white-space: nowrap;
    min-width: 70px;
}

.result-text {
    font-size: 18px;
    color: #fff;
    flex: 1;
}

.correct-row .result-text {
    color: #2ed573;
}

.evaluation-panel {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.score-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 8px;
}

.score-item-main {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 15px;
    background: rgba(102, 126, 234, 0.2);
    border-radius: 6px;
}

.score-item-main .score-label {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.7);
}

.score-value-main {
    font-size: 28px;
    font-weight: 700;
    color: #fff;
}

.score-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 6px;
}

.score-item .score-label {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.5);
}

.score-value {
    font-size: 18px;
    font-weight: 600;
    color: #fff;
}

.score-value.excellent { color: #2ed573; }
.score-value.good { color: #7bed9f; }
.score-value.acceptable { color: #ffa502; }
.score-value.poor { color: #ff4757; }

.reminders-row {
    display: flex;
    align-items: flex-start;
    gap: 15px;
    padding: 10px 12px;
    background: rgba(255, 193, 7, 0.08);
    border-radius: 8px;
}

.reminders-label {
    font-size: 14px;
    color: #ffc107;
    white-space: nowrap;
    min-width: 70px;
}

.reminders-text {
    font-size: 15px;
    color: rgba(255, 255, 255, 0.85);
    flex: 1;
    line-height: 1.5;
}

.stats-full, .records-full {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 15px;
    height: 100%;
    overflow-y: auto;
}

.stats-full h4, .records-full h4 {
    margin-bottom: 15px;
    font-size: 16px;
}

.stats-card {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.stats-card-item {
    padding: 12px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
}

.stats-card-label {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.5);
    margin-bottom: 6px;
}

.stats-card-value {
    font-size: 16px;
    color: #fff;
}

.records-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.record-item {
    padding: 10px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    font-size: 13px;
}

.record-item .record-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 6px;
    color: rgba(255, 255, 255, 0.6);
    font-size: 11px;
}

.record-item .record-text {
    color: #fff;
}

.record-item .record-score {
    color: #2ed573;
    font-weight: 600;
}

.no-records {
    color: rgba(255, 255, 255, 0.4);
    text-align: center;
    padding: 40px;
}

.recording-indicator {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(245, 87, 108, 0.95);
    padding: 15px 30px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 16px;
    font-weight: 500;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    z-index: 1001;
}

.recording-dot {
    width: 12px;
    height: 12px;
    background: #fff;
    border-radius: 50%;
    animation: blink 1s infinite;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

@media screen and (max-width: 768px) {
    .app-container {
        padding: 8px;
    }

    .top-bar {
        flex-direction: column;
        gap: 10px;
        padding: 10px;
    }

    .title-section h1 {
        font-size: 18px;
    }

    .config-section {
        display: flex;
        flex-wrap: nowrap;
        gap: 8px;
        width: 100%;
        align-items: center;
    }

    .config-item {
        flex: 1;
    }

    .config-item input {
        width: 100%;
    }

    .config-item select {
        width: 100%;
    }

    .connection-info {
        display: flex;
        flex: 0 0 auto;
        min-width: auto;
    }

    .btn-layout {
        display: none;
    }

    .mobile-nav {
        display: flex;
        gap: 6px;
        padding: 8px;
        background: rgba(255, 255, 255, 0.05);
        border-radius: 10px;
        margin-bottom: 10px;
        overflow-x: auto;
    }

    .mobile-nav-btn {
        flex: 1;
        min-width: 70px;
        padding: 8px 12px;
        background: rgba(255, 255, 255, 0.05);
        border: 1px solid rgba(255, 255, 255, 0.1);
        border-radius: 8px;
        color: rgba(255, 255, 255, 0.7);
        font-size: 12px;
        cursor: pointer;
        white-space: nowrap;
    }

    .mobile-nav-btn.active {
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        border-color: transparent;
        color: #fff;
    }

    .sidebar {
        display: none;
    }

    .main-wrapper {
        flex-direction: column;
    }

    .main-content {
        flex: 1;
    }

    .card-display {
        height: auto;
        min-height: 140px;
        padding: 20px 15px;
        flex: 1;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .card-content {
        width: 100%;
    }

    .card-prompt {
        font-size: 20px;
        margin-bottom: 12px;
    }

    .hint-row {
        margin-top: 10px;
    }

    .action-buttons {
        flex-direction: row;
        gap: 10px;
        padding: 10px 0;
    }

    .btn {
        flex: 1;
        padding: 14px 16px;
        font-size: 15px;
    }

    .btn-result {
        display: flex;
        flex: 0 0 auto;
        padding: 14px 16px;
    }

    .practice-panel {
        flex: 1;
        display: flex;
        flex-direction: column;
    }

    .practice-panel.active {
        display: flex;
    }

    .result-panel {
        display: none;
        position: fixed;
        top: 0;
        right: 0;
        bottom: 0;
        width: 85%;
        max-width: 350px;
        background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
        z-index: 1000;
        transform: translateX(100%);
        transition: transform 0.3s ease;
        box-shadow: -5px 0 30px rgba(0, 0, 0, 0.3);
        flex-direction: column;
    }

    .result-panel.show {
        display: flex;
        transform: translateX(0);
    }

    .result-panel-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 15px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        font-size: 16px;
        font-weight: 600;
    }

    .btn-close {
        width: 32px;
        height: 32px;
        background: rgba(255, 255, 255, 0.1);
        border: none;
        border-radius: 50%;
        color: #fff;
        font-size: 16px;
        cursor: pointer;
    }

    .result-panel-content {
        flex: 1;
        overflow-y: auto;
        padding: 15px;
    }

    .result-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
        padding: 8px 10px;
    }

    .result-label {
        min-width: auto;
    }

    .result-text {
        font-size: 16px;
    }

    .score-row {
        flex-wrap: wrap;
        gap: 8px;
    }

    .score-item-main {
        width: 100%;
        justify-content: center;
    }

    .score-item {
        flex: 1;
        min-width: 80px;
        justify-content: center;
    }

    .reminders-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
    }

    .recording-indicator {
        padding: 12px 20px;
        font-size: 14px;
        top: 20%;
    }
}

@media screen and (max-width: 480px) {
    .title-section h1 {
        font-size: 16px;
    }

    .mobile-nav-btn {
        font-size: 11px;
        padding: 6px 10px;
    }

    .card-prompt {
        font-size: 16px;
    }

    .btn {
        padding: 10px 12px;
        font-size: 13px;
    }

    .score-value-main {
        font-size: 24px;
    }

    .score-value {
        font-size: 16px;
    }
}
