/* ==========================================================================
   Kindle Unlimited お得度メーター - Style Sheets (Light Theme)
   ========================================================================== */

/* Variables & Base Custom Properties */
:root {
    --bg-color: #FAF6F0; /* 生成り・クラフト紙風の非常に温かいベージュ */
    --card-bg: #FFFFFF;
    --card-border: #D3C8BA; /* セピア調の落ち着いたブラウンベージュ境界線 */
    --text-main: #2A2421; /* ディープチョコレートブラック */
    --text-muted: #655953; /* セピアブラウン寄りのダークグレー */
    
    --primary: #1A5F7A; /* 高貴でインテリジェンスを感じさせるロイヤルブックブルー */
    --primary-glow: rgba(26, 95, 122, 0.08);
    --accent: #B9944A; /* アンティークゴールド・真鍮色 */
    --accent-glow: rgba(185, 148, 74, 0.08);
    
    --success: #3F5E4D; /* ブックカバーを思わせる深みのあるセージグリーン */
    --success-bg: rgba(63, 94, 77, 0.06);
    --danger: #A24838; /* アンティークレッド */
    --danger-bg: rgba(162, 72, 56, 0.06);
    --warning: #B9944A;
    
    --radius-sm: 4px; /* 手帳風なので少し角はシャープに寄せる */
    --radius-md: 8px;
    --radius-lg: 16px;
    
    --transition-smooth: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    
    /* 読書ノートらしい紙の重なりを感じさせる影 */
    --shadow-premium: 0 4px 12px rgba(42, 36, 33, 0.08), 
                      0 1px 2px rgba(42, 36, 33, 0.04);
    --shadow-wood: inset 0 2px 4px rgba(0,0,0,0.3), 
                   0 4px 8px rgba(0,0,0,0.15);
}

/* Reset & Base Styles */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-color);
    background-image: 
        radial-gradient(at 0% 0%, rgba(0, 126, 185, 0.02) 0px, transparent 40%),
        radial-gradient(at 100% 100%, rgba(217, 119, 6, 0.02) 0px, transparent 40%);
    background-attachment: fixed;
    color: var(--text-main);
    font-family: 'Outfit', 'Noto Sans JP', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    padding-bottom: 40px;
}

body.modal-open {
    overflow: hidden;
}

.number {
    font-family: 'Outfit', sans-serif;
    font-weight: 700;
}

/* Utility Elements */
.badge {
    background: linear-gradient(135deg, var(--primary), #0093CC);
    color: white;
    font-size: 0.75rem;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 20px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    display: inline-block;
}

.badge-gray {
    background: rgba(112, 108, 104, 0.1);
    color: var(--text-muted);
}

.required {
    color: var(--danger);
    margin-left: 2px;
}

/* Header */
.app-header {
    border-bottom: 1px solid var(--card-border);
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(12px);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 14px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 15px;
}



.header-title-area {
    display: flex;
    align-items: center;
    gap: 10px;
}

.header-title-area h1 {
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 60vw;
}

/* Header In-Page Navigation */
.header-nav {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

.header-nav-link {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.8rem;
    font-weight: 600;
    padding: 5px 12px;
    border-radius: 20px;
    border: 1px solid var(--card-border);
    transition: var(--transition-smooth);
    white-space: nowrap;
}

.header-nav-link:hover {
    color: var(--primary);
    border-color: var(--primary);
    background: var(--primary-glow);
    transform: translateY(-1px);
}

/* Main Layout */
.app-main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px;
}

/* Cards (Flat & Soft Shadow) */
.card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-md);
    padding: 24px;
    box-shadow: var(--shadow-premium);
    transition: var(--transition-smooth);
    margin-bottom: 24px;
    position: relative;
}

.card:hover {
    transform: translateY(-4px) rotateX(0.5deg) rotateY(-0.5deg);
    border-color: #B4A695;
    box-shadow: 4px 12px 28px rgba(42, 36, 33, 0.12), 
                0 2px 4px rgba(42, 36, 33, 0.04);
}

.card-title {
    font-size: 1.05rem;
    font-weight: 700;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-main);
    border-bottom: 1px solid var(--card-border);
    padding-bottom: 10px;
}

/* Intro Card */
.intro-card {
    background: linear-gradient(135deg, #FFFFFF 0%, #FAF8F5 100%);
    border-left: 4px solid var(--primary);
}

.intro-content h2 {
    font-size: 1.15rem;
    font-weight: 700;
    margin-bottom: 6px;
    color: var(--text-main);
}

.intro-content p {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.intro-content strong {
    color: var(--primary);
}

/* Main Grid */
.main-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 340px;
    gap: 24px;
    align-items: start;
}

/* Main Content Area */
.main-content {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* Sidebar Content Area */
.sidebar-content {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* Settings Card */
.settings-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-bottom: 12px;
}

.target-info {
    font-size: 0.85rem;
    color: var(--text-muted);
    text-align: right;
    font-weight: 500;
}

.target-info span {
    font-size: 1rem;
    color: var(--primary);
    font-weight: 700;
    margin: 0 2px;
}

.target-info-explain {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 4px;
    text-align: right;
}

/* Inputs & Form Elements (with mobile resets & placeholder contrast) */
input[type="text"],
input[type="number"],
input[type="date"],
select,
textarea {
    background: rgba(185, 148, 74, 0.01); /* うっすらとした背景色で入力欄であることを示す */
    border: 1px solid transparent;
    border-bottom: 2px dashed #bda793;
    border-radius: var(--radius-sm);
    color: var(--text-main);
    padding: 10px 8px; /* パディングを左右に少し広げて入力感を出す */
    font-size: 0.95rem;
    transition: var(--transition-smooth);
    width: 100%;
    -webkit-appearance: none; /* iOS Safari用リセット */
    -moz-appearance: none;
    appearance: none;
}

/* ホバー時に枠線と背景をうっすら表示して「編集可能」なフィードバックを返す */
input[type="text"]:hover,
input[type="number"]:hover,
input[type="date"]:hover,
select:hover,
textarea:hover {
    background: rgba(185, 148, 74, 0.03);
    border-bottom-color: var(--accent);
}

/* Placeholder Contrast Enhancement */
input::placeholder,
textarea::placeholder {
    color: #8A857E; /* プレースホルダーのコントラスト比をWCAG基準値へ調整 */
}

select {
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%235F5A56' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'></polyline></svg>");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 16px;
    padding-right: 32px;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-bottom: 2px solid var(--accent);
    background: rgba(185, 148, 74, 0.03);
    box-shadow: 0 6px 12px rgba(131, 117, 104, 0.05);
    transform: translateY(-2px);
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 16px;
}

.input-group label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
}

/* Quick Price Buttons */
.quick-prices {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: -8px;
    margin-bottom: 16px;
}

.btn-quick-price {
    background: #EAE6DF;
    border: 1px solid transparent;
    color: var(--text-main); /* 文字色のコントラスト比向上 */
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: var(--transition-smooth);
    font-weight: 600;
}

.btn-quick-price:hover {
    background: var(--primary-glow);
    color: var(--primary);
}

/* Form Layout */
.form-row-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

/* Accessibility Star Rating (JS-controlled style) */
.rating-stars {
    display: flex;
    justify-content: flex-start; /* 通常の左寄せ */
    flex-direction: row; /* 左から右の順序 */
    align-items: center;
    height: 42px;
    width: fit-content;
}

.rating-stars input {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
    opacity: 0;
}

/* ハーフ星全体の共通レイアウト */
.rating-stars label.half {
    position: relative;
    height: 42px;
    width: 0.875rem; /* 星1.75remのちょうど半分 */
    font-size: 1.75rem;
    line-height: 42px;
    cursor: pointer;
    overflow: hidden;
    color: #E2E8F0;
    transition: color 0.2s ease, transform 0.15s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: inline-block;
}

/* 左半分（x.5）：星文字をそのまま配置して左半分を露出 */
.rating-stars label.left {
    transform-origin: 100% 50%; /* 拡大時に右端を固定し分裂を防止 */
}
.rating-stars label.left::before {
    content: '★';
    position: absolute;
    left: 0;
    top: 0;
    width: 1.75rem;
}

/* 右半分（x.0）：星文字を左に半分ずらして右半分を露出 */
.rating-stars label.right {
    transform-origin: 0% 50%; /* 拡大時に左端を固定し分裂を防止 */
}
.rating-stars label.right::before {
    content: '★';
    position: absolute;
    left: -0.875rem;
    top: 0;
    width: 1.75rem;
}

/* 1. チェックされた星およびそれより左側（前）の星を着色 */
.rating-stars input:checked + label,
.rating-stars label:has(~ input:checked) {
    color: #EAB308; /* 上品なアンバーゴールド */
}

/* 2. ホバーされた星およびそれより左側（前）の星を着色 */
.rating-stars label:hover,
.rating-stars label:has(~ label:hover) {
    color: #EAB308 !important; /* ホバー時はチェック状態より優先 */
}

/* ホバー時の星拡大エフェクト（★1つ分としてペアで拡大） */
.rating-stars label.left:hover,
.rating-stars label.left:hover + label.right {
    transform: scale(1.18) rotate(-3deg);
    z-index: 10;
}
.rating-stars label.right:hover,
.rating-stars label.left:has(+ label.right:hover) {
    transform: scale(1.18) rotate(-3deg);
    z-index: 10;
}

/* ラジオボタン選択時に星を一瞬弾けさせるポップアニメーション用のスタイル */
.rating-stars input:checked + label {
    animation: starPop 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.5) forwards;
}

