/* ── Font ─────────────────────────────────────────────── */
@font-face {
    font-family: 'Arketa';
    src: url('/static/OOArketa-Regular.otf') format('opentype');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

/* ── Reset & Base ─────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg: #ffffff;
    --bg-card: #ffffff;
    --bg-card-hover: #fafafa;
    --bg-input: #f5f5f3;
    --border: #e8e8e6;
    --border-light: #d4d4d0;
    --text: #000000;
    --text-dim: #3a3a3a;
    --text-muted: #999994;
    --accent: #000000;
    --accent-glow: rgba(0, 0, 0, 0.05);
    --accent-hover: #333333;
    --green: #2a2a2a;
    --green-dim: rgba(0, 0, 0, 0.04);
    --yellow: #000000;
    --yellow-dim: rgba(0, 0, 0, 0.04);
    --red: #000000;
    --red-dim: rgba(0, 0, 0, 0.04);
    --orange: #000000;
    --highlight: #d4e4ff;
    --radius: 0px;
    --radius-sm: 0px;
    --font: 'Arketa', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', ui-monospace, monospace;
    --spacing: 0.25rem;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* ── Typography ──────────────────────────────────────── */
h1 { font-size: 1.5rem; font-weight: 400; letter-spacing: -0.01em; margin-bottom: 0.25rem; }
h2 { font-size: 1.1rem; font-weight: 400; letter-spacing: 0; margin-bottom: 0.5rem; }
h3 { font-size: 0.95rem; font-weight: 500; }
p { color: var(--text-dim); }
a { color: var(--text); text-decoration: underline; text-underline-offset: 2px; }
a:hover { opacity: 0.6; }

.subtitle { color: var(--text-muted); margin-bottom: 2.5rem; font-size: 0.9rem; }

/* ── Layout ──────────────────────────────────────────── */
.container {
    max-width: 680px;
    margin: 0 auto;
    padding: clamp(2rem, 6vw, 4rem) clamp(1.5rem, 4vw, 3rem) 6rem;
}

.view { display: none; }
.view.active { display: block; }

/* ── Navigation ──────────────────────────────────────── */
#nav {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
}

.nav-inner {
    max-width: 680px;
    margin: 0 auto;
    padding: 0.75rem clamp(1.5rem, 4vw, 3rem);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.nav-brand {
    font-weight: 400;
    font-size: 0.9rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    letter-spacing: -0.01em;
}

.logo {
    color: var(--text);
    font-size: 0.9rem;
}

.nav-links {
    display: flex;
    gap: 0;
}

.nav-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-family: var(--font);
    font-size: 0.8rem;
    font-weight: 400;
    padding: 0.35rem 0.65rem;
    border-radius: 0;
    cursor: pointer;
    transition: color 0.2s;
    letter-spacing: 0;
}

.nav-btn:hover {
    color: var(--text);
    background: none;
}

.nav-btn.active {
    color: #fff;
    background: var(--text);
}

/* ── Buttons ─────────────────────────────────────────── */
.btn {
    font-family: var(--font);
    font-size: 0.85rem;
    font-weight: 400;
    padding: 0.55rem 1.25rem;
    border-radius: 0;
    border: 1px solid var(--text);
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    letter-spacing: 0;
}

.btn-primary {
    background: var(--text);
    color: #fff;
    border: 1px solid var(--text);
}

.btn-primary:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
    box-shadow: none;
}

.btn-ghost {
    background: none;
    color: var(--text-dim);
    border: 1px solid var(--border);
}

.btn-ghost:hover {
    color: var(--text);
    border-color: var(--text);
    background: none;
}

.btn-sm {
    font-size: 0.78rem;
    padding: 0.3rem 0.65rem;
}

/* ── Today View ──────────────────────────────────────── */
.today-header {
    display: flex;
    gap: 1.5rem;
    align-items: flex-start;
    margin-bottom: calc(var(--spacing) * 12);
    padding-bottom: calc(var(--spacing) * 8);
    border-bottom: 1px solid var(--border);
}

