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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
        "Microsoft YaHei", sans-serif;
    background: #f5f5f7;
    color: #333;
    min-height: 100vh;
}

#app {
    max-width: 560px;
    margin: 0 auto;
    padding: 16px;
    min-height: 100vh;
}

.view {
    display: block;
}

.view.hidden {
    display: none;
}

/* Header */
.header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.header h1 {
    font-size: 20px;
    font-weight: 700;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.progress-text {
    font-size: 14px;
    color: #888;
    white-space: nowrap;
}

/* Buttons */
.btn {
    padding: 8px 18px;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    cursor: pointer;
    transition: all 0.15s;
    font-family: inherit;
    white-space: nowrap;
}

.btn:active {
    transform: scale(0.96);
}

.btn-primary {
    background: #4f6ef7;
    color: #fff;
}

.btn-primary:hover {
    background: #3b5de7;
}

.btn-secondary {
    background: #e8e8ed;
    color: #333;
}

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

.btn-back {
    background: transparent;
    color: #4f6ef7;
    font-size: 16px;
    padding: 8px 0;
}

.btn-large {
    width: 100%;
    padding: 16px;
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 8px;
}

.btn-icon {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: #e8e8ed;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.btn-icon:hover {
    background: #d8d8dd;
}

.btn-del {
    background: transparent;
    color: #ccc;
    font-size: 16px;
    padding: 4px 8px;
    border-radius: 6px;
    flex-shrink: 0;
}

.btn-del:hover {
    background: #fce4ec;
    color: #c62828;
}

.btn-sort {
    background: transparent;
    color: #ccc;
    font-size: 12px;
    padding: 2px 4px;
    border-radius: 4px;
    line-height: 1;
    flex-shrink: 0;
}

.btn-sort:hover:not(:disabled) {
    background: #e8e8ed;
    color: #4f6ef7;
}

.btn-sort:disabled {
    opacity: 0.3;
    cursor: default;
}

.btn-reset {
    background: #fff3e0;
    color: #e65100;
    flex: 0;
    padding: 8px 14px;
    font-size: 14px;
    font-weight: 600;
}

.btn-reset:hover {
    background: #ffe0b2;
}

.btn-familiar {
    background: #e3f2fd;
    color: #1565c0;
    flex: 1;
    padding: 14px 8px;
    font-size: 16px;
    font-weight: 600;
}

.btn-familiar:hover {
    background: #bbdefb;
}

.btn-known {
    background: #e8f5e9;
    color: #2e7d32;
    flex: 1;
    padding: 14px 8px;
    font-size: 16px;
    font-weight: 600;
}

.btn-known:hover {
    background: #c8e6c9;
}

.btn-unknown {
    background: #fce4ec;
    color: #c62828;
    flex: 1;
    padding: 14px 8px;
    font-size: 16px;
    font-weight: 600;
}

.btn-unknown:hover {
    background: #f8bbd0;
}

/* Batch Bar */
.batch-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #fff;
    border-top: 1px solid #e0e0e0;
    padding: 10px 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    z-index: 100;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.06);
    flex-wrap: wrap;
}

.batch-bar.hidden {
    display: none;
}

#batch-count {
    font-size: 13px;
    color: #666;
    white-space: nowrap;
}

.batch-bar .btn {
    font-size: 14px;
    padding: 8px 14px;
}

/* Group Select */
.group-select {
    font-size: 18px;
    color: #4f6ef7;
    width: 24px;
    flex-shrink: 0;
    cursor: pointer;
    text-align: center;
}

.group-select:hover {
    color: #3b5de7;
}

.group-todo {
    font-size: 20px;
    color: #4f6ef7;
    width: 28px;
    flex-shrink: 0;
    cursor: pointer;
}

.group-todo:hover {
    color: #3b5de7;
}

/* Word Group List */
.group-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 80px;
}

.group-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: #fff;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.15s;
    border: 2px solid transparent;
}

.group-item:hover {
    background: #f0f0f5;
}

.group-item.selected {
    border-color: #4f6ef7;
    background: #f0f2ff;
}

.group-index {
    font-size: 14px;
    color: #999;
    width: 28px;
    flex-shrink: 0;
}

.group-name {
    flex: 1;
    font-size: 16px;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.group-count {
    font-size: 13px;
    color: #999;
    flex-shrink: 0;
}

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #999;
}

.empty-state p {
    margin-bottom: 8px;
    font-size: 16px;
}

.empty-state .hint {
    font-size: 14px;
    color: #bbb;
}

/* Note Section */
.note-section {
    margin-top: 8px;
}

