/* kakama.tech. Light and dark themes: the theme is the attribute data-theme of <html> (set by js/theme.js). */
:root {
    color-scheme: light;
    --bg: #f5f6f8;
    --fg: #1d2330;
    --muted: #5d6676;
    --accent: #3f6fb5;
    --accent-fg: #ffffff;
    --border: #d5d9e0;
    --danger: #a3261f;
    --card: #ffffff;
    --soft: #f0f2f5;
    --notice: #eef3fb;
    --notice-warn: #fbeeed;
    --mark: #ffe58a;
    --hover: #e9eef7;
    --graph-ip: #b8661a;
    --graph-asn: #1f7a54;
    --graph-ns: #7040b0;
}

:root[data-theme="dark"] {
    color-scheme: dark;
    --bg: #12161d;
    --fg: #e4e8ee;
    --muted: #9aa5b5;
    --accent: #6f9bdc;
    --accent-fg: #0d1117;
    --border: #2c3544;
    --danger: #ff8a80;
    --card: #1a202a;
    --soft: #222a37;
    --notice: #1c2a40;
    --notice-warn: #3a2224;
    --mark: #6b5a12;
    --hover: #243047;
    --graph-ip: #f0a24c;
    --graph-asn: #5fcf9c;
    --graph-ns: #b794ea;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--fg);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    line-height: 1.5;
}

a { color: var(--accent); }

/* ---- top bar: the logo on the left, the account and the logout on the right */
.topbar {
    display: flex;
    gap: .5rem;
    align-items: center;
    height: 3.75rem;
    padding: 0 1.25rem;
    background: var(--card);
    border-bottom: 1px solid var(--border);
}

.brand { display: inline-flex; align-items: center; height: 100%; }
.brand img { display: block; height: 2.4rem; width: auto; }
a.brand { text-decoration: none; }
.spacer { flex: 1; }

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.4rem;
    height: 2.4rem;
    margin: 0;
    padding: 0;
    border: 1px solid transparent;
    border-radius: 50%;
    background: none;
    color: var(--fg);
    cursor: pointer;
}
.icon-btn:hover, .icon-btn:focus-visible { background: var(--hover); border-color: var(--border); }

/* ---- the menu on the left */
.shell { display: flex; min-height: calc(100vh - 3.75rem); }

.sidebar {
    display: flex;
    flex-direction: column;
    flex: 0 0 13.5rem;
    padding: 1rem .75rem;
    background: var(--card);
    border-right: 1px solid var(--border);
}

.sidebar a {
    display: block;
    padding: .5rem .75rem;
    margin-bottom: .15rem;
    border-radius: 6px;
    color: var(--fg);
    text-decoration: none;
}
.sidebar a:hover { background: var(--hover); }
.sidebar a.active { background: var(--accent); color: var(--accent-fg); }

.sidebar-foot { margin-top: auto; padding-top: 1rem; }
.side-btn {
    display: flex;
    align-items: center;
    gap: .5rem;
    width: 100%;
    margin: 0;
    padding: .5rem .75rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: none;
    color: var(--fg);
    font: inherit;
    cursor: pointer;
}
.side-btn:hover { background: var(--hover); }
.icon-sun { display: none; }
:root[data-theme="dark"] .icon-sun { display: inline; }
:root[data-theme="dark"] .icon-moon { display: none; }

/* ---- the content: top left, the whole width. Only the login page is centered. */
.main-col { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.content { flex: 1; width: 100%; margin: 0; padding: 1.25rem 1.5rem; }
.content.centered { display: flex; align-items: flex-start; justify-content: center; }
.footer { padding: 1rem 1.5rem; color: var(--muted); font-size: .85rem; }

h1 { margin: 0 0 .75rem; font-size: 1.6rem; }
h2 { font-size: 1.2rem; }
.muted { color: var(--muted); }
.inline { display: inline; margin: 0; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; overflow-wrap: anywhere; }

.card { background: var(--card); border: 1px solid var(--border); border-radius: 6px; padding: 1.5rem; }
section.card { margin-bottom: 1rem; }
/* A narrow form stays narrow (it would look wrong stretched), but it sits on the left like the rest. The login card is centered. */
.narrow { width: 100%; max-width: 26rem; margin: 0; }

.notice { padding: .6rem .8rem; border-left: 4px solid var(--accent); background: var(--notice); }
.notice.warn { border-left-color: var(--danger); background: var(--notice-warn); }
.field-error { display: block; color: var(--danger); font-size: .9rem; }
/* The error summary is always in the page (the validation scripts expect it) but it must not be seen until it has a message: an empty
   list would show a red bullet. */
.validation-summary-valid { display: none; }
.field-error ul { margin: 0; padding-left: 1.1rem; }
.field-error:empty, .field-error ul:empty { display: none; }

label { display: block; margin-top: 1rem; font-weight: 600; }
label.check { font-weight: 400; font-size: .9rem; }
input[type=email], input[type=password], input[type=text], input[type=search], select, textarea {
    width: 100%;
    padding: .5rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--card);
    color: var(--fg);
    font: inherit;
}
input[type=checkbox] { accent-color: var(--accent); }
textarea.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .9rem; }