@keyframes starPop {
    0% { transform: scale(1); }
    50% { transform: scale(1.3) rotate(10deg); }
    100% { transform: scale(1) rotate(0); }
}

/* フォーカス時のアウトライン表示（キーボード操作用） */
.rating-stars input:focus-visible + label {
    outline: 2px dashed var(--primary);
    outline-offset: 1px;
    background-color: var(--primary-glow);
    border-radius: 4px;
}

/* 表示用ログ履歴の半星グラデーション */
.book-rating-stars {
    display: inline-flex;
    align-items: center;
    font-size: 0.75rem;
    letter-spacing: -1px;
    line-height: 1;
}

.book-rating-stars .star-half {
    background: linear-gradient(90deg, #EAB308 50%, #E2E8F0 50%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    display: inline-block;
    vertical-align: middle; /* 通常の星文字と高さを完璧に合わせる */
}

textarea {
    resize: vertical;
}

.progress-bar-wrapper {
    background: linear-gradient(to bottom, #2E2925 0%, #463F3A 100%); /* 金属管の溝を模した暗い背景 */
    border: 2px solid #362F2B;
    border-radius: 20px;
    height: 22px;
    width: 100%;
    position: relative;
    box-shadow: inset 0 2px 5px rgba(0,0,0,0.5);
    padding: 2px;
}

.progress-bar-fill {
    height: 100%;
    width: 0%;
    border-radius: 20px;
    /* 鈍い光沢を放つゴールド真鍮管を再現したグラデーション */
    background: linear-gradient(to bottom, 
        #D4AF37 0%, 
        #F3E5AB 30%, 
        #AA7C11 70%, 
        #8B6508 100%);
    box-shadow: 0 1px 3px rgba(0,0,0,0.4), inset 0 1px 0 rgba(255,255,255,0.4);
    transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
    will-change: width;
    position: relative;
}

.progress-bar-fill.target-achieved {
    /* 達成時はさらにゴールドの光輝 */
    background: linear-gradient(to bottom, 
        #FFD700 0%, 
        #FFF8DC 30%, 
        #D4AF37 70%, 
        #B8860B 100%);
    box-shadow: 0 0 12px rgba(255, 215, 0, 0.6), inset 0 1px 0 rgba(255,255,255,0.5);
}

.progress-bar-labels {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 500;
}

.progress-bar-percent {
    color: var(--text-main);
    font-weight: 700;
}

.progress-bar-percent .number {
    font-size: 1.6rem;
    margin-right: 2px;
}

.progress-bar-target span {
    font-weight: 600;
}

/* Meter Dashboard Stats */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}

.stat-item {
    background: #FFFFFF;
    border: 1px solid var(--card-border);
    border-radius: var(--radius-md);
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    box-shadow: 0 2px 4px rgba(112, 108, 104, 0.02);
}

.stat-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.stat-val-container {
    display: flex;
    align-items: baseline;
}

.stat-value {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text-main);
    line-height: 1.2;
}

.stat-unit {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-left: 2px;
}

/* Savings Highlight Colors */
.savings-plus {
    color: var(--success);
}
.savings-minus {
    color: var(--danger);
}

/* Status Badge Area */
.status-badge-container {
    display: flex;
    justify-content: center;
    margin-bottom: 20px;
}

.status-badge {
    font-size: 0.85rem;
    font-weight: 600;
    padding: 6px 16px;
    border-radius: 30px;
    text-align: center;
    box-shadow: 0 2px 8px rgba(112, 108, 104, 0.08);
}

.badge-gray {
    background: #EAE6DF;
    border: 1px solid transparent;
    color: var(--text-muted);
}

.badge-info {
    background: var(--primary-glow);
    border: 1px solid rgba(0, 126, 185, 0.2);
    color: var(--primary);
}

.badge-success {
    background: var(--success-bg);
    border: 1px solid rgba(21, 128, 61, 0.2);
    color: var(--success);
    font-weight: 700;
}

.badge-gold {
    background: var(--accent-glow);
    border: 1px solid rgba(217, 119, 6, 0.3);
    color: var(--accent);
    font-weight: 700;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    padding: 11px 24px;
    border-radius: var(--radius-md);
    cursor: pointer;
    border: 1px solid transparent;
    transition: var(--transition-smooth);
    width: auto;
}

.btn-block {
    width: 100%;
}

.btn-primary {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 10px rgba(0, 126, 185, 0.2);
}

.btn-primary:hover {
    background: #006C9E;
    transform: translateY(-1px);
    box-shadow: 0 6px 14px rgba(0, 126, 185, 0.25);
}

.btn-accent {
    background: var(--accent);
    color: white;
    box-shadow: 0 4px 10px rgba(217, 119, 6, 0.2);
}

.btn-accent:hover {
    background: #C26600;
    transform: translateY(-1px);
    box-shadow: 0 6px 14px rgba(217, 119, 6, 0.25);
}

.btn-outline {
    background: #FFFFFF;
    border-color: #D2CBC0;
    color: var(--text-main);
}

.btn-outline:hover {
    background: #FAF8F5;
    border-color: var(--text-muted);
}

/* プレミアム送信ボタン - フォームの主なアクションに使用 */
.btn-submit-primary {
    background: linear-gradient(135deg, var(--accent) 0%, #C28A35 100%);
    color: white;
    font-size: 1rem;
    font-weight: 700;
    padding: 14px 24px;
    letter-spacing: 0.02em;
    box-shadow: 0 4px 16px rgba(185, 148, 74, 0.35),
                0 2px 4px rgba(185, 148, 74, 0.2),
                inset 0 1px 0 rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-md);
    position: relative;
    overflow: hidden;
}

.btn-submit-primary::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s ease;
}

.btn-submit-primary:hover {
    background: linear-gradient(135deg, #C8A050 0%, #A87228 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(185, 148, 74, 0.45),
                0 2px 6px rgba(185, 148, 74, 0.25);
}

.btn-submit-primary:hover::before {
    left: 100%;
}

.btn-submit-primary:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(185, 148, 74, 0.3);
}

.share-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.btn-share {
    width: 100%;
    padding: 12px;
    font-size: 0.95rem;
}

/* Logs List Section */
.logs-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 10px;
}

