/* ==========================================================================
   Aixis AI Audit SaaS Platform -- Main Stylesheet
   Works alongside Tailwind CSS CDN. This file handles:
   - CSS custom properties for dual theming (light/dark)
   - Component-specific styles not easily done with Tailwind
   - Plotly chart theming
   - Animation keyframes
   - Grade badge, score bar, status badge styles
   - HTMX integration
   ========================================================================== */

/* ==========================================================================
   1. CSS Custom Properties -- Light Theme
   ========================================================================== */

:root {
    --primary: #1a365d;
    --primary-light: #2b6cb0;
    --primary-lighter: #4299e1;
    --accent: #ed8936;
    --accent-hover: #dd6b20;
    --bg: #f7fafc;
    --bg-alt: #edf2f7;
    --card-bg: #ffffff;
    --card-border: #e8ecf1;
    --text: #2d3748;
    --text-light: #718096;
    --text-lighter: #a0aec0;
    --border: #e2e8f0;
    --success: #38a169;
    --success-light: #c6f6d5;
    --warning: #d69e2e;
    --warning-light: #fefcbf;
    --danger: #e53e3e;
    --danger-light: #fed7d7;
    --grade-s: #d4af37;
    --grade-a: #38a169;
    --grade-b: #2b6cb0;
    --grade-c: #ed8936;
    --grade-d: #e53e3e;
    --radius: 2px;
    --radius-sm: 1px;
    --shadow: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-md: 0 2px 8px rgba(0,0,0,0.08);
    --shadow-lg: 0 4px 16px rgba(0,0,0,0.1);
    --nav-bg: rgba(255,255,255,0.85);
    --nav-border: rgba(0,0,0,0.06);
}

/* ==========================================================================
   2. CSS Custom Properties -- Dark Theme
   ========================================================================== */

html.dark {
    --primary: #60a5fa;
    --primary-light: #93bbfc;
    --primary-lighter: #bfdbfe;
    --accent: #f6ad55;
    --accent-hover: #ed8936;
    --bg: #0f1117;
    --bg-alt: #1a1d2e;
    --card-bg: #1e2235;
    --card-border: #2d3748;
    --text: #e2e8f0;
    --text-light: #a0aec0;
    --text-lighter: #718096;
    --border: #2d3748;
    --success: #48bb78;
    --success-light: rgba(72,187,120,0.15);
    --warning: #ecc94b;
    --warning-light: rgba(236,201,75,0.15);
    --danger: #fc8181;
    --danger-light: rgba(252,129,129,0.15);
    --nav-bg: rgba(15,17,23,0.85);
    --nav-border: rgba(255,255,255,0.06);
    --shadow: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-md: 0 2px 8px rgba(0,0,0,0.4);
    --shadow-lg: 0 4px 16px rgba(0,0,0,0.5);
    /* Grade colors remain the same -- already high contrast */
}

/* ==========================================================================
   3. Global Styles
   ========================================================================== */

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

html {
    font-size: 16px;
    overflow-x: hidden;
}

body {
    font-family: "Noto Sans JP", "Hiragino Sans", "Yu Gothic",
                 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
                 Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.85;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: color 0.15s ease, background-color 0.2s ease;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, h6 {
    letter-spacing: -0.02em;
    line-height: 1.3;
}

a {
    color: var(--primary-light);
    text-decoration: none;
    transition: color 0.15s ease;
}

a:hover {
    color: var(--primary-lighter);
}

/* ==========================================================================
   4a. Navigation -- Underline Hover Animation
   ========================================================================== */

/* Desktop nav link underline animation (left-to-right) */
.nav-link::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 12px;
    right: 12px;
    height: 2px;
    background: currentColor;
    border-radius: 1px;
    transform: scaleX(0);
    transform-origin: left center;
    transition: transform 0.2s cubic-bezier(0.22, 1, 0.36, 1);
}

.nav-link:hover::after {
    transform: scaleX(1);
}

/* Hide the animated underline when there is already an active indicator */
.nav-link:has(> span)::after {
    display: none;
}

/* Legacy nav -- kept for compatibility */
nav.main-nav {
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: white;
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 64px;
    box-shadow: var(--shadow-md);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--nav-border);
}

html.dark nav.main-nav {
    background: var(--nav-bg);
    border-bottom: 1px solid var(--nav-border);
}