.note-section textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid #e0e0e0;
    border-radius: 10px;
    font-size: 14px;
    font-family: inherit;
    resize: none;
    background: #fff;
    transition: border-color 0.2s;
    line-height: 1.5;
}

.note-section textarea:focus {
    outline: none;
    border-color: #4f6ef7;
}

/* Detail Page */
.detail-actions {
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding: 20px 0;
}

.test-options {
    text-align: center;
}

.test-options h3 {
    font-size: 16px;
    margin-bottom: 12px;
    color: #666;
}

.test-options .btn {
    margin: 4px;
}

/* Flashcard */
.flashcard-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    padding: 16px 0;
}

.flashcard {
    width: 100%;
    min-height: 260px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 32px 24px;
    text-align: center;
    cursor: default;
    transition: transform 0.3s, box-shadow 0.3s;
}

.flashcard-word {
    font-size: 32px;
    font-weight: 700;
    color: #222;
    margin-bottom: 16px;
    word-break: break-word;
}

.flashcard-divider {
    width: 40px;
    height: 3px;
    background: #e0e0e0;
    border-radius: 2px;
    margin-bottom: 16px;
}

.flashcard-def {
    font-size: 18px;
    color: #555;
    line-height: 1.6;
    word-break: break-word;
}

.flashcard-def.hidden {
    display: none;
}

.test-card {
    cursor: pointer;
    min-height: 300px;
}

.test-card.revealed {
    cursor: default;
}

.tap-hint {
    font-size: 14px;
    color: #bbb;
    margin-top: 12px;
}

.flashcard-nav {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    padding: 8px 0;
}

.flashcard-nav .btn {
    flex: 1;
    padding: 14px;
    font-size: 16px;
    font-weight: 600;
}

/* Test Squares */
.test-squares {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px 0;
    justify-content: center;
}

.test-square {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    background: #e8e8ed;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 600;
    color: #888;
    cursor: pointer;
    transition: all 0.2s;
    border: 2px solid transparent;
}

.test-square:hover {
    background: #d8d8dd;
}

.test-square.current {
    border-color: #4f6ef7;
    background: #f0f2ff;
    color: #4f6ef7;
    transform: scale(1.15);
}

.test-square.known {
    background: #c8e6c9;
    color: #2e7d32;
}

.test-square.unknown {
    background: #ffcdd2;
    color: #c62828;
}

.test-square.familiar {
    background: #bbdefb;
    color: #1565c0;
}

/* Test Buttons */
.test-buttons {
    display: flex;
    gap: 8px;
    padding: 16px 0;
}

.test-buttons.hidden {
    display: none;
}

/* Test Complete */
.test-complete {
    text-align: center;
    padding: 40px 0;
}

.test-complete h2 {
    font-size: 28px;
    margin-bottom: 8px;
}

.test-complete p {
    font-size: 16px;
    color: #666;
    margin-bottom: 20px;
}

.test-complete .btn {
    padding: 14px 40px;
}

.test-complete.hidden {
    display: none;
}

/* Responsive */
@media (max-width: 400px) {
    #app {
        padding: 10px;
    }

    .flashcard-word {
        font-size: 26px;
    }

    .flashcard-def {
        font-size: 16px;
    }

    .flashcard {
        min-height: 220px;
        padding: 24px 16px;
    }

    .btn-large {
        font-size: 16px;
    }
}

/* Login */
#login-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: #f5f5f7;
}

.login-card {
    width: 100%;
    max-width: 360px;
    background: #fff;
    border-radius: 16px;
    padding: 40px 32px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
    text-align: center;
}

.login-card h1 {
    font-size: 28px;
    margin-bottom: 8px;
}

.login-sub {
    font-size: 14px;
    color: #999;
    margin-bottom: 28px;
}

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

.form-group input {
    width: 100%;
    padding: 14px 16px;
    border: 1px solid #e0e0e0;
    border-radius: 10px;
    font-size: 16px;
    font-family: inherit;
    transition: border-color 0.2s;
    outline: none;
}

.form-group input:focus {
    border-color: #4f6ef7;
}

.login-error {
    color: #c62828;
    font-size: 14px;
    margin-bottom: 12px;
}

.login-error.hidden {
    display: none;
}

.btn-login {
    width: 100%;
    padding: 14px;
    font-size: 16px;
    font-weight: 600;
    margin-top: 4px;
}

.btn-login:disabled {
    opacity: 0.6;
    cursor: default;
}

.totp-hint {
    font-size: 14px;
    color: #999;
    margin-bottom: 16px;
}

.totp-input {
    text-align: center;
    font-size: 24px !important;
    letter-spacing: 8px;
}
