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

:root {
    --bg:        #0f0f1a;
    --surface:   #1a1a2e;
    --border:    #2a2a4a;
    --accent:    #7b8cde;
    --accent-h:  #9aaae8;
    --danger:    #e94560;
    --success:   #3ddc97;
    --text:      #e0e0e0;
    --muted:     #aaa;
    --radius:    6px;
    --radius-lg: 10px;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: 'Segoe UI', sans-serif;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    font-size: 15px;
    line-height: 1.6;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-h); }

/* ── Header ── */
header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0 2rem;
}
.header-inner {
    max-width: 1000px;
    margin: 0 auto;
    height: 58px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.logo { color: var(--text); font-size: 1.1rem; font-weight: 700; }
.logo:hover { color: var(--accent-h); }
nav { display: flex; gap: 1.25rem; }
nav a { color: var(--muted); font-size: .9rem; }
nav a:hover { color: var(--text); }

/* ── Main ── */
main {
    flex: 1;
    max-width: 1000px;
    width: 100%;
    margin: 0 auto;
    padding: 2rem 1.5rem;
}

/* ── Footer ── */
footer {
    background: var(--surface);
    border-top: 1px solid var(--border);
    text-align: center;
    padding: 1rem;
    color: var(--muted);
    font-size: .85rem;
}

/* ── Page header ── */
.page-header { margin-bottom: 1.75rem; }
.page-header h1 { font-size: 1.75rem; margin-bottom: .3rem; }

/* ── Section labels ── */
.section-label {
    font-size: .7rem;
    text-transform: uppercase;
    letter-spacing: .1em;
    color: var(--muted);
    margin: 2rem 0 .75rem;
}
.section-label:first-of-type { margin-top: 0; }

/* ── Tool grid (homepage) ── */
.tool-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 1rem;
    margin-bottom: .5rem;
}
.tool-card {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.1rem 1.25rem;
    text-decoration: none;
    color: inherit;
    transition: border-color .15s, transform .15s;
}
.tool-card:hover { border-color: var(--accent); transform: translateY(-2px); color: inherit; }
.tool-icon { font-size: 1.4rem; flex-shrink: 0; line-height: 1; margin-top: .1rem; }
.tool-name { font-weight: 600; color: var(--text); margin-bottom: .2rem; }
.tool-desc { font-size: .82rem; color: var(--muted); line-height: 1.5; }

/* ── Card ── */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.75rem;
}

/* ── Form ── */
.form-group { margin-bottom: 1.1rem; }
.form-group label { display: block; color: var(--muted); font-size: .85rem; margin-bottom: .35rem; }
.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-family: inherit;
    font-size: .95rem;
    padding: .55rem .75rem;
    outline: none;
    transition: border-color .15s;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus { border-color: var(--accent); }
.form-group select option { background: var(--surface); }
.form-group textarea { resize: vertical; min-height: 110px; }
.form-heading { font-size: 1rem; font-weight: 400; color: var(--muted); margin-bottom: 1.25rem; }
.form-row { display: flex; gap: 1rem; flex-wrap: wrap; }
.form-row .form-group { flex: 1; min-width: 160px; }

/* ── Buttons ── */
.btn {
    display: inline-block;
    padding: .5rem 1.1rem;
    border-radius: var(--radius);
    border: none;
    font-size: .9rem;
    font-family: inherit;
    cursor: pointer;
    text-decoration: none;
    transition: background .15s, border-color .15s;
    white-space: nowrap;
}
.btn-primary { background: var(--accent); color: var(--bg); font-weight: 600; }
.btn-primary:hover { background: var(--accent-h); color: var(--bg); }
.btn-secondary {
    background: transparent;
    color: var(--accent);
    border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--surface); border-color: var(--accent); color: var(--accent-h); }
.btn-sm {
    padding: .3rem .7rem;
    font-size: .82rem;
    background: transparent;
    color: var(--accent);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    font-family: inherit;
    transition: background .15s;
}
.btn-sm:hover { background: var(--border); }
.btn-danger-sm {
    padding: .3rem .7rem;
    font-size: .82rem;
    background: rgba(233,69,96,.1);
    color: var(--danger);
    border: 1px solid rgba(233,69,96,.3);
    border-radius: var(--radius);
    cursor: pointer;
    font-family: inherit;
    transition: background .15s;
}
.btn-danger-sm:hover { background: rgba(233,69,96,.2); }