nav.main-nav .logo {
    font-size: 1.4rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-decoration: none;
    color: white;
    display: flex;
    align-items: center;
    gap: 8px;
}

html.dark nav.main-nav .logo {
    color: var(--text);
}

nav.main-nav .logo span {
    font-size: 0.7rem;
    opacity: 0.7;
    font-weight: 400;
}

nav.main-nav .nav-links {
    display: flex;
    align-items: center;
    gap: 4px;
}

nav.main-nav .nav-links a {
    color: rgba(255,255,255,0.85);
    text-decoration: none;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 500;
    transition: background 0.15s ease, color 0.15s ease;
}

html.dark nav.main-nav .nav-links a {
    color: var(--text-light);
}

nav.main-nav .nav-links a:hover,
nav.main-nav .nav-links a.active {
    background: rgba(255,255,255,0.15);
    color: white;
}

html.dark nav.main-nav .nav-links a:hover,
html.dark nav.main-nav .nav-links a.active {
    background: rgba(255,255,255,0.08);
    color: var(--text);
}

nav.main-nav .nav-auth a {
    background: rgba(255,255,255,0.15);
    border: 1px solid rgba(255,255,255,0.3);
}

html.dark nav.main-nav .nav-auth a {
    background: rgba(255,255,255,0.06);
    border-color: var(--border);
}

/* Mobile nav slide-down */
.mobile-nav-menu {
    display: none;
    flex-direction: column;
    gap: 4px;
    padding: 12px 0;
    animation: slideDown 0.25s ease forwards;
    overflow: hidden;
}

.mobile-nav-menu.open {
    display: flex;
}

/* ==========================================================================
   4b. Main Content
   ========================================================================== */

main {
    flex: 1;
    width: 100%;
}

/* Constrained main for dashboard/internal pages */
main.main-constrained {
    max-width: 1280px;
    margin: 0 auto;
    padding: 32px 24px;
}

/* ==========================================================================
   4c. Cards
   ========================================================================== */

.card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
    transition: box-shadow 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

.card:hover {
    box-shadow: var(--shadow-md);
}

.card h2 {
    color: var(--primary);
    font-size: 1.25rem;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--accent);
    letter-spacing: -0.02em;
}

.card h3 {
    color: var(--primary-light);
    font-size: 1.05rem;
    margin: 12px 0 8px;
    letter-spacing: -0.02em;
}

/* ==========================================================================
   4d. Tool Cards Grid
   ========================================================================== */

.tool-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.tool-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
    transition: box-shadow 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
    cursor: pointer;
    text-decoration: none;
    color: inherit;
    display: block;
}

.tool-card:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--primary-light);
}

/* Grade-color border accent on hover for tool cards */
.tool-card[data-grade="S"]:hover { border-color: var(--grade-s); box-shadow: var(--shadow-md), 0 0 0 1px rgba(212,175,55,0.15); }
.tool-card[data-grade="A"]:hover { border-color: var(--grade-a); box-shadow: var(--shadow-md), 0 0 0 1px rgba(56,161,105,0.15); }
.tool-card[data-grade="B"]:hover { border-color: var(--grade-b); box-shadow: var(--shadow-md), 0 0 0 1px rgba(43,108,176,0.15); }
.tool-card[data-grade="C"]:hover { border-color: var(--grade-c); box-shadow: var(--shadow-md), 0 0 0 1px rgba(237,137,54,0.15); }
.tool-card[data-grade="D"]:hover { border-color: var(--grade-d); box-shadow: var(--shadow-md), 0 0 0 1px rgba(229,62,62,0.15); }

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

.tool-card .tool-logo {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-sm);
    background: var(--bg-alt);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--primary);
    flex-shrink: 0;
}

.tool-card .tool-name {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--primary);
    letter-spacing: -0.01em;
}

.tool-card .tool-vendor {
    font-size: 0.78rem;
    color: var(--text-light);
}

.tool-card .tool-category {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 600;
    background: var(--bg-alt);
    color: var(--primary-light);
    margin-bottom: 12px;
}

.tool-card .tool-scores {
    display: flex;
    gap: 4px;
    margin-top: 12px;
    flex-wrap: wrap;
}

.tool-card .mini-score {
    flex: 1;
    min-width: 50px;
    text-align: center;
    padding: 6px 4px;
    background: var(--bg);
    border-radius: 6px;
    font-size: 0.68rem;
    color: var(--text-light);
}

