﻿:root {
    /* カラー - ターコイズ系（ダーク＆エレガント） */
    --bg-app: #222831;
    /* ディープガンメタル */
    --bg-panel: #283b48;
    /* スレートブルー */
    --bg-hover: #344c5c;
    /* ホバー時の明るいスレート */

    --text-primary: #d8d7ce;
    /* ボーンホワイト - 暖かく読みやすい */
    --text-secondary: #aebbc7;
    /* クールグレー - スレートと調和 */
    --text-muted: #899faf;
    /* ミュートスレート */

    /* アクセントカラー */
    --accent-primary: #00c0fe;
    /* ブルーシー（シアン）- アクション色 */
    --accent-hover: #4dd5ff;
    /* より明るいシアン */
    --accent-gold: #ffc208;
    /* ビビッドゴールド - 最重要ハイライト */

    --border-action: #ededed;

    /* 境界線 */
    --border-color: #395266;
    /* 控えめな青灰色の境界線 */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.4);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.5);

    /* レイアウト寸法 */
    --sidebar-width: 260px;
    --header-height: 64px;

    /* 角丸 */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-2xl: 24px;

    /* カード用セマンティックカラー */
    --card-bg: #283b48;
    --card-border: #395266;
    --card-hover-border: rgba(0, 192, 254, 0.5);
    --card-shadow-hover: 0 10px 25px -5px rgba(0, 0, 0, 0.5), 0 0 15px -3px rgba(0, 192, 254, 0.1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg-app);
    color: var(--text-primary);
    min-height: 100vh;
    overflow: hidden;
    /* アプリのインタラクションモデル */
    display: flex;
    /* サイドバーのレイアウト */
    -webkit-font-smoothing: antialiased;
}

/* UI要素 */
/* UI Elements */
/* 戻るリンクボタンのスタイル */
.nav-back-link {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s ease;
    outline: none;
    /* デフォルトのアウトラインを削除 */
}

.nav-back-link:hover {
    border-color: var(--text-primary);
    color: var(--text-primary);
    background: var(--bg-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
    /* わずかな浮き上がり効果 */
}

.nav-back-link:active,
.nav-back-link:focus {
    transform: translateY(1px);
    box-shadow: none;
    border-color: var(--accent-primary);
}

.nav-back-link svg {
    width: 16px;
    height: 16px;
    fill: currentColor;
}

/* グローバルコンテナ */
.container {
    width: 100%;
    max-width: 1000px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

/* アプリレイアウト */
#app-layout {
    display: flex;
    width: 100%;
    height: 100vh;
}

/* サイドバー */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-app);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    flex-shrink: 0;
}

.logo {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    letter-spacing: -0.01em;
}

.nav-menu {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    flex-grow: 1;
}

.nav-item {
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.nav-item:hover,
.nav-item.active {
    background: var(--bg-panel);
    color: var(--text-primary);
}

.nav-item.active {
    border-left: 2px solid var(--accent-primary);
}

.sidebar-footer {
    border-top: 1px solid var(--border-color);
    padding-top: 1rem;
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Main Content Area */
.main-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-app);
    position: relative;
    overflow: hidden;
}

/* Header (Search & Ads) */
.main-header {
    height: var(--header-height);
    min-height: var(--header-height);
    flex: 0 0 var(--header-height);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    background: rgba(31, 31, 31, 0.9);
    /* Updated to match new bg-app */
    backdrop-filter: blur(8px);
    z-index: 10;
}

.search-bar {
    position: relative;
    width: 300px;
}

.search-input {
    width: 100%;
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    padding: 0.5rem 1rem 0.5rem 2.5rem;
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.9rem;
    font-family: inherit;
    transition: border-color 0.2s;
}

.search-input:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.search-icon {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}

/* Scrollable Canvas for Tools */
.canvas-scroll {
    flex-grow: 1;
    overflow-y: auto;
    padding: 2rem;
}