button { margin-top: 1rem; padding: .5rem 1rem; border: 0; border-radius: 4px; background: var(--accent); color: var(--accent-fg); font: inherit; cursor: pointer; }
button:disabled { opacity: .5; cursor: default; }
a.button, a.btn { display: inline-block; margin: 0; padding: .5rem 1rem; border: 1px solid var(--accent); border-radius: 4px; background: var(--accent); color: var(--accent-fg); font: inherit; text-decoration: none; line-height: 1.5; cursor: pointer; }
a.button:hover, a.btn:hover, button:hover:not(:disabled) { filter: brightness(1.08); }
a.btn.secondary, button.secondary { background: var(--card); color: var(--accent); border-color: var(--accent); }
a.btn.active { background: var(--fg); border-color: var(--fg); color: var(--bg); }
a.btn.small, button.small { padding: .2rem .6rem; font-size: .9rem; }
/* a row of buttons: the same space between them, whatever they are */
.actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin: .75rem 0; }
.actions form { margin: 0; display: inline-flex; }
.actions button { margin: 0; }
td form.inline button { margin: 0; padding: .2rem .6rem; }

.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); gap: 0 1rem; }
.results { list-style: none; padding: 0; }
.results li { background: var(--card); border: 1px solid var(--border); border-radius: 6px; padding: .75rem 1rem; margin-bottom: .5rem; }
.fragment { margin: .4rem 0 0; white-space: pre-wrap; overflow-wrap: anywhere; background: var(--soft); padding: .4rem .6rem; border-radius: 4px; }
mark { background: var(--mark); color: inherit; }
dl { display: grid; grid-template-columns: 10rem 1fr; gap: .25rem 1rem; margin: 0; }
dt { color: var(--muted); }
dd { margin: 0; overflow-wrap: anywhere; }

.tabs { display: flex; flex-wrap: wrap; gap: .5rem; margin: .75rem 0; }
.tabs a { display: inline-block; padding: .5rem 1rem; border: 1px solid var(--accent); border-radius: 4px; text-decoration: none; background: var(--card); color: var(--accent); line-height: 1.5; }
.tabs a:hover { background: var(--hover); }
.tabs a.active { background: var(--accent); color: var(--accent-fg); }

pre.file { background: var(--soft); padding: .75rem 1rem; border-radius: 4px; overflow: auto; max-height: 70vh; white-space: pre-wrap; overflow-wrap: anywhere; }

/* ---- tables and their control bars, above and below */
table { width: 100%; border-collapse: collapse; background: var(--card); }
th, td { text-align: left; padding: .4rem .6rem; border-bottom: 1px solid var(--border); vertical-align: top; }
tr[hidden] { display: none; }

.table-filter { margin: .5rem 0; }
.table-filter input { max-width: 28rem; }

.pager {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem 1rem;
    align-items: center;
    justify-content: space-between;
    margin: .5rem 0;
}
.pager-size { display: flex; align-items: center; gap: .5rem; }
.pager-size label { margin: 0; font-weight: 400; color: var(--muted); }
.pager-size select { width: auto; padding: .25rem .4rem; }
.pager-pages { display: flex; flex-wrap: wrap; align-items: center; gap: .25rem; }
.pager-pages button {
    min-width: 2rem;
    margin: 0;
    padding: .25rem .5rem;
    border: 1px solid var(--border);
    background: var(--card);
    color: var(--fg);
}
.pager-pages button:hover:not(:disabled) { background: var(--hover); }
.pager-pages button[aria-current="page"] { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }

