/* ===== CSS変数（ライト/ダークテーマ） ===== */
:root {
    /* アクセントカラー */
    --accent: #667eea;
    --accent-end: #764ba2;
    --accent-light: rgba(102, 126, 234, 0.4);

    /* 背景 */
    --bg-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --nav-bg: rgba(255, 255, 255, 0.95);
    --nav-border: transparent;
    --nav-shadow: 0 2px 20px rgba(0,0,0,0.1);
    --card-bg: #ffffff;
    --card-border: transparent;
    --settings-bg: #f8f9fa;
    --result-bg: #f8f9fa;
    --history-item-bg: #f0f0f0;
    --icon-btn-bg: #e2e8f0;
    --icon-btn-hover: #cbd5e1;
    --checkbox-bg: #ffffff;

    /* テキスト */
    --text-primary: #333333;
    --text-secondary: #555555;
    --text-muted: #666666;
    --text-nav: #555555;
    --text-nav-active: #667eea;
    --text-footer: rgba(255, 255, 255, 0.8);
    --text-footer-link: #ffffff;

    /* ボタン */
    --btn-secondary-bg: #f0f0f0;
    --btn-secondary-color: #555555;
    --btn-secondary-hover: #e0e0e0;

    /* 区切り線 */
    --border-color: rgba(0, 0, 0, 0.1);

    /* スライダー */
    --range-track: #d1d5db;
    --range-thumb: #667eea;

    /* トグル */
    --toggle-on: #667eea;
    --toggle-off: #d1d5db;

    /* チェックボックスボーダー */
    --checkbox-border: #e2e8f0;
    --checkbox-active-border: #667eea;
    --checkbox-active-bg: rgba(102, 126, 234, 0.05);
}

@media (prefers-color-scheme: dark) {
    :root {
        /* アクセントカラー */
        --accent: #38bdf8;
        --accent-end: #818cf8;
        --accent-light: rgba(56, 189, 248, 0.3);

        /* 背景 */
        --bg-gradient: #0f172a;
        --nav-bg: rgba(30, 41, 59, 0.95);
        --nav-border: #334155;
        --nav-shadow: 0 2px 20px rgba(0,0,0,0.3);
        --card-bg: #1e293b;
        --card-border: #334155;
        --settings-bg: #0f172a;
        --result-bg: #0f172a;
        --history-item-bg: #0f172a;
        --icon-btn-bg: #334155;
        --icon-btn-hover: #475569;
        --checkbox-bg: #1e293b;

        /* テキスト */
        --text-primary: #e2e8f0;
        --text-secondary: #94a3b8;
        --text-muted: #94a3b8;
        --text-nav: #94a3b8;
        --text-nav-active: #38bdf8;
        --text-footer: rgba(148, 163, 184, 0.8);
        --text-footer-link: #94a3b8;

        /* ボタン */
        --btn-secondary-bg: #334155;
        --btn-secondary-color: #e2e8f0;
        --btn-secondary-hover: #475569;

        /* 区切り線 */
        --border-color: #334155;

        /* スライダー */
        --range-track: #334155;
        --range-thumb: #38bdf8;

        /* トグル */
        --toggle-on: #38bdf8;
        --toggle-off: #334155;

        /* チェックボックスボーダー */
        --checkbox-border: #334155;
        --checkbox-active-border: #38bdf8;
        --checkbox-active-bg: rgba(56, 189, 248, 0.1);
    }
}

/* ===== リセット・ベース ===== */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    min-height: 100vh;
    padding: 80px 20px 20px;
    background: var(--bg-gradient);
    color: var(--text-primary);
    transition: background 0.3s, color 0.3s;
}

/* ===== ナビゲーション ===== */
nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    padding: 15px 30px;
    z-index: 1000;
    backdrop-filter: blur(10px);
    background: var(--nav-bg);
    border-bottom: 1px solid var(--nav-border);
    box-shadow: var(--nav-shadow);
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-size: 1.5rem;
    font-weight: bold;
    text-decoration: none;
    transition: opacity 0.2s;
    color: var(--accent);
}

.logo:hover {
    opacity: 0.8;
}

.nav-links {
    display: flex;
    gap: 30px;
    list-style: none;
}

.nav-links a {
    text-decoration: none;
    font-weight: 500;
    transition: all 0.3s;
    position: relative;
    padding-bottom: 5px;
    color: var(--text-nav);
}

.nav-links a:hover,
.nav-links a.active {
    color: var(--text-nav-active);
}

.nav-links a::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 0;
    height: 2px;
    transition: width 0.3s;
    background: var(--accent);
}

.nav-links a:hover::after,
.nav-links a.active::after {
    width: 100%;
}

/* ===== コンテナ ===== */
.container {
    max-width: 600px;
    margin: 40px auto;
    padding: 30px;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    background: var(--card-bg);
    border: 1px solid var(--card-border);
}

.container-wide {
    max-width: 800px;
}

/* ===== タイポグラフィ ===== */
h1 {
    font-size: 1.8rem;
    margin-bottom: 10px;
    text-align: center;
    color: var(--text-primary);
}

.subtitle {
    font-size: 0.9rem;
    margin-bottom: 30px;
    text-align: center;
    opacity: 0.7;
    color: var(--text-muted);
}

