:root {
    color-scheme: dark;
    --ink: #090a0b;
    --text: #f4f4f4;
    --muted: #a8acae;
    --line: rgba(255, 255, 255, .2);
    --accent: #f4f4f4;
    --accent-strong: #fff;
    --accent-soft: rgba(255, 255, 255, .12);
    --white: #fff;
    --panel: rgba(8, 9, 10, .66);
    --surface: rgba(14, 15, 16, .97);
    --result: #111214;
    --danger: #ff9aa5;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }

body {
    margin: 0;
    min-width: 320px;
    overflow: hidden;
    background: var(--ink);
    color: var(--text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    line-height: 1.45;
}

button, input, select { font: inherit; }

.background {
    position: fixed;
    inset: 0;
    z-index: -2;
    width: 100vw;
    height: 100vh;
    height: 100svh;
    object-fit: fill;
    filter: grayscale(1) contrast(1.04);
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    background: rgba(0, 0, 0, .34);
    pointer-events: none;
}

main {
    width: 100%;
    height: 100vh;
    height: 100svh;
    padding: 70px 20px 92px;
    pointer-events: none;
}

.ip-panel {
    width: min(800px, 100%);
    margin: 0 auto;
    padding: 18px 22px 20px;
    background: var(--panel);
    border: 1px solid rgba(255, 255, 255, .28);
    border-radius: 6px;
    box-shadow: 0 18px 52px rgba(0, 0, 0, .48);
    backdrop-filter: blur(6px);
    pointer-events: auto;
}

.ip-line {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    min-width: 0;
}

h1 {
    max-width: 100%;
    margin: 0;
    overflow-wrap: anywhere;
    font-size: 54px;
    font-weight: 790;
    line-height: 1.04;
    letter-spacing: 0;
    color: var(--white);
}

.copy-value {
    border-radius: 4px;
    cursor: copy;
    outline: 0;
    transition: background-color 120ms ease, color 120ms ease, box-shadow 120ms ease;
}

.copy-value:hover,
.copy-value:focus-visible {
    background: var(--accent-soft);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.copy-value.copy-flash {
    animation: copy-blink 440ms ease;
}

@keyframes copy-blink {
    0%, 100% { background: transparent; color: inherit; }
    35% { background: var(--white); color: var(--ink); box-shadow: 0 0 0 4px rgba(255, 255, 255, .2); }
}

.facts {
    margin: 17px 0 0;
    padding-top: 14px;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    border-top: 1px solid var(--line);
}

.facts > div {
    min-width: 0;
    padding: 4px 14px 6px;
    border-left: 1px solid var(--line);
}

.facts > div:nth-child(4n + 1) { border-left: 0; }
.facts > div:nth-child(n + 5) { margin-top: 12px; }

dt {
    color: #c4c6c8;
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
}

dd {
    margin: 4px 0 0;
    overflow-wrap: anywhere;
    font-size: 13px;
    font-weight: 700;
}

.facts dd { display: inline-block; }

.tool-dock {
    position: fixed;
    left: 50%;
    bottom: 18px;
    z-index: 1000;
    min-height: 52px;
    padding: 7px;
    display: flex;
    align-items: center;
    gap: 7px;
    border: 1px solid rgba(255, 255, 255, .24);
    border-radius: 7px;
    background: rgba(5, 6, 7, .94);
    box-shadow: 0 16px 44px rgba(0, 0, 0, .48);
    backdrop-filter: blur(10px);
    transform: translateX(-50%);
}

.tool-dock button {
    height: 36px;
    padding: 0 14px;
    border: 1px solid rgba(255, 255, 255, .24);
    border-radius: 5px;
    background: rgba(255, 255, 255, .06);
    color: var(--white);
    cursor: pointer;
    font-size: 13px;
    font-weight: 750;
}

.tool-dock button:hover, .tool-dock button:focus-visible { border-color: var(--white); background: var(--white); color: var(--ink); outline: 0; }
.tool-dock [data-open-tool="subnet"] { border-color: rgba(255, 255, 255, .5); }
.window-layer {
    position: fixed;
    inset: 0;
    z-index: 100;
    pointer-events: none;
}

.lookup-window {
    position: fixed;
    width: 470px;
    height: 330px;
    min-width: 340px;
    min-height: 230px;
    max-width: calc(100vw - 16px);
    max-height: calc(100vh - 90px);
    overflow: hidden;
    resize: both;
    border: 1px solid rgba(255, 255, 255, .34);
    border-radius: 6px;
    background: var(--surface);
    box-shadow: 0 22px 60px rgba(0, 0, 0, .55);
    pointer-events: auto;
    transition: border-color 120ms ease, box-shadow 120ms ease;
}

.lookup-window.active-window {
    border-color: rgba(255, 255, 255, .82);
    box-shadow: 0 24px 68px rgba(0, 0, 0, .62), 0 0 0 2px rgba(255, 255, 255, .18);
}

.lookup-window.subnet-window { height: min(600px, calc(100vh - 90px)); }

.window-titlebar {
    height: 42px;
    padding: 0 7px 0 13px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, .18);
    background: var(--ink);
    color: var(--white);
    cursor: move;
    user-select: none;
    touch-action: none;
}

.window-titlebar strong {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    font-size: 13px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.window-actions { flex: 0 0 auto; height: 100%; display: flex; align-items: center; gap: 2px; }
.window-action {
    position: relative;
    width: 30px;
    height: 30px;
    padding: 0;
    border: 0;
    border-radius: 4px;
    background: transparent;
    color: #d8d8d8;
    cursor: pointer;
}
.window-action:hover, .window-action:focus-visible { background: rgba(255, 255, 255, .14); color: var(--white); outline: 0; }
.close-button {
    font-size: 23px;
    line-height: 1;
}
.fit-button::before,
.fit-button::after {
    content: "";
    position: absolute;
    border: 1.5px solid currentColor;
}
.fit-button::before { left: 7px; top: 8px; width: 14px; height: 11px; }
.fit-button::after { left: 11px; top: 12px; width: 6px; height: 3px; border-right: 0; border-left: 0; }
.maximize-button::before,
.maximize-button.restore-button::after {
    content: "";
    position: absolute;
    width: 10px;
    height: 9px;
    border: 1.5px solid currentColor;
}
.maximize-button::before { left: 9px; top: 9px; }
.maximize-button.restore-button::before { left: 7px; top: 11px; }
.maximize-button.restore-button::after { left: 11px; top: 7px; }

.lookup-window[data-window-state="maximized"] { resize: none; }

.snap-preview {
    position: fixed;
    z-index: 150;
    opacity: 0;
    pointer-events: none;
    border: 2px solid rgba(255, 255, 255, .72);
    border-radius: 4px;
    background: rgba(255, 255, 255, .14);
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .36), 0 8px 28px rgba(0, 0, 0, .3);
    transition: opacity 100ms ease;
}
.snap-preview.visible { opacity: 1; }

.window-form { position: relative; z-index: 2; padding: 12px; overflow: visible; border-bottom: 1px solid var(--line); background: rgba(20, 21, 22, .98); }
.window-controls { display: grid; grid-template-columns: 104px minmax(0, 1fr) 52px; min-width: 0; }
.lookup-window[data-tool-type="dns"] .window-controls { grid-template-columns: 104px minmax(0, 1fr) 72px 52px; }
.lookup-window[data-tool-type="subnet"] .window-controls {
    grid-template-columns: 104px minmax(0, 1fr) 52px;
    grid-template-rows: repeat(2, 38px);
    gap: 6px 0;
}

.window-controls > input,
.window-controls > select,
.window-controls > button[type="submit"],
.mask-picker > input {
    width: 100%;
    min-width: 0;
    height: 38px;
    border: 1px solid var(--line);
    border-right: 0;
    border-radius: 0;
}

.window-controls select,
.window-controls input { padding: 0 9px; background: rgba(255, 255, 255, .94); color: var(--ink); outline: 0; }
.window-controls select:first-child { border-radius: 5px 0 0 5px; }
.window-controls > button[type="submit"] { border-color: var(--white); border-right: 1px solid var(--white); border-radius: 0 5px 5px 0; background: var(--white); color: var(--ink); cursor: pointer; font-weight: 800; }
.window-controls > button[type="submit"]:hover, .window-controls > button[type="submit"]:focus-visible { border-color: #c9c9c9; background: #d9d9d9; }
.window-controls > input:focus,
.window-controls > select:focus,
.window-controls > button[type="submit"]:focus,
.mask-picker > input:focus { position: relative; z-index: 1; border-color: var(--white); box-shadow: inset 0 0 0 1px #777, 0 0 0 2px var(--accent-soft); outline: 0; }
.window-controls [data-record-type].hidden,
.window-controls [data-subnet-mode].hidden,
.window-controls [data-subnet-mask-picker].hidden,
.window-controls [data-subnet-hosts].hidden { display: none; }

.lookup-window[data-tool-type="subnet"] [data-lookup-type] { grid-column: 1; grid-row: 1; }
.lookup-window[data-tool-type="subnet"] [data-lookup-query] { grid-column: 2 / 4; grid-row: 1; border-right: 1px solid var(--line); border-radius: 0 5px 5px 0; }
.lookup-window[data-tool-type="subnet"] [data-subnet-mode] { grid-column: 1; grid-row: 2; }
.lookup-window[data-tool-type="subnet"] [data-subnet-mask-picker],
.lookup-window[data-tool-type="subnet"] [data-subnet-hosts] { grid-column: 2; grid-row: 2; }
.lookup-window[data-tool-type="subnet"] .window-controls > button[type="submit"] { grid-column: 3; grid-row: 2; }

.subnet-mode {
    height: 38px;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    overflow: hidden;
    border: 1px solid var(--line);
    border-right: 0;
    border-radius: 5px 0 0 5px;
    background: rgba(255, 255, 255, .08);
}
.subnet-mode button {
    min-width: 0;
    padding: 0 5px;
    border: 0;
    border-right: 1px solid var(--line);
    background: transparent;
    color: #c9cbcc;
    cursor: pointer;
    font-size: 11px;
    font-weight: 750;
}
.subnet-mode button:last-child { border-right: 0; }
.subnet-mode button[aria-pressed="true"] { background: var(--white); color: var(--ink); }
.subnet-mode button:focus-visible { outline: 2px solid var(--white); outline-offset: -2px; }

.mask-picker { position: relative; min-width: 0; height: 38px; }
.mask-picker > input { padding-right: 34px; }
.mask-picker-toggle {
    position: absolute;
    top: 1px;
    right: 1px;
    z-index: 2;
    width: 31px;
    height: 36px;
    padding: 0;
    border: 0;
    border-left: 1px solid var(--line);
    border-radius: 0;
    background: rgba(255, 255, 255, .94);
    cursor: pointer;
}
.mask-picker-toggle::before {
    content: "";
    position: absolute;
    left: 10px;
    top: 12px;
    width: 7px;
    height: 7px;
    border-right: 2px solid #444;
    border-bottom: 2px solid #444;
    transform: rotate(45deg);
}
.mask-picker-toggle:hover, .mask-picker-toggle:focus-visible { background: #ddd; outline: 0; }
.mask-options {
    position: absolute;
    top: 43px;
    right: 0;
    z-index: 8;
    width: 224px;
    min-width: 100%;
    max-width: calc(100vw - 40px);
    max-height: 218px;
    overflow: auto;
    border: 1px solid rgba(255, 255, 255, .38);
    border-radius: 5px;
    background: #171819;
    box-shadow: 0 16px 38px rgba(0, 0, 0, .52);
}
.mask-options[hidden] { display: none; }
.mask-option {
    width: 100%;
    min-height: 34px;
    padding: 6px 9px;
    display: grid;
    grid-template-columns: 38px minmax(0, 1fr);
    align-items: center;
    gap: 9px;
    border: 0;
    border-bottom: 1px solid rgba(255, 255, 255, .12);
    border-radius: 0;
    background: #171819;
    color: var(--text);
    cursor: pointer;
    text-align: left;
}
.mask-option:last-child { border-bottom: 0; }
.mask-option:hover, .mask-option.active { background: rgba(255, 255, 255, .13); }
.mask-option-prefix { color: var(--white); font-size: 12px; font-weight: 800; }
.mask-option-value { overflow: hidden; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12px; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }
.mask-option-empty { padding: 10px; color: var(--muted); font-size: 12px; }

.window-result {
    height: calc(100% - 105px);
    overflow: auto;
    padding: 13px;
    background: var(--result);
}

.result-empty, .result-error, .result-loading { margin: 0; color: var(--muted); font-size: 13px; }
.result-error { color: var(--danger); }
.result-heading { margin: 0 0 11px; font-size: 14px; }
.result-rows { margin: 0; }
.result-rows > div { padding: 8px 0; display: grid; grid-template-columns: 100px minmax(0, 1fr); gap: 12px; border-top: 1px solid rgba(255, 255, 255, .12); }
.result-rows > div:first-child { border-top: 0; }
.result-rows dt { padding-top: 2px; }
.result-rows dd { margin: 0; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12px; font-weight: 600; white-space: pre-wrap; }
.result-meta { display: block; margin-top: 3px; color: var(--muted); font-family: inherit; font-size: 10px; font-weight: 500; }
.whois-result { margin: 0; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 11px; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; }

.subnet-window .result-heading { display: none; }
.subnet-window .window-result { height: calc(100% - 149px); }
.subnet-window .result-rows { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 18px; }
.subnet-window .result-rows > div { min-width: 0; padding: 7px 0; display: block; }
.subnet-window .result-rows > div:nth-child(2) { border-top: 0; }
.subnet-window .result-rows dd { margin-top: 2px; }

.toast {
    position: fixed;
    left: 50%;
    bottom: 84px;
    z-index: 1200;
    padding: 9px 14px;
    border-radius: 5px;
    border: 1px solid rgba(255, 255, 255, .34);
    background: var(--ink);
    color: var(--white);
    font-size: 12px;
    font-weight: 700;
    opacity: 0;
    pointer-events: none;
    transform: translate(-50%, 8px);
    transition: opacity 150ms ease, transform 150ms ease;
}

.toast.visible { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 720px) {
    body { overflow: auto; }
    body::before { background: rgba(0, 0, 0, .18); }
    main { height: auto; min-height: 100svh; padding: 12px 10px 90px; }
    .ip-panel { padding: 15px 12px; background: rgba(8, 9, 10, .56); backdrop-filter: blur(4px); }
    .ip-line { flex-direction: column; gap: 10px; }
    h1 { font-size: 38px; }
    .facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .facts > div { margin-top: 10px; }
    .facts > div:nth-child(odd) { border-left: 0; }
    .facts > div:nth-child(even) { border-left: 1px solid var(--line); }
    .tool-dock { bottom: 8px; width: calc(100% - 16px); justify-content: center; }
    .tool-dock button { padding: 0 7px; font-size: 11px; }
    .window-layer { overflow: hidden; padding: 0; }
    .lookup-window { position: fixed; width: calc(100vw - 16px); min-width: 0; height: 330px; resize: none; }
    .window-titlebar { cursor: default; }
    .window-controls { grid-template-columns: 86px minmax(0, 1fr) 48px; }
    .lookup-window[data-tool-type="dns"] .window-controls { grid-template-columns: 86px minmax(0, 1fr) 62px 48px; }
    .lookup-window[data-tool-type="subnet"] .window-controls { grid-template-columns: 86px minmax(0, 1fr) 48px; }
}

@media (max-width: 360px) {
    .subnet-window .result-rows { grid-template-columns: minmax(0, 1fr); }
    .subnet-window .result-rows > div:nth-child(2) { border-top: 1px solid rgba(255, 255, 255, .12); }
}

@media (prefers-reduced-motion: reduce) {
    .toast, .lookup-window, .snap-preview { transition: none; }
}
