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

html, body {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
}

:root {
    --primary-color: #4a90e2;
    --secondary-color: #50c878;
    --text-color: #333;
    --bg-color: #f5f7fa;
    --card-bg: #ffffff;
    --border-color: #e0e0e0;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    --shadow-hover: 0 4px 16px rgba(0, 0, 0, 0.15);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
    line-height: 1.6;
    color: var(--text-color);
    background-color: var(--bg-color);
}

.container {
    max-width: 1600px; /* 增加PC端最大宽度，让尺子显示更长 */
    margin: 0 auto;
    padding: 0 20px;
    width: 100%;
    box-sizing: border-box;
}

/* Header */
header {
    background: linear-gradient(135deg, var(--primary-color) 0%, #357abd 100%);
    color: white;
    padding: 30px 0;
    box-shadow: var(--shadow);
}

.header-content {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.top-nav {
    margin-left: auto;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
}

.top-nav a {
    color: #fefefe;
    text-decoration: none;
    font-weight: 600;
    padding: 6px 10px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.15);
    transition: background 0.2s, color 0.2s;
}

.top-nav a:hover {
    background: rgba(255, 255, 255, 0.25);
    color: #fff;
}

.header-logo {
    flex-shrink: 0;
    width: 56px;
    height: 56px;
    background: rgba(255, 255, 255, 0.25);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px;
    box-sizing: border-box;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.logo-img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: contain;
    /* logo-white.svg已经是白色背景蓝色图案，不需要filter */
}

.header-text {
    flex: 1;
    text-align: left;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

header h1 {
    font-size: 1.8em;
    margin: 0;
    font-weight: 700;
    line-height: 1.2;
    color: white;
    letter-spacing: 0.5px;
}

.subtitle {
    font-size: 0.85em;
    opacity: 0.85;
    margin: 0;
    line-height: 1.4;
    color: rgba(255, 255, 255, 0.9);
    font-weight: 400;
}

/* Main Content */
main {
    padding: 40px 0;
}

.tool-section {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 30px;
    margin-bottom: 40px;
    box-shadow: var(--shadow);
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.tool-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 2px solid var(--border-color);
}

.control-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.control-group label {
    font-weight: 600;
    color: var(--text-color);
    white-space: nowrap;
}

.control-group select {
    padding: 10px 15px;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    font-size: 14px;
    background: white;
    cursor: pointer;
    transition: all 0.3s;
}

.control-group select:hover {
    border-color: var(--primary-color);
}

.control-group select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.1);
}

.btn-reset {
    padding: 10px 20px;
    background: var(--secondary-color);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    margin-left: 10px;
    white-space: nowrap;
}

