/* デザインシステムとリセット */
:root {
    --bg-color: #111827; /* ディープダークグレー */
    --card-bg: #1f2937;  /* 少し明るいダークグレー */
    --border-color: #374151; /* 枠線グレー */
    --text-primary: #f9fafb; /* メイン文字色 白 */
    --text-secondary: #cbd5e1; /* サブ文字色 グレー */
    
    /* 指定のボタン色 */
    --orange-primary: #f97316; /* 選択中オレンジ */
    --btn-non-select-bg: #1f2937; /* 非選択背景 */
    --btn-non-select-text: #cbd5e1; /* 非選択文字 */
    --btn-non-select-border: #475569; /* 非選択枠線 */
    
    /* エラー色 */
    --error-color: #ef4444; /* 赤色 */
    
    --transition-fast: 0.15s ease;
}

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

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    font-family: 'Inter', 'Noto Sans JP', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    padding: 16px 16px 40px 16px;
}

.app-container {
    width: 100%;
    max-width: 520px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* ヘッダーデザイン (COO CRAFT追加) */
.app-header {
    text-align: center;
    padding: 8px 0;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.brand-logo {
    font-size: 0.8rem;
    font-weight: 900;
    color: var(--orange-primary);
    letter-spacing: 0.2em;
    text-transform: uppercase;
    margin-bottom: 2px;
}

.app-header h1 {
    font-size: 1.45rem;
    font-weight: 900;
    color: var(--text-primary);
    letter-spacing: -0.025em;
    margin-bottom: 4px;
}

.app-header .subtitle {
    font-size: 0.825rem;
    color: var(--text-secondary);
    font-weight: 500;
    opacity: 0.85;
}

.app-main {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* モード切り替えボタン (スマホ最適化) */
.mode-selector {
    display: flex;
    gap: 8px;
    width: 100%;
}

.mode-btn {
    flex: 1;
    min-height: 48px; /* 最低48px以上 */
    font-weight: 700; /* 文字は太字 */
    font-size: 0.95rem;
    border-radius: 8px; /* 角丸 */
    cursor: pointer;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px 16px;
    outline: none;
    border: 1px solid var(--btn-non-select-border);
    background-color: var(--btn-non-select-bg);
    color: var(--btn-non-select-text);
}

/* 選択中の見た目 */
.mode-btn.active {
    background-color: var(--orange-primary); /* 背景色：オレンジ #F97316 */
    color: #ffffff; /* 文字色：白 #FFFFFF */
    border-color: var(--orange-primary); /* 枠線：オレンジ #F97316 */
    box-shadow: 0 4px 12px rgba(249, 115, 22, 0.25);
}

/* スマホ幅が狭い場合は上下並びに */
@media (max-width: 360px) {
    .mode-selector {
        flex-direction: column;
    }
}

/* フォーム関連 */
.calc-form {
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.form-group-row {
    display: flex;
    gap: 12px;
}

.form-group-row .form-control {
    flex: 1;
}

.form-control {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-control label {
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--text-secondary);
}

.form-control input {
    width: 100%;
    min-height: 48px; /* タップしやすさ向上 */
    background-color: #111827;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: #ffffff;
    padding: 10px 14px;
    font-size: 1.1rem;
    font-weight: 700;
    outline: none;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-control input:focus {
    border-color: var(--orange-primary);
    box-shadow: 0 0 0 2px rgba(249, 115, 22, 0.25);
}

/* バリデーションエラー時の枠線 */
.form-control.has-error input {
    border-color: var(--error-color);
    box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.2);
}

/* エラーメッセージ赤文字 */
.error-message {
    color: var(--error-color);
    font-size: 0.775rem;
    font-weight: 700;
    min-height: 16px;
    display: none;
    margin-top: 2px;
}

.form-control.has-error .error-message {
    display: block;
    animation: fadeIn 0.15s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-2px); }
    to { opacity: 1; transform: translateY(0); }
}

.form-control input::placeholder {
    color: #4b5563;
}

/* 操作ボタンエリア */
.action-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 8px;
}

/* 計算するボタン (高さ56px以上, オレンジ) */
.btn-calculate {
    min-height: 56px;
    background-color: var(--orange-primary);
    color: #ffffff;
    border: 1px solid var(--orange-primary);
    border-radius: 8px;
    font-size: 1.1rem;
    font-weight: 800;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color var(--transition-fast), transform var(--transition-fast), box-shadow var(--transition-fast);
    box-shadow: 0 4px 6px -1px rgba(249, 115, 22, 0.2);
    width: 100%;
}

.btn-calculate:hover {
    background-color: #ea580c;
    border-color: #ea580c;
}

.btn-calculate:active {
    transform: scale(0.98);
}

/* リセットボタン (高さ48px以上, 非選択色調) */
.btn-reset {
    min-height: 48px;
    background-color: var(--btn-non-select-bg);
    color: var(--btn-non-select-text);
    border: 1px solid var(--btn-non-select-border);
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    width: 100%;
}

.btn-reset:hover {
    background-color: #273549;
    color: #ffffff;
}

.btn-reset:active {
    transform: scale(0.98);
}

/* 計算結果カード */
.result-card {
    background-color: var(--card-bg);
    border: 2px solid var(--orange-primary);
    border-radius: 12px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    box-shadow: 0 10px 15px -3px rgba(249, 115, 22, 0.15), 0 4px 6px -2px rgba(249, 115, 22, 0.05);
    animation: slideUp 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.result-header {
    text-align: center;
    border-bottom: 1px dashed var(--border-color);
    padding-bottom: 14px;
}

.result-title {
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--text-secondary);
    display: block;
    margin-bottom: 4px;
}

.result-value-container {
    display: flex;
    align-items: baseline;
    justify-content: center;
    color: var(--orange-primary);
}

.result-value-prefix {
    font-size: 1rem;
    font-weight: 700;
    margin-right: 4px;
}

.result-value {
    font-size: 2.5rem;
    font-weight: 900;
    line-height: 1;
}

.result-unit {
    font-size: 1.25rem;
    font-weight: 700;
    margin-left: 4px;
}

.result-details {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.detail-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.95rem;
}

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

.detail-val {
    font-weight: 700;
    color: var(--text-primary);
}

.detail-row.divider {
    height: 1px;
    background-color: var(--border-color);
    margin: 4px 0;
}

.detail-row.sub-detail {
    font-size: 0.85rem;
}

.detail-row.sub-detail .detail-label {
    color: #9ca3af;
}

.detail-row.sub-detail .detail-val {
    color: #cbd5e1;
    font-weight: 500;
}

/* コピーボタン */
.btn-copy {
    min-height: 48px;
    background-color: var(--orange-primary);
    color: #ffffff;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: background-color var(--transition-fast), transform var(--transition-fast);
    width: 100%;
}

.btn-copy:active {
    transform: scale(0.98);
}

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

.copy-icon {
    stroke: currentColor;
}

/* 短い注意書き */
.short-note {
    font-size: 0.775rem;
    color: #9ca3af;
    text-align: center;
    line-height: 1.4;
    padding: 0 8px;
}

/* 相談ボタン (高さ48px以上, 外部リンク) */
.btn-consult {
    min-height: 48px;
    background-color: transparent;
    color: var(--orange-primary);
    border: 2px solid var(--orange-primary);
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 700;
    text-decoration: none;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all var(--transition-fast);
    width: 100%;
    margin-top: 4px;
}

.btn-consult:hover {
    background-color: rgba(249, 115, 22, 0.08);
    box-shadow: 0 4px 12px rgba(249, 115, 22, 0.1);
}

.btn-consult:active {
    transform: scale(0.98);
}

.external-link-icon {
    stroke: currentColor;
}

/* トースト通知 */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background-color: #10b981; /* グリーン */
    color: #ffffff;
    padding: 12px 24px;
    border-radius: 9999px;
    font-weight: 700;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.4);
    pointer-events: none;
    opacity: 0;
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.25s ease;
    z-index: 100;
}

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

/* ページ下部詳細注意書き */
.app-footer {
    border-top: 1px solid var(--border-color);
    margin-top: 24px;
    padding-top: 16px;
}

.footer-notes-container {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.footer-note-title {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-secondary);
}

.footer-note-item {
    font-size: 0.75rem;
    color: #9ca3af;
    line-height: 1.45;
}
