:root {
    color-scheme: light;
    --bg: #f4f7fb;
    --surface: rgba(255, 255, 255, .92);
    --surface-solid: #fff;
    --ink: #172033;
    --muted: #667085;
    --line: #e5eaf2;
    --accent: #635bff;
    --accent-dark: #4b43dc;
    --accent-soft: #eeecff;
    --cyan: #16b8c4;
    --success: #15803d;
    --success-bg: #ecfdf3;
    --warning: #a15c00;
    --warning-bg: #fff7e8;
    --danger: #b42318;
    --danger-bg: #fff1f0;
    --shadow: 0 20px 60px rgba(23, 32, 51, .08);
    --radius: 24px;
}

html[data-theme="dark"] {
    color-scheme: dark;
    --bg: #0b1020;
    --surface: rgba(20, 27, 45, .92);
    --surface-solid: #141b2d;
    --ink: #eef2ff;
    --muted: #a5afc1;
    --line: #2b354b;
    --accent: #817aff;
    --accent-dark: #6e66f2;
    --accent-soft: #29264c;
    --cyan: #35c9d4;
    --success: #72d995;
    --success-bg: #122b22;
    --warning: #f1bd68;
    --warning-bg: #302413;
    --danger: #ff9189;
    --danger-bg: #321b20;
    --shadow: 0 20px 60px rgba(0, 0, 0, .28);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { scroll-behavior: smooth; }

html, body { transition: background-color .25s ease, color .25s ease; }

body {
    margin: 0;
    min-width: 320px;
    color: var(--ink);
    background:
        radial-gradient(circle at 10% 0%, rgba(99, 91, 255, .10), transparent 30rem),
        radial-gradient(circle at 90% 16%, rgba(22, 184, 196, .09), transparent 28rem),
        var(--bg);
    font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

button, input, select { font: inherit; }

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.page-shell {
    width: min(1180px, calc(100% - 40px));
    margin: 0 auto;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 82px;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 11px;
    color: var(--ink);
    font-size: 16px;
    font-weight: 600;
    letter-spacing: -.02em;
    text-decoration: none;
}

.brand-mark {
    display: grid;
    width: 38px;
    height: 38px;
    place-items: center;
    color: #fff;
    background: linear-gradient(145deg, var(--accent), #7f78ff);
    border-radius: 12px;
    box-shadow: 0 9px 24px rgba(99, 91, 255, .26);
}

.brand-mark svg { width: 20px; height: 20px; }
.brand-muted { color: #929bad; font-weight: 400; }

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.language-picker {
    position: relative;
    display: inline-flex;
    align-items: center;
    color: #536071;
}

.language-picker svg {
    position: absolute;
    inset-inline-start: 12px;
    width: 16px;
    height: 16px;
    pointer-events: none;
}

.language-picker select {
    height: 38px;
    padding: 0 32px 0 36px;
    color: #536071;
    background: rgba(255, 255, 255, .78);
    border: 1px solid rgba(229, 234, 242, .95);
    border-radius: 999px;
    outline: none;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
}

html[dir="rtl"] .language-picker select { padding: 0 36px 0 32px; }
.language-picker select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(99, 91, 255, .12); }

.theme-toggle {
    display: inline-grid;
    width: 38px;
    height: 38px;
    flex: 0 0 38px;
    place-items: center;
    padding: 0;
    color: #536071;
    background: rgba(255, 255, 255, .78);
    border: 1px solid rgba(229, 234, 242, .95);
    border-radius: 50%;
    outline: none;
    cursor: pointer;
    transition: color .2s ease, background .2s ease, border-color .2s ease, transform .2s ease;
}

.theme-toggle:hover { color: var(--accent); border-color: #c7c3ff; transform: translateY(-1px); }
.theme-toggle:focus-visible { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(99, 91, 255, .16); }
.theme-icon { width: 18px; height: 18px; }
.theme-icon-sun { display: none; }
html[data-theme="dark"] .theme-icon-moon { display: none; }
html[data-theme="dark"] .theme-icon-sun { display: block; }

.service-state {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    color: #536071;
    background: rgba(255, 255, 255, .72);
    border: 1px solid rgba(229, 234, 242, .9);
    border-radius: 999px;
    font-size: 13px;
    font-weight: 500;
}

.service-state::before {
    width: 8px;
    height: 8px;
    content: "";
    background: #22c55e;
    border-radius: 50%;
    box-shadow: 0 0 0 4px rgba(34, 197, 94, .12);
}

.workspace-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.03fr) minmax(360px, .97fr);
    gap: 22px;
    align-items: stretch;
}

.card {
    overflow: hidden;
    background: var(--surface);
    border: 1px solid rgba(229, 234, 242, .9);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    backdrop-filter: blur(16px);
}

.ip-card {
    position: relative;
    display: flex;
    min-height: 520px;
    flex-direction: column;
    justify-content: space-between;
    padding: 34px;
    isolation: isolate;
}

.ip-card::after {
    position: absolute;
    right: -90px;
    bottom: -110px;
    z-index: -1;
    width: 330px;
    height: 330px;
    content: "";
    background: radial-gradient(circle, rgba(99, 91, 255, .18), transparent 66%);
}

.card-kicker {
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: #536071;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: .035em;
    text-transform: uppercase;
}

.icon-box {
    display: grid;
    width: 42px;
    height: 42px;
    place-items: center;
    color: var(--accent);
    background: var(--accent-soft);
    border-radius: 13px;
}

.icon-box svg { width: 21px; height: 21px; }

.ip-main { padding: 34px 0 26px; }

.ip-label { margin: 0 0 10px; color: var(--muted); font-size: 14px; }

.ip-value {
    overflow-wrap: anywhere;
    font-size: clamp(33px, 5vw, 58px);
    font-weight: 700;
    letter-spacing: -.05em;
    line-height: 1.08;
}

.ip-lookup-main {
    display: flex;
    align-items: center;
    gap: 10px;
}

.ip-value-input {
    width: 100%;
    min-width: 0;
    height: 70px;
    padding: 0;
    color: var(--ink);
    background: transparent;
    border: 0;
    border-bottom: 2px solid #dfe5ee;
    border-radius: 0;
    outline: none;
    font-size: clamp(30px, 4.3vw, 52px);
    font-weight: 700;
    letter-spacing: -.05em;
    line-height: 1.08;
    transition: border-color .2s ease;
    direction: ltr;
    text-align: start;
}

.ip-value-input:focus { border-color: var(--accent); }

.ip-check-button {
    display: inline-flex;
    flex: 0 0 auto;
    min-height: 46px;
    align-items: center;
    gap: 7px;
    padding: 0 14px;
    color: #fff;
    background: var(--accent);
    border: 0;
    border-radius: 12px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    transition: background .2s ease, transform .2s ease;
}

.ip-check-button:hover { background: var(--accent-dark); transform: translateY(-1px); }
.ip-check-button svg { width: 16px; height: 16px; }
.ip-check-button:disabled { cursor: wait; opacity: .82; transform: none; }

.button-spinner {
    display: none;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, .38);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin .7s linear infinite;
}

.ip-check-button.is-loading .button-icon { display: none; }
.ip-check-button.is-loading .button-spinner { display: inline-block; }

@keyframes spin { to { transform: rotate(360deg); } }

.ip-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 18px;
    color: var(--muted);
    font-size: 13px;
}

