* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    background-attachment: fixed;
    min-height: 100vh;
    padding: 12px;
    display: flex;
    justify-content: center;
    align-items: flex-start;
}

.container {
    width: 100%;
    max-width: 100%;
    background: white;
    border-radius: 16px;
    padding: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    position: relative;
    animation: fadeInUp 0.4s ease-out;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    gap: 10px;
    padding-bottom: 12px;
    border-bottom: 2px solid #f0f0f0;
}

h1 {
    flex: 1;
    text-align: center;
    color: #2d3748;
    margin: 0;
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.3px;
}

.btn-refresh {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    color: white;
    padding: 10px 16px;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 6px;
    box-shadow: 0 2px 8px rgba(79, 172, 254, 0.25);
    flex-shrink: 0;
}

.btn-refresh:active {
    transform: scale(0.95);
    box-shadow: 0 1px 4px rgba(79, 172, 254, 0.3);
}

/* 加载指示器 */
.loading {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    text-align: center;
}

.loading.show {
    display: flex;
}

.spinner {
    width: 36px;
    height: 36px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #667eea;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 12px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading p {
    color: #666;
    font-size: 14px;
}

/* 类目部分样式 */
.category-part {
    margin-bottom: 20px;
    padding: 16px;
    background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
    border-radius: 12px;
    border: 1.5px solid #e8e8e8;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.category-part:active {
    transform: scale(0.98);
    border-color: #667eea;
}

.category-part-header {
    margin-bottom: 16px;
}

.category-name-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    gap: 10px;
}

.category-name {
    font-size: 18px;
    font-weight: 700;
    color: #2d3748;
    margin: 0;
    flex: 1;
    line-height: 1.3;
}

.btn-category-delete {
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5a6f 100%);
    color: white;
    padding: 8px 14px;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 4px;
    box-shadow: 0 2px 6px rgba(255, 107, 107, 0.25);
    flex-shrink: 0;
    min-height: 36px;
}

.btn-category-delete:active {
    transform: scale(0.95);
}

.item-select-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.item-select-label {
    font-size: 14px;
    font-weight: 600;
    color: #4a5568;
    white-space: nowrap;
}

.item-select {
    flex: 1;
    min-width: 0;
    padding: 10px 12px;
    padding-right: 32px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 15px;
    font-family: inherit;
    background: white;
    color: #2d3748;
    cursor: pointer;
    transition: all 0.2s ease;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%234a5568' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 12px;
}

.item-select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.btn-item-add {
    background: linear-gradient(135deg, #48bb78 0%, #38a169 100%);
    color: white;
    padding: 10px 14px;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 4px;
    box-shadow: 0 2px 6px rgba(72, 187, 120, 0.25);
    flex-shrink: 0;
    min-height: 36px;
}

.btn-item-add:active {
    transform: scale(0.95);
}

.input-group {
    margin-bottom: 0;
}

.input-group-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    gap: 8px;
}

.label-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 0;
}

.item-name-input {
    flex: 1;
    padding: 10px 12px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 15px;
    font-family: inherit;
    background: white;
    color: #2d3748;
    transition: all 0.2s ease;
    min-width: 0;
}

.item-name-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.item-name-input::placeholder {
    color: #a0aec0;
}

.char-count {
    font-size: 11px;
    color: #718096;
    font-weight: 500;
    white-space: nowrap;
    flex-shrink: 0;
}

.char-count.warning {
    color: #ed8936;
}

.char-count.danger {
    color: #f56565;
}

textarea {
    width: 100%;
    min-height: 140px;
    padding: 12px;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    font-size: 16px;
    font-family: inherit;
    resize: vertical;
    transition: all 0.2s ease;
    background: white;
    line-height: 1.6;
    color: #2d3748;
}

textarea:focus {
    outline: none;
    border-color: #667eea;
    background: #fafafa;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

textarea::placeholder {
    color: #a0aec0;
}

.button-group {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin-top: 12px;
}

.button-group .btn {
    flex: none;
    min-width: 0;
}

.btn {
    padding: 12px 16px;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    position: relative;
    overflow: hidden;
    user-select: none;
    min-height: 44px;
}

.btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.4s, height 0.4s;
}