.logs-header .card-title {
    margin-bottom: 0;
    border-bottom: none;
    padding-bottom: 0;
}

.logs-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.sort-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    white-space: nowrap;
    margin-bottom: 0;
    line-height: 1;
}

.select-field {
    background: #FFFFFF;
    border: 1px solid #D2CBC0;
    color: var(--text-main);
    padding: 6px 12px;
    font-size: 0.85rem;
    border-radius: var(--radius-md);
    cursor: pointer;
    margin: 0;
}

.select-field:focus {
    outline: none;
    border-color: var(--primary);
}

.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.logs-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 480px;
    overflow-y: auto;
    padding-right: 4px;
    
    /* Firefox スクロールバー対応 */
    scrollbar-width: thin;
    scrollbar-color: #D2CBC0 #FAF8F5;
}

/* Custom Scrollbar for Logs List (WebKit) */
.logs-container::-webkit-scrollbar {
    width: 6px;
}

.logs-container::-webkit-scrollbar-track {
    background: #FAF8F5;
    border-radius: 10px;
}

.logs-container::-webkit-scrollbar-thumb {
    background: #D2CBC0;
    border-radius: 10px;
}

.logs-container::-webkit-scrollbar-thumb:hover {
    background: #B4AAA0;
}

/* Book Item Row Card (with fade-in slide animation) */
.book-item {
    background: #FCFAF7; /* 古い紙の風合い */
    border: 1px dashed var(--card-border); /* 図書カードの点線 */
    border-radius: var(--radius-sm);
    padding: 14px 16px;
    display: grid;
    grid-template-columns: auto 1fr auto auto auto;
    grid-template-areas:
        "price title stars date delete"
        "price notes notes notes notes";
    align-items: center;
    gap: 8px 15px;
    transition: var(--transition-smooth);
    box-shadow: 0 2px 4px rgba(42, 36, 33, 0.02);
}

.book-item.animating {
    animation: fadeInSlide 0.4s cubic-bezier(0.4, 0, 0.2, 1) forwards;
    will-change: transform, opacity;
}

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

.book-item:hover {
    border-color: rgba(112, 108, 104, 0.3);
    transform: translateX(2px);
    box-shadow: 0 4px 8px rgba(112, 108, 104, 0.05);
}

.book-badge-price {
    grid-area: price;
    background: var(--primary-glow);
    color: var(--primary);
    border: 1px solid rgba(0, 126, 185, 0.15);
    font-weight: 700;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    min-width: 80px;
    text-align: center;
    align-self: center;
}

.book-title-container {
    grid-area: title;
    min-width: 0;
    display: flex;
    align-items: center;
    width: 100%;
}

.book-title {
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
}

.book-date {
    grid-area: date;
    font-size: 0.75rem;
    color: var(--text-muted);
    flex-shrink: 0;
}

.book-rating-stars {
    grid-area: stars;
    color: #EAB308;
    font-size: 0.75rem;
    letter-spacing: -1px;
    flex-shrink: 0;
}

.book-notes {
    grid-area: notes;
    font-size: 0.8rem;
    color: var(--text-muted);
    background: repeating-linear-gradient(#FAF6F0, #FAF6F0 19px, #E8DFD5 20px);
    line-height: 20px;
    padding: 4px 10px;
    border-radius: 2px;
    margin-top: 4px;
    border: 1px solid #E8DFD5;
    border-left: 2px solid #C4B5A5;
    word-break: break-all;
}

.btn-delete {
    grid-area: delete;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-smooth);
}

.btn-delete:hover {
    color: var(--danger);
    background: var(--danger-bg);
}

/* Backup Card Additional CSS */
.backup-desc {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.backup-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.backup-buttons .btn {
    font-size: 0.8rem;
    padding: 10px;
}

/* Confetti Canvas for 100% Celebration */
.confetti-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 999;
    display: none; /* 初期状態は非表示。startConfetti()で表示される */
}

/* Footer styling */
.app-footer {
    max-width: 1200px;
    margin: 40px auto 0;
    padding: 20px 24px;
    border-top: 1px solid var(--card-border);
    text-align: center;
    color: var(--text-muted);
    font-size: 0.8rem;
}

.app-footer a {
    color: var(--primary);
    text-decoration: none;
    transition: var(--transition-smooth);
}

.footer-link {
    margin: 0 12px;
    display: inline-block;
}

.app-footer a:hover {
    text-decoration: underline;
}

/* ==========================================================================
   Custom Toast Notifications UI
   ========================================================================== */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    z-index: 1000;
    max-width: 380px;
    width: calc(100% - 48px);
}

.toast {
    background: #FFFFFF;
    border: 1px solid var(--card-border);
    border-radius: var(--radius-sm);
    padding: 14px 18px;
    box-shadow: 0 10px 30px rgba(112, 108, 104, 0.15);
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-main);
    transform: translateY(20px);
    opacity: 0;
    animation: toastFadeIn 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
    transition: var(--transition-smooth);
    border-left: 4px solid var(--primary);
}

