:root {
    --bg-color: #f4f1ea;
    /* Soft paper color */
    --panel-bg: #fffdf9;
    --border-color: #2c3e50;
    /* Charcoal ink */
    --text-primary: #2c3e50;
    --text-secondary: #5d6d7e;

    /* Marker/Highlighter aesthetics */
    --color-tp: #a7f3d0;
    /* Translucent mint green */
    --color-tn: #e2e8f0;
    /* Translucent gray-blue */
    --color-fp: #fecaca;
    /* Translucent pink-red */
    --color-fn: #fde68a;
    /* Translucent yellow-orange */
}

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

body {
    font-family: 'Patrick Hand', cursive;
    background-color: var(--bg-color);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    /* Subtle paper noise texture via SVG data URI */
    background-image: url("data:image/svg+xml,%3Csvg width='200' height='200' viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.6' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23noise)' opacity='0.05'/%3E%3C/svg%3E");
}

.demo-container {
    width: 95vw;
    height: 95vh;
    display: grid;
    grid-template-columns: 1fr 400px;
    grid-template-rows: auto 1fr;
    gap: 20px;
    padding: 20px;
}

.sketch-panel {
    background: var(--panel-bg);
    border: 3px solid var(--border-color);
    box-shadow: 6px 6px 0 rgba(44, 62, 80, 0.15);
    /* Hard drawn shadow */
    padding: 24px;
    /* Hand-drawn wobbly borders using complex border radii */
    border-radius: 255px 15px 225px 15px/15px 225px 15px 255px;
}

.header {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    text-align: center;
    padding: 16px 24px;
}

.header h1 {
    font-size: 2.2rem;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--text-primary);
    letter-spacing: 1px;
    /* Sketchy underline wrapper imitation */
    display: inline-block;
    border-bottom: 3px solid var(--border-color);
    border-radius: 10px 50px 10px 50px;
    padding-bottom: 2px;
}

.header p {
    color: var(--text-secondary);
    font-size: 1.2rem;
    max-width: 950px;
    margin: 0 auto;
    font-family: 'Patrick Hand', cursive;
}

.visualization-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.chart-wrapper {
    flex-grow: 1;
    position: relative;
    padding: 0;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    background: #fff;
}

.flex-grow {
    flex-grow: 1;
}

.relative {
    position: relative;
}

canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: block;
    cursor: crosshair;
}

.overlay-stats {
    position: absolute;
    top: 20px;
    left: 20px;
    font-family: 'Courier Prime', Courier, monospace;
    font-size: 0.95rem;
    pointer-events: none;
    z-index: 10;
}

.sketch-note {
    background: #fff9c4;
    /* Post-it yellow */
    padding: 12px 18px;
    border: 1px solid #d4c454;
    box-shadow: 3px 3px 0 rgba(0, 0, 0, 0.1);
    transform: rotate(-2deg);
    border-radius: 2px 5px 2px 5px;
}

#val-absolute {
    color: #d32f2f;
    font-weight: bold;
}

#val-zoom {
    color: #1976d2;
    font-weight: bold;
}

.controls {
    display: flex;
    justify-content: center;
    padding: 20px 24px;
}

.slider-wrapper {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.slider-wrapper label {
    font-size: 1.3rem;
    color: var(--text-primary);
    font-weight: 700;
    text-align: center;
}

input[type=range] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    background: transparent;
}

/* Pencil-drawn slider thumb */
input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    height: 28px;
    width: 14px;
    background: #e74c3c;
    /* Red marker tip */
    border: 2px solid var(--border-color);
    border-radius: 3px;
    cursor: pointer;
    margin-top: -10px;
    box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.2);
}

input[type=range]::-moz-range-thumb {
    height: 28px;
    width: 14px;
    background: #e74c3c;
    border: 2px solid var(--border-color);
    border-radius: 3px;
    cursor: pointer;
    box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.2);
}

/* Charcoal drawn track */
input[type=range]::-webkit-slider-runnable-track {
    width: 100%;
    height: 8px;
    cursor: pointer;
    background: var(--border-color);
    border-radius: 4px;
    /* Rough hand-drawn track edge */
    border-radius: 255px 15px 225px 15px/15px 225px 15px 255px;
}

.tooltip-sketch {
    position: absolute;
    pointer-events: none;
    background: #fdfdf9;
    /* Light paper */
    border: 2px solid var(--border-color);
    border-radius: 2px 15px 2px 15px/15px 2px 15px 2px;
    padding: 15px;
    z-index: 100;
    transition: opacity 0.2s;
    box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.1);
    min-width: 250px;
    opacity: 1;
}

.tooltip.hidden {
    opacity: 0;
}

.tooltip h4 {
    margin-bottom: 8px;
    font-size: 1.3rem;
    color: var(--border-color);
    border-bottom: 2px dashed #a0aec0;
    padding-bottom: 5px;
    font-family: inherit;
}

.tooltip p {
    font-size: 1.05rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

.sidebar {
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.sidebar h2 {
    font-size: 1.6rem;
    margin-bottom: 15px;
    text-align: center;
    color: var(--text-primary);
    border-bottom: 3px solid var(--border-color);
    padding-bottom: 5px;
    border-radius: 10px 50px 10px 50px;
}

.sidebar h3 {
    font-size: 1.3rem;
    color: var(--border-color);
    margin-bottom: 10px;
    margin-top: 20px;
}

.mt-4 {
    margin-top: 1.5rem;
}

.mt-2 {
    margin-top: 0.5rem;
}

.info-block p {
    font-size: 1.1rem;
    line-height: 1.5;
    color: var(--text-secondary);
    margin-bottom: 20px;
}

.legend {
    list-style: none;
    font-size: 1.05rem;
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 20px;
}

.legend li {
    display: flex;
    align-items: flex-start;
    color: var(--text-secondary);
}

.legend li strong {
    color: var(--text-primary);
    margin-right: 5px;
    white-space: nowrap;
}

.color-box {
    width: 20px;
    height: 20px;
    border-radius: 3px;
    margin-right: 10px;
    margin-top: 4px;
    flex-shrink: 0;
    /* Sketchy box border */
    border: 2px solid var(--border-color);
}

.color-box.tp {
    background: var(--color-tp);
}

.color-box.tn {
    background: var(--color-tn);
}

.color-box.fp {
    background: var(--color-fp);
}

.color-box.fn {
    background: var(--color-fn);
}

.specs-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.spec-item {
    padding: 12px;
    background-color: transparent;
    border: 2px solid transparent;
    border-left: 4px solid transparent;
    transition: all 0.3s ease;
}

.spec-item.active {
    background-color: rgba(0, 0, 0, 0.02);
    border-left-color: #e74c3c;
    border-radius: 2px 10px 2px 10px;
}

.spec-item.past {
    opacity: 0.6;
}

.spec-title {
    font-weight: 700;
    margin-bottom: 4px;
    font-size: 1.2rem;
    color: var(--text-primary);
}

.spec-desc {
    font-size: 1.0rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

/* Custom Sketch Scrollbars */
::-webkit-scrollbar {
    width: 14px;
}
::-webkit-scrollbar-track {
    background: transparent;
    border-left: 2px solid var(--border-color);
}
::-webkit-scrollbar-thumb {
    background-color: var(--border-color);
    border-radius: 10px;
    border: 4px solid var(--panel-bg);
}