/* Midori English - Dark Theme */

:root {
    --bg-primary: #0d1117;
    --bg-secondary: #161b22;
    --bg-tertiary: #21262d;
    --bg-card: #1c2333;
    --text-primary: #e6edf3;
    --text-secondary: #8b949e;
    --text-muted: #6e7681;
    --accent: #58a6ff;
    --accent-green: #3fb950;
    --accent-red: #f85149;
    --accent-yellow: #d29922;
    --accent-purple: #bc8cff;
    --accent-orange: #f0883e;
    --border: #30363d;
    --hover: #1f2937;
    --shadow: rgba(0, 0, 0, 0.3);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans JP', Helvetica, Arial, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

a {
    color: var(--accent);
    text-decoration: none;
    transition: color 0.2s;
}

a:hover {
    color: #79c0ff;
    text-decoration: underline;
}

/* Navigation */
.navbar {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    padding: 0.75rem 2rem;
    display: flex;
    align-items: center;
    gap: 2rem;
    position: sticky;
    top: 0;
    z-index: 100;
}

.navbar-brand {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--accent-green) !important;
    text-decoration: none !important;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.navbar-links {
    display: flex;
    gap: 1.5rem;
    list-style: none;
    flex-wrap: wrap;
}

.navbar-links a {
    color: var(--text-secondary);
    font-size: 0.95rem;
    padding: 0.25rem 0;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
}

.navbar-links a:hover,
.navbar-links a.active {
    color: var(--text-primary);
    border-bottom-color: var(--accent);
    text-decoration: none;
}

.dashboard {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    margin: 0 auto 2.5rem;
    padding: 1.25rem 1.5rem;
    max-width: 640px;
    background: var(--bg-secondary, #1c1c1a);
    border: 1px solid var(--border, #2a2a28);
    border-radius: 12px;
}

.dash-tile {
    text-align: center;
    min-width: 90px;
}

.dash-num {
    font-size: 2rem;
    font-weight: 700;
    color: var(--accent-green);
    line-height: 1.1;
}

.dash-num-review {
    color: var(--accent-red);
}

.dash-label {
    margin-top: 0.25rem;
    font-size: 0.8rem;
    color: var(--text-secondary, #888);
}

.weakspots {
    margin-bottom: 1.75rem;
    padding: 1rem 1.25rem;
    background: var(--bg-secondary, #1c1c1a);
    border: 1px solid var(--accent-red);
    border-radius: 10px;
}

.weakspot-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.4rem 0;
    border-bottom: 1px solid var(--border, #2a2a28);
}

.weakspot-row:last-child {
    border-bottom: none;
}

.weakspot-topic {
    font-weight: 600;
    text-transform: capitalize;
}

.weakspot-acc {
    font-size: 0.85rem;
    color: var(--accent-red);
}

.weakspot-n {
    color: var(--text-secondary, #888);
}

.rp-article-list {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.rp-article-btn {
    text-align: left;
    white-space: normal;
    line-height: 1.4;
}

.rp-article-num {
    display: inline-block;
    margin-right: 0.6rem;
    min-width: 1.4rem;
    padding: 0 0.4rem;
    color: #fff;
    background: var(--accent);
    border-radius: 0.4rem;
    text-align: center;
    font-weight: 700;
}

.rp-passage {
    padding: 1.25rem 1.5rem;
    background: var(--bg-secondary, #1c1c1a);
    border-left: 3px solid var(--accent);
    border-radius: 8px;
}

.rp-headline {
    margin-bottom: 0.75rem;
    color: var(--accent-green);
}

.rp-passage p {
    margin-bottom: 0.75rem;
    line-height: 1.7;
}

.rp-passage p:last-child {
    margin-bottom: 0;
}

.wp-instruction {
    font-weight: 600;
    margin-bottom: 0.75rem;
}

.wp-original {
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
    background: var(--bg-secondary, #1c1c1a);
    border-left: 3px solid var(--accent-red);
    border-radius: 6px;
    font-style: italic;
}

.wp-input {
    width: 100%;
    padding: 0.75rem 1rem;
    background: var(--bg-secondary, #1c1c1a);
    border: 1px solid var(--border, #2a2a28);
    border-radius: 6px;
    color: var(--text-primary, #eee);
    font-family: inherit;
    font-size: 0.95rem;
    resize: vertical;
}

.wp-model-label {
    font-size: 0.8rem;
    color: var(--text-secondary, #888);
    margin-bottom: 0.35rem;
}

.wp-model {
    padding: 0.75rem 1rem;
    background: var(--bg-secondary, #1c1c1a);
    border-left: 3px solid var(--accent-green);
    border-radius: 6px;
    margin-bottom: 0.75rem;
}

.wp-note {
    font-size: 0.9rem;
}

.sp-line {
    font-size: 1.3rem;
    font-weight: 600;
    line-height: 1.5;
    margin-bottom: 0.5rem;
}

.sp-gloss {
    color: var(--text-secondary, #888);
    margin-bottom: 0.5rem;
}

.sp-focus-label,
.sp-check-label {
    font-size: 0.8rem;
    color: var(--text-secondary, #888);
    margin: 0.75rem 0 0.35rem;
}

.sp-focus {
    padding: 0.75rem 1rem;
    background: var(--bg-secondary, #1c1c1a);
    border-left: 3px solid var(--accent-green);
    border-radius: 6px;
    line-height: 1.6;
}

.sp-check {
    margin: 0.25rem 0 0;
    padding-left: 1.25rem;
    line-height: 1.8;
}

.pg-section {
    margin: 2rem 0;
}

.pg-h3 {
    margin-bottom: 1rem;
}

.pg-empty {
    color: var(--text-secondary, #888);
    font-size: 0.9rem;
}

/* Quiz accuracy trend (vertical bars) */
.pg-trend {
    display: flex;
    align-items: flex-end;
    gap: 0.5rem;
    height: 180px;
    padding: 0.5rem 0.25rem 0;
    background: var(--bg-secondary, #1c1c1a);
    border: 1px solid var(--border, #2a2a28);
    border-radius: 10px;
    overflow-x: auto;
}

.pg-bar-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    flex: 1 0 32px;
    height: 100%;
}

.pg-bar-val {
    font-size: 0.7rem;
    color: var(--text-secondary, #888);
    margin-bottom: 0.2rem;
}

.pg-bar {
    width: 60%;
    min-width: 14px;
    border-radius: 4px 4px 0 0;
    transition: height 0.3s;
}

.pg-bar-x {
    font-size: 0.65rem;
    color: var(--text-secondary, #888);
    margin-top: 0.3rem;
    white-space: nowrap;
}

/* Topic mastery (horizontal bars) */
.pg-topic-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.4rem 0;
}

.pg-topic-name {
    flex: 0 0 11rem;
    text-transform: capitalize;
    font-size: 0.9rem;
}

.pg-topic-track {
    flex: 1 1 auto;
    height: 0.7rem;
    background: var(--bg-secondary, #1c1c1a);
    border-radius: 0.5rem;
    overflow: hidden;
}

.pg-topic-fill {
    display: block;
    height: 100%;
    border-radius: 0.5rem;
    transition: width 0.3s;
}

.pg-topic-pct {
    flex: 0 0 5rem;
    text-align: right;
    font-size: 0.85rem;
}

.pg-topic-n {
    color: var(--text-secondary, #888);
}

.streak-banner {
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 0.5rem;
    margin: 0 auto 2rem;
    padding: 1.25rem;
    max-width: 640px;
    background: var(--bg-secondary, #1c1c1a);
    border: 1px solid var(--accent-orange, #f0883e);
    border-radius: 12px;
}

.streak-flame { font-size: 2rem; }

.streak-num {
    font-size: 2.5rem;
    font-weight: 800;
    color: var(--accent-orange, #f0883e);
}

.streak-label { color: var(--text-secondary, #888); }

.today-plan {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-width: 720px;
    margin: 0 auto;
}

.today-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.25rem;
    background: var(--bg-secondary, #1c1c1a);
    border: 1px solid var(--border, #2a2a28);
    border-radius: 10px;
    text-decoration: none;
    color: inherit;
    transition: border-color 0.2s, transform 0.1s;
}

.today-card:hover {
    border-color: var(--accent);
    transform: translateX(2px);
    text-decoration: none;
}

.today-icon { font-size: 1.6rem; flex: 0 0 auto; }

.today-body { display: flex; flex-direction: column; flex: 1 1 auto; }

.today-title { font-weight: 600; }

.today-desc { font-size: 0.85rem; color: var(--text-secondary, #888); }

.today-cta {
    flex: 0 0 auto;
    color: var(--accent-green);
    font-size: 0.9rem;
    white-space: nowrap;
}

.sp-score-head { margin-bottom: 0.5rem; font-size: 0.9rem; }

.sp-score-pct { font-weight: 700; }

.sp-score-words { line-height: 2; margin-bottom: 0.5rem; }

.sp-w {
    display: inline-block;
    padding: 0.05rem 0.4rem;
    border-radius: 0.4rem;
    font-size: 0.95rem;
}

.sp-w-ok { background: rgba(63, 185, 80, 0.22); color: var(--accent-green); }

.sp-w-miss {
    background: rgba(248, 81, 73, 0.18);
    color: var(--accent-red);
    text-decoration: line-through;
}

.sp-heard { font-size: 0.85rem; color: var(--text-secondary, #888); }

.nav-badge {
    display: inline-block;
    margin-left: 0.35rem;
    min-width: 1.1rem;
    padding: 0 0.35rem;
    font-size: 0.72rem;
    font-weight: 700;
    line-height: 1.3rem;
    text-align: center;
    color: #fff;
    background: var(--accent-red);
    border-radius: 0.7rem;
    vertical-align: top;
}

/* Container */
.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 2rem;
}

/* Hero Section */
.hero {
    text-align: center;
    padding: 3rem 0;
}

.hero h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    color: var(--accent-green);
}

.hero p {
    font-size: 1.1rem;
    color: var(--text-secondary);
    max-width: 600px;
    margin: 0 auto;
}

/* Cards Grid */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-top: 2rem;
}

.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.5rem;
    transition: all 0.3s;
    cursor: pointer;
    text-decoration: none !important;
    display: block;
}

.card:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px var(--shadow);
}

.card h3 {
    font-size: 1.2rem;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.card p {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.card-icon {
    font-size: 2rem;
    margin-bottom: 0.75rem;
    display: block;
}

/* Feature Cards on Homepage */
.feature-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-top: 2rem;
}

.feature-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 2rem;
    text-align: center;
    transition: all 0.3s;
}

.feature-card:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
}

.feature-card .icon {
    font-size: 2.5rem;
    margin-bottom: 1rem;
}

.feature-card h3 {
    margin-bottom: 0.5rem;
}

.feature-card p {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Content Page */
.content-page {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 2.5rem;
    margin-top: 1rem;
}

.content-page h1 {
    font-size: 2rem;
    margin-bottom: 1.5rem;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid var(--border);
    color: var(--accent-green);
}

.content-page h2 {
    font-size: 1.5rem;
    margin-top: 2rem;
    margin-bottom: 1rem;
    color: var(--accent);
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
}

.content-page h3 {
    font-size: 1.2rem;
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
    color: var(--accent-purple);
}

.content-page h4 {
    font-size: 1.05rem;
    margin-top: 1rem;
    margin-bottom: 0.5rem;
    color: var(--accent-orange);
}

.content-page p {
    margin-bottom: 1rem;
}

.content-page ul, .content-page ol {
    margin-bottom: 1rem;
    padding-left: 1.5rem;
}

.content-page li {
    margin-bottom: 0.4rem;
}

.content-page strong {
    color: var(--accent-green);
}

.content-page em {
    color: var(--accent-yellow);
}

.content-page code {
    background: var(--bg-tertiary);
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    font-size: 0.9rem;
    color: var(--accent-orange);
}

.content-page pre {
    background: var(--bg-tertiary);
    padding: 1rem;
    border-radius: 8px;
    overflow-x: auto;
    margin-bottom: 1rem;
}

.content-page blockquote {
    border-left: 3px solid var(--accent);
    padding-left: 1rem;
    color: var(--text-secondary);
    margin: 1rem 0;
}

/* Tables */
.content-page table {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0;
    font-size: 0.9rem;
}

.content-page th {
    background: var(--bg-tertiary);
    padding: 0.75rem;
    text-align: left;
    border: 1px solid var(--border);
    color: var(--accent);
    font-weight: 600;
}

.content-page td {
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--border);
}

.content-page tr:nth-child(even) {
    background: rgba(255, 255, 255, 0.02);
}

.content-page tr:hover {
    background: rgba(88, 166, 255, 0.05);
}

/* Quiz Section */
.quiz-container {
    max-width: 800px;
    margin: 0 auto;
}

.quiz-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.quiz-category-select {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-bottom: 2rem;
}

.quiz-btn {
    padding: 0.6rem 1.2rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.95rem;
}

.quiz-btn:hover {
    border-color: var(--accent);
    background: var(--bg-tertiary);
}

.quiz-btn.active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

.quiz-btn.start-btn {
    background: var(--accent-green);
    color: #fff;
    border: none;
    font-size: 1.1rem;
    padding: 0.75rem 2rem;
}

.quiz-btn.start-btn:hover {
    opacity: 0.9;
}

.question-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 2rem;
    margin-bottom: 1.5rem;
}

.question-number {
    color: var(--accent);
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

.question-text {
    font-size: 1.15rem;
    margin-bottom: 1.5rem;
    line-height: 1.5;
}

.options {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.option {
    padding: 0.75rem 1rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.option:hover {
    border-color: var(--accent);
    background: var(--bg-tertiary);
}

.option.selected {
    border-color: var(--accent);
    background: rgba(88, 166, 255, 0.1);
}

.option.correct {
    border-color: var(--accent-green);
    background: rgba(63, 185, 80, 0.1);
}

.option.wrong {
    border-color: var(--accent-red);
    background: rgba(248, 81, 73, 0.1);
}

.option-letter {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    font-weight: 600;
    flex-shrink: 0;
}

.explanation {
    margin-top: 1rem;
    padding: 1rem;
    background: var(--bg-tertiary);
    border-radius: 8px;
    border-left: 3px solid var(--accent);
    display: none;
}

.explanation.show {
    display: block;
}

/* Score */
.score-display {
    text-align: center;
    padding: 2rem;
}

.score-number {
    font-size: 3rem;
    font-weight: 700;
    color: var(--accent-green);
}

.score-label {
    font-size: 1.1rem;
    color: var(--text-secondary);
}

/* Progress Bar */
.progress-bar {
    width: 100%;
    height: 6px;
    background: var(--bg-tertiary);
    border-radius: 3px;
    margin-bottom: 1.5rem;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--accent-green);
    border-radius: 3px;
    transition: width 0.3s;
}

/* Listening Section */
.listening-container {
    max-width: 800px;
    margin: 0 auto;
}

.audio-controls {
    display: flex;
    gap: 1rem;
    margin: 1.5rem 0;
    flex-wrap: wrap;
}

.audio-btn {
    padding: 0.75rem 1.5rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s;
    font-size: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.audio-btn:hover {
    border-color: var(--accent);
    background: var(--bg-tertiary);
}

.audio-btn.play {
    background: var(--accent);
    color: #fff;
    border: none;
}

.audio-btn.play:hover {
    opacity: 0.9;
}

.dictation-input {
    width: 100%;
    padding: 1rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 1.1rem;
    line-height: 1.5;
    resize: vertical;
    min-height: 100px;
    font-family: inherit;
}

.dictation-input:focus {
    outline: none;
    border-color: var(--accent);
}

.result-correct {
    color: var(--accent-green);
    font-weight: 600;
}

.result-wrong {
    color: var(--accent-red);
}

.difficulty-select {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

/* History Table */
.history-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
}

.history-table th {
    background: var(--bg-tertiary);
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
    color: var(--accent);
}

.history-table td {
    padding: 0.6rem 0.75rem;
    border-bottom: 1px solid var(--border);
}

/* Back Link */
.back-link {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

.back-link:hover {
    color: var(--accent);
}

/* Page Title */
.page-title {
    font-size: 2rem;
    margin-bottom: 0.5rem;
    color: var(--accent-green);
}

.page-subtitle {
    color: var(--text-secondary);
    margin-bottom: 2rem;
}

/* Footer */
.footer {
    text-align: center;
    padding: 2rem;
    color: var(--text-muted);
    font-size: 0.85rem;
    border-top: 1px solid var(--border);
    margin-top: 3rem;
}

/* Responsive */
@media (max-width: 768px) {
    .navbar {
        flex-direction: column;
        gap: 0.75rem;
        padding: 1rem;
    }

    .navbar-links {
        gap: 1rem;
        justify-content: center;
    }

    .container {
        padding: 1rem;
    }

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

    .cards-grid {
        grid-template-columns: 1fr;
    }

    .content-page {
        padding: 1.5rem;
    }

    .content-page table {
        font-size: 0.8rem;
    }

    .content-page th,
    .content-page td {
        padding: 0.4rem;
    }
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: var(--bg-tertiary);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* === NO-SCROLL app shell (design/NO_SCROLL.md) ===
   The page itself never scrolls: navbar/footer are a fixed HUD and
   <main> is the single designated internal pane (rule 6). */
html { height: 100%; }
body { height: 100dvh; overflow: hidden; display: flex; flex-direction: column; }
.navbar { flex: none; }
main.container { flex: 1 1 auto; min-height: 0; overflow-y: auto; width: 100%; }
.footer { flex: none; padding: 0.45rem 1rem; }

/* === Exercise density (NO_SCROLL progression): one-viewport exercise views === */
.page-title { font-size: 1.15rem; margin: 0 0 0.15rem; }
.page-subtitle { font-size: 0.8rem; margin: 0 0 0.6rem; }
.back-link { font-size: 0.75rem; }
.question-card { padding: 14px 18px; margin-bottom: 12px; }
.option { padding: 8px 12px; font-size: 0.92rem; }
.options { gap: 8px; }
.quiz-progress, .progress-text { font-size: 0.8rem; }

/* Slim one-row navbar (HUD): smaller brand/links so 11 links fit one line */
.navbar { padding: 0.4rem 1.2rem; gap: 1rem; }
.navbar-brand { font-size: 1.05rem; }
.navbar-links { gap: 0.9rem; }
.navbar-links a { font-size: 0.82rem; }
.container { padding: 1rem 1.5rem; }
/* Explanation = the one designated internal-scroll pane (NO_SCROLL rule 6) */
.explanation { margin-top: 0.6rem; padding: 0.7rem 0.9rem; font-size: 0.9rem; max-height: 26vh; overflow-y: auto; }

/* === MOTION v1 (NO_SCROLL.md): entrance + hover lift; reduced-motion safe === */
@keyframes mvRise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: no-preference) {
  .question-card, .quiz-container, .card { animation: mvRise 0.3s ease both; }
  .option, .quiz-btn, .navbar-links a { transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease; }
  .option:hover, .quiz-btn:hover { transform: translateY(-2px); }
}