.btn-reset:hover {
    background: #45b869;
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.btn-auto-detect {
    padding: 10px 15px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    margin-left: 10px;
    white-space: nowrap;
}

.btn-auto-detect:hover {
    background: #357abd;
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

/* Ruler Wrapper */
.ruler-wrapper {
    margin: 30px 0;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

/* 尺子单位标签（在尺子内部，不遮挡刻度） */
.ruler-unit-label {
    position: absolute;
    font-weight: 700;
    font-size: 12px;
    color: #333;
    white-space: nowrap;
    z-index: 15;
    pointer-events: none; /* 不阻挡鼠标事件 */
}

/* 厘米标签（上方区域左侧，在刻度开始之前） */
.cm-unit-label {
    top: 2px;
    left: 2px;
    background: rgba(255, 255, 255, 0.85);
    padding: 1px 4px;
    border-radius: 2px;
}

/* 英寸标签（下方区域左侧，在刻度开始之前） */
.inch-unit-label {
    bottom: 2px;
    left: 2px;
    background: rgba(255, 255, 255, 0.85);
    padding: 1px 4px;
    border-radius: 2px;
}

/* Ruler Container */
.ruler-container {
    background: white;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    padding: 20px;
    margin: 0;
    overflow-x: auto;
    overflow-y: hidden;
    min-height: 180px;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    -webkit-overflow-scrolling: touch; /* iOS平滑滚动 */
    width: 100%;
    max-width: 100%;
}

/* PC端：让尺子容器使用更大的宽度 */
@media (min-width: 1024px) {
    .ruler-container {
        padding: 25px 30px; /* 增加内边距 */
    }
    
    .container {
        padding: 0 40px; /* PC端增加左右内边距 */
    }
}

/* 大屏幕PC端：进一步增加宽度 */
@media (min-width: 1400px) {
    .container {
        max-width: 1800px; /* 大屏幕使用更大的最大宽度 */
        padding: 0 50px;
    }
    
    .ruler-container {
        padding: 30px 40px;
    }
}

.ruler {
    position: relative;
    background: linear-gradient(to bottom, #f8f8f8 0%, #ffffff 35%, #ffffff 65%, #f8f8f8 100%);
    border: 1px solid #ccc;
    border-radius: 4px;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
    width: 100%;
    height: 180px; /* 增加高度以容纳数字和空白 */
    border-top: 2px solid #333;
    border-bottom: 2px solid #333;
}

.ruler-mark {
    position: absolute;
    border-left: 1px solid #666;
}

/* 厘米刻度（上方区域） */
.ruler-mark.cm-major {
    top: 0;
    height: 35%; /* 厘米刻度区域占35% */
    border-left-width: 2px;
    border-left-color: #333;
}

.ruler-mark.cm-half {
    top: 0;
    height: 28%;
    border-left-width: 1.5px;
    border-left-color: #666;
}

.ruler-mark.cm-minor {
    top: 0;
    height: 20%;
    border-left-width: 1px;
    border-left-color: #999;
}

/* 英寸刻度（下方区域） */
.ruler-mark.inch-major {
    bottom: 0;
    height: 35%; /* 英寸刻度区域占35% */
    border-left-width: 2px;
    border-left-color: #333;
}

.ruler-mark.inch-half {
    bottom: 0;
    height: 28%;
    border-left-width: 1.5px;
    border-left-color: #666;
}

.ruler-mark.inch-minor {
    bottom: 0;
    height: 20%;
    border-left-width: 1px;
    border-left-color: #999;
}

/* 厘米标签（在厘米刻度下方，更靠近厘米刻度） */
.ruler-label.cm-label {
    position: absolute;
    top: 30%; /* 在厘米刻度下方，靠近厘米区域 */
    font-size: 13px;
    font-weight: 700;
    color: #333;
    transform: translateX(-50%);
    white-space: nowrap;
    z-index: 10;
    background: rgba(255, 255, 255, 0.95);
    padding: 2px 5px;
    border-radius: 3px;
    border: 1px solid #ddd;
}

/* 英寸标签（在英寸刻度上方，更靠近英寸刻度，远离厘米数字） */
.ruler-label.inch-label {
    position: absolute;
    bottom: 30%; /* 在英寸刻度上方，靠近英寸区域 */
    font-size: 13px;
    font-weight: 700;
    color: #333;
    transform: translateX(-50%);
    white-space: nowrap;
    z-index: 10;
    background: rgba(255, 255, 255, 0.95);
    padding: 2px 5px;
    border-radius: 3px;
    border: 1px solid #ddd;
}

/* 分隔线（厘米和英寸之间，中间空白区域） */
.ruler-divider {
    position: absolute;
    left: 0;
    right: 0;
    top: 50%;
    height: 2px;
    background: #ccc;
    z-index: 5;
    margin-top: -1px;
    box-shadow: 0 0 2px rgba(0, 0, 0, 0.1);
}

/* 中间空白区域背景（用于视觉区分，确保数字不重叠） */
.ruler::before {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    top: 35%;
    bottom: 35%;
    background: rgba(255, 255, 255, 0.6);
    z-index: 1;
    pointer-events: none;
    border-top: 1px dashed #ddd;
    border-bottom: 1px dashed #ddd;
}

/* 信息卡片包装容器（PC端并排显示） */
.info-cards-wrapper {
    display: flex;
    flex-direction: column;
    gap: 30px;
    margin: 30px 0;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

/* PC端：并排显示 */
@media (min-width: 1024px) {
    .info-cards-wrapper {
        flex-direction: row;
        align-items: flex-start;
        gap: 30px;
    }
    
    .credit-card-reference,
    .measurement-info {
        flex: 1;
        margin: 0;
    }
}

/* 信用卡参考区域 */
.credit-card-reference {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 30px;
    box-shadow: var(--shadow);
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.reference-title {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
    font-size: 1.2em;
    font-weight: 600;
    color: var(--primary-color);
}

.reference-icon {
    font-size: 1.5em;
}

.credit-card-container {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 30px;
    background: #f8f9fa;
    border-radius: 8px;
    margin: 20px 0;
    min-height: 200px;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    width: 100%;
    box-sizing: border-box;
}

.credit-card {
    position: relative;
    /* 尺寸将通过JavaScript动态设置，这里设置默认值（96 DPI） */
    width: 323px; /* 8.56cm at 96 DPI */
    height: 204px; /* 5.398cm at 96 DPI */
    min-width: 200px; /* 最小宽度，确保在小屏幕上也能看到 */
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3);
    color: white;
    font-family: 'Courier New', monospace;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    box-sizing: border-box;
    flex-shrink: 0; /* 防止被压缩，保持正确的物理尺寸 */
}

.card-chip {
    width: 50px;
    height: 40px;
    background: linear-gradient(135deg, #ffd700 0%, #ffed4e 100%);
    border-radius: 6px;
    margin-bottom: 20px;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2);
}

.card-number {
    font-size: 1.2em;
    font-weight: 600;
    letter-spacing: 2px;
    margin-bottom: 20px;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.card-info {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    font-size: 0.9em;
}

.card-name {
    text-transform: uppercase;
    letter-spacing: 1px;
}

.card-expiry {
    letter-spacing: 1px;
}

.reference-text {
    margin-top: 20px;
    padding: 15px;
    background: #e8f4f8;
    border-radius: 6px;
    border-left: 4px solid var(--primary-color);
}

.reference-text p {
    margin: 8px 0;
    line-height: 1.6;
    color: #555;
}

.reference-text strong {
    color: var(--primary-color);
}

/* Measurement Info - 简洁专业设计 */
.measurement-info {
    display: flex;
    flex-direction: column;
    padding: 0;
    background: var(--card-bg);
    border-radius: 12px;
    box-shadow: var(--shadow);
    margin-top: 0;
    color: var(--text-color);
    overflow: hidden;
    min-height: 280px;
    border: 1px solid var(--border-color);
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

/* 信息头部 */
.info-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 25px 30px 20px;
    background: linear-gradient(to right, #f8f9fa 0%, #ffffff 100%);
    border-bottom: 2px solid var(--border-color);
}

.info-icon {
    font-size: 2em;
}

.info-title {
    font-size: 1.4em;
    font-weight: 700;
    color: var(--primary-color);
    letter-spacing: 0.5px;
}

/* 信息内容区域 */
.info-content {
    display: flex;
    flex-direction: column;
    gap: 0;
    padding: 20px 30px 30px;
    flex: 1;
    background: #ffffff;
}

.info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 0;
    border-bottom: 1px solid #f0f0f0;
    font-size: 0.95em;
}

.info-row:last-child {
    border-bottom: none;
}

.info-label {
    font-weight: 600;
    color: #666;
    letter-spacing: 0.3px;
}

.info-value {
    font-weight: 700;
    font-size: 1.05em;
    text-align: right;
    color: var(--primary-color);
}

.device-info-item {
    width: 100%;
    padding: 10px;
    background: #e8f4f8;
    border-radius: 6px;
    border-left: 3px solid var(--primary-color);
    margin-bottom: 10px;
}

.info-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 0;
    border-bottom: 1px solid #f0f0f0;
}

.info-item:last-child {
    border-bottom: none;
}

.info-label {
    font-weight: 600;
    color: #666;
}

.info-item span:last-child {
    color: var(--primary-color);
    font-weight: 700;
    font-size: 1.1em;
}

/* Features Section */
.features-section {
    margin-bottom: 40px;
}

.features-section h2,
.usage-section h2,
.faq-section h2 {
    font-size: 2em;
    margin-bottom: 30px;
    color: var(--text-color);
    text-align: center;
}

.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 25px;
}

.feature-card {
    background: var(--card-bg);
    padding: 30px;
    border-radius: 12px;
    text-align: center;
    box-shadow: var(--shadow);
    transition: all 0.3s;
}

.feature-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-hover);
}

.feature-icon {
    font-size: 3em;
    margin-bottom: 15px;
}

.feature-card h3 {
    font-size: 1.3em;
    margin-bottom: 10px;
    color: var(--primary-color);
}

.feature-card p {
    color: #666;
    line-height: 1.6;
}

/* Usage Section */
.usage-section {
    background: var(--card-bg);
    padding: 40px;
    border-radius: 12px;
    margin-bottom: 40px;
    box-shadow: var(--shadow);
}

.usage-steps {
    max-width: 800px;
    margin: 0 auto;
    padding-left: 20px;
}

.usage-steps li {
    margin-bottom: 15px;
    line-height: 1.8;
    color: #555;
}

.usage-steps li::marker {
    color: var(--primary-color);
    font-weight: bold;
}

/* FAQ Section */
.faq-section {
    background: var(--card-bg);
    padding: 40px;
    border-radius: 12px;
    margin-bottom: 40px;
    box-shadow: var(--shadow);
}

.faq-list {
    max-width: 900px;
    margin: 0 auto;
}

.faq-item {
    margin-bottom: 25px;
    padding-bottom: 25px;
    border-bottom: 1px solid var(--border-color);
}

.faq-item:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.faq-item h3 {
    color: var(--primary-color);
    margin-bottom: 10px;
    font-size: 1.2em;
}

.faq-item p {
    color: #666;
    line-height: 1.8;
}

/* Footer */
footer {
    background: #2c3e50;
    color: white;
    padding: 30px 0;
    text-align: center;
    margin-top: 60px;
}

.footer-links {
    margin-top: 15px;
}

.footer-links a {
    color: #ecf0f1;
    text-decoration: none;
    transition: color 0.3s;
}

.footer-links a:hover {
    color: var(--primary-color);
}

/* Responsive Design */
@media (max-width: 768px) {
    header {
        padding: 20px 0;
    }
    
    .header-content {
        gap: 10px;
        flex-direction: column;
        align-items: flex-start;
    }
    
    .header-logo {
        width: 48px;
        height: 48px;
        padding: 6px;
    }
    
    .top-nav {
        margin-left: 0;
        gap: 8px;
        width: 100%;
        justify-content: flex-start;
    }
    
    .top-nav a {
        padding: 5px 8px;
        font-size: 13px;
    }
    
    header h1 {
        font-size: 1.5em;
    }

    .subtitle {
        font-size: 0.8em;
    }

    .tool-controls {
        flex-direction: column;
    }

    .control-group {
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
        flex-wrap: wrap;
        gap: 10px;
    }

    .control-group label {
        width: 100%;
        margin-bottom: 5px;
    }

    .control-group select {
        width: 100%;
        margin-bottom: 10px;
        flex: none;
    }

    .btn-auto-detect,
    .btn-reset {
        margin-left: 0;
        margin-top: 0;
        flex: 1;
        min-width: 0;
        box-sizing: border-box;
    }
    
    .btn-auto-detect {
        margin-right: 5px;
    }
    
    .btn-reset {
        margin-left: 5px;
    }

    .ruler-wrapper {
        margin: 20px 0;
    }
    
    .ruler-unit-label {
        font-size: 11px;
        padding: 1px 3px;
    }
    
    .cm-unit-label {
        top: 1px;
        left: 1px;
    }
    
    .inch-unit-label {
        bottom: 1px;
        left: 1px;
    }
    
    .ruler-container {
        padding: 10px;
        margin: 0;
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }
    
    .tool-section {
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
        padding: 20px 15px;
    }
    
    .info-cards-wrapper {
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }
    
    .ruler {
        height: 160px; /* 移动端也增加高度 */
    }
    
    .ruler-mark.cm-major,
    .ruler-mark.inch-major {
        height: 30%;
    }
    
    .ruler-label {
        font-size: 11px;
    }
    
    .ruler-label.cm-label {
        font-size: 11px;
        padding: 1px 3px;
        top: 28%; /* 在厘米刻度下方，更靠近厘米区域 */
    }
    
    .ruler-label.inch-label {
        font-size: 11px;
        padding: 1px 3px;
        bottom: 28%; /* 在英寸刻度上方，更靠近英寸区域，远离厘米数字 */
    }

    .measurement-info {
        flex-direction: column;
        gap: 15px;
        padding: 15px;
    }
    
    .device-info-item {
        font-size: 0.85em;
    }

    .info-cards-wrapper {
        flex-direction: column;
        gap: 20px;
        margin: 20px 0;
    }
    
    .credit-card-reference {
        padding: 15px;
        margin: 0;
    }
    
    .measurement-info {
        margin-top: 0;
        min-height: 250px;
    }
    
    .info-header {
        padding: 20px 20px 15px;
    }
    
    .info-icon {
        font-size: 1.6em;
    }
    
    .info-title {
        font-size: 1.2em;
    }
    
    .info-content {
        padding: 15px 20px 20px;
    }
    
    .info-row {
        padding: 10px 0;
        font-size: 0.9em;
    }
    
    .reference-title {
        font-size: 0.95em;
        flex-wrap: wrap;
    }
    
    .credit-card-container {
        padding: 15px;
        min-height: 180px;
        margin: 15px 0;
    }
    
    .credit-card {
        padding: 12px;
        border-radius: 10px;
    }
    
    .card-chip {
        width: 40px;
        height: 32px;
        margin-bottom: 15px;
    }
    
    .card-number {
        font-size: 0.9em;
        letter-spacing: 1px;
        margin-bottom: 15px;
    }
    
    .card-info {
        font-size: 0.75em;
    }
    
    .reference-text {
        font-size: 0.85em;
        padding: 12px;
        margin-top: 15px;
    }
    
    .reference-text p {
        margin: 6px 0;
    }

    .features-grid {
        grid-template-columns: 1fr;
    }

    .usage-section,
    .faq-section {
        padding: 25px 20px;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 0 10px;
        width: 100%;
        max-width: 100%;
    }
    
    main {
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }
    
    .header-content {
        gap: 8px;
    }
    
    .top-nav {
        gap: 6px;
        width: 100%;
    }
    
    .top-nav a {
        padding: 4px 8px;
        font-size: 12px;
    }
    
    .header-content {
        gap: 8px;
    }
    
    .top-nav {
        gap: 6px;
        width: 100%;
        justify-content: flex-start;
    }
    
    .top-nav a {
        padding: 4px 8px;
        font-size: 12px;
    }
    
    .tool-section {
        padding: 15px 10px;
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }
    
    .control-group {
        flex-wrap: wrap;
    }
    
    .control-group label {
        width: 100%;
    }
    
    .control-group select {
        width: 100%;
        margin-bottom: 10px;
    }
    
    .btn-auto-detect,
    .btn-reset {
        flex: 1;
        min-width: 0;
        margin-left: 0;
        margin-top: 0;
        box-sizing: border-box;
    }
    
    .btn-auto-detect {
        margin-right: 5px;
    }
    
    .btn-reset {
        margin-left: 5px;
    }

    header {
        padding: 20px 0;
    }
    
    .header-content {
        gap: 10px;
    }
    
    .header-logo {
        width: 44px;
        height: 44px;
        padding: 5px;
        border-radius: 10px;
    }

    header h1 {
        font-size: 1.3em;
    }
    
    .subtitle {
        font-size: 0.75em;
    }

    main {
        padding: 20px 0;
    }

    .tool-section {
        padding: 15px;
    }
    
    .ruler {
        height: 150px; /* 小屏幕也增加高度 */
    }
    
    .ruler-mark.cm-major,
    .ruler-mark.inch-major {
        height: 28%;
    }
    
    .ruler-label {
        font-size: 10px;
    }
    
    .ruler-label.cm-label {
        top: 26%; /* 在厘米刻度下方，更靠近厘米区域 */
        font-size: 10px;
    }
    
    .ruler-label.inch-label {
        bottom: 26%; /* 在英寸刻度上方，更靠近英寸区域，远离厘米数字 */
        font-size: 10px;
    }
    
    .ruler-unit-label {
        font-size: 10px;
        padding: 1px 2px;
    }
    
    .cm-unit-label {
        top: 1px;
        left: 1px;
    }
    
    .inch-unit-label {
        bottom: 1px;
        left: 1px;
    }
}

