body {
    font-family: Arial, sans-serif;
    background-color: #f4f4f4;
    margin: 0;
    padding: 0;
}

.container {
    width: 80%;
    margin: 0 auto;
    padding: 20px;
    background-color: #fff;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}

.results {
    width: 80%;
    margin: 20px auto 0;
    padding: 20px;
    display: block;
}

h1 {
    text-align: center;
    color: #333;
}

p {
    font-size: 1.2em;
    color: #666;
}

#easy-bank, #medium-bank, #hard-bank, #random-problem, #run-tests, #sample-answer {
    display: block;
    margin: 10px 0;
    padding: 10px;
    font-size: 1em;
}

#problem-bank-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

#info {
    margin: 20px 0;
    padding: 10px;
    border: 1px solid #ddd;
    background-color: #fafafa;
}

/* === Input row: regex left, debugger right === */
#input-row {
    display: none; /* hidden until problem loaded */
    gap: 15px;
    margin-top: 15px;
}

#input-col {
    flex: 1;
    min-width: 0;
}

#button-row {
    display: flex;
    gap: 8px;
    margin-top: 8px;
    flex-wrap: wrap;
}

#button-row button {
    padding: 8px 14px;
    font-size: 0.95em;
}

/* === Regex input with highlight backdrop === */
#input-wrapper {
    position: relative;
    flex: 1;
    min-width: 0;
}

#input-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
    padding: 10px;
    border: 1px solid transparent;
    border-radius: 4px;
    box-sizing: border-box;
    font-family: Consolas, monospace;
    font-size: 1em;
    line-height: 1.4;
    white-space: pre-wrap;
    word-wrap: break-word;
    color: transparent;
}

#input {
    position: relative;
    display: block;
    font-family: Consolas, monospace;
    font-size: 1em;
    padding: 10px;
    line-height: 1.4;
    white-space: pre-wrap;
    word-wrap: break-word;
    border: 1px solid #ddd;
    border-radius: 4px;
    box-sizing: border-box;
    width: 100%;
    margin: 0;
    background: transparent;
    color: #333;
    resize: none;
    min-height: 38px;
    z-index: 1;
    caret-color: #333;
    overflow: hidden;
}

/* === Highlight colors === */
.hl-depth0 { background: rgba(66, 133, 244, 0.25); border-radius: 2px; }
.hl-depth1 { background: rgba(234, 67, 53, 0.25); border-radius: 2px; }
.hl-depth2 { background: rgba(52, 168, 83, 0.25); border-radius: 2px; }
.hl-depth3 { background: rgba(251, 188, 4, 0.30); border-radius: 2px; }
.hl-depth4 { background: rgba(171, 71, 188, 0.25); border-radius: 2px; }
.hl-depth5 { background: rgba(255, 112, 67, 0.25); border-radius: 2px; }
.hl-charclass { background: rgba(0, 188, 212, 0.25); border-radius: 2px; }
.hl-quantifier { background: rgba(158, 158, 158, 0.30); border-radius: 2px; }
.hl-escape { background: rgba(121, 85, 72, 0.22); border-radius: 2px; }
.hl-lookaround { background: rgba(233, 30, 99, 0.22); border-radius: 2px; }

/* === Debugger panel === */
#debugger {
    flex: 1;
    min-width: 0;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 12px;
    background: #fafafa;
}

#debug-input {
    width: 100%;
    box-sizing: border-box;
    font-family: Consolas, monospace;
    font-size: 1em;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
}

#debug-controls {
    display: flex;
    gap: 6px;
    margin-top: 8px;
}

#debug-controls button {
    padding: 5px 12px;
    font-size: 0.9em;
}

#debug-display {
    margin-top: 10px;
    font-family: Consolas, monospace;
    font-size: 1em;
    line-height: 1.8;
    min-height: 30px;
    white-space: pre-wrap;
    word-break: break-all;
}

#debug-display .dbg-consumed { color: #333; }
#debug-display .dbg-cursor { background: #ffeb3b; border-bottom: 2px solid #f44336; padding: 1px 0; }
#debug-display .dbg-remaining { color: #999; }
.dbg-match { color: #2e7d32; font-weight: bold; }
.dbg-fail { color: #c62828; font-weight: bold; }

#debug-regex-display {
    margin-top: 8px;
    font-family: Consolas, monospace;
    font-size: 1em;
    line-height: 1.8;
    min-height: 24px;
    white-space: pre-wrap;
    word-break: break-all;
    color: #666;
}

.dbg-regex-active {
    background: rgba(76, 175, 80, 0.35);
    border-radius: 2px;
    color: #1b5e20;
    font-weight: bold;
}

#debug-status {
    margin-top: 8px;
    font-size: 0.95em;
    min-height: 20px;
}

/* === Example reveal buttons === */
#examples-valid-buttons, #examples-invalid-buttons {
    margin-bottom: 10px;
}

#examples-valid-buttons button, #examples-invalid-buttons button {
    padding: 5px 12px;
    font-size: 0.85em;
    margin-right: 5px;
}

/* === Sample answer popup === */
#sample-answer-popup {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 8px;
    z-index: 10;
    background: #fff;
    border: 1px solid #ccc;
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    min-width: 320px;
    width: min(70vw, 760px);
    max-width: 760px;
}

#sample-answer-popup::before {
    content: '';
    position: absolute;
    top: -8px;
    left: 20px;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-bottom: 8px solid #ccc;
}

#sample-answer-popup::after {
    content: '';
    position: absolute;
    top: -7px;
    left: 21px;
    border-left: 7px solid transparent;
    border-right: 7px solid transparent;
    border-bottom: 7px solid #fff;
}

#sample-answer-popup.visible { display: block; }

.popup-content {
    padding: 10px;
}

.popup-content pre {
    margin: 0 0 8px;
    font-family: Consolas, monospace;
    font-size: 0.95em;
    white-space: pre-wrap;
    word-break: break-all;
}

#copy-answer {
    padding: 4px 12px;
    font-size: 0.85em;
}

/* === Feedback === */
#feedback {
    margin: 10px 0 1px;
    padding: 1px;
}

button {
    background-color: #007BFF;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

button:hover {
    background-color: #0056b3;
}

/* === Test output === */
#detailed-output {
    width: 100%;
    table-layout: auto;
    border-spacing: 0;
    border-collapse: collapse;
    margin: 10px 0;
}

#detailed-output th, #detailed-output td {
    border: 1px solid black;
    padding: 8px;
    font-family: Consolas, monospace;
    font-size: 14px;
    text-align: center;
    white-space: nowrap;
}

#detailed-output th {
    background-color: #007BFF;
    color: white;
    font-weight: bold;
}

#test-results {
    display: none;
}

#run-tests, #feedback {
    display: inline-block;
    vertical-align: middle;
}

/* === Collapsible cheatsheet === */
#cheatsheet summary {
    cursor: pointer;
    font-weight: bold;
    user-select: none;
}

#cheatsheet summary:hover {
    color: #007BFF;
}

#cheatsheet[open] summary {
    margin-bottom: 8px;
}