.day-badge {
    flex-shrink: 0;
    width: 72px;
    height: 72px;
    border-radius: 0;
    background: var(--text);
    border: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.day-number {
    font-size: 1.5rem;
    font-weight: 400;
    color: #fff;
    line-height: 1;
}

.day-label {
    font-size: 0.6rem;
    color: rgba(255,255,255,0.5);
    margin-top: 2px;
    letter-spacing: 0.02em;
}

.today-meta h1 {
    margin-bottom: 0.35rem;
}

.phase-goal {
    font-size: 0.9rem;
    line-height: 1.5;
    margin-bottom: 0.5rem;
}

.today-info {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* ── Exercises ───────────────────────────────────────── */
.exercises-list {
    display: flex;
    flex-direction: column;
    gap: 0;
    margin-bottom: calc(var(--spacing) * 10);
}

.exercise-card {
    background: var(--bg-card);
    border: none;
    border-top: 1px solid var(--border);
    border-radius: 0;
    padding: calc(var(--spacing) * 8) 0;
    transition: none;
}

.exercise-card:last-child {
    border-bottom: 1px solid var(--border);
}

.exercise-card:hover {
    border-color: var(--border);
}

.exercise-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: calc(var(--spacing) * 4);
}

.exercise-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.exercise-icon {
    width: 24px;
    height: 24px;
    border-radius: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    flex-shrink: 0;
    background: none !important;
}

.exercise-duration {
    font-size: 0.75rem;
    color: var(--text-muted);
    background: none;
    padding: 0;
    border-radius: 0;
    font-family: var(--font-mono);
}

.exercise-body {
    font-size: 0.9rem;
    line-height: 1.65;
    color: var(--text-dim);
}

.exercise-body strong {
    color: var(--text);
    font-weight: 500;
}

.exercise-body em {
    color: var(--text);
    font-style: italic;
}

.exercise-body blockquote {
    border-left: 2px solid var(--text);
    padding: 0.5rem 1rem;
    margin: 0.75rem 0;
    background: var(--bg-input);
    border-radius: 0;
    color: var(--text);
    font-style: italic;
}

/* ── Tip Card ────────────────────────────────────────── */
.tip-card {
    background: none;
    border: none;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    border-left: none;
    border-radius: 0;
    padding: calc(var(--spacing) * 6) 0;
    margin-bottom: calc(var(--spacing) * 10);
    font-size: 0.88rem;
    color: var(--text-dim);
    line-height: 1.6;
}

.tip-card .tip-label {
    color: var(--text-muted);
    font-weight: 500;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 0.3rem;
}

/* ── Completion ──────────────────────────────────────── */
.completion-section {
    background: none;
    border: 1px solid var(--border);
    border-radius: 0;
    padding: calc(var(--spacing) * 8);
    margin-bottom: calc(var(--spacing) * 8);
    text-align: center;
}

.completion-section h3 {
    margin-bottom: 1rem;
    font-weight: 400;
}

.rating-stars {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    margin-bottom: 1rem;
}

.star {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--border);
    cursor: pointer;
    transition: color 0.1s;
    padding: 0;
}

.star:hover, .star.active {
    color: var(--text);
    transform: none;
}

#day-notes {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 0;
    color: var(--text);
    font-family: var(--font);
    font-size: 0.88rem;
    padding: 0.75rem;
    resize: vertical;
    min-height: 80px;
    margin-bottom: 1rem;
}

#day-notes::placeholder {
    color: var(--text-muted);
}

#day-notes:focus {
    outline: none;
    border-color: var(--text);
}

.completion-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    flex-wrap: wrap;
}

.completion-status {
    margin-top: 0.75rem;
    font-size: 0.85rem;
    color: var(--text-dim);
}

.day-nav {
    display: flex;
    justify-content: space-between;
}

/* completed state */
.completion-section.completed {
    border-color: var(--text);
    background: none;
}

/* ── Calendar View ───────────────────────────────────── */
.calendar-phase {
    margin-bottom: calc(var(--spacing) * 12);
}

.calendar-phase-header {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 0.75rem;
}

.calendar-phase-number {
    width: 24px;
    height: 24px;
    border-radius: 0;
    background: var(--text);
    color: #fff;
    font-size: 0.7rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: center;
}

.calendar-phase-name {
    font-weight: 400;
    font-size: 0.9rem;
}

.calendar-phase-weeks {
    color: var(--text-muted);
    font-size: 0.8rem;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, 36px);
    gap: 3px;
}

.cal-day {
    width: 36px;
    height: 36px;
    border-radius: 0;
    background: var(--bg);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s;
    font-family: var(--font-mono);
}

.cal-day:hover {
    border-color: var(--text);
    color: var(--text);
}