@media (max-width: 760px) {
    .shell { flex-direction: column; }
    .sidebar { flex: none; flex-direction: row; flex-wrap: wrap; gap: .25rem; border-right: 0; border-bottom: 1px solid var(--border); }
    .sidebar-foot { margin: 0 0 0 auto; padding: 0; }
    .side-btn { width: auto; }
}

/* ---- introductions and help */
.lead { margin: 0 0 1rem; font-size: 1.02rem; }
.cards-title { margin: 1.5rem 0 .5rem; font-size: 1.05rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr)); gap: .75rem; }
.tile {
    display: flex;
    flex-direction: column;
    gap: .25rem;
    padding: .9rem 1rem;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--fg);
    text-decoration: none;
}
.tile:hover, .tile:focus-visible { border-color: var(--accent); background: var(--hover); }
.tile strong { color: var(--accent); }
.tile span { color: var(--muted); font-size: .92rem; }
.remember { padding-left: 1.2rem; }
.remember li { margin-bottom: .45rem; }

details.help { margin: 0 0 1rem; background: var(--card); border: 1px solid var(--border); border-radius: 6px; }
details.help > summary { padding: .6rem 1rem; cursor: pointer; font-weight: 600; color: var(--accent); }
details.help[open] > summary { border-bottom: 1px solid var(--border); }
.help-body { padding: .25rem 1rem .75rem; }
.help-body p { margin: .6rem 0; }
.help-list { grid-template-columns: 12rem 1fr; margin: .5rem 0; }
.help-list dt { color: var(--fg); font-weight: 600; }
@media (max-width: 760px) { .help-list { grid-template-columns: 1fr; } }

/* ---- forms laid out in rows: the label on the left, the box on the right, one field for each row */
.form-rows .form-row {
    display: grid;
    grid-template-columns: 16rem 1fr;
    gap: .5rem 1rem;
    align-items: center;
    margin-top: .6rem;
}
.form-row > label, .form-row > .row-name { margin: 0; font-weight: 600; }
.form-row > label.check { font-weight: 400; }

/* a short form on a single line: label, box and button, with the hint below */
.form-inline { display: flex; flex-wrap: wrap; gap: .5rem 1rem; align-items: center; }
.form-inline > label { margin: 0; white-space: nowrap; }
.form-inline > input { flex: 1 1 18rem; width: auto; min-width: 0; }
.form-inline > button { margin: 0; }

@media (max-width: 760px) { .form-rows .form-row { grid-template-columns: 1fr; } }

.form-inline + .field-error:empty { display: none; }
.card > p.muted:last-child { margin-bottom: 0; }

/* rows of a form: the label on the left, the box on the right */
.form-rows .form-row .hint { grid-column: 2; margin: 0; color: var(--muted); font-size: .9rem; }
.form-rows .form-row.options { align-items: start; }
.form-rows .form-row .options-list { display: flex; flex-wrap: wrap; gap: .25rem 1.25rem; }
.form-rows .form-row .options-list label { margin: 0; font-weight: 400; display: inline-flex; align-items: center; gap: .35rem; }
.form-rows .form-row textarea { min-height: 18rem; }
.form-rows > .actions, .form-rows > button { margin-left: 0; }
.split { display: grid; grid-template-columns: repeat(auto-fit, minmax(22rem, 1fr)); gap: 1rem; }
.split > * { min-width: 0; }
@media (max-width: 760px) { .form-rows .form-row .hint { grid-column: 1; } }

/* boxes one after the other are never glued together */
form.card, .split > .card { margin-bottom: 1rem; }
.split > form.card, .split > section.card { margin-bottom: 0; }
.tabs + .lead, .tabs + p { margin-top: 1rem; }