@keyframes toastFadeIn {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.toast.toast-success {
    border-left-color: var(--success);
}

.toast.toast-error {
    border-left-color: var(--danger);
    background: #FFFDFD;
}

.toast.toast-warning {
    border-left-color: var(--warning);
}

/* ==========================================================================
   Custom Modal Dialog UI (Confirm popup replacement)
   ========================================================================== */
.custom-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(44, 42, 41, 0.45);
    backdrop-filter: blur(4px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1001;
    opacity: 0;
    animation: modalFadeIn 0.2s ease-out forwards;
    will-change: opacity;
}

@keyframes modalFadeIn {
    to { opacity: 1; }
}

.modal-content {
    background: #FFFFFF;
    border: 1px solid var(--card-border);
    border-radius: var(--radius-md);
    padding: 28px;
    max-width: 440px;
    width: calc(100% - 32px);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    transform: translateY(20px);
    animation: modalContentSlide 0.25s cubic-bezier(0.4, 0, 0.2, 1) forwards;
    will-change: transform, opacity;
}

@keyframes modalContentSlide {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-content h3 {
    font-size: 1.15rem;
    font-weight: 700;
    margin-bottom: 12px;
    color: var(--text-main);
}

.modal-content p {
    font-size: 0.95rem;
    color: var(--text-muted);
    margin-bottom: 24px;
    line-height: 1.5;
}

.modal-buttons {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.modal-buttons .btn {
    font-size: 0.85rem;
    padding: 9px 18px;
}

/* ==========================================================================
   Responsive Breakpoints
   ========================================================================== */
@media (max-width: 1024px) {
    .main-grid {
        grid-template-columns: 1fr;
    }
    
    .toast-container {
        bottom: 16px;
        right: 16px;
        width: calc(100% - 32px);
    }
}

@media (max-width: 480px) {
    body {
        padding-bottom: 20px;
    }
    
    .app-main {
        padding: 12px;
    }
    
    .card {
        padding: 16px;
        margin-bottom: 16px;
    }
    
    .form-row-2 {
        grid-template-columns: 1fr;
        gap: 0;
    }
    
    .settings-grid {
        grid-template-columns: 1fr;
        gap: 0;
    }
    
    .backup-buttons {
        grid-template-columns: 1fr;
    }
    
    .header-container {
        padding: 10px 16px 10px 12px; /* 右端の余白を少し増やす */
        flex-wrap: nowrap;
        gap: 8px;
    }

    .header-title-area {
        flex-wrap: nowrap !important;
        min-width: 0;
        flex: 1;
    }

    .header-title-area h1 {
        font-size: 0.9rem;
        max-width: 45vw;
        min-width: 0;
        flex: 1;
    }

    .header-nav {
        gap: 6px;
        padding-right: 4px; /* スクロールバー領域と重なるのを防止 */
    }

    .header-nav-link {
        font-size: 0.72rem;
        padding: 4px 8px;
        white-space: nowrap;
    }
    
    /* 1. モバイルログ履歴のすっきり配置（3列グリッド） */
    .book-item {
        grid-template-columns: auto 1fr auto;
        grid-template-areas:
            "title title date"
            "price stars delete"
            "notes notes notes";
        gap: 8px 10px;
        padding: 10px;
    }
    
    .book-badge-price {
        font-size: 0.85rem;
        min-width: 60px;
        padding: 4px 6px;
        text-align: center;
    }

    .book-title-container {
        width: 100%;
        min-width: 0;
    }

    .book-rating-stars {
        justify-self: start;
    }

    .book-date {
        justify-self: end;
        font-size: 0.72rem;
        color: #8C8275;
    }

    .btn-delete {
        justify-self: end;
        padding: 4px;
    }

    /* 2. 評価星の左寄せ */
    .rating-stars {
        justify-content: flex-start !important; /* 通常の左寄せ */
        align-self: flex-start;
        width: fit-content;
    }

    /* モバイルでの統計カード: 2列グリッドに変更して省スペース化 */
    .stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    /* 「実質お得額」は全幅で強調表示、かつ一番上に配置して縦積みを解消 */
    .stats-grid .stat-item:nth-child(2) {
        grid-column: 1 / -1;
        order: -1; /* 実質お得額を最上部に配置 */
    }

    /* モバイルでのクイック価格ボタンの均等化と1行化、および隙間の確保 */
    .quick-prices {
        gap: 6px !important;
        justify-content: space-between;
        margin-bottom: 16px !important;
    }
    .btn-quick-price {
        padding: 6px 6px !important;
        font-size: 0.72rem !important;
        flex: 1;
        text-align: center;
        margin: 0 1px; /* 個別のめくれ札の境界がはっきり見えるように極小のマージンを設定 */
    }

    /* モバイルでの広告コンテナ: 広告なし時は小さく */
    .ads-card {
        min-height: 80px !important;
    }
    .ads-placeholder {
        min-height: 40px !important;
    }

    /* モバイルでの凡例数値見切れ防止: 縦並びにして全幅確保 */
    .analytics-container {
        flex-direction: column;
        align-items: center;
        gap: 20px;
        padding: 20px 12px;
    }

    /* 4. ドーナツグラフ凡例の横2列配置化による縦幅圧縮 */
    .chart-legend {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 6px 12px;
        width: 100%;
    }

    /* モバイルでのグラフ切り替えトグルボタンのタップ領域拡張（44px以上） */
    .chart-toggle {
        padding: 4px !important;
    }
    .btn-chart-toggle {
        padding: 12px 18px !important;
        font-size: 0.8rem !important;
        line-height: 1.4 !important;
        min-height: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    /* 期間・カテゴリフィルタータブのモバイル1行横スクロール化 */
    .period-tabs,
    .filter-tabs {
        display: flex !important;
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
        gap: 6px !important;
        padding-bottom: 6px !important; /* 横スクロールバーの回避領域 */
        border-bottom: 2px solid #E8DFD5 !important;
        margin-bottom: 14px !important;
        scrollbar-width: none; /* Firefox用 */
        /* 右端にグラデーションフェードを適用して、スクロール可能であることを示す (切り切れ問題対策) */
        mask-image: linear-gradient(to right, black 85%, transparent 100%);
        -webkit-mask-image: linear-gradient(to right, black 85%, transparent 100%);
    }
    .period-tabs::-webkit-scrollbar,
    .filter-tabs::-webkit-scrollbar {
        display: none; /* Chrome, Safari用 */
    }
    .period-tab,
    .filter-tab {
        flex-shrink: 0 !important;
        white-space: nowrap !important;
        top: 0 !important;
        margin-bottom: 0 !important;
    }
}

/* ==========================================================================
   Wooden Bookshelf Visualization UI
   ========================================================================== */
.bookshelf-wrapper {
    background: #4E3629; /* ダークマホガニー調の木枠 */
    border-radius: var(--radius-md) var(--radius-md) 0 0;
    padding: 16px;
    box-shadow: var(--shadow-wood);
    margin-bottom: 20px;
    border: 4px solid #3B281E;
    position: relative;
    overflow: hidden;
}

.bookshelf-wood-header {
    font-family: 'Playfair Display', 'Outfit', sans-serif;
    color: #FAF6F0;
    text-align: center;
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 0.2em;
    opacity: 0.8;
    margin-bottom: 12px;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
    border-bottom: 1px dashed rgba(250, 246, 240, 0.2);
    padding-bottom: 8px;
}

.bookshelf {
    min-height: 120px;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    position: relative;
    z-index: 2;
}

.shelf-row {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
}

.books-row {
    display: flex;
    align-items: flex-end;
    justify-content: flex-start;
    padding: 0 10px;
    height: 90px;
    gap: 3px;
    position: relative;
    z-index: 3;
}

/* 木目調の棚板 (3D) */
.shelf-plank {
    height: 14px;
    background: linear-gradient(180deg, #A0522D 0%, #8B4513 50%, #5C2E0B 100%);
    border-radius: 2px;
    box-shadow: inset 0 1px 2px rgba(255,255,255,0.2), 0 3px 6px rgba(0,0,0,0.4);
    position: relative;
    z-index: 4;
}

/* 個々の背表紙 */
.shelf-book {
    width: var(--book-width, 16px);
    height: var(--book-height, 75px);
    /* 3D風の巻き込みグラデーションを背景色の上に重ねて表現 */
    background: linear-gradient(90deg, 
        rgba(0, 0, 0, 0.35) 0%, 
        rgba(0, 0, 0, 0.1) 8%, 
        var(--book-color, #1A5F7A) 18%, 
        var(--book-color, #1A5F7A) 82%, 
        rgba(255, 255, 255, 0.25) 90%, 
        rgba(0, 0, 0, 0.3) 100%);
    border-radius: 3px 3px 0 0;
    box-shadow: 
        -2px 0 6px rgba(0, 0, 0, 0.45),
        inset 1px 1px 0 rgba(255, 255, 255, 0.2),
        inset -1px 0 0 rgba(0, 0, 0, 0.3);
    cursor: pointer;
    transition: transform 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275), filter 0.2s ease, box-shadow 0.2s ease;
    transform-origin: bottom center;
    position: relative;
    animation: bookPlace 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

.shelf-book:hover {
    transform: scale(1.08) translateY(-6px) rotate(1.5deg);
    filter: brightness(1.12);
    box-shadow: 
        -4px 4px 12px rgba(0, 0, 0, 0.5),
        0 12px 20px rgba(0, 0, 0, 0.3);
    z-index: 10;
}

/* 本の背表紙の装飾ライン（上部の帯や金箔エンボス） */
.shelf-book::before {
    content: '';
    position: absolute;
    top: 10%;
    bottom: 12%;
    left: 2px;
    right: 2px;
    border-top: 2px solid rgba(255, 255, 255, 0.3);
    border-bottom: 2px solid rgba(255, 255, 255, 0.3);
    opacity: 0.7;
    pointer-events: none;
}

/* 本の縦溝（本のヒンジ）表現 */
.shelf-book::after {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    left: 12%;
    width: 1px;
    background: rgba(0, 0, 0, 0.25);
    box-shadow: 1px 0 0 rgba(255, 255, 255, 0.1);
    pointer-events: none;
}

@keyframes bookPlace {
    from {
        opacity: 0;
        transform: translateY(-20px) scaleY(0.5);
    }
    to {
        opacity: 1;
        transform: translateY(0) scaleY(1);
    }
}

/* 100%達成時ゴールドエフェクト */
.bookshelf-wrapper.achieved {
    border-color: #B9944A;
    box-shadow: 0 0 24px rgba(185, 148, 74, 0.55), var(--shadow-wood);
}
.bookshelf-wrapper.achieved .bookshelf-wood-header {
    color: #FFD700;
    text-shadow: 0 0 8px rgba(255, 215, 0, 0.6);
}

/* カテゴリ別の図書カード枠線 */
.book-item-business { border-left: 4px solid #1A5F7A !important; }
.book-item-novel    { border-left: 4px solid #A24838 !important; }
.book-item-comic    { border-left: 4px solid #D99E32 !important; }
.book-item-magazine { border-left: 4px solid #5C7A5C !important; }
.book-item-other    { border-left: 4px solid #837568 !important; }

/* 見出しのPlayfair serif文字の適用 */
.app-header h1, .bookshelf-wood-header, .modal-content h3 {
    font-family: 'Playfair Display', 'Noto Sans JP', serif;
}

/* ==========================================================================
   Redesign Upgrades (Notepad backgrounds, tabs/index visual enhancements)
   ========================================================================== */

/* 記録フォームを手帳風方眼紙（方眼グリッド）デザインに */
.record-form-card {
    background-color: #FFFFFF;
    background-image: 
        linear-gradient(to right, rgba(131, 117, 104, 0.05) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(131, 117, 104, 0.05) 1px, transparent 1px);
    background-size: 20px 20px; /* 20px幅の方眼 */
    border-left: 5px solid var(--accent); /* 背表紙風の金色の縁取り */
}

/* クイック価格入力ボタンを「本に挟むインデックス付箋」風に美化 */
.quick-prices {
    margin-top: -6px;
    margin-bottom: 20px;
    display: flex;
    gap: 12px;
}

.btn-quick-price {
    background: #FAF6F0;
    border: 1px solid #D2CBC0;
    border-top: 3px solid var(--primary); /* インデックスのタブ感を表現 */
    color: var(--text-main);
    padding: 6px 14px;
    border-radius: 0 0 6px 6px; /* 下部のみ角丸にすることでインデックス札を表現 */
    font-size: 0.82rem;
    cursor: pointer;
    font-weight: 600;
    box-shadow: 0 2px 4px rgba(42, 36, 33, 0.04);
    transition: var(--transition-smooth);
}

.btn-quick-price:hover {
    background: var(--primary-glow);
    border-color: var(--primary);
    transform: translateY(2px); /* 押し込むようなインタラクション */
    box-shadow: none;
}

.btn-quick-price.active {
    background: var(--primary-glow);
    border-color: var(--primary);
    transform: translateY(2px);
    box-shadow: none;
    font-weight: 700;
}

.btn-quick-price[data-price="490"] { border-top-color: #A24838; }
.btn-quick-price[data-price="780"] { border-top-color: #D99E32; }
.btn-quick-price[data-price="980"] { border-top-color: #5C7A5C; }
.btn-quick-price[data-price="1500"] { border-top-color: #1A5F7A; }
.btn-quick-price[data-price="2000"] { border-top-color: #837568; }

/* 広告プレースホルダーカードの美化 */
.ads-card {
    padding: 16px;
    text-align: center;
    border: 1px dashed var(--card-border);
    background: #FAF8F5;
}

.ads-label {
    display: block;
    font-size: 0.68rem;
    font-weight: 700;
    color: var(--text-muted);
    letter-spacing: 0.1em;
    text-transform: uppercase;
    margin-bottom: 10px;
}

.ads-placeholder {
    height: 250px;
    border: 1px solid #EAE6DF;
    background: #FFFFFF;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.02);
}

.ads-placeholder-text {
    font-family: 'Outfit', sans-serif;
    font-size: 0.8rem;
    font-weight: 600;
    color: #C2BBB0;
    letter-spacing: 0.05em;
    border: 2px dashed #FAF8F5;
    padding: 12px 24px;
    border-radius: 4px;
}

/* 広告プレースホルダー内部（日本語内容） */
.ads-placeholder-inner {
    text-align: center;
}

.ads-placeholder-title {
    font-family: 'Playfair Display', serif;
    font-size: 0.85rem;
    font-weight: 700;
    color: #B4A695;
    letter-spacing: 0.1em;
    margin-bottom: 10px;
}

.ads-placeholder-inner .ads-placeholder-text {
    font-family: 'Outfit', sans-serif;
    font-size: 0.78rem;
    color: #C8C0B6;
    line-height: 1.7;
    white-space: normal;
    border: none;
    padding: 0;
    letter-spacing: 0.02em;
}

/* 開発者プロフィールカード */
.author-profile-card {
    border-top: 4px solid var(--primary);
    background: linear-gradient(to bottom, #FFFFFF 0%, #FAF9F6 100%);
}

.profile-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 14px;
}

.profile-avatar {
    font-size: 2.2rem;
    line-height: 1;
    background: var(--primary-glow);
    padding: 8px;
    border-radius: 50%;
    border: 1px solid rgba(26, 95, 122, 0.1);
}

.profile-title-area h4 {
    font-family: 'Playfair Display', 'Noto Sans JP', serif;
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-main);
}

.profile-subtext {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-muted);
    letter-spacing: 0.02em;
}

.profile-bio {
    font-size: 0.82rem;
    color: var(--text-muted);
    line-height: 1.5;
    margin-bottom: 18px;
    border-left: 2px solid var(--card-border);
    padding-left: 10px;
}

.profile-links {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.profile-btn {
    font-size: 0.85rem;
    padding: 12px 18px;
    border-radius: var(--radius-sm);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    transition: var(--transition-smooth);
    position: relative;
    overflow: hidden;
}

.profile-btn.btn-outline {
    background: #FFFFFF;
    border: 1.5px solid #D2CBC0;
    color: var(--text-main);
    box-shadow: 0 2px 4px rgba(0,0,0,0.02);
}

.profile-btn.btn-outline:hover {
    border-color: var(--text-muted);
    background: #FAF8F5;
    transform: translateY(-1px);
}

/* ブログボタンを「料理店の看板・暖簾」を思わせる温かく訴求力の高デザインに */
.profile-btn.btn-primary {
    background: linear-gradient(135deg, #B9944A 0%, #A37E36 100%); /* 真鍮ブロンズゴールド */
    border: 1.5px solid #8C6A28;
    color: #FFFFFF;
    box-shadow: 0 4px 10px rgba(185, 148, 74, 0.25);
    text-shadow: 0 1px 2px rgba(0,0,0,0.2);
    padding-right: 90px; /* 右側の追加テキスト用にパディングを広げる */
}

.profile-btn.btn-primary:hover {
    background: linear-gradient(135deg, #A37E36 0%, #8C6A28 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 14px rgba(185, 148, 74, 0.35);
}

.profile-btn.btn-primary::after {
    content: '好評試食中！ ≫';
    position: absolute;
    right: 12px;
    font-size: 0.65rem;
    opacity: 0.85;
    font-weight: 500;
    letter-spacing: 0.05em;
}

/* ==========================================================================
   Notepad & Scrapbook Theme Collage Upgrades
   ========================================================================== */

/* マスキングテープ（マステ）風のコラージュ装飾 */
.card::before {
    content: '';
    position: absolute;
    top: -10px;
    left: 15%;
    width: 90px;
    height: 22px;
    background-color: rgba(185, 148, 74, 0.22); /* セピアゴールド系マステ */
    background-image: repeating-linear-gradient(45deg, 
        rgba(255,255,255,0.2) 0px, rgba(255,255,255,0.2) 4px, 
        transparent 4px, transparent 8px);
    transform: rotate(-1.5deg);
    opacity: 0.85;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
    border-left: 1.5px dashed rgba(0,0,0,0.1);
    border-right: 1.5px dashed rgba(0,0,0,0.1);
    z-index: 5;
    pointer-events: none;
    transition: var(--transition-smooth);
}

/* カードごとにマステの色・配置をバラつかせて本物の手帳感を演出 */
.settings-card::before {
    left: 25%;
    background-color: rgba(26, 95, 122, 0.15); /* ブルー系マステ */
    transform: rotate(2deg);
    width: 105px;
}

.backup-card::before {
    left: 50%;
    background-color: rgba(63, 94, 77, 0.16); /* セージグリーン系マステ */
    transform: rotate(-2.5deg);
    width: 85px;
}

.author-profile-card::before {
    left: 20%;
    background-color: rgba(162, 72, 56, 0.13); /* アンティークレッド系マステ */
    transform: rotate(1deg);
    width: 95px;
}

/* 既にデザイン装飾のある主要な左側カードはマステを非表示にしてスッキリさせる */
.record-form-card::before,
.intro-card::before,
.dashboard-card::before,
.logs-card::before {
    display: none;
}

/* バックアップ注意書きのレトロスタンプ風デザイン */
.backup-desc {
    font-size: 0.82rem;
    color: #6d5b4e;
    background: #FAF6F0;
    border: 2px double #D2CBC0;
    border-radius: 4px;
    padding: 12px 14px;
    margin-bottom: 20px;
    position: relative;
    line-height: 1.45;
}

.backup-desc::before {
    content: 'LOCAL SECURITY ONLY';
    position: absolute;
    bottom: -6px;
    right: 8px;
    font-family: 'Outfit', sans-serif;
    font-size: 0.55rem;
    font-weight: 900;
    color: rgba(162, 72, 56, 0.7); /* 消印スタンプ風の赤 */
    border: 1px solid rgba(162, 72, 56, 0.7);
    padding: 0 4px;
    transform: rotate(-3deg);
    background: #FAF6F0;
    letter-spacing: 0.05em;
    border-radius: 2px;
    pointer-events: none;
}

/* 複数段本棚の縦間隔調整 */
.bookshelf {
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-height: 125px;
    height: auto;
    justify-content: flex-end;
}

.shelf-row {
    margin-bottom: 2px;
}

/* Drag and Drop Zone Styles */
.drop-zone {
    border: 2px dashed #D2CBC0;
    border-radius: var(--radius-sm);
    padding: 24px 16px;
    text-align: center;
    background: #FCFAF7;
    cursor: pointer;
    transition: var(--transition-smooth);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 80px;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.01);
}

.drop-zone:hover, .drop-zone.dragover {
    border-color: var(--accent);
    background: #F5EFEB;
    color: var(--accent-dark);
}

.drop-zone-text {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 500;
    line-height: 1.4;
    transition: var(--transition-smooth);
}

.drop-zone:hover .drop-zone-text, .drop-zone.dragover .drop-zone-text {
    color: #8C6A28;
}

/* Celebration Modal & Stamp Styles */
.celebration-modal .modal-content {
    max-width: 440px;
    background: #FAF6F0; /* セピア生成り紙 */
    border: 2px solid #8C6A28; /* 真鍮ゴールドの枠線 */
    border-radius: var(--radius-md);
    box-shadow: 0 12px 30px rgba(140, 106, 40, 0.25), 0 2px 5px rgba(0,0,0,0.05);
    position: relative;
    padding: 30px 24px 36px;
    text-align: center;
    animation: celebrationPop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.celebration-close {
    position: absolute;
    top: 10px;
    right: 15px;
    background: transparent;
    border: none;
    font-size: 1.5rem;
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition-smooth);
    padding: 5px;
    line-height: 1;
}

.celebration-close:hover {
    color: var(--text-main);
    transform: scale(1.1);
}

.celebration-content h3 {
    font-family: 'Playfair Display', serif;
    font-size: 1.4rem;
    color: #8C6A28;
    margin-bottom: 20px;
    letter-spacing: 0.05em;
    border-bottom: 1px double #D2CBC0;
    padding-bottom: 10px;
}

.stamp-container {
    height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 20px;
}

/* かすれ感のある赤いレトロスタンプ */
.achieved-stamp {
    color: #A24838; /* 消印ヴィンテージ赤 */
    font-size: 1.3rem;
    font-weight: 900;
    text-transform: uppercase;
    border: 3px double #A24838;
    padding: 8px 16px;
    border-radius: 4px;
    letter-spacing: 0.1em;
    transform: rotate(-10deg);
    opacity: 0;
    background: rgba(250, 246, 240, 0.8);
    display: inline-block;
    box-shadow: 0 0 2px rgba(162, 72, 56, 0.1);
    
    /* スタンプのかすれエフェクトを線形グラデーションマスクで再現 */
    mask-image: repeating-linear-gradient(45deg, 
        rgba(0, 0, 0, 0.7) 0px, rgba(0, 0, 0, 0.7) 1px, 
        rgba(0, 0, 0, 0.9) 1px, rgba(0, 0, 0, 0.9) 3px);
    -webkit-mask-image: repeating-linear-gradient(45deg, 
        rgba(0, 0, 0, 0.7) 0px, rgba(0, 0, 0, 0.7) 1px, 
        rgba(0, 0, 0, 0.9) 1px, rgba(0, 0, 0, 0.9) 3px);
}

/* モーダル表示時にスタンプがポンと押されるアニメーション */
.celebration-modal:not([style*="display: none"]) .achieved-stamp {
    animation: stampFall 0.4s cubic-bezier(0.18, 0.89, 0.32, 1.28) 0.3s forwards;
}

.celebration-message {
    font-size: 0.95rem;
    color: var(--text-main);
    line-height: 1.6;
    margin-bottom: 12px;
}

.celebration-message strong {
    color: #A24838;
    font-size: 1.3rem;
}

.celebration-sub {
    font-size: 0.78rem;
    color: var(--text-muted);
    line-height: 1.5;
    margin-bottom: 24px;
}

@keyframes celebrationPop {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

@keyframes stampFall {
    0% {
        opacity: 0;
        transform: scale(2.5) rotate(-35deg);
    }
    90% {
        opacity: 0.9;
        transform: scale(0.95) rotate(-8deg);
    }
    100% {
        opacity: 1;
        transform: scale(1) rotate(-10deg);
    }
}

/* Book Notes Placeholder Italic Style */
#book-notes::placeholder {
    font-family: 'Playfair Display', 'Noto Serif JP', serif;
    font-style: italic;
    opacity: 0.65;
}

/* Shelf Book Symbol Styles */
.shelf-book {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.shelf-book-symbol {
    font-size: 0.58rem;
    line-height: 1;
    margin: 1px 0;
    opacity: 0.55;
    pointer-events: none;
    user-select: none;
    transform: scale(0.95);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

/* Analytics & Pie Chart Styles */
.analytics-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    padding: 0 4px;
}

.analytics-title {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-main);
}

.chart-toggle {
    display: flex;
    background: #EADFD3;
    padding: 2px;
    border-radius: 6px;
    border: 1px solid #D2CBC0;
}

.btn-chart-toggle {
    background: transparent;
    border: none;
    padding: 3px 10px;
    font-size: 0.72rem;
    font-family: 'Outfit', 'Noto Sans JP', sans-serif;
    font-weight: 700;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: 4px;
    transition: var(--transition-smooth);
    line-height: 1.2;
}

.btn-chart-toggle:hover {
    color: var(--text-main);
}

.btn-chart-toggle.active {
    background: var(--accent);
    color: #FFFFFF;
    box-shadow: 0 1px 3px rgba(140, 106, 40, 0.2);
}

.analytics-container {
    display: flex;
    align-items: center;
    justify-content: space-around;
    gap: 15px;
    background: #FCFAF7; /* 古い日記紙 */
    border: 1px solid #E8DFD5;
    border-radius: var(--radius-sm);
    padding: 16px;
    margin-bottom: 20px;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.01);
}

.chart-wrapper {
    position: relative;
    width: 110px;
    height: 110px;
    flex-shrink: 0;
    transition: var(--transition-smooth);
}
@media (min-width: 1025px) {
    .chart-wrapper {
        width: 130px;
        height: 130px;
    }
}

.stats-chart {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg); /* 12時の位置から描画開始するため */
}

/* ドーナツスライスの基本スタイル */
.chart-slice {
    fill: none;
    stroke-width: 14; /* ドーナツの太さ */
    transition: stroke-dashoffset 0.6s ease-in-out, stroke 0.3s;
    cursor: pointer;
}

.chart-slice:hover {
    stroke-width: 17; /* ホバー時に太くする */
}

.chart-center-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    pointer-events: none;
}

#chart-center-val {
    font-size: 1.5rem;
    font-weight: 900;
    color: var(--text-main);
    display: block;
    line-height: 1;
}

.chart-center-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-weight: 700;
}

.chart-legend {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-size: 0.8rem;
    color: var(--text-main);
    min-width: 190px; /* デスクトップでの凡例数値クリッピング防止 */
}

.legend-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 4px 6px;
    border-radius: 3px;
    transition: background-color 0.2s;
    cursor: pointer;
}

.legend-item:hover {
    background-color: #F3EBE1;
}

.legend-color-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}

.legend-label-group {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 600;
    white-space: nowrap;   /* 凸例ラベルの折り返しを禁止 */
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;          /* flex子要素のシュリンク有効化 */
    flex: 1;               /* 親フレックス内で伸縮可能にし、数値を右側に押し出さないようにする */
}

.legend-val-group {
    color: var(--text-muted);
    font-weight: 500;
    text-align: right;
    white-space: nowrap;   /* 数値の折り返しを禁止 */
    flex-shrink: 0;
}

/* Period Filter Tabs (Notebook Index Design) */
.period-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 12px;
    border-bottom: 2px solid #E8DFD5;
    padding-bottom: 2px;
}

.period-tab {
    background: #FAF6F0;
    border: 1px solid #D2CBC0;
    border-bottom: none;
    border-radius: 4px 4px 0 0;
    color: var(--text-muted);
    padding: 6px 12px;
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    top: 2px;
}

.period-tab:hover {
    color: var(--text-main);
    background: #FAF6F0;
    transform: translateY(-1px);
}

.period-tab.active {
    color: var(--text-main);
    background: #FCFAF7;
    border-color: #E8DFD5;
    border-bottom: 2px solid #FCFAF7;
    z-index: 2;
    transform: translateY(-2px);
    box-shadow: 0 -2px 4px rgba(42, 36, 33, 0.04);
    border-top: 3px solid var(--accent);
}

/* Category Filter Tabs (Notebook Index Design) */
.filter-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 16px;
    border-bottom: 2px solid #E8DFD5;
    padding-bottom: 2px;
}

.filter-tab {
    background: #F3EBE1;
    border: 1px solid #D2CBC0;
    border-bottom: none;
    border-radius: 4px 4px 0 0;
    color: var(--text-muted);
    padding: 6px 10px;
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    top: 2px; /* ボーダーに重ねる */
}

.filter-tab:hover {
    color: var(--text-main);
    background: #FAF6F0;
    transform: translateY(-1px);
}

.filter-tab.active {
    color: var(--text-main);
    background: #FCFAF7;
    border-color: #E8DFD5;
    border-bottom: 2px solid #FCFAF7; /* 親のボーダーを打ち消す */
    z-index: 2;
    transform: translateY(-2px);
    box-shadow: 0 -2px 4px rgba(42, 36, 33, 0.04);
}

/* カテゴリごとの付箋アクセントカラー */
.filter-tab[data-category="business"].active { border-top: 3px solid #1A5F7A; color: #1A5F7A; }
.filter-tab[data-category="novel"].active    { border-top: 3px solid #A24838; color: #A24838; }
.filter-tab[data-category="comic"].active    { border-top: 3px solid #D99E32; color: #D99E32; }
.filter-tab[data-category="magazine"].active { border-top: 3px solid #5C7A5C; color: #5C7A5C; }
.filter-tab[data-category="other"].active    { border-top: 3px solid #837568; color: #837568; }

/* フィルタ時のアニメーションフェード効果 */
.book-item.filtered-out {
    display: none !important;
}

/* Ads Card (Antiquarian Book Ad Style & CLS Prevention) */
.ads-card {
    min-height: 120px; /* 広告なし時の過度な空白を抑制 */
    display: flex;
    flex-direction: column;
    background: #FCFAF7; /* 古い紙・新聞紙の風合い */
    border: 3px double #C4B5A5; /* レトロな二重枠線 */
    padding: 16px;
    position: relative;
    overflow: hidden;
    transition: var(--transition-smooth);
}

/* 広告が実際に入った場合はmin-heightをCLS防止のため確保 */
.ads-card.has-ad {
    min-height: 280px;
}

.ads-label {
    font-family: 'Playfair Display', serif;
    font-size: 0.65rem;
    font-weight: 900;
    color: #A24838; /* 消印風の赤 */
    letter-spacing: 0.15em;
    text-transform: uppercase;
    border: 1px solid #A24838;
    padding: 2px 6px;
    width: fit-content;
    margin: 0 auto 12px;
    transform: rotate(-1.5deg);
    display: block;
    background: #FCFAF7;
    box-shadow: 0 0 1px rgba(162, 72, 56, 0.1);
}

.ads-placeholder {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px dashed rgba(196, 181, 165, 0.4);
    background: rgba(196, 181, 165, 0.02);
    border-radius: 2px;
    padding: 10px;
    min-height: 60px;  /* 広告なし時は最小限の高さに抑える */
}

.ads-placeholder-text {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-family: 'Playfair Display', serif;
    font-style: italic;
    text-align: center;
    letter-spacing: 0.05em;
}

/* モバイル挿入時のマージン調整 */
.main-content > .ads-card {
    margin-top: 10px;
    margin-bottom: 24px;
    width: 100%;
}/* Zero-state elements and UI additions */
.stat-value.savings-zero {
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-muted);
}

.bookshelf-empty-guide {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 90px;
    width: 100%;
    color: #FAF6F0;
    opacity: 0.7;
    font-family: 'Playfair Display', 'Noto Sans JP', serif;
    font-style: italic;
    font-size: 0.85rem;
    text-align: center;
    font-weight: 500;
    line-height: 1.5;
    border: 1px dashed rgba(250, 246, 240, 0.25);
    border-radius: 4px;
}

.chart-empty-legend {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-align: center;
    padding: 10px;
    line-height: 1.6;
    font-family: 'Playfair Display', 'Noto Sans JP', serif;
    font-style: italic;
    font-weight: 500;
}

/* --- プレミアム機能：しおり風検索窓 --- */
.search-bar-container {
    display: flex;
    align-items: center;
    background: var(--bg-paper);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 2px 8px;
    margin: 12px 0 16px 0;
    position: relative;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.05);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.search-bar-container:focus-within {
    border-color: var(--primary);
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.05), 0 0 0 3px var(--primary-glow);
}

.search-bookmark-tab {
    font-size: 1.1rem;
    margin-right: 6px;
    transform: rotate(-10deg);
    user-select: none;
}

#log-search-input {
    flex: 1;
    border: none;
    background: transparent;
    padding: 8px 4px;
    font-size: 0.88rem;
    color: var(--text-main);
    font-family: inherit;
}

#log-search-input:focus {
    outline: none;
}

#log-search-input::placeholder {
    font-style: italic;
    font-family: 'Playfair Display', 'Noto Sans JP', serif;
    color: var(--text-muted);
}

/* --- プレミアム機能：背表紙の装幀バリエーション --- */
/* ストライプ装幀 */
.shelf-book.spine-decor-stripes {
    background-image: linear-gradient(
        45deg,
        rgba(255, 255, 255, 0.06) 25%,
        transparent 25%,
        transparent 50%,
        rgba(255, 255, 255, 0.06) 50%,
        rgba(255, 255, 255, 0.06) 75%,
        transparent 75%,
        transparent
    );
    background-size: 12px 12px;
}

/* 金箔ライン装幀 */
.shelf-book.spine-decor-gold::before {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    top: 10px;
    height: 3px;
    background: linear-gradient(90deg, #D4AF37 0%, #FFDF73 50%, #AA7C11 100%);
    box-shadow: 0 1px 1px rgba(0,0,0,0.2);
}

.shelf-book.spine-decor-gold::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    bottom: 10px;
    height: 3px;
    background: linear-gradient(90deg, #D4AF37 0%, #FFDF73 50%, #AA7C11 100%);
    box-shadow: 0 -1px 1px rgba(0,0,0,0.2);
}

/* 中央ラベル装幀 */
.shelf-book.spine-decor-label {
    box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.3);
}

.shelf-book.spine-decor-label::before {
    content: '';
    position: absolute;
    left: 2px;
    right: 2px;
    top: 25%;
    bottom: 25%;
    background: rgba(250, 246, 240, 0.95);
    border: 1px solid rgba(139, 92, 26, 0.4);
    border-radius: 1px;
    z-index: 1;
}

/* --- プレミアム機能：消印風アンティーク称号スタンプ --- */
.dashboard-card {
    position: relative; /* スタンプ絶対配置用 */
}

.achievement-stamp-container {
    position: absolute;
    top: 12px;
    right: 20px;
    width: 80px;
    height: 80px;
    pointer-events: none;
    z-index: 20;
    user-select: none;
}

.achievement-stamp {
    width: 100%;
    height: 100%;
    border: 2px double rgba(196, 77, 86, 0.7); /* かすれ赤 */
    border-radius: 50%;
    color: rgba(196, 77, 86, 0.75);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-family: 'Outfit', 'Noto Sans JP', sans-serif;
    font-weight: 700;
    text-transform: uppercase;
    text-align: center;
    transform: rotate(-14deg);
    background: radial-gradient(circle, rgba(253, 251, 247, 0.9) 60%, transparent 60%);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.04);
    animation: stampAppear 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
    pointer-events: auto; /* ホバーできるように */
    cursor: help;
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.5);
}

.achievement-stamp:hover {
    transform: rotate(-8deg) scale(1.15);
}

.achievement-stamp-title {
    font-size: 0.52rem;
    letter-spacing: 0.5px;
    border-bottom: 1px dashed rgba(196, 77, 86, 0.4);
    padding-bottom: 1px;
    margin-bottom: 1px;
}

.achievement-stamp-rank {
    font-size: 0.68rem;
    line-height: 1.1;
    font-family: 'Playfair Display', 'Noto Sans JP', serif;
    font-style: italic;
}

/* スタンプが青インクになるバリエーション */
.achievement-stamp.stamp-blue {
    border-color: rgba(26, 95, 122, 0.7);
    color: rgba(26, 95, 122, 0.75);
}

.achievement-stamp.stamp-blue .achievement-stamp-title {
    border-bottom-color: rgba(26, 95, 122, 0.4);
}

@keyframes stampAppear {
    0% {
        opacity: 0;
        transform: rotate(-30deg) scale(2);
    }
    100% {
        opacity: 1;
        transform: rotate(-14deg) scale(1);
    }
}

/* --- プレミアム機能：黄色いマステ付きバックアップ推奨ふせん --- */
.backup-card {
    position: relative; /* ふせん絶対配置用 */
}

.backup-reminder-sticky {
    position: absolute;
    top: -24px;
    left: -16px;
    right: 16px;
    background: #FEF08A; /* 柔らかなイエローフセン色 */
    color: #451a03;
    padding: 12px 14px 10px 14px;
    border-radius: 2px;
    box-shadow: 2px 8px 15px rgba(0, 0, 0, 0.08);
    font-size: 0.78rem;
    line-height: 1.4;
    z-index: 30;
    transform: rotate(-2deg);
    border-left: 2px solid #FACC15;
    animation: stickyAppear 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

/* マスキングテープ装飾 */
.backup-reminder-sticky::before {
    content: '';
    position: absolute;
    top: -8px;
    left: 30%;
    width: 60px;
    height: 16px;
    background: rgba(250, 204, 21, 0.55); /* 半透明ゴールドのテープ */
    transform: rotate(-4deg);
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.backup-reminder-text {
    font-weight: 500;
    margin-bottom: 6px;
}

.backup-reminder-btn-group {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 4px;
}

.btn-sticky-action {
    background: rgba(0, 0, 0, 0.05);
    border: 1px solid rgba(0, 0, 0, 0.15);
    border-radius: 4px;
    padding: 2px 8px;
    font-size: 0.7rem;
    cursor: pointer;
    color: #451a03;
    transition: background 0.2s;
}

.btn-sticky-action:hover {
    background: rgba(0, 0, 0, 0.1);
}

.btn-sticky-action.primary {
    background: #451a03;
    color: #FEF08A;
    border-color: #451a03;
}

.btn-sticky-action.primary:hover {
    background: #78350f;
}

@keyframes stickyAppear {
    0% {
        opacity: 0;
        transform: translateY(-20px) rotate(-5deg);
    }
    100% {
        opacity: 1;
        transform: translateY(0) rotate(-2deg);
    }
}

/* --- Keyboard Focus Accessibility (A11y) --- */
.period-tab:focus-visible,
.filter-tab:focus-visible,
.btn:focus-visible,
.btn-quick-price:focus-visible,
.drop-zone:focus-visible,
.select-field:focus-visible,
.chart-toggle button:focus-visible,
#subscription-type:focus-visible,
#book-category:focus-visible,
#sort-select:focus-visible {
    outline: 2px dashed var(--accent) !important;
    outline-offset: 3px !important;
    box-shadow: 0 0 0 4px rgba(185, 148, 74, 0.15) !important;
}

/* --- Auto-resizing Notes Textarea & Character Counter --- */
.textarea-wrapper {
    position: relative;
    width: 100%;
}

#book-notes {
    resize: none;
    overflow-y: hidden;
    min-height: 60px;
    padding-bottom: 24px; /* カウンターと被らないように下部に余白を確保 */
    transition: height 0.15s ease-out, border-bottom 0.15s, background 0.15s;
}

.char-counter {
    position: absolute;
    right: 12px;
    bottom: 8px;
    font-size: 0.68rem;
    color: var(--text-muted);
    pointer-events: none;
    transition: color 0.15s ease;
    font-family: 'Outfit', sans-serif;
    opacity: 0.7;
}

.char-counter.warning {
    color: #B91C1C;
    font-weight: 700;
    opacity: 1;
}

/* --- Share Action & Canvas Modal --- */
.card-header-with-action {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.card-header-with-action .card-title {
    margin-bottom: 0;
}

.btn-share-action {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    padding: 6px 12px;
    height: 32px;
    border-radius: var(--radius-sm);
}

.icon-share {
    flex-shrink: 0;
}

.share-modal-content {
    max-width: 550px !important;
}

.share-modal-body {
    padding-top: 8px;
}

.share-desc {
    font-size: 0.8rem;
    line-height: 1.4;
    color: var(--text-muted);
}

.canvas-preview-wrapper {
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.share-image-preview {
    transition: transform 0.2s ease;
}

.share-image-preview:hover {
    transform: scale(1.01);
}
