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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: #333;
    background: #f5f7fa;
    font-size: 14px;
}

.container { max-width: 1100px; margin: 0 auto; padding: 2rem 1rem; }

header {
    margin-bottom: 2rem; background: white; padding: 1.5rem;
    border-radius: 8px; box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
header h1 { font-size: 1.8rem; margin-bottom: 0.5rem; font-weight: 500; color: #2c3e50; }
header p { font-size: 0.95rem; color: #666; }
header p a { color: #0066cc; text-decoration: none; }
header p a:hover { text-decoration: underline; }

/* Sections */
.step-section {
    background: white; padding: 1.5rem; border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1); margin-bottom: 1.5rem;
}

/* Collapsible explanation */
.explain-details { padding: 0; }
.explain-details > summary {
    cursor: pointer; font-size: 1rem; font-weight: 600; color: #2c3e50;
    list-style: none; padding: 0.25rem 0; user-select: none;
}
.explain-details > summary::-webkit-details-marker { display: none; }
.explain-details > summary::before {
    content: '▸'; display: inline-block; margin-right: 0.5rem;
    color: #888; transition: transform 0.18s ease;
}
.explain-details[open] > summary::before { transform: rotate(90deg); }
.explain-details .read-more {
    color: #3498db; font-weight: 500; font-size: 0.85rem; margin-left: 0.4rem;
}
.explain-details[open] .read-more { display: none; }
.explain-details .explanation-box { margin-top: 0.75rem; margin-bottom: 0; }
.step-section h2 {
    font-size: 1.2rem; font-weight: 500; margin-bottom: 1rem; color: #2c3e50;
    display: flex; align-items: center; gap: 0.5rem;
}
.step-badge {
    background: #3498db; color: white; padding: 0.2rem 0.6rem;
    border-radius: 4px; font-size: 0.8rem;
}

.explanation-box {
    background: #f0f4f8; border-left: 4px solid #3498db; color: #2c3e50;
    padding: 1rem; border-radius: 4px; margin-bottom: 1rem;
}
.explanation-box h4 { font-size: 0.95rem; margin-bottom: 0.5rem; color: #2c3e50; }
.explanation-box p { font-size: 0.9rem; color: #444; }

.info-box {
    background: #eaf2f8; border-left: 4px solid #2980b9; color: #2c3e50;
    padding: 1rem; border-radius: 4px;
}
.info-box h4 { font-size: 1rem; margin-bottom: 0.5rem; color: #2980b9; }
.info-box p { font-size: 0.9rem; color: #444; }

/* Tab switcher */
.tab-switcher {
    display: flex; gap: 0.5rem; margin-bottom: 1rem; border-bottom: 2px solid #e0e0e0;
}
.tab-btn {
    padding: 0.5rem 1.1rem; font-size: 0.9rem; border: none; background: transparent;
    color: #777; cursor: pointer; border-bottom: 3px solid transparent;
    margin-bottom: -2px; transition: all 0.2s ease;
}
.tab-btn:hover { color: #3498db; }
.tab-btn.active {
    color: #3498db; border-bottom-color: #3498db; font-weight: 600;
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* Encoding selector */
.encoding-selector {
    display: flex; align-items: center; gap: 0.6rem; margin-bottom: 1rem;
}
.encoding-selector label { font-weight: 600; color: #2c3e50; font-size: 0.9rem; }
.encoding-selector select {
    padding: 0.4rem 0.7rem; font-size: 0.9rem; border: 1px solid #ccc;
    border-radius: 4px; color: #333; background: #fff; cursor: pointer;
}
.encoding-selector select:focus { outline: none; border-color: #3498db; }

/* Inputs */
.field-label {
    display: block; font-size: 0.85rem; color: #555; margin-bottom: 0.3rem;
    font-weight: 600;
}
textarea {
    width: 100%; padding: 0.6rem; font-size: 0.95rem;
    font-family: 'Courier New', monospace; border: 1px solid #ccc;
    border-radius: 4px; resize: vertical; margin-bottom: 1rem;
}
textarea:focus {
    outline: none; border-color: #3498db;
    box-shadow: 0 0 3px rgba(52,152,219,0.3);
}

/* Output tables — keep all columns (including binary); swipe sideways on small screens */
.output-wrapper {
    overflow-x: auto; border: 1px solid #e0e0e0; border-radius: 6px;
    max-height: 420px; overflow-y: auto; margin-bottom: 1rem;
    -webkit-overflow-scrolling: touch;
}
table.encode-table, table.decode-table {
    width: max-content; min-width: 100%; border-collapse: collapse; font-size: 0.85rem;
}
table.encode-table th, table.encode-table td,
table.decode-table th, table.decode-table td {
    padding: 0.5rem 0.7rem; text-align: left;
    border-bottom: 1px solid #eee;
}
table.encode-table thead th, table.decode-table thead th {
    background: #eaf0f6; color: #2c3e50; font-weight: 600;
    position: sticky; top: 0; z-index: 1;
}
.char-cell {
    font-size: 1.1rem; text-align: center; font-family: 'Courier New', monospace;
}
.cp-cell { font-family: 'Courier New', monospace; color: #2980b9; }
.hex-cell {
    font-family: 'Courier New', monospace; color: #2c3e50; font-weight: 600;
    letter-spacing: 0.05em; white-space: nowrap;
}
.bin-cell {
    font-family: 'Courier New', monospace; font-size: 0.78rem; color: #666;
    white-space: nowrap;
}
.note-cell { font-size: 0.82rem; color: #777; }
tr.error-row { background: #fadbd8; }
tr.error-row .note-cell { color: #c0392b; font-weight: 600; }
td.empty {
    text-align: center; color: #999; padding: 1.5rem; font-style: italic;
}

/* Summary */
.summary-line {
    font-size: 0.9rem; color: #555; padding: 0.5rem 0;
}
.summary-line strong { color: #2c3e50; }
.err-count { color: #c0392b; font-weight: 600; }

/* Decode output */
.decode-output { margin-bottom: 1rem; }
.decode-error {
    background: #fadbd8; border-left: 4px solid #e74c3c; color: #922b21;
    padding: 0.6rem 0.9rem; border-radius: 4px; font-size: 0.85rem;
    margin-bottom: 0.75rem;
}
.decoded-string {
    background: #f0f4f8; padding: 0.75rem 1rem; border-radius: 4px;
    font-size: 0.95rem; color: #2c3e50;
}
.decoded-string code.decoded-result {
    font-family: 'Courier New', monospace; font-size: 1.1rem;
    background: white; padding: 0.2rem 0.5rem; border-radius: 3px;
    border: 1px solid #ddd; color: #1e8449;
}
.empty-text { color: #999; font-style: italic; font-size: 0.9rem; }

footer {
    text-align: center; margin-top: 2rem; padding: 1.5rem;
    background: white; border-radius: 8px; box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
footer a { color: #3498db; text-decoration: none; }
footer a:hover { text-decoration: underline; }

@media (max-width: 768px) {
    .container { padding: 1rem; }
}
