:root {
    --primary: #2563eb;
    --primary-dark: #1e40af;
    --secondary: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --bg-dark: #0f172a;
    --bg-card: #1e293b;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --border: #334155;
    --font-main: 'Inter', 'Noto Sans JP', sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    font-family: var(--font-main);
    line-height: 1.5;
    /* 老眼対応：ベースフォントサイズ拡大 */
    font-size: 18px;
    font-weight: 500;
    padding-bottom: 40px;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.app-container {
    max-width: 600px;
    margin: 0 auto;
    padding: 1rem;
    flex: 1;
}

/* ヘッダー */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
}

.app-header h1 {
    font-size: 1.4rem;
    font-weight: 800;
    background: linear-gradient(90deg, #60a5fa, #34d399);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.btn-icon {
    background: none;
    border: 1px solid var(--border);
    width: 40px;
    height: 40px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    color: var(--text-muted);
    border-radius: 8px;
    margin-top: 0;
}

.btn-icon:active {
    background-color: var(--bg-card);
}

#clock-display {
    font-family: monospace;
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--text-muted);
}

/* 進捗入力ラベルの目標値表示 */
.plan-label-sub {
    display: block;
    font-size: 0.8em;
    color: var(--text-muted);
    font-weight: normal;
    margin-top: 2px;
}

/* カード */
.area-card {
    background-color: var(--bg-card);
    border-radius: 20px;
    padding: 1.5rem;
    border: 1px solid var(--border);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s, box-shadow 0.2s;
    position: relative;
    overflow: hidden;
    grid-column: span 2;
    
    display: flex;
    flex-direction: column;
    min-height: 230px; /* 一覧でカード高さを統一 */
}
.card {
    background-color: var(--bg-card);
    border-radius: 12px;
    padding: 1.25rem;
    margin-bottom: 1rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.card h2,
.card h3 {
    margin-bottom: 1rem;
    font-size: 1.2rem;
    color: var(--text-main);
    font-weight: 700;
}

.card h2 {
    font-size: 1.5rem;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.5rem;
}

/* フォーム */
.form-group {
    margin-bottom: 1rem;
    flex: 1;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-muted);
}

.form-group-row {
    display: flex;
    gap: 1rem;
}

input,
select {
    width: 100%;
    padding: 0.75rem;
    border-radius: 8px;
    border: 1px solid var(--border);
    background-color: var(--bg-dark);
    color: var(--text-main);
    font-size: 1.1rem;
    font-weight: 600;
    outline: none;
    transition: border-color 0.2s;
}

input:focus,
select:focus {
    border-color: var(--primary);
}

/* 時刻入力を他の入力欄と同じサイズに統一 */
input[type="time"] {
    -webkit-appearance: none;
    appearance: none;
    min-height: 3rem;
    box-sizing: border-box;
}

/* ボタン */
button {
    width: 100%;
    padding: 1rem;
    border: none;
    border-radius: 8px;
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.1s, opacity 0.2s;
    margin-top: 0.5rem;
}

button:active {
    transform: scale(0.98);
}

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

.btn-secondary {
    background-color: var(--secondary);
    color: #064e3b;
}

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

.btn-danger {
    background-color: var(--danger);
    color: white;
    margin-top: 2rem;
}

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

.btn-dark {
    background-color: #1e293b;
    color: var(--text-muted);
    border: 1px solid var(--border);
}

/* ステータスグリッド */
.status-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.status-card {
    background-color: var(--bg-card);
    padding: 1rem;
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    text-align: center;
    border: 1px solid var(--border);
}

.status-card.highlight {
    grid-column: span 2;
    background: linear-gradient(135deg, var(--bg-card), #1e3a8a);
    border-color: var(--primary);
}

.status-card .label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.status-card .value {
    /* 老眼対応：ステータス値を大きく太く */
    font-size: 1.8rem;
    font-weight: 800;
}

/* プログレスバー */
.progress-bar {
    height: 5px;
    background-color: var(--bg-dark);
    border-radius: 2px;
    margin-top: 0.5rem;
    overflow: hidden;
}

.progress-bar .fill {
    height: 100%;
    background-color: var(--primary);
    transition: width 0.3s ease;
}

/* チャート */
.chart-container {
    position: relative;
    height: 250px;
    width: 100%;
}

/* ユーティリティ */
.hidden {
    display: none !important;
}

/* フッターシグネチャー */
.signature-footer {
    text-align: center;
    margin-top: auto;
    padding-bottom: 1rem;
    font-family: 'Inter', sans-serif;
    font-size: 0.9rem;
    color: var(--text-muted);
    opacity: 0.5;
    letter-spacing: 0.3em;
    font-weight: 700;
}

.card-header-action {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
}

/* 結果画面 */
.result-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.result-item {
    background-color: var(--bg-dark);
    padding: 1rem;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.result-item span {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
}

.result-item strong {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--text-main);
    margin-top: 0.25rem;
}

.button-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

/* トースト */
.toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background-color: var(--secondary);
    color: #064e3b;
    padding: 0.75rem 1.5rem;
    border-radius: 50px;
    font-weight: 700;
    font-size: 1rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 100;
    animation: fadeUp 0.3s ease-out;
}

@keyframes fadeUp {
    from {
        opacity: 0;
        transform: translate(-50%, 20px);
    }

    to {
        opacity: 1;
        transform: translate(-50%, 0);
    }
}

/* 快調ステータス用：虹色アニメーション */
@keyframes rainbow-shift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

.btn-pink {
    background: linear-gradient(135deg, #f472b6, #ec4899);
    color: white;
    border: none;
    padding: 2px 8px; /* 文字にオートフィット */
    border-radius: 6px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(236, 72, 153, 0.2);
    border-bottom: 2px solid #db2777;
    transition: all 0.2s;
    font-size: 0.75rem; /* 小さめ */
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: fit-content;
    vertical-align: middle;
}
.btn-pink:active {
    transform: translateY(2px);
    border-bottom-width: 1px;
}

/* モーダル */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(4px);
    display: none; /* JSで切り替え */
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: 1.5rem;
}
.modal-overlay.active {
    display: flex;
    animation: fadeIn 0.3s ease;
}
.modal-content {
    background-color: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 20px;
    width: 100%;
    max-width: 450px;
    padding: 2rem;
    position: relative;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    transform: scale(0.7);
    animation: modalShow 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}
.modal-header { margin-bottom: 1.5rem; text-align: center; }
.modal-header h3 { font-size: 1.5rem; color: #f472b6; }
.modal-body { font-size: 1rem; line-height: 1.6; color: var(--text-main); }
.manual-item { margin-bottom: 1.25rem; }
.manual-label { display: block; color: #f472b6; font-weight: 800; margin-bottom: 0.25rem; font-size: 1.1rem; }
.btn-modal-close {
    margin-top: 1.5rem; width: 100%; background: var(--border); color: var(--text-main);
    border: none; padding: 0.75rem; border-radius: 10px; font-weight: 700; cursor: pointer;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
@keyframes modalShow {
    from { transform: scale(0.7); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.status-badge {
    font-size: 0.75rem;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: bold;
    margin-left: 6px;
}
.status-idle { background-color: #4b5563; color: #fff; }
.status-running { background-color: #10b981; color: #fff; }
.status-paused { background-color: #f59e0b; color: #fff; }
.status-finished { background-color: #ef4444; color: #fff; }