body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    margin: 0;
    background: linear-gradient(135deg, #e60012 0%, #ff4d4d 100%);
    color: #333;
    display: flex;
    justify-content: flex-start; /* 改为顶部对齐 */
    align-items: center;
    min-height: 100vh;
    padding: 0; /* 移除内边距使窗口完全置顶 */
    box-sizing: border-box;
}

.container {
    background: linear-gradient(135deg, #fff9f0 0%, #fff5e6 100%);
    padding: 20px;
    border-radius: 0; /* 移除顶部圆角 */
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    width: 100%;
    max-width: 450px; /* 调整最大宽度以适应移动端 */
    box-sizing: border-box;
    margin-top: 0; /* 移除顶部边距 */
    border: 1px solid rgba(255, 215, 0, 0.3);
    position: relative;
    overflow: hidden;
}

.container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(45deg, transparent 0%, rgba(255, 215, 0, 0.1) 50%, transparent 100%);
    pointer-events: none;
}

.form-group {
    margin-bottom: 3em;
}

label {
    display: block;
    margin-bottom: .7em; /* 增加标签和输入框的间距 */
    font-weight: 500; /* 中等字重 */
    color: #333333;
    font-size: 0.95em;
}

textarea,
input[type="text"] {
    width: 100%;
    padding: 12px; /* 增加内边距 */
    border: 1px solid #e0e0e0; /* 浅色边框 */
    border-radius: 8px; /* 更圆润的输入框 */
    box-sizing: border-box;
    font-size: 0.9em; /* 调整文字大小 */
    background-color: #f7f7f7; /* 浅灰色背景 */
    text-align: left; /* 确保文本左对齐 */
}

textarea::placeholder {
    font-size: 0.9em; /* 调整占位符文字大小 */
    color: #999;
    text-align: left;
}

textarea:focus,
input[type="text"]:focus {
    border-color: #007aff; /* 微信蓝作为焦点色 */
    background-color: #fff;
    outline: none; /* 移除默认outline */
    box-shadow: 0 0 0 2px rgba(0, 122, 255, 0.2); /* 焦点时的阴影效果 */
}

textarea {
    resize: vertical;
    min-height: 80px; /* 调整最小高度 */
}

/* Shared styles for action buttons */
.action-button {
    color: white;
    padding: 10px 20px;
    border: none;
    border-radius: 8px; /* Consistent with textarea and result-area */
    cursor: pointer;
    font-size: 1em;
    font-weight: 500;
    width: auto;
    display: block;
    margin-left: auto;
    margin-right: auto;
    min-width: 120px; /* 统一最小宽度，之前复制按钮是150px */
    transition: background-color 0.2s ease, transform 0.1s ease;
}

.action-button:active {
    transform: scale(0.98);
}

/* 红包雨动画容器 */
.red-packets-container {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 1000;
    display: none;
}