/* ── Messages ── */
.error-msg {
    background: rgba(233,69,96,.1);
    border: 1px solid var(--danger);
    color: var(--danger);
    border-radius: var(--radius);
    padding: .7rem 1rem;
    font-size: .9rem;
}
.success-msg {
    background: rgba(61,220,151,.1);
    border: 1px solid var(--success);
    color: var(--success);
    border-radius: var(--radius);
    padding: .7rem 1rem;
    font-size: .9rem;
}
.empty-msg { color: var(--muted); padding: 1rem 0; }
.muted { color: var(--muted); }

/* ── Result box ── */
.result-box {
    background: var(--bg);
    border: 1px solid var(--accent);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    font-size: 1rem;
    color: var(--text);
    line-height: 1.6;
}

/* ── Two-column tool layout ── */
.two-col { display: flex; gap: 1rem; }
.col { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.col-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: .4rem;
    color: var(--muted);
    font-size: .85rem;
}
.col textarea {
    flex: 1;
    min-height: 260px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-family: 'Courier New', monospace;
    font-size: .85rem;
    padding: .75rem;
    resize: vertical;
    outline: none;
    transition: border-color .15s;
    width: 100%;
}
.col textarea:focus { border-color: var(--accent); }

/* ── Diff output ── */
.diff-legend { display: flex; gap: .75rem; margin-bottom: .75rem; font-size: .8rem; }
.diff-add-pill { background: rgba(61,220,151,.15); color: var(--success); border-radius: 4px; padding: .15rem .5rem; }
.diff-del-pill { background: rgba(233,69,96,.15); color: var(--danger); border-radius: 4px; padding: .15rem .5rem; }
.diff-eq-pill { background: var(--border); color: var(--muted); border-radius: 4px; padding: .15rem .5rem; }
.diff-output {
    font-family: 'Courier New', monospace;
    font-size: .85rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow-x: auto;
}
.diff-line { padding: .2rem .75rem; display: flex; gap: .75rem; line-height: 1.6; }
.diff-add { background: rgba(61,220,151,.08); }
.diff-del { background: rgba(233,69,96,.08); }
.diff-eq { color: var(--muted); }
.diff-sign { flex-shrink: 0; width: .75rem; }

/* ── Tabs ── */
.tab-bar { display: flex; gap: .4rem; flex-wrap: wrap; }
.tab {
    padding: .4rem .9rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: transparent;
    color: var(--muted);
    font-size: .85rem;
    cursor: pointer;
    font-family: inherit;
    text-decoration: none;
    transition: background .15s, color .15s;
}
.tab:hover { color: var(--text); background: var(--border); }
.tab.active { background: var(--accent); color: var(--bg); border-color: var(--accent); font-weight: 600; }

/* ── Converter ── */
.converter-body { margin-top: 1.25rem; }

/* ── Colour palette ── */
.palette-group { margin-bottom: 1.5rem; }
.palette-name { font-size: .75rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-bottom: .5rem; }
.swatch-row { display: flex; gap: .5rem; flex-wrap: wrap; }
.swatch {
    width: 110px;
    height: 80px;
    border-radius: var(--radius);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    padding: .4rem;
    cursor: pointer;
    border: 1px solid rgba(255,255,255,.05);
    transition: transform .15s;
}
.swatch:hover { transform: scale(1.05); }
.swatch-hex { font-size: .75rem; font-family: monospace; font-weight: 600; }
.swatch-label { font-size: .65rem; opacity: .7; }

/* ── Search row ── */
.search-row { display: flex; gap: .5rem; }
.search-row input {
    flex: 1;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: .9rem;
    padding: .5rem .8rem;
    outline: none;
    transition: border-color .15s;
}
.search-row input:focus { border-color: var(--accent); }

