/* ── Design tokens ───────────────────────────────── */
:root {
    --th-bg: #f5f3ef;
    --th-surface: #ffffff;
    --th-surface-2: #faf9f7;
    --th-border: #e4e0d8;
    --th-border-light: #eeebe5;
    --th-text-primary: #1a1816;
    --th-text-secondary: #4a4744;
    --th-text-muted: #9a948c;
    --th-text-dim: #c8c4bc;

    --th-accent: #b8841a;
    --th-accent-bg: #fdf5e4;
    --th-accent-border: #f0d99a;

    --th-green: #1a7a48;
    --th-green-bg: #edf7f2;
    --th-green-border: #a3d9bc;

    --th-red: #b83232;
    --th-red-bg: #fdf0f0;
    --th-red-border: #f0b0b0;

    --th-blue: #1a5a9a;
    --th-blue-bg: #eef4fc;
    --th-blue-border: #a8c8f0;

    --th-purple: #6a2a9a;
    --th-purple-bg: #f4eef9;
    --th-purple-border: #c8a8e8;

    --th-orange: #b85a1a;
    --th-orange-bg: #fdf3ec;
    --th-orange-border: #f0c898;
}

/* ── Scoped wrapper so Dashlite styles don't bleed ─ */
.th-wrap {
    background: var(--th-bg);
    border-radius: 16px;
    padding: 40px 36px 60px;
    font-family: "DM Sans", sans-serif;
    font-weight: 400;
    color: var(--th-text-primary);
}

/* ── Header ─────────────────────────────────────── */
.th-header {
    margin-bottom: 36px;
    animation: th-fadeUp 0.55s ease both;
}

.th-task-meta {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
    flex-wrap: wrap;
}

.th-task-title {
    font-family: "Playfair Display", serif;
    font-size: clamp(20px, 1vw, 34px);
    font-weight: 700;
    line-height: 1.0;
    letter-spacing: -0.02em;
    color: var(--th-text-primary);
    margin-bottom: 8px;
}

.th-task-title em {
    font-style: italic;
    color: var(--th-accent);
}

.th-task-id {
    font-family: "DM Mono", monospace;
    font-size: 12px;
    color: var(--th-text-muted);
    letter-spacing: 0.08em;
}

.th-outline-pending {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 7px 15px;
    border-radius: 100px;
    font-family: "DM Mono", monospace;
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    background: var(--th-bg);
    color: var(--th-text-muted);
    border: 1px solid var(--th-text-secondary);
    white-space: nowrap;
    margin-top: 4px;
}

.th-outline-in-progress {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 7px 15px;
    border-radius: 100px;
    font-family: "DM Mono", monospace;
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    background: var(--th-orange-bg);
    color: var(--th-orange);
    border: 1px solid var(--th-orange-border);
    white-space: nowrap;
    margin-top: 4px;
}

.th-outline-completed {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 7px 15px;
    border-radius: 100px;
    font-family: "DM Mono", monospace;
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    background: var(--th-green-bg);
    color: var(--th-green);
    border: 1px solid var(--th-green-border);
    white-space: nowrap;
    margin-top: 4px;
}

.th-status-pending {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--th-text-secondary);
    animation: th-pulse 2s ease-in-out infinite;
}

.th-status-ongoing {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--th-orange);
    animation: th-pulse 2s ease-in-out infinite;
}

.th-status-completed {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--th-green);
    animation: th-pulse 2s ease-in-out infinite;
}

@keyframes th-pulse {
    0%,
    100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.4;
        transform: scale(0.8);
    }
}

.th-divider {
    margin-top: 28px;
    height: 1px;
    background: linear-gradient(to right, var(--th-border), transparent 80%);
}

/* ── Stats ───────────────────────────────────────── */
.th-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1px;
    background: var(--th-border);
    border: 1px solid var(--th-border);
    border-radius: 14px;
    overflow: hidden;
    margin-bottom: 40px;
    animation: th-fadeUp 0.55s 0.08s ease both;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
}