/* 单个红包样式 */
.red-packet {
    position: absolute;
    width: 40px;
    height: 50px;
    background: linear-gradient(135deg, #ff4d4d 0%, #ff1a1a 100%);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #FFD700;
    font-weight: bold;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    animation: fallAnimation 2s linear;
    opacity: 0;
}

/* 红包中间的圆点 */
.red-packet::after {
    content: '';
    width: 8px;
    height: 8px;
    background: #FFD700;
    border-radius: 50%;
}

/* 进度条容器 */
.progress-container {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 80%;
    max-width: 300px;
    text-align: center;
    z-index: 1001;
    background: rgba(255, 255, 255, 0.95);
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* 倒计时显示 */
.countdown {
    font-size: 2em;
    color: #333;
    margin-bottom: 20px;
    font-weight: bold;
}

.countdown span {
    color: #ff4d4d;
}

/* 进度条 */
.progress-bar {
    width: 100%;
    height: 8px;
    background: #f0f0f0;
    border-radius: 4px;
    overflow: hidden;
}

.progress-bar-fill {
    width: 0%;
    height: 100%;
    background: linear-gradient(to right, #4CAF50, #8BC34A);
    border-radius: 4px;
    transition: width 0.1s linear;
}

@keyframes fallAnimation {
    0% {
        transform: translateY(-100px) rotate(0deg);
        opacity: 1;
    }
    20% {
        opacity: 1;
    }
    100% {
        transform: translateY(100vh) rotate(360deg);
        opacity: 0;
    }
}

/* 提交按钮样式 */
#submitButton {
    background: linear-gradient(135deg, #FFD700 0%, #FFA500 100%);
    color: #fff;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

#submitButton:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255, 215, 0, 0.3);
}

#submitButton:disabled {
    background: linear-gradient(135deg, #ffd700aa 0%, #ffa500aa 100%);
    transform: none;
}

/* 复制按钮样式 */
#copyButton {
    width: 100%;
    max-width: 200px;
    margin: 0 auto;
    display: block;
    background: linear-gradient(135deg, #FFD700 0%, #FFA500 100%);
    color: #fff;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 15px;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

#copyButton:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255, 215, 0, 0.3);
}

#copyButton:disabled {
    background: linear-gradient(135deg, #ffd700aa 0%, #ffa500aa 100%);
    transform: none;
}

/* General disabled state for all buttons if needed more broadly */
button:disabled {
    cursor: not-allowed;
    transform: none;
    /* General disabled colors can be set here if not overridden by specific IDs */
     /* background-color: #cccccc; */
    /* color: #666666; */
}

/* New style for the label outside result-area */
#resultLabel {
    display: block;
    margin-bottom: 1em;
    color: #333333;
    font-size: 1em;
    font-weight: 500;
}

.result-section {
    margin-top: 3em;
    padding-top: 1em;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
}

.result-area {
    background-color: #f7f7f7;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 1.5em;
    min-height: 70px;
}

.result-text-content {
    white-space: pre-wrap;
    color: #1a1a1a;
    font-size: 0.95em;
    line-height: 1.5;
    font-family: monospace;
}

/* Red Envelope Animation */
#loadingAnimationContainer {
    /* Ensure its top margin is similar to where #resultLabel would be */
    margin-top: 1.5em; /* Matches #resultLabel's new top margin */
    text-align: center; 
    min-height: 100px; /* from HTML, ensure it's styled if not set in HTML */
}

#loadingAnimationContainer p {
    margin-bottom: 15px;
    font-size: 0.95em; /* Consistent with labels */
    color: #555;
}

.red-envelope-container {
    position: relative;
    height: 60px; /* 减小红包动画区域高度 */
    overflow: hidden;
    margin-bottom: 5px; /* 与下方文字的间距 */
}

.red-envelope {
    font-size: 2.5em; /* 减小红包大小 */
    position: absolute;
    left: 50%;
    top: -40px; /* Start above the container */
    transform: translateX(-50%);
    animation: 红包雨 1.3s infinite ease-in-out;
}

@keyframes 红包雨 {
    0% {
        top: -40px;
        opacity: 0;
    }
    20% {
        opacity: 1;
    }
    100% {
        top: 70px; /* Fall to below the container */
        opacity: 0;
    }
}

/* Mobile-specific adjustments */
@media (max-width: 600px) {
    body {
        padding: 0;
    }
    .container {
        padding: 16px;
        margin-top: 0;
        border-radius: 0;
    }
    .form-group {
        margin-bottom: 2em;
    }
    label {
        margin-bottom: .5em;
    }
    #submitButton, #copyButton {
        font-size: 0.95em;
        padding: 10px 18px;
        margin-top: 12px;
    }
    textarea, input[type="text"] {
        font-size: 0.9em;
        padding: 10px;
        min-height: 60px;
    }
    .red-envelope-container {
        height: 50px;
    }
    .red-envelope {
        font-size: 2em;
    }
    #loadingAnimationContainer {
        margin-top: 1em;
        min-height: 80px;
    }
    #resultLabel {
        margin-bottom: 0.8em;
    }
    .result-area {
        padding: 12px;
        margin-bottom: 1.2em;
    }
    .result-text-content {
        font-size: 0.9em;
    }
    .result-section {
        margin-top: 2em;
    }
    .loading-text {
        font-size: 1.1em;
    }
    .countdown {
        font-size: 1.8em;
        margin-bottom: 15px;
    }
    .progress-container {
        padding: 15px;
        width: 90%;
    }
}