/* Compact Grid System */
/* Logo */
.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    color: var(--text-primary);
    font-weight: 700;
    font-size: 1.25rem;
    padding: 0 1rem;
    margin-bottom: 2rem;
}

.logo img {
    height: 50px;
    /* Reduced from 60px */
    width: auto;
    object-fit: contain;
}

.section-title {
    font-size: 1.75rem;
    color: var(--text-primary);
    font-weight: 700;
    margin-bottom: 0.5rem;
    margin-top: 4rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    letter-spacing: -0.02em;
}

.section-title:first-child,
.home-section:first-child .section-title {
    margin-top: 0;
}

.section-subtitle {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 2rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 1rem;
    line-height: 1.6;
}

.compact-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 1.5rem;
}

.app-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-xl);
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    text-decoration: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    height: 100%;
}

.featured-card {
    padding: 0;
}

.home-section {
    margin-bottom: 4rem;
}

.app-card:hover {
    border-color: var(--card-hover-border);
    transform: translateY(-4px);
    box-shadow: var(--card-shadow-hover);
}

.app-card:not(.featured-card)::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 80px;
    background: linear-gradient(to bottom, rgba(255, 255, 255, 0.03), transparent);
    pointer-events: none;
}

.card-icon-wrapper {
    width: 56px;
    height: 56px;
    border-radius: var(--radius-lg);
    background: linear-gradient(135deg, var(--bg-hover), var(--bg-panel));
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1rem;
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    transition: transform 0.3s ease;
}

.featured-card .card-icon-wrapper {
    width: 80px;
    height: 80px;
    margin-bottom: 0;
    border: none;
    background: transparent;
    box-shadow: none;
}

.card-banner {
    height: 140px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.card-content {
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

.app-card:hover .card-icon-wrapper {
    transform: scale(1.05);
    border-color: var(--accent-primary);
}

/* .app-card svg, */
.app-card .app-icon {
    width: 24px;
    height: 24px;
    /* Accent #00c0fe */
    filter: invert(56%) sepia(76%) saturate(2175%) hue-rotate(163deg) brightness(103%) contrast(102%) drop-shadow(0 0 4px rgba(0, 192, 254, 0.4));
    transition: transform 0.3s ease;
}

.featured-card .app-icon {
    width: 48px;
    height: 48px;
    filter: brightness(0) invert(1) drop-shadow(0 4px 8px rgba(0, 0, 0, 0.3));
}

.app-name {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.3;
    margin-bottom: 0.5rem;
    transition: color 0.2s;
}

.app-card:hover .app-name {
    color: var(--accent-primary);
}

.app-card .app-desc {
    font-size: 0.9rem;
    color: #c6d0d8;
    /* Even brighter for better clarity */
    line-height: 1.5;
    margin-bottom: 1.5rem;
    flex-grow: 1;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.card-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: auto;
}

.card-tag {
    font-size: 12px;
    font-family: 'JetBrains Mono', monospace;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    padding: 2px 8px;
    border-radius: 4px;
    text-transform: uppercase;
}

.card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 1.25rem;
    padding-top: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.card-version {
    font-size: 11px;
    color: var(--text-muted);
    font-family: 'JetBrains Mono', monospace;
}

.card-price {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--accent-gold);
    background: rgba(255, 194, 8, 0.1);
    padding: 2px 8px;
    border-radius: 4px;
    border: 1px solid rgba(255, 194, 8, 0.2);
}

.card-price.free {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
}

.app-badge {
    position: absolute;
    top: 12px;
    right: 12px;
    font-size: 10px;
    padding: 2px 8px;
    border-radius: 99px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    z-index: 5;
}

.badge-new {
    background: var(--accent-primary);
    color: var(--bg-app);
    box-shadow: 0 0 12px rgba(0, 192, 254, 0.4);
}

/* Ad Placeholder in Header */
.header-ad {
    height: 50px;
    width: 468px;
    background: var(--bg-panel);
    border: 1px dashed var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    color: var(--text-muted);
    border-radius: var(--radius-sm);
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* 
   ----------------------------------------
   Layout Shift Preventions (CLS)
   ----------------------------------------
*/
#related-tools,
#ranking-widget {
    min-height: 200px;
    /* 推奨ツールの最小高さ確保 */
}

#tools-container {
    min-height: 800px;
    /* トップページ ツール一覧の最小高さ確保 */
}