/* ---- the login page: the form on the left, what the console offers on the right (one column on a small screen) */
.welcome { display: grid; grid-template-columns: 26rem minmax(0, 1fr); gap: 2rem; width: 100%; align-items: start; }
/* the announcement on top of the login page: it spans both columns */
.launch-banner { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem 1.5rem; padding: .9rem 1.25rem; border: 1px solid var(--accent); border-left-width: 6px; border-radius: 6px; background: var(--notice); }
.launch-text { display: grid; gap: .2rem; flex: 1 1 20rem; }
.launch-text strong { font-size: 1.1rem; }
.launch-banner .btn { flex: 0 0 auto; font-weight: 600; }
.welcome-side { position: sticky; top: 1rem; display: grid; gap: 1rem; }
.welcome-info > h1:first-child { margin-top: 0; }
.facts { padding-left: 1.2rem; }
.facts li { margin-bottom: .35rem; }
pre.code { margin: .5rem 0; padding: .75rem 1rem; overflow-x: auto; background: var(--card); border: 1px solid var(--border); border-radius: 6px; }
@media (max-width: 60rem) {
    .welcome { grid-template-columns: minmax(0, 1fr); }
    .welcome-side { position: static; max-width: 26rem; }
}

/* ---- the error page: friendly, centered, with the way back */
.error-page { width: 100%; max-width: 38rem; margin: 2rem auto; text-align: center; }
.error-code { margin: 0; font-size: 4.5rem; font-weight: 700; line-height: 1; color: var(--accent); }
.error-tips { margin: 1.5rem 0; text-align: left; }
.error-tips h2 { margin-top: 0; }
.error-ref { margin-top: 1.5rem; font-size: .85rem; }

/* ---- the contact form. The trap for robots is out of the screen (not display:none: some robots skip those). */
.contact { width: 100%; }
.trap { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }

/* ---- the graph of the results of the search. Colours come from the theme, so it follows the light and the dark mode. */
.graph-panel { margin: 1rem 0; }
.graph-tools { margin-top: 0; }
.graph-tools .check { margin: 0 0 0 .5rem; }
.graph-layout { display: grid; grid-template-columns: minmax(0, 1fr) 17rem; gap: 1rem; align-items: start; }
.graph-canvas { background: var(--soft); border: 1px solid var(--border); border-radius: 6px; min-height: 22rem; overflow: hidden; }
.graph-svg { display: block; width: 100%; height: auto; max-height: 70vh; touch-action: none; cursor: grab; user-select: none; }
.graph-svg:active { cursor: grabbing; }
.graph-svg .edge { stroke: var(--muted); stroke-opacity: .55; stroke-width: 1; }
.graph-svg .node { cursor: pointer; }
.graph-svg .node circle { stroke: var(--card); stroke-width: 1.5; }
.graph-svg .node text { fill: var(--fg); paint-order: stroke; stroke: var(--soft); stroke-width: 3px; stroke-linejoin: round; pointer-events: none; }
.graph-svg .node:focus { outline: none; }
.graph-svg .node:focus circle, .graph-svg .node.selected circle { stroke: var(--fg); stroke-width: 3; }
.graph-svg .node-host circle, .dot-host { fill: var(--accent); background: var(--accent); }
.graph-svg .node-kind circle, .graph-svg .node-status circle, .dot-kind { fill: var(--muted); background: var(--muted); }
.graph-svg .node-ip circle, .dot-ip { fill: var(--graph-ip); background: var(--graph-ip); }
.graph-svg .node-asn circle, .dot-asn { fill: var(--graph-asn); background: var(--graph-asn); }
.graph-svg .node-ns circle, .dot-ns { fill: var(--graph-ns); background: var(--graph-ns); }
.graph-svg .node-tag circle, .dot-tag { fill: var(--danger); background: var(--danger); }
.graph-legend { display: flex; flex-wrap: wrap; gap: .25rem .75rem; margin-bottom: .75rem; font-size: .85rem; color: var(--muted); }
.graph-legend .dot { display: inline-block; width: .7rem; height: .7rem; border-radius: 50%; margin-right: .3rem; vertical-align: baseline; }
.graph-details { overflow-wrap: anywhere; }
.graph-details h3 { margin: 0 0 .25rem; }
.graph-details .wrap { overflow-wrap: anywhere; }
.graph-hosts { list-style: none; padding: 0; margin: 0 0 .5rem; }
.graph-hosts li { margin: 0; padding: .1rem 0; }
.link-button { background: none; border: 0; padding: 0; color: var(--accent); text-decoration: underline; cursor: pointer; font: inherit; }
.graph-switch { margin-bottom: .5rem; }
.graph-switch button[aria-pressed="true"] { background: var(--accent); color: var(--accent-fg); }
[hidden] { display: none !important; }
@media (max-width: 800px) { .graph-layout { grid-template-columns: 1fr; } }