/* ===== ボタン ===== */
.btn {
    padding: 12px 24px;
    font-size: 1rem;
    cursor: pointer;
    border: none;
    border-radius: 8px;
    transition: all 0.2s;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn:hover {
    transform: translateY(-2px);
}

.btn-primary {
    padding: 15px 40px;
    font-size: 1.1rem;
    width: 100%;
    margin-bottom: 12px;
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-end) 100%);
    color: white;
}

.btn-primary:hover {
    box-shadow: 0 5px 20px var(--accent-light);
}

.btn-secondary {
    width: 100%;
    margin-bottom: 12px;
    background: var(--btn-secondary-bg);
    color: var(--btn-secondary-color);
}

.btn-secondary:hover {
    background: var(--btn-secondary-hover);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* ===== 設定パネル ===== */
.settings {
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 25px;
    background: var(--settings-bg);
}

.setting-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.setting-row:last-child {
    margin-bottom: 0;
}

.setting-label {
    font-size: 0.95rem;
    color: var(--text-primary);
}

/* ===== スライダー ===== */
.length-control {
    display: flex;
    align-items: center;
    gap: 12px;
}

input[type="range"] {
    width: 120px;
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
    border-radius: 3px;
    outline: none;
    cursor: pointer;
    background: var(--range-track);
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.2s;
    background: var(--range-thumb);
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

.length-value {
    font-weight: bold;
    min-width: 24px;
    text-align: center;
    color: var(--text-primary);
}

/* ===== トグルスイッチ ===== */
.toggle {
    position: relative;
    width: 48px;
    height: 26px;
}

.toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    transition: 0.3s;
    border-radius: 26px;
    background: var(--toggle-off);
}

input:checked + .toggle-slider {
    background: var(--toggle-on);
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background: white;
    transition: 0.3s;
    border-radius: 50%;
}

input:checked + .toggle-slider:before {
    transform: translateX(22px);
}

/* ===== チェックボックス ===== */
.checkbox-group {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.checkbox-item {
    display: flex;
    align-items: center;
    cursor: pointer;
    padding: 8px 12px;
    border-radius: 8px;
    border: 2px solid var(--checkbox-border);
    transition: all 0.2s;
    background: var(--checkbox-bg);
    color: var(--text-primary);
}

.checkbox-item:has(input:checked) {
    border-color: var(--checkbox-active-border);
    background: var(--checkbox-active-bg);
}

.checkbox-item input[type="checkbox"] {
    margin-right: 8px;
    cursor: pointer;
    width: 18px;
    height: 18px;
    accent-color: var(--accent);
}

/* ===== 結果表示 ===== */
.result-box {
    border-radius: 12px;
    padding: 25px;
    margin-bottom: 20px;
    text-align: center;
    background: var(--result-bg);
    border: 1px solid var(--card-border);
}

.result {
    font-size: 1.8rem;
    letter-spacing: 2px;
    word-break: break-all;
    min-height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: "SF Mono", Monaco, "Cascadia Code", monospace;
    color: var(--text-primary);
}

.result-placeholder {
    font-size: 1rem;
    opacity: 0.5;
}

/* ===== 強度バー ===== */
.strength-bar {
    height: 4px;
    border-radius: 2px;
    margin-top: 15px;
    overflow: hidden;
    background: var(--border-color);
}

.strength-fill {
    height: 100%;
    width: 0%;
    transition: all 0.3s;
    border-radius: 2px;
}

.strength-text {
    font-size: 0.85rem;
    margin-top: 8px;
    opacity: 0.7;
    color: var(--text-muted);
}

/* ===== 履歴 ===== */
.history-section {
    margin-top: 25px;
    padding-top: 20px;
    border-top: 2px solid var(--border-color);
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.history-title {
    font-weight: 600;
    font-size: 0.9rem;
    opacity: 0.7;
    color: var(--text-primary);
}

.clear-btn {
    font-size: 0.8rem;
    background: none;
    border: none;
    cursor: pointer;
    opacity: 0.5;
    transition: opacity 0.2s;
    color: var(--text-primary);
}

.clear-btn:hover {
    opacity: 1;
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.history-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    border-radius: 8px;
    font-family: monospace;
    font-size: 0.95rem;
    background: var(--history-item-bg);
    color: var(--text-primary);
}

.history-actions {
    display: flex;
    gap: 6px;
}

.icon-btn {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    transition: all 0.2s;
    background: var(--icon-btn-bg);
    color: var(--text-primary);
}

.icon-btn:hover {
    background: var(--icon-btn-hover);
}

/* ===== トースト ===== */
.toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    padding: 12px 24px;
    border-radius: 8px;
    opacity: 0;
    transition: all 0.3s;
    z-index: 1000;
    font-weight: 500;
    color: white;
    background: var(--accent);
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

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

footer a {
    text-decoration: none;
    border-bottom: 1px solid;
    color: var(--text-footer-link);
}

/* ===== 戻るリンク ===== */
.back-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    font-weight: 500;
    margin-bottom: 20px;
    transition: opacity 0.2s;
    color: var(--accent);
}

.back-link:hover {
    opacity: 0.8;
}

/* ===== レスポンシブ ===== */
@media (max-width: 768px) {
    .nav-links {
        gap: 15px;
        font-size: 0.9rem;
    }
    
    .container {
        padding: 20px;
        margin: 20px auto;
    }
    
    .result {
        font-size: 1.4rem;
    }
    
    .setting-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    
    .checkbox-group {
        flex-direction: column;
    }
    
    .checkbox-item {
        width: 100%;
    }
}