.tool-card .mini-score .score-value {
    font-size: 0.95rem;
    font-weight: 700;
    display: block;
    color: var(--text);
}

/* ==========================================================================
   4e. Grade Badges
   ========================================================================== */

.grade-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 6px;
    font-weight: 800;
    font-size: 0.85rem;
    color: white;
    line-height: 1;
    flex-shrink: 0;
    letter-spacing: 0.02em;
}

.grade-badge-lg {
    width: 60px;
    height: 60px;
    font-size: 1.8rem;
    border-radius: 10px;
}

.grade-S { background: var(--grade-s); }
.grade-A { background: var(--grade-a); }
.grade-B { background: var(--grade-b); }
.grade-C { background: var(--grade-c); }
.grade-D { background: var(--grade-d); }

/* ==========================================================================
   4f. Score Bars
   ========================================================================== */

.score-bar {
    height: 4px;
    border-radius: 2px;
    background: var(--border);
    overflow: hidden;
    margin: 4px 0;
}

.score-bar-fill {
    height: 100%;
    border-radius: 2px;
    transition: width 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}

.score-bar-fill.excellent { background: var(--success); }
.score-bar-fill.good      { background: var(--primary-light); }
.score-bar-fill.average   { background: var(--warning); }
.score-bar-fill.poor      { background: var(--danger); }

/* ==========================================================================
   4g. Status Badges
   ========================================================================== */

.status-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.status-pending {
    background: var(--bg-alt);
    color: var(--text-light);
}

.status-running {
    background: #bee3f8;
    color: #2a4365;
}

html.dark .status-running {
    background: rgba(96,165,250,0.15);
    color: #93bbfc;
}

.status-waiting_login {
    background: #fef3c7;
    color: #92400e;
}

html.dark .status-waiting_login {
    background: rgba(251,191,36,0.15);
    color: #fbbf24;
}

.status-awaiting_manual {
    background: var(--warning-light);
    color: #744210;
}

html.dark .status-awaiting_manual {
    color: var(--warning);
}

.status-completed {
    background: var(--success-light);
    color: #22543d;
}

html.dark .status-completed {
    color: var(--success);
}

.status-failed {
    background: var(--danger-light);
    color: #742a2a;
}

html.dark .status-failed {
    color: var(--danger);
}

.status-aborted {
    background: #fed7d7;
    color: #9b2c2c;
}

html.dark .status-aborted {
    background: rgba(245,101,101,0.15);
    color: #fc8181;
}

.status-aborting {
    background: #fed7d7;
    color: #9b2c2c;
    animation: pulse 2s infinite;
}

html.dark .status-aborting {
    background: rgba(245,101,101,0.15);
    color: #fc8181;
}

.status-cancelled {
    background: var(--bg-alt);
    color: #718096;
}

html.dark .status-cancelled {
    background: rgba(113,128,150,0.15);
    color: #a0aec0;
}

/* ==========================================================================
   4h. Tags
   ========================================================================== */

.tag {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 0.78rem;
    font-weight: 600;
}