.th-stat {
    background: var(--th-surface);
    padding: 20px 24px;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.th-stat-label {
    font-family: "DM Mono", monospace;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.13em;
    color: var(--th-text-muted);
}

.th-stat-value {
    font-family: "Playfair Display", serif;
    font-size: 24px;
    font-weight: 700;
    color: var(--th-text-primary);
    line-height: 1.1;
}

.th-stat-sub {
    font-size: 11px;
    color: var(--th-text-muted);
}

/* ── Section heading ─────────────────────────────── */
.th-section-heading {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 24px;
    animation: th-fadeUp 0.55s 0.16s ease both;
}

.th-section-label {
    font-family: "DM Mono", monospace;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.16em;
    color: var(--th-text-muted);
    white-space: nowrap;
}

.th-section-line {
    flex: 1;
    height: 1px;
    background: var(--th-border);
}

/* ── Timeline ────────────────────────────────────── */
.th-timeline {
    display: flex;
    flex-direction: column;
}

.th-item {
    display: grid;
    grid-template-columns: 50px 1fr;
    opacity: 0;
    animation: th-fadeUp 0.5s ease both;
}

.th-item:nth-child(1) {
    animation-delay: 0.22s;
}
.th-item:nth-child(2) {
    animation-delay: 0.3s;
}
.th-item:nth-child(3) {
    animation-delay: 0.38s;
}
.th-item:nth-child(4) {
    animation-delay: 0.46s;
}
.th-item:nth-child(5) {
    animation-delay: 0.54s;
}
.th-item:nth-child(6) {
    animation-delay: 0.62s;
}
.th-item:nth-child(7) {
    animation-delay: 0.7s;
}

.th-connector {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-top: 20px;
}

.th-dot {
    width: 13px;
    height: 13px;
    border-radius: 50%;
    border: 2px solid var(--th-border);
    background: var(--th-surface);
    flex-shrink: 0;
    z-index: 1;
    transition: transform 0.2s;
}

.th-item:hover .th-dot {
    transform: scale(1.3);
}

.th-dot.created {
    border-color: var(--th-accent);
    background: var(--th-accent-bg);
}
.th-dot.assigned {
    border-color: var(--th-blue);
    background: var(--th-blue-bg);
}
.th-dot.started {
    border-color: var(--th-purple);
    background: var(--th-purple-bg);
}
.th-dot.updated {
    border-color: var(--th-orange);
    background: var(--th-orange-bg);
}
.th-dot.blocked {
    border-color: var(--th-red);
    background: var(--th-red-bg);
}
.th-dot.reviewed {
    border-color: var(--th-blue);
    background: var(--th-blue-bg);
}
.th-dot.completed {
    border-color: var(--th-green);
    background: var(--th-green-bg);
}

.th-line {
    width: 1px;
    flex: 1;
    min-height: 20px;
    background: var(--th-border-light);
}

.th-item:last-child .th-line {
    display: none;
}

/* ── Card ────────────────────────────────────────── */
.th-card {
    margin-left: 4px;
    margin-bottom: 10px;
    padding: 16px 20px;
    background: var(--th-surface);
    border: 1px solid var(--th-border);
    border-radius: 14px;
    position: relative;
    cursor: pointer;
    transition:
        border-color 0.2s,
        transform 0.2s,
        box-shadow 0.2s;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.th-card:hover {
    border-color: #ccc8c0;
    transform: translateX(4px);
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.07);
}

.th-card::before {
    content: "";
    position: absolute;
    left: 0;
    top: 14px;
    bottom: 14px;
    width: 3px;
    border-radius: 4px;
}

.th-item.created .th-card::before {
    background: var(--th-accent);
}
.th-item.assigned .th-card::before {
    background: var(--th-blue);
}
.th-item.started .th-card::before {
    background: var(--th-purple);
}
.th-item.updated .th-card::before {
    background: var(--th-orange);
}
.th-item.blocked .th-card::before {
    background: var(--th-red);
}
.th-item.reviewed .th-card::before {
    background: var(--th-blue);
}
.th-item.completed .th-card::before {
    background: var(--th-green);
}

.th-card-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 7px;
}

.th-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 11px;
    border-radius: 100px;
    font-family: "DM Mono", monospace;
    font-size: 10px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    border: 1px solid transparent;
}

.th-badge.created {
    background: var(--th-accent-bg);
    color: var(--th-accent);
    border-color: var(--th-accent-border);
}
.th-badge.assigned {
    background: var(--th-blue-bg);
    color: var(--th-blue);
    border-color: var(--th-blue-border);
}
.th-badge.started {
    background: var(--th-purple-bg);
    color: var(--th-purple);
    border-color: var(--th-purple-border);
}
.th-badge.updated {
    background: var(--th-orange-bg);
    color: var(--th-orange);
    border-color: var(--th-orange-border);
}
.th-badge.blocked {
    background: var(--th-red-bg);
    color: var(--th-red);
    border-color: var(--th-red-border);
}
.th-badge.reviewed {
    background: var(--th-blue-bg);
    color: var(--th-blue);
    border-color: var(--th-blue-border);
}
.th-badge.completed {
    background: var(--th-green-bg);
    color: var(--th-green);
    border-color: var(--th-green-border);
}

.th-timestamp {
    font-family: "DM Mono", monospace;
    font-size: 11px;
    color: var(--th-text-muted);
    white-space: nowrap;
    flex-shrink: 0;
    padding-top: 2px;
}

.th-card-title {
    font-family: "Playfair Display", serif;
    font-size: 16px;
    font-weight: 700;
    line-height: 1.3;
    margin-bottom: 4px;
    color: var(--th-text-primary);
}

.th-card-desc {
    font-size: 13px;
    color: var(--th-text-secondary);
    line-height: 1.65;
}

.th-card-footer {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid var(--th-border-light);
    flex-wrap: wrap;
}

.th-actor {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--th-text-secondary);
}

.th-avatar {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 9px;
    font-weight: 700;
    flex-shrink: 0;
    border: 1.5px solid transparent;
}

