* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: system-ui, sans-serif; background: #f5f5f5; min-height: 100vh; }
.container { max-width: 1200px; margin: 0 auto; padding: 20px; }
h1 { text-align: center; margin-bottom: 20px; color: #333; }

.top-toolbar {
    background: rgba(255,255,255,0.96);
    border-radius: 16px;
    padding: 14px 16px;
    box-shadow: 0 8px 24px rgba(15,23,42,0.08);
    margin-bottom: 20px;
    backdrop-filter: blur(10px);
}

.toolbar-main {
    display: flex;
    align-items: center;
    gap: 12px;
}

.toolbar-play-btn {
    flex: 1;
}

.toolbar-settings {
    margin-top: 14px;
    border-top: 1px solid #edf2f7;
    padding-top: 14px;
}

.toolbar-settings .control-group {
    margin-bottom: 16px;
    padding-bottom: 16px;
}

.toolbar-settings .control-group.last-group {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.main-layout { display: block; }
.content-panel { flex: 1; min-width: 0; }
.hidden { display: none !important; }

.input-card {
    background: white;
    padding: 16px;
    border-radius: 12px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.06);
}

.text-input {
    width: 100%;
    min-height: 120px;
    resize: vertical;
    border: 1px solid #ddd;
    border-radius: 10px;
    padding: 12px;
    font-size: 14px;
    line-height: 1.5;
    color: #333;
    margin-bottom: 10px;
}

.text-input:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 3px rgba(0,123,255,0.12);
}