#update-history-home {
    min-height: 150px;
    /* ホームの更新履歴の最小高さ確保 */
}

#update-history-full {
    min-height: 600px;
    /* 履歴一覧ページの最小高さ確保 */
}

/* Retention Widgets (Moved from tools.css) */
.retention-box {
    margin-top: 4rem;
    padding: 2rem;
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
}

.retention-box h3 {
    margin-bottom: 1.5rem;
    font-size: 1.1rem;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.75rem;
}

.retention-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.retention-item {
    display: flex;
    align-items: center;
    padding: 1rem;
    background: var(--bg-app);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    text-decoration: none;
    transition: all 0.2s;
}

.retention-item:hover {
    border-color: var(--accent-primary);
    transform: translateX(4px);
}

.rank-num {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text-muted);
    width: 2.5rem;
    text-align: center;
    margin-right: 1rem;
}

.retention-item:nth-child(1) .rank-num {
    color: var(--accent-gold);
}

.retention-item:nth-child(2) .rank-num {
    color: #94a3b8;
}

.retention-item:nth-child(3) .rank-num {
    color: #b45309;
}

.retention-info {
    flex-grow: 1;
}

.retention-name {
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.retention-desc {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 0.2rem;
}

/* Related Box Specifics */
.related-box .compact-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 1rem;
}

.related-box .app-card {
    background: var(--bg-app);
    min-height: 80px;
}

/* Lightbox Modal */
.lightbox-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    cursor: zoom-out;
}

.lightbox-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.lightbox-image {
    max-width: 90%;
    max-height: 90%;
    object-fit: contain;
    border-radius: 4px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
    transform: scale(0.95);
    transition: transform 0.3s ease;
}

.lightbox-overlay.active .lightbox-image {
    transform: scale(1);
}

/* Cursor for zoomable images */
.lp-hero img,
.lp-feature-card img,
.tool-article img {
    cursor: zoom-in;
    transition: transform 0.2s;
}

.lp-hero img:hover,
.lp-feature-card img:hover,
.tool-article img:hover {
    transform: scale(1.02);
}

/* App Description in Cards */
.app-desc {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 0.5rem;
    line-height: 1.4;
    font-weight: 400;
    opacity: 0.8;
}

/* 
   ----------------------------------------
   Language Switcher (JP / EN)
   ----------------------------------------
*/
.lang-switch-wrapper {
    display: inline-flex;
    align-items: center;
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid var(--border-color);
    border-radius: 30px;
    padding: 3px;
    font-family: 'Inter', sans-serif;
    font-size: 0.75rem;
    position: relative;
    user-select: none;
}

.lang-switch-item {
    text-decoration: none;
    color: var(--text-muted);
    font-weight: 600;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    padding: 5px 12px;
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    letter-spacing: 0.05em;
}

.lang-switch-item:hover:not(.active) {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

.lang-switch-item.active {
    background: var(--accent-primary);
    color: #fff;
    font-weight: 800;
    pointer-events: none;
    box-shadow: 0 2px 8px rgba(0, 192, 254, 0.4);
}

.lang-separator {
    display: none;
}

/* Header Specific Override */
.header-lang-switch {
    margin-left: 1.0rem;
    flex-shrink: 0;
    white-space: nowrap;
}

/* Sidebar Specific Override */
.sidebar-lang-switch {
    margin: 0.5rem auto 1.25rem;
    width: fit-content;
}

/* 
   ----------------------------------------
   Responsive Adjustments
   ----------------------------------------
*/
@media (max-width: 768px) {
    .compact-grid {
        grid-template-columns: 1fr;
    }

    .canvas-scroll {
        padding: 1.5rem 1rem;
    }
}