.th-av-a {
    background: var(--th-blue-bg);
    color: var(--th-blue);
    border-color: var(--th-blue-border);
}
.th-av-b {
    background: var(--th-purple-bg);
    color: var(--th-purple);
    border-color: var(--th-purple-border);
}
.th-av-c {
    background: var(--th-green-bg);
    color: var(--th-green);
    border-color: var(--th-green-border);
}

.th-meta {
    font-size: 11px;
    color: var(--th-text-muted);
    font-family: "DM Mono", monospace;
}

.th-pill {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 4px;
    font-family: "DM Mono", monospace;
    font-size: 11px;
    border: 1px solid transparent;
}

.th-pill.add {
    background: var(--th-green-bg);
    color: var(--th-green);
    border-color: var(--th-green-border);
}
.th-pill.rem {
    background: var(--th-red-bg);
    color: var(--th-red);
    border-color: var(--th-red-border);
}

/* ── Expandable detail ───────────────────────────── */
.th-detail {
    max-height: 0;
    overflow: hidden;
    transition:
        max-height 0.35s ease,
        margin-top 0.3s ease;
}

.th-detail.open {
    max-height: 200px;
    margin-top: 10px;
}

.th-detail-inner {
    padding: 12px 14px;
    background: var(--th-surface-2);
    border: 1px solid var(--th-border-light);
    border-radius: 8px;
    font-family: "DM Mono", monospace;
    font-size: 12px;
    color: var(--th-text-secondary);
    line-height: 1.75;
}

.th-detail-inner strong {
    color: var(--th-text-primary);
    font-weight: 500;
}

.th-expand {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--th-text-dim);
    font-size: 15px;
    transition: transform 0.25s;
    line-height: 1;
}

.th-card.expanded .th-expand {
    transform: translateY(-50%) rotate(180deg);
}

@keyframes th-fadeUp {
    from {
        opacity: 0;
        transform: translateY(14px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (max-width: 540px) {
    .th-stats {
        grid-template-columns: 1fr 1fr;
    }
    .th-stats .th-stat:last-child {
        grid-column: 1 / -1;
    }
    .th-wrap {
        padding: 24px 16px 48px;
    }
}

/* ── Search bar ──────────────────────────────────── */
.th-search-card {
    background: #ffffff;
    border: 1px solid var(--th-border);
    border-radius: 14px;
    padding: 20px 24px 16px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
    margin-bottom: 4px;
}

.th-search-card-label {
    display: flex;
    align-items: center;
    gap: 7px;
    font-family: "DM Mono", monospace;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.13em;
    color: var(--th-text-muted);
    margin-bottom: 14px;
}

.th-search-card-label .ni {
    font-size: 14px;
}
.th-search-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 6px;
}

.th-search-box {
    position: relative;
    flex: 1;
}

.th-search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--th-text-muted);
    font-size: 16px;
    pointer-events: none;
}

.th-search-input {
    width: 100%;
    height: 42px;
    padding: 0 40px 0 42px;
    background: #ffffff;
    border: 1px solid var(--th-border);
    border-radius: 10px;
    font-family: "DM Sans", sans-serif;
    font-size: 13.5px;
    color: var(--th-text-primary);
    outline: none;
    transition:
        border-color 0.2s,
        box-shadow 0.2s;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.th-search-input::placeholder {
    color: var(--th-text-dim);
}

.th-search-input:focus {
    border-color: var(--th-blue);
    box-shadow: 0 0 0 3px rgba(26, 90, 154, 0.1);
}

.th-search-clear {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: none;
    background: var(--th-border);
    color: var(--th-text-muted);
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    transition:
        background 0.15s,
        color 0.15s;
}

.th-search-clear:hover {
    background: var(--th-text-dim);
    color: var(--th-text-primary);
}
.th-search-clear.visible {
    display: flex;
}

.th-search-btn {
    height: 42px;
    padding: 0 20px;
    background: var(--th-blue);
    color: #ffffff;
    border: none;
    border-radius: 10px;
    font-family: "DM Sans", sans-serif;
    font-size: 13.5px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 7px;
    white-space: nowrap;
    transition:
        background 0.2s,
        box-shadow 0.2s;
    box-shadow: 0 1px 4px rgba(26, 90, 154, 0.18);
}

.disabled {
    pointer-events: none; /* Disable mouse interactions */
    cursor: not-allowed;
    opacity: 0.6;
}

.th-search-btn:hover {
    background: #174f88;
    box-shadow: 0 3px 10px rgba(26, 90, 154, 0.25);
}

.th-search-btn .ni {
    font-size: 15px;
}

.th-search-meta {
    font-family: "DM Mono", monospace;
    font-size: 11px;
    color: var(--th-text-muted);
    min-height: 18px;
    padding-left: 2px;
    margin-bottom: 4px;
}

.th-item.th-hidden {
    display: none;
}

.th-no-results {
    text-align: center;
    padding: 48px 24px;
    font-family: "DM Mono", monospace;
    font-size: 13px;
    color: var(--th-text-muted);
}

@media (max-width: 480px) {
    .th-search-btn span {
        display: none;
    }
    .th-search-btn {
        padding: 0 14px;
    }
}
