:root {
    --bg-color: #f8fafc;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --accent-color: #3b82f6;
    --accent-hover: #2563eb;
    --danger-color: #ef4444;
    --border-color: #e2e8f0;
    --card-bg: #ffffff;
    --key-default: #e2e8f0;
    --key-stroke: #94a3b8;
    --key-selected: #fca5a5;
    /* Red-ish for error */
    --key-selected-stroke: #dc2626;
}

.hidden {
    display: none !important;
}

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

body {
    font-family: sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.5;
    padding: 2rem;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

header {
    text-align: center;
}

.app-icon {
    width: 64px;
    height: 64px;
    margin-bottom: 1rem;
    border-radius: 12px; /* Optional: matches icon style if needed */
}

h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1.1rem;
}

main {
    background: var(--card-bg);
    border-radius: 1rem;
    box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    padding: 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

.upload-section {
    width: 100%;
    margin-bottom: 2rem;
    text-align: center;
}

.upload-label {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    border: 2px dashed var(--border-color);
    border-radius: 1rem;
    cursor: pointer;
    background-color: #f1f5f9;
    transition: all 0.2s;
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
}

.upload-label:hover {
    border-color: var(--accent-color);
    background-color: #eff6ff;
}

.upload-label .icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.upload-label input {
    display: none;
}

.input-group {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 0.5rem;
    flex-wrap: wrap;
    /* Changed from no-wrap to support smaller screens/multiple inputs if needed */
}

.repo-input {
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    font-size: 1rem;
    width: 100%;
    max-width: 400px;
    outline: none;
    transition: all 0.2s;
}

.repo-input:focus {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.status-message {
    margin-top: 1rem;
    min-height: 1.5rem;
    font-weight: 500;
}

.status-message.error {
    color: var(--danger-color);
}

.status-message.success {
    color: #059669;
}

.input-instruction code {
    background-color: #f1f5f9;
    padding: 0.2rem 0.4rem;
    border-radius: 0.25rem;
    color: var(--accent-color);
    font-family: inherit;
    font-weight: 500;
}

#debugInterface {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
}

#debugInterface {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.canvas-container {
    width: 100%;
    overflow-x: auto;
    display: flex;
    justify-content: center;
    margin-bottom: 2rem;
    cursor: crosshair;
}

/* Keyboard Canvas styling */
#keyboardCanvas {
    max-width: 100%;
}

.controls {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
}