.btn-primary {
    width: 100%;
    padding: 12px 16px;
    border: none;
    border-radius: 10px;
    background: linear-gradient(135deg, #34a853, #1f8a3d);
    color: white;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 2px 8px rgba(52,168,83,0.28);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(52,168,83,0.36);
}

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

.input-hint {
    margin-top: 8px;
    font-size: 12px;
    color: #888;
    text-align: center;
}

.upload-area {
    border: 2px dashed #ccc;
    border-radius: 12px;
    padding: 30px 15px;
    text-align: center;
    cursor: pointer;
    background: white;
    transition: all 0.2s;
}
.upload-area:hover { border-color: #007bff; background: #f8f9ff; }
.upload-area.dragover { border-color: #007bff; background: #e7f2ff; }
.upload-area p { color: #666; font-size: 14px; }

.input-screen {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.words-screen {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.words-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.words-summary {
    color: #667085;
    font-size: 14px;
    font-weight: 500;
}

.btn-secondary {
    border: none;
    border-radius: 999px;
    padding: 10px 16px;
    background: #e8f1ff;
    color: #0056b3;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-secondary:hover {
    background: #d6e7ff;
}

.words-section { flex: 1; min-height: 0; }
.words-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    background: white;
    padding: 15px;
    border-radius: 12px;
    min-height: 360px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.06);
}
.word-item {
    display: flex;
    align-items: center;
    justify-content: center;
    width: calc((100% - 32px) / 5);
    min-width: 80px;
    height: 44px;
    padding: 4px 8px;
    background: #e9ecef;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 14px;
}
.word-item:hover { background: #dee2e6; transform: translateY(-1px); }
.word-item.selected { background: #007bff; color: white; box-shadow: 0 2px 8px rgba(0,123,255,0.3); }
.word-item .word-index { color: #999; font-size: 11px; margin-right: 4px; }
.word-item.selected .word-index { color: #ccc; }
.word-item .word-text { white-space: nowrap; }

.control-group {
    margin-bottom: 18px;
    padding-bottom: 18px;
    border-bottom: 1px solid #eee;
}
.control-group:last-of-type { border-bottom: none; margin-bottom: 15px; padding-bottom: 0; }
.control-label {
    font-size: 12px;
    color: #999;
    margin-bottom: 10px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.control-row { display: flex; align-items: center; justify-content: center; gap: 8px; }
.control-row.split { flex-wrap: wrap; }
.control-item { display: flex; flex-direction: column; gap: 4px; flex: 1; min-width: 100px; }
.control-item label { font-size: 11px; color: #888; }

.control-row.params { flex-wrap: wrap; gap: 10px; justify-content: flex-start; }
.param-item { display: flex; align-items: center; gap: 4px; }
.param-item label { font-size: 12px; color: #666; }
.param-item input { width: 50px; padding: 5px 8px; border: 1px solid #ddd; border-radius: 6px; font-size: 13px; text-align: center; }
.param-item input:focus { outline: none; border-color: #007bff; }
.param-item .param-unit { font-size: 12px; color: #999; }

select {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 13px;
    background: white;
    cursor: pointer;
    width: 100%;
}
select:focus { outline: none; border-color: #007bff; }
.full-width { width: 100%; }

.btn-auto {
    width: 100%;
    padding: 12px 20px;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    background: linear-gradient(135deg, #007bff, #0056b3);
    color: white;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
    box-shadow: 0 2px 8px rgba(0,123,255,0.3);
}
.btn-auto:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0,123,255,0.4); }
.btn-auto:active { transform: translateY(0); }
.btn-auto.is-playing {
    background: linear-gradient(135deg, #ff9f1a, #f57c00);
    box-shadow: 0 2px 8px rgba(245,124,0,0.35);
}
.btn-auto.is-playing:hover { box-shadow: 0 4px 12px rgba(245,124,0,0.45); }

.status {
    text-align: center;
    color: #888;
    font-size: 13px;
    margin-top: 16px;
    padding: 8px;
    background: #f8f9fa;
    border-radius: 6px;
}

@media (max-width: 900px) {
    .container {
        padding: 16px;
    }

    .toolbar-main {
        flex-wrap: wrap;
    }

    .toolbar-play-btn {
        order: -1;
        width: 100%;
        flex-basis: 100%;
    }

    .words-list {
        min-height: 240px;
    }

    .word-item {
        width: calc((100% - 16px) / 3);
    }
}

@media (max-width: 600px) {
    body {
        background: #eef2f6;
        overflow: hidden;
    }

    .container {
        padding: 12px;
        height: 100vh;
        display: flex;
        flex-direction: column;
    }

    h1 {
        font-size: 24px;
        margin-bottom: 16px;
    }

    .top-toolbar {
        position: sticky;
        top: 0;
        z-index: 20;
        margin-bottom: 12px;
        border-radius: 18px;
        flex-shrink: 0;
    }

    .input-card,
    .words-list,
    .upload-area {
        border-radius: 16px;
    }

    .main-layout,
    .content-panel,
    .words-screen,
    .words-section {
        min-height: 0;
    }

    .main-layout,
    .content-panel {
        flex: 1;
        display: flex;
        flex-direction: column;
    }

    .input-screen,
    .words-screen {
        flex: 1;
        overflow: hidden;
    }

    .words-section {
        overflow: hidden;
    }

    .words-list {
        height: 100%;
        min-height: 0;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 20px;
    }

    .control-group {
        margin-bottom: 16px;
        padding-bottom: 16px;
    }

    .control-row.split,
    .control-row.params {
        flex-direction: column;
        align-items: stretch;
    }

    .control-item,
    .param-item {
        width: 100%;
    }

    .param-item {
        justify-content: space-between;
    }

    .param-item input {
        width: 72px;
    }

    .words-header {
        align-items: center;
        justify-content: flex-end;
    }

    .btn-secondary,
    .btn-primary,
    .btn-auto {
        min-height: 46px;
    }

    .toolbar-main {
        gap: 10px;
    }

    .toolbar-settings {
        max-height: 45vh;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .text-input {
        min-height: 140px;
        font-size: 16px;
    }

    .word-item {
        width: calc((100% - 8px) / 2);
        min-width: 0;
        height: 48px;
        font-size: 15px;
    }

    .word-item .word-text {
        overflow: hidden;
        text-overflow: ellipsis;
    }
}