.ip-meta svg { width: 17px; height: 17px; color: var(--cyan); }

.network-facts {
    display: grid;
    grid-template-columns: 1fr 1fr;
    margin-top: 25px;
    overflow: hidden;
    background: rgba(248, 250, 253, .82);
    border: 1px solid var(--line);
    border-radius: 15px;
}

.network-fact {
    min-width: 0;
    padding: 13px 15px;
}

.network-fact:nth-child(2),
.network-fact:nth-child(4),
.network-fact:nth-child(6) { border-left: 1px solid var(--line); }
.network-fact-provider,
.network-fact-subnet { border-top: 1px solid var(--line); }
.network-fact-local,
.network-fact-ptr { border-top: 1px solid var(--line); }

.network-fact > span {
    display: block;
    margin-bottom: 3px;
    color: #8a95a5;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.network-fact strong {
    display: block;
    overflow: hidden;
    color: #354052;
    font-size: 13px;
    font-weight: 500;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.country-value {
    display: flex !important;
    align-items: center;
    gap: 7px;
}

.country-flag {
    display: inline-block !important;
    width: 20px;
    height: 14px;
    margin: 0 !important;
    object-fit: cover;
    border-radius: 3px;
    box-shadow: 0 0 0 1px rgba(23, 32, 51, .10);
    vertical-align: -2px;
}
.country-flag[hidden] { display: none !important; }

.copy-button {
    display: inline-flex;
    width: fit-content;
    align-items: center;
    gap: 9px;
    margin-top: 25px;
    padding: 11px 15px;
    color: #414c5d;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 12px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: transform .2s ease, border-color .2s ease, color .2s ease;
}

.copy-button:hover { color: var(--accent); border-color: #c7c3ff; transform: translateY(-1px); }
.copy-button svg { width: 16px; height: 16px; }

.notice {
    display: flex;
    gap: 12px;
    margin-top: 26px;
    padding: 15px 16px;
    border: 1px solid transparent;
    border-radius: 14px;
    font-size: 13px;
}

.notice svg { width: 19px; height: 19px; flex: 0 0 auto; margin-top: 1px; }
.notice strong { display: block; margin-bottom: 2px; font-size: 14px; font-weight: 600; }
.notice-success { color: var(--success); background: var(--success-bg); border-color: #ccebd7; }
.notice-warning { color: var(--warning); background: var(--warning-bg); border-color: #f0dab6; }
.notice-error { color: var(--danger); background: var(--danger-bg); border-color: #f3cbc7; }

#access-notice {
    min-height: 94px;
    align-items: flex-start;
}

#access-notice[hidden] {
    display: flex !important;
    visibility: hidden;
    pointer-events: none;
}

.access-card { padding: 34px; }
.access-card h2, .section-heading h2 { margin: 0; font-size: 24px; font-weight: 600; letter-spacing: -.035em; }
.card-description { margin: 8px 0 28px; color: var(--muted); font-size: 14px; }

.field { margin-bottom: 17px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

.field label {
    display: block;
    margin-bottom: 7px;
    color: #414c5d;
    font-size: 13px;
    font-weight: 600;
}

.field input, .field select {
    width: 100%;
    min-height: 47px;
    padding: 0 14px;
    color: var(--ink);
    background: #fbfcfe;
    border: 1px solid #dfe5ee;
    border-radius: 12px;
    outline: none;
    transition: border-color .2s ease, box-shadow .2s ease, background .2s ease;
}

.field select {
    padding-right: 38px;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23667085' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 13px center;
}

.field input:focus, .field select:focus {
    background-color: #fff;
    border-color: var(--accent);
    box-shadow: 0 0 0 4px rgba(99, 91, 255, .10);
}

.primary-button {
    display: inline-flex;
    width: 100%;
    min-height: 50px;
    align-items: center;
    justify-content: center;
    gap: 9px;
    margin-top: 4px;
    color: #fff;
    background: linear-gradient(135deg, var(--accent), #746dff);
    border: 0;
    border-radius: 13px;
    box-shadow: 0 12px 25px rgba(99, 91, 255, .24);
    cursor: pointer;
    font-weight: 600;
    transition: transform .2s ease, box-shadow .2s ease;
}

.primary-button:hover { transform: translateY(-1px); box-shadow: 0 15px 30px rgba(99, 91, 255, .3); }
.primary-button:active { transform: translateY(0); }
.primary-button svg { width: 18px; height: 18px; }
.primary-button:disabled { cursor: wait; opacity: .82; transform: none; }
.primary-button.is-loading .button-icon { display: none; }
.primary-button.is-loading .button-spinner { display: inline-block; }

.form-note { display: flex; gap: 8px; margin: 17px 0 0; color: #7c8798; font-size: 12px; }
.form-note svg { width: 15px; height: 15px; flex: 0 0 auto; margin-top: 1px; }

.whois-section { padding: 58px 0 32px; }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin-bottom: 16px; }
.section-heading p { max-width: 560px; margin: 5px 0 0; color: var(--muted); font-size: 13px; }

.lookup-error {
    margin: -4px 0 14px;
    padding: 10px 13px;
    color: var(--danger);
    background: var(--danger-bg);
    border: 1px solid #f3cbc7;
    border-radius: 11px;
    font-size: 12px;
}

.whois-loading {
    display: flex;
    min-height: 128px;
    align-items: center;
    justify-content: center;
    gap: 10px;
    color: var(--muted);
    background: rgba(255, 255, 255, .7);
    border: 1px solid var(--line);
    border-radius: 15px;
    font-size: 13px;
}

.whois-loading::before {
    width: 18px;
    height: 18px;
    content: "";
    border: 2px solid #d8d5ff;
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin .7s linear infinite;
}

.whois-tabs {
    display: flex;
    gap: 7px;
    margin-bottom: 10px;
    overflow-x: auto;
    padding: 3px 2px 5px;
    scrollbar-width: thin;
}

.whois-tab {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    gap: 7px;
    min-height: 38px;
    padding: 0 13px;
    color: #667085;
    background: rgba(255, 255, 255, .72);
    border: 1px solid var(--line);
    border-radius: 10px;
    cursor: pointer;
    font-size: 11px;
    font-weight: 600;
    transition: color .2s ease, background .2s ease, border-color .2s ease;
}

.whois-tab:hover { color: var(--accent); border-color: #c7c3ff; }
.whois-tab.is-active { color: #fff; background: #202a44; border-color: #202a44; }
.whois-tab-index { opacity: .62; font-family: "SFMono-Regular", Consolas, monospace; }
.whois-tab-panel[hidden] { display: none; }

.whois-card {
    overflow: hidden;
    min-width: 0;
    background: var(--surface-solid);
    border: 1px solid var(--line);
    border-radius: 15px;
    box-shadow: 0 10px 34px rgba(23, 32, 51, .045);
}

.whois-tab-panel .whois-row { grid-template-columns: minmax(110px, .28fr) minmax(0, 1fr); }

.whois-card-head {
    padding: 12px 15px;
    color: #fff;
    background: linear-gradient(135deg, #202a44, #303c5d);
}

.whois-type { color: #aeb8cf; font-size: 9px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; }
.whois-name { overflow-wrap: anywhere; margin-top: 2px; font-size: 13px; font-weight: 600; }
.whois-list { margin: 0; }

.whois-row {
    display: grid;
    grid-template-columns: minmax(90px, .72fr) minmax(0, 1.28fr);
    gap: 10px;
    padding: 7px 14px;
    border-top: 1px solid #edf0f5;
    font-size: 11px;
}

.whois-row dt { color: #8490a2; font-weight: 500; }
.whois-row dd { min-width: 0; margin: 0; overflow-wrap: anywhere; color: #354052; }
.empty-state { padding: 30px; color: var(--muted); text-align: center; }

.footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 28px 0 42px;
    color: #8a95a5;
    border-top: 1px solid rgba(218, 224, 234, .9);
    font-size: 12px;
}

.footer a { color: #667085; text-decoration: none; }
.footer a:hover { color: var(--accent); }

html[data-theme="dark"] body {
    background:
        radial-gradient(circle at 10% 0%, rgba(129, 122, 255, .16), transparent 30rem),
        radial-gradient(circle at 90% 16%, rgba(53, 201, 212, .10), transparent 28rem),
        var(--bg);
}

html[data-theme="dark"] .brand-muted,
html[data-theme="dark"] .network-fact > span,
html[data-theme="dark"] .footer { color: #8995aa; }

html[data-theme="dark"] .language-picker,
html[data-theme="dark"] .language-picker select,
html[data-theme="dark"] .theme-toggle,
html[data-theme="dark"] .service-state,
html[data-theme="dark"] .card-kicker { color: #b5bfd1; }

html[data-theme="dark"] .language-picker select,
html[data-theme="dark"] .theme-toggle,
html[data-theme="dark"] .service-state,
html[data-theme="dark"] .whois-tab {
    background: rgba(20, 27, 45, .82);
    border-color: var(--line);
}

html[data-theme="dark"] .card { border-color: rgba(55, 67, 92, .82); }
html[data-theme="dark"] .ip-value-input { border-bottom-color: #364159; }
html[data-theme="dark"] .network-facts { background: rgba(11, 16, 32, .48); }
html[data-theme="dark"] .network-fact strong,
html[data-theme="dark"] .field label,
html[data-theme="dark"] .whois-row dd { color: #dce3f2; }

html[data-theme="dark"] .copy-button {
    color: #d5dceb;
    background: #171f32;
}

html[data-theme="dark"] .copy-button:hover,
html[data-theme="dark"] .theme-toggle:hover,
html[data-theme="dark"] .whois-tab:hover { border-color: #7069c8; }

html[data-theme="dark"] .notice-success { border-color: #28513e; }
html[data-theme="dark"] .notice-warning { border-color: #5b4524; }
html[data-theme="dark"] .notice-error,
html[data-theme="dark"] .lookup-error { border-color: #62343a; }

html[data-theme="dark"] .field input,
html[data-theme="dark"] .field select {
    background-color: #101729;
    border-color: #344058;
}

html[data-theme="dark"] .field select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23aab4c7' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
}

html[data-theme="dark"] .field input:focus,
html[data-theme="dark"] .field select:focus { background-color: #151d30; }
html[data-theme="dark"] .form-note { color: #929db1; }
html[data-theme="dark"] .whois-loading { background: rgba(20, 27, 45, .72); }
html[data-theme="dark"] .whois-loading::before { border-color: #403c70; border-top-color: var(--accent); }
html[data-theme="dark"] .whois-tab { color: #aab4c7; }
html[data-theme="dark"] .whois-tab.is-active { color: #fff; background: #5d56d8; border-color: #5d56d8; }
html[data-theme="dark"] .whois-card { box-shadow: 0 10px 34px rgba(0, 0, 0, .18); }
html[data-theme="dark"] .whois-row { border-top-color: #283248; }
html[data-theme="dark"] .footer { border-top-color: #273147; }
html[data-theme="dark"] .footer a { color: #a5afc1; }

#ip2,
.whois-name,
.whois-row dd { direction: ltr; text-align: start; }

html[dir="rtl"] .ip-value-input,
html[dir="rtl"] #ip2,
html[dir="rtl"] .whois-name,
html[dir="rtl"] .whois-row dd { text-align: left; }

@media (max-width: 940px) {
    .workspace-grid { grid-template-columns: 1fr; }
    .ip-card { min-height: 400px; }
}

@media (max-width: 640px) {
    .page-shell { width: min(100% - 24px, 1180px); }
    .topbar { min-height: 68px; }
    .brand-muted, .service-state { display: none; }
    .language-picker select { max-width: 152px; }
    .ip-card, .access-card { padding: 24px; border-radius: 20px; }
    .ip-card { min-height: 370px; }
    .ip-lookup-main { align-items: stretch; flex-direction: column; }
    .ip-check-button { justify-content: center; }
    .field-row { grid-template-columns: 1fr; }
    .section-heading { align-items: flex-start; flex-direction: column; }
    .whois-section { padding-top: 58px; }
    .footer { align-items: flex-start; flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