.tag-success { background: var(--success-light); color: #22543d; }
.tag-warning { background: var(--warning-light); color: #744210; }
.tag-danger  { background: var(--danger-light);  color: #742a2a; }
.tag-info    { background: #bee3f8; color: #2a4365; }

html.dark .tag-success { color: var(--success); }
html.dark .tag-warning { color: var(--warning); }
html.dark .tag-danger  { color: var(--danger); }
html.dark .tag-info    { background: rgba(96,165,250,0.15); color: #93bbfc; }

/* ==========================================================================
   4i. Search & Filters
   ========================================================================== */

.search-section {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius);
    padding: 20px 24px;
    margin-bottom: 24px;
    box-shadow: var(--shadow);
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: center;
}

.search-input {
    flex: 1;
    min-width: 200px;
    padding: 10px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    font-family: inherit;
    background: var(--card-bg);
    color: var(--text);
}

.search-input::placeholder {
    color: var(--text-lighter);
}

.search-input:focus {
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(43,108,176,0.1);
}

html.dark .search-input {
    background: var(--bg-alt);
    border-color: var(--border);
}

html.dark .search-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(96,165,250,0.12);
}

.filter-select {
    padding: 10px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    background: var(--card-bg);
    color: var(--text);
    outline: none;
    cursor: pointer;
    font-family: inherit;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.filter-select:focus {
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(43,108,176,0.1);
}

html.dark .filter-select {
    background: var(--bg-alt);
    border-color: var(--border);
}

html.dark .filter-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(96,165,250,0.12);
}

/* ==========================================================================
   4j. Buttons
   ========================================================================== */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    border-radius: 1px;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: background 0.15s ease, transform 0.1s ease, box-shadow 0.15s ease;
    text-decoration: none;
    font-family: inherit;
    line-height: 1.4;
}

.btn:active {
    transform: scale(0.97);
}

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

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

html.dark .btn-primary {
    background: var(--primary);
    color: #0f1117;
}

html.dark .btn-primary:hover {
    background: var(--primary-light);
}

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

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

.btn-outline {
    background: transparent;
    color: var(--primary);
    border: 1px solid var(--primary);
}

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

.btn-sm { padding: 6px 14px; font-size: 0.78rem; }
.btn-lg { padding: 14px 28px; font-size: 0.95rem; }

/* ==========================================================================
   4k. Data Tables
   ========================================================================== */

.data-table {
    width: 100%;
    border-collapse: collapse;
    margin: 16px 0;
}

.data-table th,
.data-table td {
    padding: 10px 14px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.data-table th {
    background: var(--bg-alt);
    color: var(--primary);
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.data-table tbody tr {
    transition: background 0.1s ease;
}

.data-table tbody tr:hover {
    background: rgba(0,0,0,0.02);
}

html.dark .data-table tbody tr:hover {
    background: rgba(255,255,255,0.03);
}

.data-table .rank-1 { background: rgba(212,175,55,0.08); }
.data-table .rank-2 { background: rgba(192,192,192,0.08); }
.data-table .rank-3 { background: rgba(205,127,50,0.08); }

html.dark .data-table .rank-1 { background: rgba(212,175,55,0.12); }
html.dark .data-table .rank-2 { background: rgba(192,192,192,0.10); }
html.dark .data-table .rank-3 { background: rgba(205,127,50,0.10); }

/* ==========================================================================
   4l. Hero Section
   ========================================================================== */

.hero {
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: white;
    padding: 60px 40px;
    border-radius: var(--radius);
    margin-bottom: 32px;
    text-align: center;
}

html.dark .hero {
    background: linear-gradient(135deg, #1a1d2e, #2d3748);
}

.hero h1 {
    font-size: 2rem;
    margin-bottom: 12px;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.hero p {
    font-size: 1.05rem;
    opacity: 0.9;
    max-width: 600px;
    margin: 0 auto;
}

/* ==========================================================================
   4m. Chart Container & Plotly Theming
   ========================================================================== */

.chart-container {
    width: 100%;
    margin: 16px 0;
}

/* Ensure Plotly charts blend with card backgrounds */
.js-plotly-plot .plotly .main-svg {
    background: transparent !important;
}

html.dark .js-plotly-plot .plotly text {
    fill: var(--text) !important;
}

html.dark .js-plotly-plot .plotly .gridlayer line,
html.dark .js-plotly-plot .plotly .zerolinelayer line {
    stroke: var(--border) !important;
}

/* ==========================================================================
   4n. Stats Row
   ========================================================================== */

.stats-row {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    margin: 20px 0;
}

.stat-card {
    flex: 1;
    min-width: 140px;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-sm);
    padding: 16px;
    text-align: center;
    box-shadow: var(--shadow);
}

.stat-card .stat-value {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--primary);
    letter-spacing: -0.02em;
}

.stat-card .stat-label {
    font-size: 0.75rem;
    color: var(--text-light);
    margin-top: 4px;
}

/* ==========================================================================
   4o. Forms
   ========================================================================== */

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 6px;
    font-size: 0.88rem;
    color: var(--text);
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    font-family: inherit;
    background: var(--card-bg);
    color: var(--text);
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(43,108,176,0.08);
}

html.dark .form-group input:focus,
html.dark .form-group textarea:focus,
html.dark .form-group select:focus {
    box-shadow: 0 0 0 3px rgba(96,165,250,0.12);
}

/* ==========================================================================
   4p. Checklist Items (Manual Evaluation)
   ========================================================================== */

.checklist-item {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 16px;
    margin-bottom: 12px;
    background: var(--card-bg);
    transition: border-color 0.15s ease;
}

.checklist-item:hover {
    border-color: var(--primary-lighter);
}

.checklist-item .item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.checklist-item .item-title {
    font-weight: 700;
    color: var(--primary);
}

.checklist-item .score-input {
    width: 80px;
    text-align: center;
    font-size: 1.1rem;
    font-weight: 700;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--card-bg);
    color: var(--text);
    outline: none;
    transition: border-color 0.15s ease;
}

.checklist-item .score-input:focus {
    border-color: var(--primary-light);
}

.checklist-item .scoring-guide {
    font-size: 0.78rem;
    color: var(--text-light);
    margin-top: 4px;
    line-height: 1.5;
}

/* ==========================================================================
   4q. Paywall Blur Overlay
   ========================================================================== */

.paywall-section {
    position: relative;
}

.paywall-blur {
    filter: blur(8px);
    -webkit-filter: blur(8px);
    pointer-events: none;
    user-select: none;
    -webkit-user-select: none;
}

.paywall-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,0.6);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    border-radius: var(--radius);
    z-index: 10;
    padding: 24px;
    text-align: center;
}