.cal-day.completed {
    background: var(--text);
    border-color: var(--text);
    color: #fff;
    font-weight: 500;
}

.cal-day.today {
    border-color: var(--text);
    color: var(--text);
    font-weight: 600;
    box-shadow: none;
    border-width: 2px;
}

.cal-day.future {
    opacity: 0.3;
}

/* ── Analyse View ────────────────────────────────────── */
.analyse-input-section {
    margin-bottom: calc(var(--spacing) * 10);
}

.input-group {
    display: flex;
    gap: 0.5rem;
}

.input-group input {
    flex: 1;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 0;
    color: var(--text);
    font-family: var(--font);
    font-size: 0.88rem;
    padding: 0.55rem 0.75rem;
}

.input-group input:focus {
    outline: none;
    border-color: var(--text);
}

.input-group input::placeholder {
    color: var(--text-muted);
}

.channel-videos {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.video-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 0;
    overflow: hidden;
    cursor: pointer;
    transition: border-color 0.2s;
}

.video-card:hover {
    border-color: var(--text);
    transform: none;
}

.video-card img {
    width: 100%;
    aspect-ratio: 16/9;
    object-fit: cover;
}

.video-card-title {
    padding: 0.5rem 0.6rem;
    font-size: 0.78rem;
    color: var(--text-dim);
    line-height: 1.4;
}

/* Analysis Result */
.analysis-card {
    background: none;
    border: none;
    border-bottom: 1px solid var(--border);
    border-radius: 0;
    padding: calc(var(--spacing) * 6) 0;
    margin-bottom: 0;
}

.analysis-card h2 {
    margin-bottom: 1rem;
    font-weight: 400;
}

.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 1px;
    margin-bottom: 0;
    background: var(--border);
    border: 1px solid var(--border);
}

.metric {
    background: var(--bg);
    border-radius: 0;
    padding: 1rem;
    text-align: center;
}

.metric-value {
    font-size: 1.35rem;
    font-weight: 400;
    color: var(--text);
    font-family: var(--font-mono);
}

.metric-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.filler-bar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.filler-word {
    width: 80px;
    font-size: 0.8rem;
    color: var(--text-dim);
    text-align: right;
    font-family: var(--font-mono);
}

.filler-track {
    flex: 1;
    height: 16px;
    background: var(--bg-input);
    border-radius: 0;
    overflow: hidden;
}

.filler-fill {
    height: 100%;
    background: var(--text);
    border-radius: 0;
    transition: width 0.5s ease;
    min-width: 2px;
}

.filler-count {
    width: 30px;
    font-size: 0.78rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
}

.summary-points {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0;
}

.summary-points li {
    font-size: 0.9rem;
    line-height: 1.6;
    color: var(--text-dim);
    padding: calc(var(--spacing) * 4) 0;
    background: none;
    border-radius: 0;
    border-bottom: 1px solid var(--border);
}

.summary-points li:first-child {
    border-top: 1px solid var(--border);
}

.summary-points li strong {
    color: var(--text);
}

.transcript-preview {
    background: var(--bg-input);
    border-radius: 0;
    padding: 1.25rem;
    font-size: 0.82rem;
    color: var(--text-dim);
    line-height: 1.7;
    max-height: none;
    font-family: var(--font-mono);
    border: 1px solid var(--border);
}

/* Past analyses */
.past-analysis-item {
    background: none;
    border: none;
    border-bottom: 1px solid var(--border);
    border-radius: 0;
    padding: calc(var(--spacing) * 4) 0;
    margin-bottom: 0;
    display: flex;
    align-items: center;
    gap: calc(var(--spacing) * 3);
}

.past-analysis-content {
    flex: 1;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    transition: opacity 0.15s;
}

.past-analysis-content:hover {
    opacity: 0.6;
}

.btn-delete {
    background: none;
    border: 1px solid var(--border);
    border-radius: 50%;
    width: 28px;
    height: 28px;
    font-size: 1rem;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
    flex-shrink: 0;
    line-height: 1;
}

.btn-delete:hover {
    border-color: #c00;
    color: #c00;
}

/* ── Progress View ───────────────────────────────────── */
.progress-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 1px;
    margin-bottom: calc(var(--spacing) * 12);
    background: var(--border);
    border: 1px solid var(--border);
}

