:root {
    --primary-color: #2c3e50;
    --secondary-color: #3498db;
    --success-color: #27ae60;
    --warning-color: #e67e22;
    --error-color: #e74c3c;
    --light-bg: #f8f9fa;
    --dark-bg: #343a40;
    --border-color: #dee2e6;
}

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f5f7fa;
    padding: 10px;
    min-height: 100vh;
    overflow-x: hidden;
}

.container {
    max-width: 1800px;
    margin: 0 auto;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

header {
    text-align: center;
    margin-bottom: 10px;
    padding: 10px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    flex-shrink: 0;
}

h1 {
    font-size: 1.8rem;
    margin-bottom: 5px;
}

.subtitle {
    font-size: 0.9rem;
    opacity: 0.9;
}

.main-content {
    display: grid;
    grid-template-columns: 160px 1fr 1fr 1fr 160px;
    gap: 10px;
    flex: 1;
    overflow: hidden;
}

/* 桌面端布局 */
@media (min-width: 1201px) {
    .main-content {
        grid-template-columns: 160px 1fr 1fr 1fr 160px;
    }
}

/* 平板端布局 */
@media (max-width: 1200px) and (min-width: 768px) {
    .main-content {
        grid-template-columns: 1fr 1fr;
    }
    
    .panel:nth-child(3) {
        grid-column: 1 / -1;
    }
}

/* 手机端布局 */
@media (max-width: 767px) {
    body {
        padding: 5px;
    }
    
    .main-content {
        grid-template-columns: 1fr;
        gap: 8px;
    }
    
    h1 {
        font-size: 1.5rem;
    }
    
    .subtitle {
        font-size: 0.8rem;
    }
    
    .panel-header {
        padding: 10px;
        height: auto;
        min-height: 50px;
        flex-wrap: wrap;
    }
    
    .button-group-mobile {
    display: flex;
    gap: 5px;
    width: 100%; /* 改为 auto */
    margin-top: 5px;
   /* margin-left: auto;  添加这一行 */
	justify-content: flex-end; /* 添加这一行 */
}
    
    .panel-body {
        padding: 8px;
    }
    
    textarea, input {
        padding: 10px;
        font-size: 16px; /* 防止iOS缩放 */
    }
    
    .button-group {
        flex-direction: column;
        gap: 8px;
    }
    
    .elements-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 4px;
        padding: 3px;
    }
    
    .element-item {
        font-size: 0.65rem;
        padding: 4px 1px;
        min-height: 22px;
    }
    
    .output-content {
        padding: 8px;
    }
    
    .code-block {
        padding: 8px;
        font-size: 14px;
    }
    
    .info-box {
        padding: 6px;
        font-size: 0.75rem;
    }
    
    .footer {
        padding: 8px;
        font-size: 0.7rem;
    }
}

.panel {
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.panel-header {
    padding: 12px 15px;
    background-color: var(--primary-color);
    color: white;
    font-weight: bold;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 60px;
}

.panel-body {
    padding: 10px;
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

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

label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
}

textarea, input {
    width: 100%;
    padding: 8px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-family: 'Consolas', 'Courier New', monospace;
    font-size: 14px;
}

.code-input-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#codeInput {
    flex: 1;
    resize: none;
    min-height: 150px;
}

.action-button {
    background-color: var(--secondary-color);
    color: white;
    border: none;
    padding: 8px 15px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: background-color 0.3s;
}

.action-button:hover {
    background-color: #2980b9;
}

.button-group {
    display: flex;
    gap: 10px;
    margin-top: 15px;
}

.button-group button {
    flex: 1;
}

.btn-success {
    background-color: var(--success-color);
}

.btn-success:hover {
    background-color: #219653;
}

.btn-warning {
    background-color: var(--warning-color);
}

.btn-warning:hover {
    background-color: #d35400;
}

.btn-danger {
    background-color: var(--error-color);
}

.btn-danger:hover {
    background-color: #c0392b;
}

.code-block-container {
    position: relative;
    background-color: var(--light-bg);
    border-radius: 4px;
    margin-top: 8px;
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
}

