:root {
    --bg-color: #f0f2f5;
    --text-color: #212529;
    --container-bg: #fff;
    --container-border: #ddd;
    --muted-text: #4b5563;
    --input-bg: #fff;
    --input-border: #ccc;
    --log-bg: #1e1e1e;
    --log-text: #cccccc;
    --box-bg: #f9f9f9;
    --box-border: #eee;
    --h2-border: #4285f4;
    --highlight-hit: #28a745;
    --highlight-loss: #dc3545;
}

.hidden {
    display: none !important;
}

.auth-box {
    max-width: 420px;
    margin: 50px auto;
    padding: 30px;
    background: var(--container-bg);
    border: 1px solid var(--container-border);
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.auth-box h2 {
    text-align: center;
    margin-bottom: 20px;
    border-bottom: none;
    color: var(--h2-border);
}

.session-info {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.9em;
    color: var(--text-color);
    margin-bottom: 10px;
}

.session-info button {
    width: auto;
    padding: 8px 12px;
    background: #dc3545;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
}

.session-info .pill {
    border: 1px solid var(--container-border);
    background: var(--box-bg);
    padding: 5px 10px;
    border-radius: 4px;
}

.scan-card {
    border: 1px solid var(--container-border);
    background: var(--box-bg);
    border-radius: 8px;
    padding: 10px;
    margin-bottom: 10px;
}

.scan-card .meta {
    font-size: 0.85em;
    color: var(--muted-text);
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.scan-card .title {
    font-weight: bold;
    margin-bottom: 6px;
}

.scan-card .actions {
    text-align: right;
}

.scan-card button {
    width: auto;
    padding: 6px 10px;
    background: #dc3545;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    margin-left: 5px;
}

.scan-card button.edit-scan {
    background: #0d6efd;
}

.small-note {
    font-size: 12px;
    color: var(--muted-text);
}

body.dark-mode {
    --bg-color: #121212;
    --text-color: #e0e0e0;
    --container-bg: #1e1e1e;
    --container-border: #444;
    --muted-text: #cbd5e1;
    --input-bg: #2a2a2a;
    --input-border: #555;
    --log-bg: #000000;
    --log-text: #f1f1f1;
    --box-bg: #2a2a2a;
    --box-border: #444;
    --h2-border: #4285f4;
    --highlight-hit: #4dabf7;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    margin: 0;
    padding: 10px;
    background-color: var(--bg-color);
    color: var(--text-color);
    font-size: 14px;
}

.container {
    max-width: 950px;
    margin: auto;
    padding: 20px;
    background-color: var(--container-bg);
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    border: 1px solid var(--container-border);
}

h2 {
    border-bottom: 2px solid var(--h2-border);
    padding-bottom: 10px;
    font-size: 1.6em;
    margin-top: 0;
    color: var(--h2-border);
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.dark-mode-toggle {
    display: flex;
    align-items: center;
    font-size: 0.8em;
    gap: 10px;
}

.switch {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 22px;
}

.switch input {
    display: none;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
    border-radius: 22px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked+.slider {
    background-color: #007bff;
}

input:checked+.slider:before {
    transform: translateX(18px);
}

input,
select,
button,
textarea {
    width: 100%;
    padding: 12px;
    border-radius: 6px;
    border: 1px solid var(--input-border);
    background-color: var(--input-bg);
    color: var(--text-color);
    box-sizing: border-box;
    font-size: 14px;
    margin-bottom: 0;
}

.flex-bar {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

.flex-bar>* {
    flex: 1;
}

.data-loader {
    background: var(--box-bg);
    padding: 15px;
    border-radius: 8px;
    border: 1px solid var(--box-border);
    margin-bottom: 20px;
}

.controls-grid-full {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin-bottom: 20px;
}

label {
    font-weight: bold;
    font-size: 0.85em;
    margin-bottom: 5px;
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.run-button {
    background: linear-gradient(135deg, #4285f4 0%, #0d47a1 100%);
    color: white;
    font-weight: bold;
    border: none;
    cursor: pointer;
    padding: 15px;
    font-size: 15px;
    transition: transform 0.1s, box-shadow 0.2s;
}

.run-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(66, 133, 244, 0.3);
}

.run-button:disabled {
    background: #6c757d;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.ai-help-btn {
    background: #fff;
    border: 2px solid #4285f4;
    color: #4285f4;
    font-weight: bold;
    cursor: pointer;
    padding: 10px 20px;
    margin-top: 15px;
    font-size: 13px;
    display: none;
    width: auto;
    border-radius: 30px;
    transition: all 0.3s;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.ai-help-btn:hover {
    background: #4285f4;
    color: white;
    box-shadow: 0 4px 8px rgba(66, 133, 244, 0.3);
}

pre.log {
    background-color: var(--log-bg);
    color: var(--log-text);
    padding: 15px;
    border-radius: 5px;
    font-family: 'Courier New', Courier, monospace;
    white-space: pre-wrap;
    border: 1px solid var(--container-border);
    min-height: 100px;
    font-size: 13px;
    line-height: 1.5;
}

.win-dot {
    color: var(--highlight-hit);
    font-weight: bold;
    font-size: 1.2em;
}

.loss-dot {
    color: var(--highlight-loss);
    font-weight: bold;
    font-size: 1.2em;
}

.rank-block-simple {
    padding: 4px 0;
    margin-bottom: 6px;
    border-bottom: 1px dashed var(--container-border);
}

.rank-block-simple:last-child {
    border-bottom: none;
}

#geminiResponse {
    margin-top: 15px;
    padding: 15px;
    background: #e8f5e9;
    border: 1px solid #4caf50;
    border-radius: 8px;
    display: none;
    color: #1b5e20;
}

body.dark-mode #geminiResponse {
    background: #1b5e20;
    border-color: #8bc34a;
    color: #dcedc8;
}

.gemini-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 5px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    padding-bottom: 5px;
}

@media (max-width: 768px) {

    .data-loader,
    .flex-bar {
        display: grid;
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .controls-grid-full {
        grid-template-columns: repeat(2, 1fr);
    }

    .container {
        padding: 10px;
    }
}

/* Form Groups for Login */
.form-group {
    margin-bottom: 15px;
}

/* Log Container - Replaces .log pre style for outer wrapper */
.log-container {
    background-color: var(--box-bg);
    color: var(--text-color);
    padding: 15px;
    border-radius: 8px;
    border: 1px solid var(--container-border);
    min-height: 100px;
    font-size: 14px;
    line-height: 1.5;
    margin-bottom: 20px;
}

/* Navigation Bar */
.main-nav {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    background: var(--box-bg);
    padding: 10px;
    border-radius: 8px;
    border: 1px solid var(--container-border);
}

.main-nav a {
    text-decoration: none;
    color: var(--text-color);
    padding: 8px 16px;
    border-radius: 6px;
    font-weight: bold;
    transition: background 0.2s;
}

.main-nav a:hover {
    background: rgba(0, 0, 0, 0.05);
}

.main-nav a.active {
    background: #4285f4;
    color: white;
}