:root {
    --primary-color: #5b6cff;
    --primary-hover: #4757e6;
    --secondary-color: #ff6b6b;
    --background: #f8f9fa;
    --surface: #ffffff;
    --text-primary: #2c3e50;
    --text-secondary: #6c757d;
    --border-color: #e9ecef;
    --success-color: #28a745;
    --warning-color: #ffc107;
    --error-color: #dc3545;
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
    --radius-sm: 6px;
    --radius-md: 12px;
    --radius-lg: 16px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--background);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* ヘッダー */
header {
    text-align: center;
    margin-bottom: 40px;
    position: relative;
}

h1 {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 8px;
    letter-spacing: -0.02em;
}

.subtitle {
    font-size: 1.1rem;
    color: var(--text-secondary);
    margin-bottom: 20px;
}

.language-selector {
    position: absolute;
    top: 0;
    right: 0;
}

.language-selector select {
    padding: 8px 16px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text-primary);
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
}

.language-selector select:hover {
    border-color: var(--primary-color);
}

/* カード */
.card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 32px;
    margin-bottom: 24px;
    box-shadow: var(--shadow-sm);
    transition: all 0.3s ease;
}

.card:hover {
    box-shadow: var(--shadow-md);
}

.card h2 {
    font-size: 1.5rem;
    margin-bottom: 24px;
    color: var(--text-primary);
    font-weight: 600;
}

/* 入力セクション */
.input-grid {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin-bottom: 24px;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.input-group label {
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.input-group input {
    width: 120px;
    padding: 12px 16px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 1.1rem;
    font-weight: 600;
    text-align: center;
    transition: all 0.2s;
}

.input-group input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(91, 108, 255, 0.1);
}

.separator {
    font-size: 1.5rem;
    color: var(--text-secondary);
    margin-top: 30px;
}

.unit {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-left: 8px;
}

.current-ratio {
    text-align: center;
    font-size: 1.1rem;
    color: var(--text-secondary);
}

.ratio-value {
    font-weight: 600;
    color: var(--primary-color);
    margin-left: 8px;
}

/* プリセットセクション */
.preset-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
}

.preset-button {
    padding: 16px;
    border: 2px solid var(--border-color);
    background: var(--surface);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.preset-button:hover {
    border-color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.preset-button.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.preset-button .ratio {
    font-size: 1.2rem;
    font-weight: 700;
}

.preset-button .name {
    font-size: 0.85rem;
    opacity: 0.8;
}

/* 結果セクション */
.result-options {
    display: flex;
    gap: 16px;
    margin-bottom: 24px;
    flex-wrap: wrap;
    justify-content: center;
}

.option-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.option-group input[type="radio"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.option-group label {
    cursor: pointer;
    font-size: 0.95rem;
}

.result-display {
    background: var(--background);
    padding: 24px;
    border-radius: var(--radius-md);
    margin-bottom: 24px;
}

.result-item {
    display: flex;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-color);
}

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

.result-label {
    color: var(--text-secondary);
}

.result-value {
    font-weight: 600;
    color: var(--primary-color);
}

/* プレビュー */
.visual-preview {
    margin-top: 24px;
}

.preview-container {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 32px;
    min-height: 250px;
}

.preview-box {
    border: 2px dashed var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    transition: all 0.3s ease;
}

.preview-box span {
    position: absolute;
    top: -25px;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.preview-box.original {
    border-color: var(--text-secondary);
}

.preview-box.converted {
    border-color: var(--primary-color);
    background: rgba(91, 108, 255, 0.05);
}

/* 解像度セクション */
.resolution-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
    border-bottom: 2px solid var(--border-color);
}

.tab-button {
    padding: 12px 24px;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 1rem;
    color: var(--text-secondary);
    border-bottom: 3px solid transparent;
    transition: all 0.2s;
    margin-bottom: -2px;
}

.tab-button:hover {
    color: var(--text-primary);
}

.tab-button.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
    font-weight: 600;
}

.resolution-list {
    display: grid;
    gap: 8px;
}

.resolution-item {
    display: grid;
    grid-template-columns: 2fr 1.5fr 1fr;
    align-items: center;
    padding: 12px 16px;
    background: var(--background);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s;
}

.resolution-item:hover {
    background: var(--primary-color);
    color: white;
    transform: translateX(4px);
}

.res-name {
    font-weight: 500;
}

.res-size {
    font-family: 'SF Mono', Monaco, monospace;
    font-size: 0.95rem;
}

.res-ratio {
    text-align: right;
    opacity: 0.7;
    font-size: 0.9rem;
}

/* 計算セクション */
.calculator-grid {
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    gap: 16px;
    align-items: end;
    margin-bottom: 24px;
}

.calc-input {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.calc-input label {
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.calc-input input {
    padding: 12px 16px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    transition: all 0.2s;
}

.calc-input input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(91, 108, 255, 0.1);
}

.calculate-btn {
    padding: 12px 32px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.calculate-btn:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.calc-result {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.calc-option {
    background: var(--background);
    padding: 20px;
    border-radius: var(--radius-md);
    text-align: center;
}

.calc-option h3 {
    font-size: 1.1rem;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.calc-option p {
    margin: 4px 0;
    color: var(--text-secondary);
}

.calc-option p:first-of-type {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--primary-color);
}

/* フッター */
footer {
    text-align: center;
    padding: 40px 20px 20px;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* レスポンシブ */
@media (max-width: 768px) {
    .container {
        padding: 16px;
    }
    
    h1 {
        font-size: 2rem;
    }
    
    .card {
        padding: 20px;
    }
    
    .input-grid {
        flex-direction: column;
    }
    
    .separator {
        display: none;
    }
    
    .preview-container {
        flex-direction: column;
    }
    
    .calculator-grid {
        grid-template-columns: 1fr;
    }
    
    .calc-result {
        grid-template-columns: 1fr;
    }
    
    .resolution-tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .language-selector {
        position: static;
        margin-top: 16px;
    }
}