.code-block {
    padding: 10px;
    font-family: 'Consolas', 'Courier New', monospace;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.copy-btn {
    position: absolute;
    top: 5px;
    right: 5px;
    background-color: var(--secondary-color);
    color: white;
    border: none;
    padding: 5px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: background-color 0.3s;
    z-index: 10;
}

.copy-btn:hover {
    background-color: #2980b9;
}

.output-container {
    margin-top: 10px;
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.output-header {
    padding: 8px 12px;
    background-color: var(--secondary-color);
    color: white;
    font-weight: bold;
    border-radius: 4px 4px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.output-content {
    padding: 10px;
    border: 1px solid var(--border-color);
    border-top: none;
    border-radius: 0 0 4px 4px;
    background-color: white;
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.info-box {
    background-color: rgba(52, 152, 219, 0.1);
    border-left: 4px solid var(--secondary-color);
    padding: 8px;
    margin-bottom: 10px;
    border-radius: 4px;
    font-size: 0.8rem;
}

.footer {
    text-align: center;
    margin-top: 10px;
    padding: 10px;
    color: #7f8c8d;
    font-size: 0.8rem;
    flex-shrink: 0;
}

.elements-grid {
    display: grid;
    grid-template-columns: repeat(10, 1fr);
    gap: 5px;
    overflow-y: auto;
    flex: 1;
    padding: 5px;
    max-height: 100%;
}

.element-item {
    background-color: rgba(52, 152, 219, 0.1);
    border: 1px solid var(--border-color);
    border-radius: 2px;
    padding: 5px 2px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
    font-size: 0.7rem;
    word-break: break-all;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 25px;
}

.element-item:hover {
    background-color: rgba(52, 152, 219, 0.2);
    transform: translateY(-1px);
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.status-indicator {
    display: inline-block;
    padding: 5px 10px;
    border-radius: 4px;
    font-weight: bold;
    font-size: 0.8rem;
    background-color: rgba(231, 76, 60, 0.2);
    color: var(--error-color);
}

.status-valid {
    background-color: rgba(39, 174, 96, 0.3);
    color: #fff;
    border: 1px solid var(--success-color);
    box-shadow: 0 0 5px rgba(39, 174, 96, 0.5);
}

.status-invalid {
    background-color: rgba(231, 76, 60, 0.3);
    color: #fff;
    border: 1px solid var(--error-color);
    box-shadow: 0 0 5px rgba(231, 76, 60, 0.5);
}

.hint-text {
    font-size: 0.8rem;
    opacity: 0.8;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
}

.no-elements {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 40px;
    font-size: 0.9rem;
    color: #7f8c8d;
    background-color: rgba(0,0,0,0.05);
    border-radius: 4px;
    border: 1px dashed var(--border-color);
    grid-column: 1 / -1;
    margin-bottom: 5px;
}

.panel-header-relative {
    position: relative;
}

/* 新增样式 */
.input-with-button {
    display: flex;
    gap: 5px;
}

.input-with-button input {
    flex: 1;
}

.input-with-button button {
    width: auto;
    min-width: 60px;
}

/* 广告容器样式 */
.ad-container {
    background: #f8f9fa;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* 嵌入式广告 */
.embedded-ad {
    width: 100%;
    height: 100%;
}

/* 顶部和底部广告 */
.top-ad, .bottom-ad {
    width: 100%;
    height: 90px;
    margin: 10px 0;
}

/* 桌面端广告 */
.desktop-ad {
    /* 现在广告是嵌入式，不需要固定定位 */
}

/* 移动端广告 */
.mobile-ad {
    width: 100%;
    margin: 8px 0;
    display: none;
}

.mobile-top-ad {
    height: 80px;
}

.mobile-bottom-ad {
    height: 80px;
}

.ad-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 10px;
    text-align: center;
}

.ad-title {
    font-size: 14px;
    font-weight: bold;
    margin-bottom: 10px;
    color: var(--primary-color);
}

.ad-placeholder {
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #e0e0e0, #f5f5f5);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #666;
    font-size: 14px;
}

.ad-close {
    position: absolute;
    top: 5px;
    right: 5px;
    background: none;
    border: none;
    font-size: 16px;
    cursor: pointer;
    color: #999;
}

.ad-close:hover {
    color: var(--error-color);
}

/* 响应式设计 - 在不同屏幕上显示不同的广告 */
@media (max-width: 1200px) {
    .desktop-ad {
        display: none;
    }
}

@media (max-width: 767px) {
    .mobile-ad {
        display: flex;
    }
    
    .ad-title {
        font-size: 12px;
    }
    
    .ad-placeholder {
        font-size: 12px;
    }
}

/* 平板端布局优化 */
@media (max-width: 1200px) and (min-width: 768px) {
    .desktop-ad {
        display: none;
    }
    
    .mobile-ad {
        display: flex;
        height: 70px;
    }
}

/* 统一所有面板头部按钮的大小 - 修复标题换行问题 */
.panel-header .action-button,
.panel-header-relative .action-button,
.button-group-mobile .action-button {
    padding: 6px 6px;  /* 进一步减少左右内边距 */
    font-size: 12px;   /* 减小字体大小 */
    min-height: 36px;
    min-width: 50px;   /* 设置最小宽度 */
    max-width: 80px;   /* 设置最大宽度，防止按钮过长 */
}

/* 移动端也保持统一 */
@media (max-width: 767px) {
    .panel-header .action-button,
    .panel-header-relative .action-button,
    .button-group-mobile .action-button {
        padding: 6px 4px;  /* 移动端进一步减少左右内边距 */
        font-size: 11px;   /* 移动端字体更小 */
        min-height: 34px;
        min-width: 45px;   /* 移动端最小宽度稍小 */
        max-width: 70px;   /* 移动端最大宽度稍小 */
    }
}

/* 保留按钮组中按钮的flex布局 */
.button-group-mobile {
    display: flex;
    gap: 5px;
    width: 100%; /* 改为 auto会缩短 */
    margin-top: 5px;
    /*margin-left: auto;  添加这一行 */
	justify-content: flex-end; /* 添加这一行 */
}

.button-group-mobile .action-button {
    flex: 1;
    /* 不再设置特殊的padding和font-size，使用上面统一的样式 */
}

/* 专门解决输入代码面板标题换行问题 */
.panel-header {
    flex-wrap: nowrap; /* 确保标题和按钮组在同一行 */
}

.panel-header > span {
    white-space: nowrap; /* 防止标题换行 */
    flex-shrink: 0; /* 防止标题被压缩 */
    margin-right: 10px; /* 标题和按钮组之间的间距 */
}

.button-group-mobile {
    flex-shrink: 1; /* 允许按钮组适当收缩 */
    min-width: 0; /* 允许按钮组收缩到0 */
}