/* 剩余次数显示器 */
.remaining-queries {
    position: absolute;
    top: 15px;
    right: 15px;
    background: linear-gradient(135deg, #FFD700 0%, #FFA500 100%);
    padding: 8px 12px;
    border-radius: 20px;
    color: #fff;
    font-size: 14px;
    font-weight: 500;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    z-index: 10;
    display: flex;
    align-items: center;
    gap: 5px;
}

.remaining-queries .icon {
    font-size: 16px;
    color: #fff;
}

.remaining-queries .count {
    font-weight: bold;
}

/* 历史记录区域样式 */
.history-section {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid rgba(255, 215, 0, 0.3);
}

.history-section h3 {
    color: #333;
    font-size: 1.1em;
    margin-bottom: 15px;
    font-weight: 500;
}

.history-container {
    max-height: 300px;
    overflow-y: auto;
    padding-right: 5px;
}

.history-item {
    background: rgba(255, 255, 255, 0.8);
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 10px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
    border: 1px solid rgba(255, 215, 0, 0.2);
}

.history-time {
    font-size: 0.85em;
    color: #666;
    margin-bottom: 8px;
}

.history-content {
    font-size: 0.9em;
    color: #333;
}

.history-coupon-box {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    padding: 8px;
    word-break: break-all;
    line-height: 1.4;
    font-family: monospace;
    position: relative;
    cursor: pointer;
    transition: background-color 0.2s;
}

.history-coupon-box:hover {
    background: #f5f5f5;
}

.history-coupon-box::before {
    content: '点击复制';
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.8em;
    color: #999;
    opacity: 0;
    transition: opacity 0.2s;
}

.history-coupon-box:hover::before {
    opacity: 1;
}

.loading-text, .error-text, .empty-text {
    text-align: center;
    padding: 20px;
    color: #666;
    font-size: 0.9em;
}

.error-text {
    color: #ff4d4d;
}

/* 自定义滚动条样式 */
.history-container::-webkit-scrollbar {
    width: 6px;
}

.history-container::-webkit-scrollbar-track {
    background: rgba(255, 215, 0, 0.1);
    border-radius: 3px;
}

.history-container::-webkit-scrollbar-thumb {
    background: rgba(255, 215, 0, 0.5);
    border-radius: 3px;
}

.history-container::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 215, 0, 0.7);
}

/* 移动端适配 */
@media (max-width: 600px) {
    .history-section {
        margin-top: 20px;
        padding-top: 15px;
    }

    .history-section h3 {
        font-size: 1em;
        margin-bottom: 12px;
    }

    .history-container {
        max-height: 250px;
    }

    .history-item {
        padding: 10px;
        margin-bottom: 8px;
    }

    .history-coupon-box {
        padding: 6px;
        font-size: 0.9em;
    }

    .countdown {
        font-size: 36px;
        margin-bottom: 15px;
    }

    .progress-container {
        padding: 15px;
    }
}

/* 状态日志样式 */
.status-log {
    margin-top: 15px;
    font-size: 0.9em;
    color: #555;
    text-align: center;
    white-space: pre-line;
}

/* 拼多多链接容器样式 */
.pdd-links-container {
    margin-top: 20px;
    padding: 15px;
    background: linear-gradient(135deg, #f0f8ff 0%, #e6f3ff 100%);
    border-radius: 8px;
    border: 1px solid rgba(0, 122, 255, 0.2);
}

.pdd-links-container h3 {
    margin: 0 0 15px 0;
    color: #333;
    font-size: 1.1em;
    text-align: center;
}

.pdd-link-item {
    margin-bottom: 15px;
    padding: 10px;
    background: white;
    border-radius: 6px;
    border: 1px solid #e0e0e0;
}

.pdd-link-item:last-child {
    margin-bottom: 0;
}

.pdd-link-item label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #007aff;
    font-size: 0.9em;
}

.pdd-link-text {
    background: #f8f8f8;
    padding: 8px;
    border-radius: 4px;
    font-size: 0.85em;
    color: #333;
    word-break: break-all;
    margin-bottom: 8px;
    min-height: 20px;
    border: 1px solid #e0e0e0;
}

.pdd-copy-button {
    background: #007aff;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85em;
    transition: background-color 0.2s ease;
}

.pdd-copy-button:hover:not(:disabled) {
    background: #0056cc;
}

.pdd-copy-button:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.pdd-copy-button:active:not(:disabled) {
    transform: scale(0.98);
}