.btn:active::before {
    width: 200px;
    height: 200px;
}

.btn-icon {
    font-size: 16px;
    line-height: 1;
}

.btn-text {
    position: relative;
    z-index: 1;
}

.btn-upload {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.25);
}

.btn-upload:active:not(:disabled) {
    transform: scale(0.97);
}

.btn-copy {
    background: linear-gradient(135deg, #48bb78 0%, #38a169 100%);
    color: white;
    box-shadow: 0 2px 8px rgba(72, 187, 120, 0.25);
}

.btn-copy:active:not(:disabled) {
    transform: scale(0.97);
}

.btn-paste {
    background: linear-gradient(135deg, #ed8936 0%, #dd6b20 100%);
    color: white;
    box-shadow: 0 2px 8px rgba(237, 137, 54, 0.25);
}

.btn-paste:active:not(:disabled) {
    transform: scale(0.97);
}

.btn-item-delete {
    background: linear-gradient(135deg, #f56565 0%, #e53e3e 100%);
    color: white;
    box-shadow: 0 2px 8px rgba(245, 101, 101, 0.25);
}

.btn-item-delete:active:not(:disabled) {
    transform: scale(0.97);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

.btn.loading {
    pointer-events: none;
}

.btn.loading .btn-icon {
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: rgba(45, 55, 72, 0.95);
    backdrop-filter: blur(10px);
    color: white;
    padding: 14px 20px;
    border-radius: 12px;
    font-size: 14px;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
    max-width: calc(100% - 32px);
    text-align: center;
    font-weight: 500;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.toast.success {
    background: rgba(72, 187, 120, 0.95);
}

.toast.error {
    background: rgba(245, 101, 101, 0.95);
}

.add-category-container {
    margin-top: 16px;
    margin-bottom: 8px;
}

.btn-add {
    width: 100%;
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
    padding: 14px 20px;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: 0 4px 12px rgba(240, 147, 251, 0.3);
    position: relative;
    z-index: 10;
    min-height: 48px;
}

.btn-add:active {
    transform: scale(0.98);
}

/* 移动端优化 */
@media (max-width: 480px) {
    body {
        padding: 8px;
    }

    .container {
        padding: 14px;
        border-radius: 12px;
    }

    .header-row {
        margin-bottom: 16px;
        padding-bottom: 10px;
    }

    h1 {
        font-size: 20px;
    }

    .btn-refresh {
        padding: 8px 12px;
        font-size: 13px;
    }

    .category-part {
        padding: 14px;
        margin-bottom: 16px;
    }

    .category-name {
        font-size: 17px;
    }

    .category-name-row {
        margin-bottom: 10px;
    }

    .item-select-row {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .item-select-label {
        font-size: 13px;
        margin-bottom: 0;
    }

    .item-select {
        width: 100%;
        padding: 11px 12px;
        padding-right: 32px;
        font-size: 15px;
    }

    .btn-item-add {
        width: 100%;
        padding: 11px 14px;
    }

    .input-group-header {
        margin-bottom: 8px;
    }

    .item-name-input {
        padding: 10px 12px;
        font-size: 15px;
    }

    textarea {
        min-height: 120px;
        font-size: 16px;
        padding: 12px;
    }

    .button-group {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
        margin-top: 10px;
    }

    .btn {
        padding: 12px 14px;
        font-size: 14px;
        min-height: 44px;
    }

    .btn-icon {
        font-size: 15px;
    }

    .toast {
        bottom: 20px;
        padding: 12px 18px;
        font-size: 13px;
        max-width: calc(100% - 24px);
    }

    .char-count {
        font-size: 10px;
    }

    .btn-add {
        padding: 14px 18px;
        font-size: 15px;
        min-height: 48px;
    }
}

/* 防止iOS Safari缩放 */
@supports (-webkit-touch-callout: none) {
    textarea,
    .item-name-input {
        font-size: 16px !important;
    }
}

/* 小屏幕优化 */
@media (max-width: 360px) {
    .button-group {
        grid-template-columns: 1fr;
    }
    
    .btn {
        width: 100%;
    }
}