.btn {
    padding: 10px 20px;
    border-radius: 8px;
    border: 1px solid transparent;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn svg {
    width: 18px;
    height: 18px;
    stroke: currentColor;
    stroke-width: 2.5;
    fill: none;
}

.btn-primary {
    background-color: var(--accent-color);
    color: white;
}

.btn-primary:hover {
    background-color: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.btn-secondary {
    background-color: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
}

.btn-secondary:hover {
    background-color: var(--bg-color);
    color: var(--text-primary);
}

.btn-db-template {
    background-color: #f0fdf4;
    color: #15803d;
    border-color: #86efac;
}

.btn-db-template:hover {
    background-color: #dcfce7;
    border-color: #4ade80;
}

.result-area {
    width: 100%;
    background-color: #fff1f2;
    /* Light red/pink bg */
    border: 1px solid #fecdd3;
    border-radius: 0.75rem;
    padding: 1.5rem;
}

.result-area {
    width: 100%;
    background-color: #fff1f2;
    /* Light red/pink bg */
    border: 1px solid #fecdd3;
    border-radius: 0.75rem;
    padding: 1.5rem;
}

.result-area h2 {
    color: #9f1239;
    font-size: 1.25rem;
    margin-bottom: 1rem;
}

.diagnosis-list {
    list-style: none;
    counter-reset: issue-counter;
}

.diagnosis-item {
    background: white;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    border-radius: 0.75rem;
    border: 1px solid #fce7f3;
    border-left: 8px solid var(--issue-color, var(--danger-color));
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    position: relative;
    transition: transform 0.2s, box-shadow 0.2s;
}

.diagnosis-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

.diagnosis-item::before {
    counter-increment: issue-counter;
    content: "Issue #" counter(issue-counter);
    position: absolute;
    top: -0.75rem;
    right: 1.5rem;
    background: var(--issue-color, var(--danger-color));
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 1rem;
    font-size: 0.75rem;
    font-weight: 800;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* failure type specific styling */
.diagnosis-item.type-row { border-left-color: #e11d48; background-color: #fff1f2; }
.diagnosis-item.type-col { border-left-color: #be123c; background-color: #fff1f2; }
.diagnosis-item.type-charlie { border-left-color: #9f1239; background-color: #fff1f2; }
.diagnosis-item.type-interrupt { border-left-color: #881337; background-color: #fff1f2; }
.diagnosis-item.type-single { border-left-color: #fda4af; background-color: #ffffff; }

.diagnosis-item strong {
    display: block;
    color: #881337;
    margin-bottom: 0.5rem;
    font-size: 1.1rem;
}

.cause-box {
    margin-top: 1rem;
    padding: 1rem;
    background-color: #fffafb;
    border: 1px dashed #fecdd3;
    border-radius: 0.4rem;
}

.cause-box strong {
    color: #9f1239;
    font-size: 0.95rem;
    margin-bottom: 0.25rem;
}

.diagnosis-item p {
    font-size: 1rem;
    color: #4b5563;
    line-height: 1.5;
}

footer {
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-top: 2rem;
}

/* Tooltip container */
.tooltip-container {
    position: relative;
    display: inline-block;
}

/* Tooltip text */
.tooltip-container::before {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 125%;
    left: 50%;
    transform: translateX(-50%) translateY(10px);
    width: 280px;
    padding: 10px 14px;
    border-radius: 8px;
    background: rgba(15, 23, 42, 0.95);
    color: #f8fafc;
    font-size: 13px;
    font-weight: 400;
    line-height: 1.6;
    text-align: left;
    white-space: normal;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.2), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1000;
    pointer-events: none;
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Tooltip arrow */
.tooltip-container::after {
    content: "";
    position: absolute;
    bottom: 110%;
    left: 50%;
    transform: translateX(-50%) translateY(10px);
    border-width: 6px;
    border-style: solid;
    border-color: rgba(15, 23, 42, 0.95) transparent transparent transparent;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1000;
    pointer-events: none;
}

.tooltip-container:hover::before,
.tooltip-container:hover::after {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

/* --- Guide Page Styles --- */
/* --- Guide Page Styles --- */
.guide-content {
    background: white;
    padding: 3rem;
    border-radius: 1.5rem;
    box-shadow: 0 10px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
    margin-top: 2rem;
    max-width: 860px;
    margin-left: auto;
    margin-right: auto;
    line-height: 1.7;
    color: #334155;
}

.guide-content h2 {
    color: #0f172a;
    border-bottom: 2px solid #f1f5f9;
    padding-bottom: 0.75rem;
    margin-top: 3rem;
    margin-bottom: 1.5rem;
    font-size: 1.5rem;
    font-weight: 700;
}

.guide-content section:first-child h2 {
    margin-top: 0;
}

.guide-content h3 {
    color: #0f172a;
    margin-top: 2rem;
    margin-bottom: 0.75rem;
    font-size: 1.15rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.guide-content h3::before {
    content: '';
    display: block;
    width: 6px;
    height: 6px;
    background-color: var(--accent-color);
    border-radius: 50%;
}

.step-list {
    counter-reset: step;
    list-style: none;
    padding: 0;
    margin-top: 1rem;
}

.step-list li {
    position: relative;
    padding-left: 3.5rem;
    margin-bottom: 2.5rem;
}

.step-list li:last-child {
    margin-bottom: 0;
}

.step-list li::before {
    counter-increment: step;
    content: counter(step);
    position: absolute;
    left: 0;
    top: 0;
    width: 2.2rem;
    height: 2.2rem;
    background: linear-gradient(135deg, var(--accent-color), #60a5fa);
    color: white;
    border-radius: 50%;
    text-align: center;
    line-height: 2.2rem;
    font-weight: 700;
    font-size: 1rem;
    box-shadow: 0 4px 6px -1px rgba(59, 130, 246, 0.4);
}

.step-list li strong {
    display: block;
    font-size: 1.1rem;
    color: #1e293b;
    margin-bottom: 0.5rem;
}

.back-link {
    display: inline-flex;
    align-items: center;
    color: var(--text-secondary);
    text-decoration: none;
    margin-top: 0.5rem;
    font-weight: 500;
    padding: 0.5rem 1rem;
    border-radius: 9999px;
    background-color: transparent;
    transition: all 0.2s;
    font-size: 0.9rem;
}

.back-link:hover {
    color: var(--accent-color);
    background-color: #f1f5f9;
    text-decoration: none;
}

pre {
    background: #1e293b; /* Dark theme for code */
    color: #e2e8f0;
    padding: 1.5rem;
    border-radius: 0.75rem;
    overflow-x: auto;
    border: 1px solid #0f172a;
    margin: 1rem 0;
    box-shadow: inset 0 2px 4px 0 rgb(0 0 0 / 0.2);
}

code {
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.9em;
}

.input-instruction code, p code {
    color: var(--accent-color);
    background-color: #f1f5f9;
    padding: 0.15rem 0.3rem;
    border-radius: 0.25rem;
}

.btn-sm {
    padding: 0.2rem 0.6rem;
    font-size: 0.75rem;
    background: #f8fafc;
    color: #475569;
    font-weight: 600;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    cursor: default;
    box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
}

.comparison-container {
    display: flex;
    gap: 1.5rem;
    margin-top: 2rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.comparison-item {
    flex: 1;
    min-width: 250px;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 0.75rem;
    overflow: hidden;
    box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.05);
    transition: transform 0.2s, box-shadow 0.2s;
    display: flex;
    flex-direction: column;
}

.comparison-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1);
}

.comparison-item .img-wrapper {
    width: 100%;
    /* Aspect ratio placeholder or background could go here */
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-grow: 1; /* Allow wrapper to take available space if needed, though usually fixed height or aspect ratio is better */
    height: 300px; /* Fixed height to ensure alignment */
    padding: 1rem;
}

.comparison-item img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    display: block;
    object-fit: contain;
}

.comparison-item .caption {
    padding: 1rem;
    text-align: center;
    font-weight: 700;
    color: #1e293b;
    background: #fff;
    margin-top: auto; /* Push caption to bottom */
    border-top: 1px solid #e2e8f0; /* Optional separator */
}

.comparison-item .sub-caption {
    display: block;
    margin-top: 0.25rem;
    font-size: 0.85rem;
    font-weight: 400;
    color: #64748b;
}