html.dark .paywall-overlay {
    background: rgba(15,17,23,0.7);
}

.paywall-overlay .paywall-title {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 8px;
    letter-spacing: -0.02em;
}

.paywall-overlay .paywall-desc {
    font-size: 0.9rem;
    color: var(--text-light);
    margin-bottom: 16px;
    max-width: 400px;
}

.paywall-overlay .btn {
    font-size: 0.95rem;
    padding: 12px 28px;
}

/* ==========================================================================
   4r. Comparison Toolbar
   ========================================================================== */

.compare-toolbar {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
    margin-bottom: 20px;
}

.compare-tool-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    background: var(--bg-alt);
    border-radius: 20px;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text);
}

.compare-tool-tag .remove-btn {
    cursor: pointer;
    color: var(--text-light);
    font-weight: 400;
    transition: color 0.1s ease;
}

.compare-tool-tag .remove-btn:hover {
    color: var(--danger);
}

/* ==========================================================================
   4s. Pentagon / Radar Mini
   ========================================================================== */

.pentagon-mini {
    width: 120px;
    height: 120px;
    margin: 0 auto;
}

/* ==========================================================================
   4t. Footer
   ========================================================================== */

footer {
    background: var(--bg-alt);
    border-top: 1px solid var(--border);
    color: var(--text-light);
    text-align: center;
    padding: 24px;
    font-size: 0.82rem;
    margin-top: auto;
}

footer a {
    color: var(--text-light);
    text-decoration: none;
    transition: color 0.15s ease;
}

footer a:hover {
    color: var(--primary);
}

/* ==========================================================================
   5. Plotly Chart Theming (additional)
   -- See also section 4m above
   ========================================================================== */

html.dark .js-plotly-plot .plotly .bg {
    fill: transparent !important;
}

html.dark .js-plotly-plot .plotly .layer-above .shapelayer path {
    stroke: var(--border) !important;
}

html.dark .js-plotly-plot .plotly .angularaxistick text,
html.dark .js-plotly-plot .plotly .radialaxistick text {
    fill: var(--text-light) !important;
}

/* ==========================================================================
   6. Animations
   ========================================================================== */

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

@keyframes spin {
    0%   { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes slideDown {
    from {
        max-height: 0;
        opacity: 0;
    }
    to {
        max-height: 500px;
        opacity: 1;
    }
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.5; }
}

.fade-in {
    animation: fadeIn 0.25s ease-in;
}

.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid var(--border);
    border-top-color: var(--primary-light);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.pulse {
    animation: pulse 2s ease-in-out infinite;
}

/* ==========================================================================
   Design System — UI Overhaul Utilities
   ========================================================================== */

/* --- Global heading override --- */
h1, h2, h3, h4, h5, h6 {
    font-family: 'Noto Serif JP', 'Noto Sans JP', serif;
    font-weight: 700;
    letter-spacing: -0.02em;
}

/* --- Typography: explicit font separation --- */
.font-num {
    font-family: 'Inter', sans-serif;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.03em;
}
.font-jp {
    font-family: 'Noto Sans JP', sans-serif;
}
.font-jp-heading {
    font-family: 'Noto Serif JP', serif;
    font-weight: 700;
    letter-spacing: -0.01em;
}
.font-jp-body {
    font-family: 'Noto Sans JP', sans-serif;
    font-weight: 400;
    line-height: 1.85;
    letter-spacing: 0.02em;
}
.font-serif {
    font-family: 'Noto Serif JP', serif;
}
.font-label {
    font-family: 'Inter', sans-serif;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    font-size: 11px;
}

/* --- Clickable element hover --- */
.hover-lift {
    transition: box-shadow 200ms ease;
}
.hover-lift:hover {
    box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}
html.dark .hover-lift:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.30);
}

