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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background-color: #f5f7fa;
    color: #333;
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header */
header {
    background: linear-gradient(135deg, #1a5276 0%, #2980b9 100%);
    padding: 15px 0;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo a {
    color: #fff;
    text-decoration: none;
    font-size: 1.5rem;
    font-weight: 700;
}

.nav {
    display: flex;
    gap: 25px;
}

.nav-link {
    color: rgba(255,255,255,0.9);
    text-decoration: none;
    font-size: 0.95rem;
    transition: color 0.2s;
}

.nav-link:hover {
    color: #fff;
}

/* Main content */
main {
    flex: 1;
    padding: 40px 0;
}

/* Calculator section */
.calculator-section {
    background: #fff;
    border-radius: 12px;
    padding: 35px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
    margin-bottom: 30px;
}

h1 {
    font-size: 1.8rem;
    color: #1a5276;
    margin-bottom: 10px;
}

.description {
    color: #666;
    margin-bottom: 25px;
}

/* Form */
.calc-form {
    margin-bottom: 30px;
}

.form-row {
    display: flex;
    gap: 15px;
    align-items: flex-end;
    flex-wrap: wrap;
}

.form-group {
    flex: 1;
    min-width: 200px;
}

.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
    color: #444;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: #2980b9;
    box-shadow: 0 0 0 3px rgba(41,128,185,0.15);
}

.btn-calculate {
    background: linear-gradient(135deg, #27ae60 0%, #2ecc71 100%);
    color: #fff;
    border: none;
    padding: 12px 30px;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.btn-calculate:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(39,174,96,0.3);
}

/* Results */
.results {
    border-top: 2px solid #f0f0f0;
    padding-top: 25px;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.results h2 {
    font-size: 1.3rem;
    color: #1a5276;
    margin-bottom: 20px;
}

.results-table {
    width: 100%;
    border-collapse: collapse;
}

.results-table tr {
    border-bottom: 1px solid #f0f0f0;
}

.results-table tr:last-child {
    border-bottom: none;
}

.results-table td {
    padding: 12px 10px;
}

.results-table .label {
    font-weight: 600;
    color: #555;
    width: 220px;
}

.results-table .value {
    font-family: 'Consolas', 'Monaco', monospace;
    color: #2980b9;
    font-weight: 600;
}

.results-table .binary {
    font-family: 'Consolas', 'Monaco', monospace;
    color: #888;
    font-size: 0.85rem;
}

/* Info section */
.info-section {
    background: #fff;
    border-radius: 12px;
    padding: 30px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
    margin-bottom: 30px;
}

.info-section h2 {
    font-size: 1.4rem;
    color: #1a5276;
    margin-bottom: 15px;
}

.info-section h3 {
    font-size: 1.1rem;
    color: #444;
    margin: 20px 0 10px;
}

.info-section p {
    color: #555;
    margin-bottom: 15px;
}

.info-section ul {
    list-style: none;
    padding-left: 0;
}

.info-section li {
    padding: 8px 0;
    padding-left: 25px;
    position: relative;
    color: #555;
}

.info-section li::before {
    content: "•";
    color: #2980b9;
    font-weight: bold;
    position: absolute;
    left: 5px;
}

/* FAQ section */
.faq-section {
    background: #fff;
    border-radius: 12px;
    padding: 30px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
}

.faq-section h2 {
    font-size: 1.4rem;
    color: #1a5276;
    margin-bottom: 20px;
}

.faq-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 10px;
}

.faq-link {
    color: #2980b9;
    text-decoration: none;
    padding: 10px;
    border-radius: 6px;
    transition: background 0.2s;
}

.faq-link:hover {
    background: #f0f7fc;
}

/* Footer */
footer {
    background: #2c3e50;
    color: rgba(255,255,255,0.7);
    padding: 20px 0;
    text-align: center;
    font-size: 0.9rem;
}

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

/* Chat panel - embedded in page, looks like results */
.chat-panel {
    border-top: 2px solid #f0f0f0;
    padding-top: 25px;
    margin-top: 20px;
}

.chat-messages {
    min-height: 200px;
    max-height: 400px;
    overflow-y: auto;
    padding: 15px;
    background: #fafafa;
    border-radius: 8px;
    margin-bottom: 15px;
}

.chat-message-wrapper {
    margin-bottom: 15px;
}

.chat-messages .user-msg {
    color: #1a5276;
    padding: 10px 15px;
    background: #e8f4f8;
    border-radius: 8px;
    margin-bottom: 5px;
    font-size: 0.95rem;
}

.chat-messages .assistant-msg {
    color: #333;
    padding: 12px 15px;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    white-space: pre-wrap;
    font-size: 0.95rem;
    line-height: 1.6;
    position: relative;
}

.chat-messages .error-msg {
    color: #c0392b;
    padding: 10px 15px;
    background: #fdeaea;
    border-radius: 8px;
}

.chat-messages .loading {
    color: #888;
    padding: 10px 15px;
    font-style: italic;
}

.copy-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    background: #f0f0f0;
    border: none;
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.75rem;
    color: #666;
    opacity: 0;
    transition: opacity 0.2s, background 0.2s;
}

.assistant-msg:hover .copy-btn {
    opacity: 1;
}

.copy-btn:hover {
    background: #e0e0e0;
    color: #333;
}

.copy-btn.copied {
    background: #27ae60;
    color: #fff;
}

.chat-input-area {
    display: flex;
    gap: 10px;
}

.chat-input-area textarea {
    flex: 1;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    padding: 12px 15px;
    font-size: 0.95rem;
    resize: none;
    font-family: inherit;
    transition: border-color 0.2s;
}

.chat-input-area textarea:focus {
    outline: none;
    border-color: #2980b9;
}

.chat-send-inline {
    background: linear-gradient(135deg, #2980b9 0%, #3498db 100%);
    color: #fff;
    border: none;
    padding: 12px 25px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.95rem;
    transition: transform 0.2s, box-shadow 0.2s;
}

.chat-send-inline:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(41,128,185,0.3);
}

.chat-send-inline:disabled {
    background: #bdc3c7;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Responsive */
@media (max-width: 768px) {
    header .container {
        flex-direction: column;
        gap: 15px;
    }

    .nav {
        flex-wrap: wrap;
        justify-content: center;
    }

    .form-row {
        flex-direction: column;
    }

    .form-group {
        width: 100%;
    }

    .btn-calculate {
        width: 100%;
    }

    .results-table .binary {
        display: none;
    }

    .results-table .label {
        width: auto;
    }
}
