:root {
    --bg: #0d1117;
    --text: #c9d1d9;
    --accent: #58a6ff;
    --card: #161b22;
    --border: #30363d;
    --tab-bg: #21262d;
}

* { box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
    background-color: var(--bg);
    color: var(--text);
    line-height: 1.6;
    margin: 0;
    padding: 0;
    scroll-behavior: smooth;
}

/* --- Header & Nav --- */
header {
    background: #010409;
    padding: 2.5rem 1rem;
    text-align: center;
    border-bottom: 1px solid var(--border);
}

header h1 { margin: 0.25rem 0; }
header p  { margin: 0.25rem 0; opacity: 0.7; }

nav {
    margin-bottom: 1rem;
    display: flex;
    justify-content: center;
    gap: 6px;
    flex-wrap: wrap;
}

nav a {
    color: var(--accent);
    text-decoration: none;
    font-weight: bold;
    padding: 4px 12px;
    border-radius: 20px;
    border: 1px solid transparent;
    transition: border-color 0.2s, background 0.2s;
    font-size: 0.85rem;
}

nav a:hover {
    border-color: var(--accent);
    background: rgba(88, 166, 255, 0.08);
}

/* --- Layout --- */
.container {
    max-width: 850px;
    margin: 2rem auto;
    padding: 0 1.5rem;
}

/* --- Search --- */
.search-box {
    width: 100%;
    padding: 14px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--card);
    color: white;
    margin-bottom: 2.5rem;
    outline: none;
    font-size: 1rem;
}
.search-box:focus { border-color: var(--accent); }

/* --- Cards --- */
.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 2rem;
    position: relative;
    transition: transform 0.2s;
}
.card:hover { transform: translateY(-2px); }

/* --- Category Grid --- */
.category-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-top: 1rem;
}

.content-card {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 1.5rem;
}

.browse-link {
    display: inline-block;
    margin-top: 15px;
    color: var(--accent);
    text-decoration: none;
    font-weight: bold;
}
.browse-link:hover { text-decoration: underline; }

/* --- Tab System --- */
.tabs {
    display: flex;
    background: var(--tab-bg);
    border-radius: 8px 8px 0 0;
    overflow: hidden;
    border: 1px solid var(--border);
    border-bottom: none;
    margin-top: 1rem;
}

.tab-btn {
    flex: 1;
    padding: 10px;
    border: none;
    background: none;
    color: var(--text);
    cursor: pointer;
    font-size: 0.75rem;
    transition: background 0.2s, color 0.2s;
    border-right: 1px solid var(--border);
}
.tab-btn:last-child { border-right: none; }
.tab-btn.active { background: var(--accent); color: white; font-weight: bold; }
.tab-btn:hover:not(.active) { background: rgba(88,166,255,0.1); }

/* --- Code Header & Copy Button --- */
.code-header {
    display: flex;
    justify-content: flex-end;
    background: var(--tab-bg);
    border-left: 1px solid var(--border);
    border-right: 1px solid var(--border);
    padding: 5px 10px;
}

.copy-btn {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--accent);
    border-radius: 4px;
    padding: 2px 8px;
    font-size: 0.7rem;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}
.copy-btn:hover { background: var(--border); color: white; }

/* --- Code Display --- */
.code-display, pre {
    background: #000;
    padding: 1.2rem;
    border-radius: 0 0 8px 8px;
    border: 1px solid var(--border);
    font-family: 'Fira Code', monospace;
    overflow-x: auto;
    margin: 0;
    white-space: pre;
    font-size: 0.9rem;
    line-height: 1.5;
    font-weight: bold;
}

/* --- Chat Page --- */
#chat-window {
    height: 450px;
    overflow-y: auto;
    background: #0d1117;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 15px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.message {
    padding: 10px 15px;
    border-radius: 8px;
    background: var(--card);
    border-left: 4px solid var(--accent);
    max-width: 85%;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(5px); }
    to   { opacity: 1; transform: translateY(0); }
}

.msg-user { color: var(--accent); font-weight: bold; display: block; font-size: 0.8rem; margin-bottom: 4px; }
.msg-time { color: #555; font-size: 0.7rem; float: right; }
.msg-text { color: var(--text); word-wrap: break-word; display: block; }

#chat-form { display: flex; gap: 10px; margin-top: 4px; }

#msg-input {
    flex-grow: 1;
    padding: 12px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: white;
    outline: none;
    font-size: 0.95rem;
}
#msg-input:focus { border-color: var(--accent); }

#cooldown-hint {
    font-size: 0.75rem;
    color: #555;
    text-align: right;
    margin-top: 6px;
    min-height: 1em;
}

/* --- Footer --- */
footer {
    text-align: center;
    padding: 3rem 0;
    opacity: 0.6;
    font-size: 0.85rem;
    border-top: 1px solid var(--border);
    margin-top: 4rem;
}