.stat-card {
    background: var(--bg);
    border: none;
    border-radius: 0;
    padding: 1.25rem;
    text-align: center;
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 400;
    color: var(--text);
    font-family: var(--font-mono);
    line-height: 1;
}

.stat-value.accent { color: var(--text); }
.stat-value.green { color: var(--text); }
.stat-value.yellow { color: var(--text); }

.stat-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 0.4rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.streak-section {
    margin-bottom: calc(var(--spacing) * 8);
}

.streak-bar {
    display: flex;
    gap: 2px;
    flex-wrap: wrap;
    margin-top: 0.75rem;
}

.streak-dot {
    width: 14px;
    height: 14px;
    border-radius: 0;
    background: var(--bg-input);
    border: 1px solid var(--border);
}

.streak-dot.done {
    background: var(--text);
    border-color: var(--text);
}

.streak-dot.today {
    border-color: var(--text);
    border-width: 2px;
    box-shadow: none;
}

.progress-chart {
    margin-top: calc(var(--spacing) * 8);
}

.chart-bars {
    display: flex;
    align-items: flex-end;
    gap: 2px;
    height: 120px;
    padding: 0 0 1.5rem;
    border-bottom: 1px solid var(--border);
    position: relative;
}

.chart-bar {
    flex: 1;
    background: var(--text);
    border-radius: 0;
    min-height: 2px;
    transition: height 0.3s;
    position: relative;
}

.chart-bar:hover {
    background: var(--text-muted);
}

.chart-bar::after {
    content: attr(data-label);
    position: absolute;
    bottom: -1.5rem;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.5rem;
    color: var(--text-muted);
    white-space: nowrap;
    font-family: var(--font-mono);
}

/* ── Loading ─────────────────────────────────────────── */
.loading {
    text-align: center;
    padding: 3rem;
}

.spinner {
    width: 24px;
    height: 24px;
    border: 2px solid var(--border);
    border-top-color: var(--text);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 1rem;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ── Responsive ──────────────────────────────────────── */
@media (max-width: 600px) {
    .container { padding: 1.5rem 1rem calc(5rem + env(safe-area-inset-bottom, 0px)); }
    h1 { font-size: 1.25rem; }
    .today-header { flex-direction: column; gap: 1rem; }
    .day-badge { width: 56px; height: 56px; }
    .day-number { font-size: 1.25rem; }
    .metrics-grid { grid-template-columns: repeat(2, 1fr); }
    .input-group { flex-direction: column; }
    .calendar-grid { grid-template-columns: repeat(auto-fill, 30px); }
    .cal-day { width: 30px; height: 30px; font-size: 0.6rem; }

    /* ── Bottom Tab Bar ─────────────────────────────── */
    #nav {
        position: fixed;
        top: auto;
        bottom: 0;
        left: 0;
        right: 0;
        border-bottom: none;
        border-top: 1px solid var(--border);
        background: rgba(255, 255, 255, 0.95);
        backdrop-filter: blur(16px);
        -webkit-backdrop-filter: blur(16px);
        padding-bottom: env(safe-area-inset-bottom, 0px);
    }

    .nav-inner {
        padding: 0;
        justify-content: center;
    }

    .nav-brand {
        display: none;
    }

    .nav-links {
        display: flex;
        width: 100%;
        justify-content: space-around;
        gap: 0;
    }

    .nav-btn {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 0.2rem;
        padding: 0.6rem 0.25rem 0.5rem;
        font-size: 0.65rem;
        letter-spacing: 0.02em;
    }

    .nav-btn::before {
        font-size: 1.1rem;
        line-height: 1;
    }

    .nav-btn[data-view="today"]::before    { content: "◉"; }
    .nav-btn[data-view="calendar"]::before { content: "▦"; }
    .nav-btn[data-view="analyse"]::before  { content: "◎"; }
    .nav-btn[data-view="progress"]::before { content: "▲"; }

    .nav-btn.active {
        color: var(--text);
        background: none;
    }

    .nav-btn:not(.active) {
        color: var(--text-muted);
    }
}

/* ── Markdown-like rendering in exercises ────────────── */
.exercise-body ul, .exercise-body ol {
    margin: 0.5rem 0;
    padding-left: 1.5rem;
}

.exercise-body li {
    margin-bottom: 0.3rem;
}

.exercise-body p {
    margin-bottom: 0.5rem;
    color: inherit;
}