/* --- Card hover: border to primary --- */
.card-hover-primary {
    transition: border-color 200ms ease, box-shadow 200ms ease;
}
.card-hover-primary:hover {
    border-color: #9ca3af;
    box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}
html.dark .card-hover-primary:hover {
    border-color: #6b7280;
    box-shadow: 0 2px 8px rgba(0,0,0,0.30);
}

/* --- Button hovers: explicit bg colors (NO filter:brightness) --- */
.btn-primary-hover {
    background-color: #1a365d;
    transition: background-color 150ms ease-out, transform 150ms ease-out, box-shadow 150ms ease-out;
}
.btn-primary-hover:hover {
    background-color: #234b7a;
    box-shadow: 0 4px 12px rgba(26, 54, 93, 0.3);
}
html.dark .btn-primary-hover {
    background-color: #3b82f6;
}
html.dark .btn-primary-hover:hover {
    background-color: #5b9cf7;
}

.btn-blue-hover {
    transition: background-color 150ms ease-out, transform 150ms ease-out, box-shadow 150ms ease-out;
}
.btn-blue-hover:hover {
    background-color: #3b7cf5;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.btn-white-hover {
    transition: background-color 150ms ease-out, transform 150ms ease-out, box-shadow 150ms ease-out;
}
.btn-white-hover:hover {
    background-color: #f3f4f6;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

/* --- Progress/score bars --- */
.score-bar-data {
    height: 4px;
    overflow: hidden;
    border-radius: 1px;
}
.score-bar-data .score-bar-fill,
.score-bar-data > div {
    border-radius: 1px;
}

/* --- Report label (research institution style) --- */
.report-label {
    display: block;
    font-family: 'Inter', monospace;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.1em;
    color: #9ca3af;
    text-transform: uppercase;
    margin-bottom: 8px;
}
html.dark .report-label {
    color: #6b7280;
}

/* --- Thin gray divider (research authority) --- */
.divider-thin {
    border: none;
    border-top: 1px solid #E5E7EB;
    margin: 24px 0;
}
html.dark .divider-thin {
    border-top-color: #374151;
}
.divider-thin-sm {
    border: none;
    border-top: 1px solid #E5E7EB;
    margin: 12px 0;
}
html.dark .divider-thin-sm {
    border-top-color: #374151;
}

/* --- Data source annotation --- */
.data-annotation {
    font-size: 11px;
    color: #9ca3af;
    font-family: 'Inter', sans-serif;
    line-height: 1.4;
}
html.dark .data-annotation {
    color: #6b7280;
}

/* --- Last updated date --- */
.updated-date {
    font-size: 11px;
    color: #9ca3af;
    font-family: 'Inter', sans-serif;
}
html.dark .updated-date {
    color: #6b7280;
}

/* --- Stat number (48px) + unit (20px) --- */
.stat-number {
    font-family: 'Inter', sans-serif;
    font-size: 48px;
    font-weight: 900;
    letter-spacing: -0.03em;
    line-height: 1;
    color: #1a365d;
    font-variant-numeric: tabular-nums;
}
html.dark .stat-number {
    color: #a5b4fc;
}
.stat-unit {
    font-size: 20px;
    font-weight: 700;
    color: #6b7280;
    margin-left: 4px;
    vertical-align: baseline;
}

/* --- 5-axis card odd/even reversal --- */
.axis-card {
    display: flex;
    gap: 24px;
    align-items: flex-start;
}
.axis-card:nth-child(odd) {
    flex-direction: row;
}
.axis-card:nth-child(even) {
    flex-direction: row-reverse;
    text-align: right;
}
.axis-card:nth-child(even) .score-bar-data {
    margin-left: auto;
}
@media (max-width: 768px) {
    .axis-card:nth-child(even) {
        flex-direction: column;
        text-align: left;
    }
    .axis-card:nth-child(odd) {
        flex-direction: column;
    }
    .axis-card:nth-child(even) .score-bar-data {
        margin-left: 0;
    }
}

/* --- Dark "surprise" section --- */
.section-dark-surprise {
    background: #0c0f1a;
    color: #e2e8f0;
}
.section-dark-surprise h2,
.section-dark-surprise h3 {
    color: #ffffff;
}
.section-dark-surprise p {
    color: #94a3b8;
}
.section-dark-surprise .report-label {
    color: #475569;
}
.section-dark-surprise .divider-thin {
    border-top-color: #1e293b;
}

/* --- Section heading left-aligned (anti-center) --- */
.section-heading-left {
    text-align: left;
}
.section-heading-left p {
    max-width: 600px;
}

/* --- Section heading top accent line (replaces report-label on most sections) --- */
.section-line::before {
    content: '';
    display: block;
    width: 32px;
    height: 1px;
    background: #d1d5db;
    margin-bottom: 20px;
}
html.dark .section-line::before {
    background: #374151;
}

/* --- Per-page background variants --- */
.page-bg-pure-white { background-color: #FFFFFF; }
html.dark .page-bg-pure-white { background-color: var(--bg); }
.page-bg-warm { background-color: #FAFAFA; }
html.dark .page-bg-warm { background-color: var(--bg); }

/* --- Sophisticated section divider (thin full-width line) --- */
.section-divide {
    border: none;
    border-top: 1px solid #e5e7eb;
    margin: 0;
}
html.dark .section-divide {
    border-top-color: #1f2937;
}

/* ==========================================================================
   7. Responsive Overrides
   ========================================================================== */

@media (max-width: 768px) {
    nav.main-nav {
        flex-direction: column;
        height: auto;
        padding: 12px;
        gap: 8px;
    }

    nav.main-nav .nav-links {
        flex-wrap: wrap;
        justify-content: center;
    }

    .mobile-nav-menu {
        width: 100%;
    }

    .tool-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .hero {
        padding: 32px 20px;
    }

    .hero h1 {
        font-size: 1.5rem;
    }

    .stats-row {
        flex-direction: column;
    }

    main {
        padding: 0;
    }
    main.main-constrained {
        padding: 16px 12px;
    }

    .card {
        padding: 16px;
        margin-bottom: 12px;
    }

    .card:hover {
        transform: none;
    }

    .tool-card:hover {
        transform: none;
    }

    .search-section {
        flex-direction: column;
        padding: 16px;
    }

    .search-input {
        min-width: unset;
        width: 100%;
    }

    .filter-select {
        width: 100%;
    }

    .data-table {
        font-size: 0.85rem;
    }

    .data-table th,
    .data-table td {
        padding: 8px 10px;
    }

    .checklist-item .item-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .paywall-overlay {
        padding: 16px;
    }

    .paywall-overlay .paywall-title {
        font-size: 1.1rem;
    }
}

@media (max-width: 480px) {
    .tool-card .tool-scores {
        flex-direction: column;
    }

    .tool-card .mini-score {
        min-width: unset;
    }

    .grade-badge-lg {
        width: 52px;
        height: 52px;
        font-size: 1.6rem;
    }

    .compare-toolbar {
        flex-direction: column;
        align-items: stretch;
    }
}

/* ==========================================================================
   8. HTMX Integration
   ========================================================================== */

.htmx-indicator {
    display: none;
}

.htmx-request .htmx-indicator {
    display: inline-block;
}

.htmx-request.htmx-indicator {
    display: inline-block;
}

/* Smooth content swaps */
.htmx-swapping {
    opacity: 0;
    transition: opacity 0.1s ease-out;
}

.htmx-settling {
    opacity: 1;
    transition: opacity 0.15s ease-in;
}

/* ==========================================================================
   9. Utility / Misc
   ========================================================================== */

/* Scrollbar styling for dark mode */
html.dark ::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

html.dark ::-webkit-scrollbar-track {
    background: var(--bg);
}

html.dark ::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

html.dark ::-webkit-scrollbar-thumb:hover {
    background: var(--text-lighter);
}

/* Selection color */
::selection {
    background: rgba(43,108,176,0.15);
    color: inherit;
}

html.dark ::selection {
    background: rgba(96,165,250,0.2);
}

/* Print: remove dark backgrounds */
@media print {
    body {
        background: white;
        color: black;
    }

    .card,
    .tool-card,
    .stat-card,
    .checklist-item {
        box-shadow: none;
        border: 1px solid #ccc;
    }

    nav.main-nav,
    footer,
    .paywall-overlay {
        display: none;
    }
}