/* ── Reference tables ── */
.ref-section { margin-bottom: 2rem; }
.ref-group-title {
    font-size: .75rem;
    text-transform: uppercase;
    letter-spacing: .08em;
    margin-bottom: .6rem;
    padding: .3rem .6rem;
    border-radius: var(--radius);
    display: inline-block;
}
.c1 { background: rgba(123,140,222,.15); color: #9aaae8; }
.c2 { background: rgba(61,220,151,.15); color: #3ddc97; }
.c3 { background: rgba(250,196,62,.15); color: #fac43e; }
.c4 { background: rgba(233,69,96,.15); color: #e94560; }
.c5 { background: rgba(233,69,96,.25); color: #ff6b6b; }

.ref-table { border-collapse: collapse; width: auto; }
.ref-table-full { width: 100%; }
.ref-table th, .ref-table td {
    text-align: left;
    padding: .55rem .75rem;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}
.ref-table th { font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.ref-table tbody tr:last-child td { border-bottom: none; }
.ref-table tbody tr:hover td { background: rgba(255,255,255,.02); }

.code-badge {
    background: var(--border);
    color: var(--accent);
    font-family: monospace;
    font-size: .85rem;
    padding: .15rem .45rem;
    border-radius: 4px;
    font-weight: 600;
}
.proto-badge {
    background: rgba(123,140,222,.12);
    color: var(--accent);
    font-size: .75rem;
    padding: .15rem .5rem;
    border-radius: 4px;
}
.kbd {
    background: var(--border);
    color: var(--text);
    font-family: monospace;
    font-size: .85rem;
    padding: .15rem .5rem;
    border-radius: 4px;
    border-bottom: 2px solid rgba(0,0,0,.4);
}

/* ── ASCII output ── */
.ascii-output {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    font-family: 'Courier New', monospace;
    font-size: .82rem;
    line-height: 1.3;
    overflow-x: auto;
    white-space: pre;
    color: var(--accent);
}

/* ── Cron examples ── */
.cron-examples { margin-top: 1.75rem; }
.cron-examples-title { font-size: .75rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-bottom: .6rem; }
.cron-examples .ref-table td:first-child code { font-family: monospace; color: var(--accent); }

/* ── TIL entries ── */
.til-list { display: flex; flex-direction: column; gap: 1rem; }
.til-entry {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.25rem 1.5rem;
}
.til-meta { font-size: .75rem; color: var(--muted); margin-bottom: .35rem; }
.til-title { font-size: 1.05rem; margin-bottom: .5rem; }
.til-content { color: var(--muted); line-height: 1.7; }

/* ── Q&A ── */
.qa-list { display: flex; flex-direction: column; gap: 1rem; }
.qa-item {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.25rem 1.5rem;
}
.qa-question { font-weight: 600; margin-bottom: .6rem; }
.qa-answer { color: var(--muted); padding-left: 1rem; border-left: 3px solid var(--accent); line-height: 1.6; }
.qa-meta { font-size: .75rem; color: var(--muted); margin-top: .5rem; }

/* ── Admin list ── */
.admin-list { display: flex; flex-direction: column; }
.admin-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: .9rem 0;
    border-bottom: 1px solid var(--border);
}
.admin-row:last-child { border-bottom: none; }

/* ── Admin login ── */
.admin-login {
    max-width: 340px;
    margin: 6rem auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 2rem;
    text-align: center;
}
.admin-login h1 { margin-bottom: 1.5rem; }
.admin-login .form-group input { margin-bottom: .75rem; }

/* ── IP info ── */
.ip-label { width: 180px; color: var(--muted); font-size: .85rem; }

/* ── QR code ── */
.qr-result { margin-top: 1.5rem; display: flex; flex-direction: column; align-items: center; }
.qr-img { border: 6px solid white; border-radius: var(--radius); max-width: 260px; }

/* ── SQL cheat sheet ── */
.sql-code {
    font-family: 'Courier New', monospace;
    font-size: .82rem;
    color: var(--accent-h);
    white-space: pre-wrap;
    word-break: break-word;
}

/* ── Big-O ── */
.bigo-legend { display: flex; gap: .6rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.bigo-pill { font-size: .78rem; padding: .2rem .6rem; border-radius: 4px; }
.bigo-good { background: rgba(61,220,151,.15); color: #3ddc97; }
.bigo-ok   { background: rgba(250,196,62,.15);  color: #fac43e; }
.bigo-bad  { background: rgba(233,69,96,.15);   color: #e94560; }

.bigo-table td { font-family: monospace; font-size: .85rem; }
.bigo-table td:first-child, .bigo-table td:last-child { font-family: inherit; }
.bigo-c-good { color: #3ddc97; font-weight: 600; }
.bigo-c-ok   { color: #fac43e; }
.bigo-c-bad  { color: #e94560; font-weight: 600; }

/* ── Responsive ── */
@media (max-width: 680px) {
    header { padding: 0 1rem; }
    main { padding: 1.25rem 1rem; }
    .two-col { flex-direction: column; }
    .tool-grid { grid-template-columns: 1fr; }
    .swatch { width: 80px; height: 60px; }
}
