:root {
    --bg-color: #ffffff;
    --text-primary: #1e1e1e;
    --text-secondary: #6965db;
    --accent: #6965db;
    --accent-strong: #E03E3E;
    --border-color: #1e1e1e;
    --font-hand: 'Patrick Hand', cursive;
    --font-ui: 'Patrick Hand', cursive;
    /* Using handwritten font for everything */
    --sketch-border: 2px solid #1e1e1e;
    --sketch-radius: 255px 15px 225px 15px / 15px 225px 15px 255px;
}

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

body {
    font-family: var(--font-hand);
    font-size: 1.1rem;
    line-height: 1.6;
    --shadow-sm: 2px 2px 0 rgba(0, 0, 0, 0.1);
}

/* Anti-flicker loading state */
.js-loading {
    opacity: 0 !important;
    pointer-events: none;
    transition: opacity 0.2s ease-in;
}

body {
    color: var(--text-primary);
    background-color: var(--bg-color);
    /* Subtle dot grid background */
    background-image: radial-gradient(#e0e0e0 1px, transparent 1px);
    background-size: 20px 20px;
    min-height: 100vh;
}

.container {
    width: min(1000px, 90vw);
    margin: 0 auto;
    padding: 0 1rem;
}

/* --- Typography --- */
h1,
h2,
h3,
h4,
h5,
h6 {
    font-weight: 400;
    /* Handwritten fonts usually have their own weight */
    color: var(--text-primary);
}

a {
    color: var(--accent);
    text-decoration: none;
    border-bottom: 2px solid transparent;
    transition: border-color 0.2s;
}

a:hover {
    border-bottom-color: var(--accent);
}

/* --- Common Components --- */
.button {
    font-family: var(--font-hand);
    font-size: 1.1rem;
    background: #e0e0e0;
    border: 2px solid #1e1e1e;
    color: #1e1e1e;
    padding: 0.5rem 1.5rem;
    border-radius: 255px 15px 225px 15px / 15px 225px 15px 255px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 2px 2px 0px #1e1e1e;
}

.button:hover {
    transform: translate(-1px, -1px);
    box-shadow: 4px 4px 0px #1e1e1e;
    background: #d4d4d4;
}

.button:active {
    transform: translate(1px, 1px);
    box-shadow: 1px 1px 0px #1e1e1e;
}

.button.secondary {
    background: transparent;
}

.button.icon-button {
    padding: 0.2rem 0.6rem;
    border-radius: 50%;
    /* More irregular circle for icon buttons */
    border-radius: 60% 40% 30% 70% / 60% 30% 70% 40%;
}

/* --- Header / Nav --- */
.site-nav {
    padding: 1.5rem 0;
    display: flex;
    justify-content: center;
}

.nav-container {
    display: flex;
    gap: 1.5rem;
    background: #fff;
    padding: 0.5rem 1rem;
    border: 2px solid #1e1e1e;
    border-radius: 255px 15px 225px 15px / 15px 225px 15px 255px;
    box-shadow: 3px 3px 0 #1e1e1e;
}

.nav-link {
    color: #1e1e1e;
    font-size: 1.2rem;
    padding: 0.2rem 0.5rem;
}

.language-switcher {
    position: absolute;
    top: 1.5rem;
    right: 2rem;
    font-size: 0.9rem;
}

.lang-button {
    background: none;
    border: none;
    font-family: var(--font-hand);
    cursor: pointer;
    text-decoration: underline;
    opacity: 0.6;
}

.lang-button.active {
    opacity: 1;
    font-weight: bold;
    text-decoration: none;
    border-bottom: 2px solid #1e1e1e;
}

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

.hero h1 {
    font-size: 3rem;
    margin-bottom: 0.5rem;
}

.hero-subtitle {
    max-width: 600px;
    margin: 0 auto 2rem;
    opacity: 0.8;
}

/* --- Panel / Cards --- */
.application-panel,
.card,
.section,
.tracker-main {
    margin-bottom: 3rem;
}

.panel-header {
    text-align: center;
    margin-bottom: 2rem;
}

.panel-title {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}

.panel-locale {
    font-size: 0.9rem;
    opacity: 0.5;
}

.app-container {
    max-width: 800px;
}

/* --- Ticker Input Area --- */
.ticker-board {
    background: #fff;
    border: 2px solid #1e1e1e;
    /* Sketchy box */
    border-radius: 2px 255px 3px 25px / 255px 5px 225px 5px;
    box-shadow: 5px 5px 0px #1e1e1e;
    padding: 2rem;
    text-align: center;
}

.ticker-header {
    margin-bottom: 1.5rem;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
}

.input-wrapper {
    position: relative;
    max-width: 300px;
    margin: 0 auto;
}

input.ticker-input-large {
    width: 100%;
    font-family: var(--font-hand);
    font-size: 1.5rem;
    text-align: center;
    padding: 0.5rem;
    border: 2px solid #1e1e1e;
    border-radius: 255px 15px 225px 15px / 15px 225px 15px 255px;
    outline: none;
    background: #f9f9f9;
}

input.ticker-input-large:focus {
    box-shadow: 2px 2px 0 #6965db;
    border-color: #6965db;
}

.ticker-history {
    margin-top: 1.5rem;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.8rem;
}

.history-tag {
    background: #fff;
    border: 1px solid #1e1e1e;
    padding: 0.3rem 0.8rem;
    border-radius: 15px 225px 15px 255px / 225px 15px 255px 15px;
    cursor: pointer;
    transition: transform 0.1s;
}

.history-tag:hover {
    transform: scale(1.05);
    background: #f0f0f0;
}

.history-tag.active {
    background: #6965db;
    color: #fff;
    border-color: #6965db;
}

.history-tag .remove-btn {
    margin-left: 0.5rem;
    opacity: 0.6;
    font-size: 0.8em;
}

.history-tag .remove-btn:hover {
    opacity: 1;
    color: #000;
}

/* --- Status & Banner --- */
.status-banner {
    margin-top: 1rem;
    padding: 0.5rem;
    text-align: center;
    min-height: 1.5em;
    font-weight: bold;
}

.status-banner[data-status="error"] {
    color: var(--accent-strong);
}

.status-banner[data-status="success"] {
    color: #2e7d32;
}

/* --- Chart Area --- */
.chart-card {
    margin-top: 2rem;
    padding: 1rem;
    background: #fff;
    border: 2px solid #1e1e1e;
    border-radius: 5px 5px 5px 5px / 5px 5px 5px 5px;
    /* straighter box for chart */
    box-shadow: 4px 4px 0px rgba(0, 0, 0, 0.1);
    position: relative;
}

.chart-placeholder {
    height: 300px;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0.5;
    border: 2px dashed #ccc;
}

/* --- Collapsible Settings --- */
.adv-settings-toggle {
    margin-top: 2rem;
    text-align: center;
    cursor: pointer;
    font-size: 0.9rem;
    text-decoration: underline;
    color: #666;
}

.settings-panel {
    display: none;
    margin-top: 1rem;
    padding: 1rem;
    border: 1px dashed #999;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.8);
}

.settings-panel.open {
    display: block;
}

.control-group {
    margin-bottom: 1rem;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
}

.control-group label {
    font-weight: bold;
}

.control-group input {
    font-family: var(--font-hand);
    padding: 0.3rem;
    border: 1px solid #1e1e1e;
    border-radius: 5px;
    width: 80px;
    text-align: center;
}

/* --- Live Results (Small Cards) --- */
.results-container {
    margin-top: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.result-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.8rem 1.2rem;
    border-bottom: 1px solid #e0e0e0;
}

.result-card.active {
    background: #f0f0ff;
    border: 1px solid #6965db;
    border-radius: 10px;
}

/* --- Footer --- */
.footer {
    text-align: center;
    padding: 3rem 0;
    opacity: 0.6;
    font-size: 0.9rem;
}

/* --- Theory Page Specifics --- */
.theory-content {
    background: #fff;
    padding: 2rem;
    border: 2px solid #1e1e1e;
    border-radius: 2px 255px 3px 25px / 255px 5px 225px 5px;
    box-shadow: 5px 5px 0px #1e1e1e;
}

.theory-content h2 {
    margin-top: 2rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid #eee;
    padding-bottom: 0.5rem;
}

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

.list li {
    list-style: square;
    margin-left: 1.5rem;
    margin-bottom: 0.5rem;
}

/* Utilities */
.hidden {
    display: none !important;
}

.danger {
    color: var(--accent-strong);
}

@media (max-width: 600px) {
    .ticker-history {
        justify-content: center;
    }

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