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

body {
    font-family: system-ui, -apple-system, sans-serif;
    margin: 24px;
}

main {
    max-width: 900px;
    margin: 0 auto;
}

textarea {
    width: 100%;
    font-size: 16px;
    padding: 12px;
}

pre {
    white-space: pre-wrap;
    word-break: break-word;
    overflow-wrap: break-word;
    background: #f6f6f6;
    padding: 12px;
    border-radius: 8px;
}

.row {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-top: 12px;
    flex-wrap: wrap;
}

button,
.btn {
    display: inline-block;
    padding: 10px 14px;
    border-radius: 10px;
    border: 1px solid #ccc;
    background: white;
    cursor: pointer;
    font-family: inherit;
    font-size: 13.3333px;
    color: black;
    text-decoration: none;
    text-align: center;
}

small {
    color: #666;
}

.hidden {
    display: none !important;
}

#turnstile-widget {
    margin-top: 12px;
}

.char-count {
    color: #666;
    font-size: 0.9em;
    margin-left: auto;
    /* Push to right if in flex container */
}

.char-count-error {
    color: #ef4444;
    /* Red-500 */
    font-weight: bold;
}

.cursor {
    display: inline-block;
    width: 2px;
    height: 1.2em;
    background: black;
    margin-left: 1px;
    vertical-align: text-bottom;
    animation: blink 1s step-end infinite;
}

@keyframes blink {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0;
    }
}

.selection {
    background-color: #b4d5fe;
}

/* Proof Box */
.proof-box {
    margin-top: 2rem;
    border: 1px solid #ccc;
    border-radius: 8px;
    background: #fafafa;
    overflow: hidden;
}

.proof-box summary {
    padding: 12px;
    cursor: pointer;
    font-weight: bold;
    background: #f0f0f0;
    border-bottom: 1px solid transparent;
    transition: border-bottom-color 0.2s;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.verified-badge {
    font-size: 0.9em;
    color: #059669;
    background: #d1fae5;
    padding: 2px 8px;
    border-radius: 999px;
    font-weight: normal;
}

.proof-box[open] summary {
    border-bottom-color: #ccc;
}

.proof-content {
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.proof-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.proof-item strong {
    font-size: 0.9em;
    color: #333;
}

.proof-item small {
    display: block;
    color: #666;
    margin-bottom: 4px;
    font-size: 0.8em;
}

.proof-item code {
    background: #eee;
    padding: 8px;
    border-radius: 4px;
    font-family: monospace;
    font-size: 0.85em;
    word-break: break-all;
    border: 1px solid #ddd;
    color: #444;
}

/* Stats Grid */
.stats-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: #fff;
    border: 1px solid #eee;
    padding: 16px;
    border-radius: 12px;
    text-align: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
}

.stat-value {
    font-size: 24px;
    font-weight: 700;
    color: #111;
    margin-bottom: 4px;
}

.stat-label {
    font-size: 13px;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Timeline */
.timeline-container {
    --timeline-bg: #1a1a2e;
    --timeline-chart-bg: #16213e;
    --timeline-text: #9ca3af;
    --timeline-grid: #2d3a5a;

    background: var(--timeline-bg);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 24px;
    overflow: hidden;
}

.timeline-svg {
    display: block;
    width: 100%;
    height: auto;
}

.timeline-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    padding: 12px 0 0;
    justify-content: center;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--timeline-text);
}

.legend-color {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 2px;
}

.timeline-marker {
    cursor: pointer;
    transition: opacity 0.2s;
}

.timeline-marker:hover {
    opacity: 0.8;
}

/* Share Box */
.share-box {
    display: flex;
    gap: 12px;
    margin-bottom: 24px;
    align-items: center;
}

.share-box input {
    flex: 1;
    padding: 12px;
    border: 1px solid #ccc;
    border-radius: 10px;
    font-size: 16px;
    background: #fff;
    color: #333;
    font-family: inherit;
}

.share-box button {
    background: #111;
    color: white;
    border-color: #111;
    font-weight: 600;
    min-width: 100px;
}

.share-box button:hover {
    background: #333;
}

/* Text Truncation */
.text-wrapper {
    position: relative;
    margin-bottom: 24px;
}

.text-container {
    position: relative;
    max-height: 300px;
    overflow: hidden;
    transition: max-height 0.3s ease-out;
}

.text-container.expanded {
    max-height: none;
    overflow: visible;
}

/* Fade effect */
.text-container::after {
    content: "";
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 80px;
    background: linear-gradient(to bottom, transparent, #fff);
    pointer-events: none;
    transition: opacity 0.3s;
    opacity: 0;
    /* Hidden by default */
}

.text-container.is-truncated:not(.expanded)::after {
    opacity: 1;
    /* Show only when truncated and not expanded */
}

.toggle-text-btn {
    display: block;
    margin: 12px auto 0;
    background: transparent;
    color: #555;
    border: 1px solid #ccc;
    font-size: 14px;
}

.toggle-text-btn:hover {
    background: #f0f0f0;
}

.replay-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
}

.replay-icon {
    width: 20px;
    height: 20px;
    stroke-width: 2;
}

/* Replay Section */
.replay-section {
    margin-top: 2rem;
    margin-bottom: 2rem;
}

.replay-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 1rem;
}

.replay-header h2 {
    margin: 0;
}

/* Share Section */
.share-section {
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 1px solid #eee;
}

.share-hint {
    margin-top: -12px;
    margin-bottom: 24px;
    color: #666;
    font-size: 0.9em;
}

.share-cta {
    margin-bottom: 2rem;
}

/* Highlighted Proof Item */
.highlight-item {
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    padding: 16px;
    border-radius: 8px;
    margin-bottom: 16px;
}

.highlight-item strong {
    font-size: 1.1em;
    color: #166534;
}

.highlight-item code {
    background: #fff;
    border-color: #bbf7d0;
    font-size: 1em;
    color: #14532d;
    display: block;
    margin-top: 8px;
    padding: 12px;
}

/* Advanced Details */
.advanced-proof-details {
    margin-top: 8px;
}

.advanced-proof-details summary {
    font-size: 0.85em;
    color: #6b7280;
    padding: 8px 0;
    background: transparent;
    border: none;
    font-weight: normal;
}

.advanced-proof-details .proof-item {
    margin-top: 12px;
    padding-left: 12px;
    border-left: 2px solid #e5e7eb;
}

/* ── Responsive ── */
@media (max-width: 600px) {
    body {
        margin: 16px;
    }

    textarea {
        min-height: 200px;
    }

    button,
    .btn {
        padding: 12px 16px;
        min-height: 44px;
    }

    #publish {
        width: 100%;
    }

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

    .char-count {
        margin-left: 0;
        text-align: center;
    }

    .share-box {
        flex-direction: column;
    }

    .share-box button {
        width: 100%;
        min-width: unset;
    }

    .stats-container {
        grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    }
}