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

        :root {
            --bg: #f5f5f4;
            --surface: #ffffff;
            --border: #e2e0de;
            --border-strong: #c8c6c3;
            --text: #1a1917;
            --text-muted: #6b6966;
            --text-faint: #9c9a97;
            --accent: #1a1917;
            --open: #1a6b3c;
            --open-bg: #f0faf4;
            --open-border: #a7d9bc;
            --closed: #7a2020;
            --closed-bg: #fdf4f4;
            --closed-border: #e2b0b0;
            --mono: 'DM Mono', monospace;
            --sans: 'DM Sans', sans-serif;
        }

        html { font-size: 17px; }

        body {
            font-family: var(--sans);
            background: var(--bg);
            color: var(--text);
            min-height: 100vh;
            display: flex;
            flex-direction: column;
            line-height: 1.6;
            -webkit-font-smoothing: antialiased;
        }

        a { color: inherit; text-decoration: none; }
        a:hover { text-decoration: underline; }

        header {
            background: var(--surface);
            border-bottom: 1px solid var(--border);
            padding: 0 24px;
        }
        .header-inner {
            max-width: 780px;
            margin: 0 auto;
            height: 56px;
            display: flex;
            align-items: center;
            justify-content: space-between;
        }
        .logo {
            font-family: var(--mono);
            font-size: 16px;
            font-weight: 500;
            letter-spacing: -0.02em;
            color: var(--text);
        }
        .logo span {
            color: var(--text-muted);
            font-weight: 400;
        }
        nav { display: flex; gap: 24px; align-items: center; }
        nav a {
            font-size: 14px;
            color: var(--text-muted);
            font-weight: 400;
        }
        nav a:hover { color: var(--text); text-decoration: none; }

        main {
            flex: 1;
            padding: 24px 24px;
            max-width: 780px;
            margin: 0 auto;
            width: 100%;
        }

        .page-header { margin-bottom: 36px; }
        .page-header h1 {
            font-size: 30px;
            font-weight: 600;
            letter-spacing: -0.03em;
            line-height: 1.2;
            margin-bottom: 8px;
        }
        .page-header p {
            font-size: 15px;
            color: var(--text-muted);
            font-weight: 300;
            max-width: 500px;
        }

        .card {
            background: var(--surface);
            border: 1px solid var(--border);
            border-radius: 8px;
            padding: 28px;
            margin-bottom: 24px;
        }

        .form-row {
            display: flex;
            gap: 10px;
            align-items: flex-end;
        }

        .field {
            display: flex;
            flex-direction: column;
            gap: 6px;
        }
        .field.host { flex: 1; min-width: 0; }
        .field.port { width: 110px; flex-shrink: 0; }

        label {
            font-size: 12px;
            font-weight: 500;
            letter-spacing: 0.08em;
            text-transform: uppercase;
            color: var(--text-muted);
        }

        input[type="text"],
        input[type="number"] {
            font-family: var(--mono);
            font-size: 15px;
            padding: 9px 12px;
            border: 1px solid var(--border-strong);
            border-radius: 5px;
            background: var(--bg);
            color: var(--text);
            outline: none;
            transition: border-color 0.15s, background 0.15s;
            width: 100%;
        }
        input:focus {
            border-color: var(--accent);
            background: #fff;
        }
        input::placeholder { color: var(--text-faint); }

        input[type=number]::-webkit-inner-spin-button,
        input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; }
        input[type=number] { -moz-appearance: textfield; }

        .btn {
            font-family: var(--sans);
            font-size: 14px;
            font-weight: 500;
            padding: 10px 20px;
            background: var(--accent);
            color: #fff;
            border: none;
            border-radius: 5px;
            cursor: pointer;
            white-space: nowrap;
            transition: opacity 0.15s;
            height: 40px;
            letter-spacing: 0.01em;
            flex-shrink: 0;
        }
        .btn:hover { opacity: 0.82; }
        .btn:active { opacity: 0.7; }

        .alert-error {
            padding: 12px 16px;
            border-radius: 5px;
            background: var(--closed-bg);
            border: 1px solid var(--closed-border);
            color: var(--closed);
            font-size: 14px;
            margin-bottom: 20px;
        }

        /* ---- Your IP bar ---- */
        .your-ip-bar {
            font-size: 13px;
            color: var(--text-faint);
            font-family: var(--mono);
            margin-top: 14px;
            padding-top: 12px;
            border-top: 1px solid var(--border);
        }
        .your-ip-val {
            color: var(--text-muted);
            cursor: pointer;
            border-bottom: 1px dashed var(--border-strong);
            transition: color 0.12s, border-color 0.12s;
        }
        .your-ip-val:hover {
            color: var(--accent);
            border-bottom-color: var(--accent);
        }
        .your-ip-val.loading {
            color: var(--text-faint);
            cursor: default;
            border-bottom-color: transparent;
        }

        .result-card {
            border-radius: 8px;
            border: 1px solid var(--border);
            overflow: hidden;
            margin-bottom: 24px;
        }
        .result-header {
            padding: 20px 24px;
            display: flex;
            align-items: center;
            gap: 14px;
        }
        .result-card.open .result-header {
            background: var(--open-bg);
            border-bottom: 1px solid var(--open-border);
        }
        .result-card.closed .result-header {
            background: var(--closed-bg);
            border-bottom: 1px solid var(--closed-border);
        }

        .status-dot {
            width: 10px;
            height: 10px;
            border-radius: 50%;
            flex-shrink: 0;
        }
        .open .status-dot { background: var(--open); }
        .closed .status-dot { background: var(--closed); }

        .result-title {
            font-size: 17px;
            font-weight: 600;
            letter-spacing: -0.02em;
        }
        .open .result-title { color: var(--open); }
        .closed .result-title { color: var(--closed); }

        .result-subtitle {
            font-size: 14px;
            color: var(--text-muted);
            margin-left: auto;
            font-family: var(--mono);
        }

        .result-meta {
            background: var(--surface);
            padding: 16px 24px;
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
            gap: 16px;
        }
        .meta-item label {
            display: block;
            font-size: 11px;
            font-weight: 500;
            letter-spacing: 0.08em;
            text-transform: uppercase;
            color: var(--text-faint);
            margin-bottom: 3px;
        }
        .meta-item .value {
            font-family: var(--mono);
            font-size: 14px;
            color: var(--text);
        }

        .section-title {
            font-size: 12px;
            font-weight: 500;
            letter-spacing: 0.08em;
            text-transform: uppercase;
            color: var(--text-muted);
            margin-bottom: 12px;
        }

        .ports-grid {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
            gap: 6px;
        }
        .port-btn {
            font-family: var(--mono);
            font-size: 13px;
            padding: 8px 10px;
            border: 1px solid var(--border);
            border-radius: 4px;
            background: var(--surface);
            cursor: pointer;
            color: var(--text);
            transition: border-color 0.12s, background 0.12s;
            text-align: left;
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 6px;
            min-width: 0;
            overflow: hidden;
            width: 100%;
        }
        .port-btn:hover {
            border-color: var(--accent);
            background: var(--bg);
        }
        .port-btn .pnum {
            color: var(--text);
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
            min-width: 0;
        }
        .port-btn .pname {
            color: var(--text-faint);
            font-size: 11px;
            flex-shrink: 0;
            white-space: nowrap;
        }

        .info-grid {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
            gap: 16px;
            margin-top: 16px;
        }
        .info-card {
            background: var(--surface);
            border: 1px solid var(--border);
            border-radius: 7px;
            padding: 18px 20px;
        }
        .info-card h3 {
            font-size: 14px;
            font-weight: 600;
            margin-bottom: 6px;
            letter-spacing: -0.01em;
        }
        .info-card p {
            font-size: 14px;
            color: var(--text-muted);
            font-weight: 300;
            line-height: 1.55;
        }

        .faq { margin-top: 40px; }
        .faq h2 {
            font-size: 19px;
            font-weight: 600;
            letter-spacing: -0.02em;
            margin-bottom: 18px;
        }
        .faq-item {
            border-top: 1px solid var(--border);
            padding: 16px 0;
        }
        .faq-item:last-child { border-bottom: 1px solid var(--border); }
        .faq-item h3 {
            font-size: 15px;
            font-weight: 500;
            margin-bottom: 6px;
        }
        .faq-item p {
            font-size: 14px;
            color: var(--text-muted);
            font-weight: 300;
            line-height: 1.6;
        }

        footer {
            border-top: 1px solid var(--border);
            background: var(--surface);
            padding: 20px 24px;
        }
        .footer-inner {
            max-width: 780px;
            margin: 0 auto;
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 12px;
        }
        footer p {
            font-size: 13px;
            color: var(--text-faint);
        }

        .btn-loading {
            display: none;
            align-items: center;
            gap: 8px;
        }
        .spinner {
            width: 14px;
            height: 14px;
            border: 2px solid rgba(255,255,255,0.3);
            border-top-color: #fff;
            border-radius: 50%;
            animation: spin 0.7s linear infinite;
        }
        @keyframes spin { to { transform: rotate(360deg); } }
        .ip-link {
            color: var(--text);
            text-decoration: underline;
            text-decoration-color: var(--border-strong);
            text-underline-offset: 2px;
            transition: text-decoration-color 0.15s;
        }
        .ip-link:hover {
            text-decoration-color: var(--text);
        }

        /* ---- History Section ---- */
        #historyList {
            grid-template-columns: repeat(4, 1fr);
        }
        @media (max-width: 560px) {
            #historyList {
                grid-template-columns: repeat(2, 1fr);
            }
        }

        .history-header {
            display: flex;
            align-items: center;
            justify-content: space-between;
            margin-bottom: 10px;
        }
        .history-clear-btn {
            font-family: var(--sans);
            font-size: 12px;
            color: var(--text-faint);
            background: none;
            border: none;
            cursor: pointer;
            padding: 2px 0;
            letter-spacing: 0.02em;
            transition: color 0.12s;
        }
        .history-clear-btn:hover { color: var(--closed); }

        /* ---- History item wrapper with per-item delete ---- */
        .history-item-wrapper {
            position: relative;
            display: flex;
            align-items: stretch;
        }
        .history-item-wrapper .port-btn {
            border-radius: 4px;
            flex: 1;
        }
        .history-del-btn {
            position: absolute;
            right: 5px;
            top: 50%;
            transform: translateY(-50%);
            display: flex;
            align-items: center;
            justify-content: center;
            width: 20px;
            height: 20px;
            border-radius: 3px;
            border: none;
            background: var(--border);
            color: var(--text-muted);
            cursor: pointer;
            opacity: 0;
            transition: opacity 0.12s, background 0.12s, color 0.12s;
            flex-shrink: 0;
            padding: 0;
            line-height: 1;
        }
        .history-item-wrapper:hover .history-del-btn {
            opacity: 1;
        }
        .history-del-btn:hover {
            background: var(--closed-border);
            color: var(--closed);
        }

        /* ---- Mobile Fix ---- */
        @media (max-width: 560px) {
            .form-row {
                flex-direction: column;
                align-items: stretch;
            }
            .field.host,
            .field.port {
                width: 100%;
            }
            .btn {
                width: 100%;
                height: 42px;
                display: flex;
                align-items: center;
                justify-content: center;
            }
            .header-inner { gap: 12px; }
            nav { gap: 16px; }
            /* On mobile, always show del btn (no hover) */
            .history-del-btn { opacity: 1; }
        }

        /* ---- Products Section ---- */
        .products-section {
            margin-top: 40px;
        }
        .products-grid {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
            gap: 6px;
        }
        .product-card {
            display: flex;
            flex-direction: column;
            align-items: flex-start;
            gap: 6px;
            background: var(--surface);
            border: 1px solid var(--border);
            border-radius: 4px;
            padding: 10px 12px;
            transition: border-color 0.12s, background 0.12s;
            text-decoration: none;
        }
        .product-card:hover {
            border-color: var(--accent);
            background: var(--bg);
            text-decoration: none;
        }
        .product-card-top {
            display: flex;
            align-items: center;
            gap: 7px;
            width: 100%;
        }
        .product-favicon {
            width: 24px;
            height: 24px;
            flex-shrink: 0;
            border-radius: 2px;
        }
        .product-name {
            font-family: var(--mono);
            font-size: 13px;
            font-weight: 500;
            color: var(--text);
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }
        .product-desc {
            font-size: 12px;
            color: var(--text-faint);
            font-weight: 400;
            line-height: 1.4;
        }

        /* ---- Language Switcher ---- */
        .lang-switcher {
            position: relative;
        }
        .lang-btn {
            display: flex;
            align-items: center;
            gap: 5px;
            font-family: var(--sans);
            font-size: 14px;
            color: var(--text-muted);
            background: none;
            border: none;
            cursor: pointer;
            padding: 4px 6px;
            border-radius: 4px;
            transition: color 0.12s, background 0.12s;
            white-space: nowrap;
        }
        .lang-btn:hover {
            color: var(--text);
            background: var(--bg);
        }
        .lang-menu {
            display: none;
            position: absolute;
            top: calc(100% + 6px);
            right: 0;
            background: var(--surface);
            border: 1px solid var(--border-strong);
            border-radius: 6px;
            box-shadow: 0 4px 16px rgba(0,0,0,0.10);
            min-width: 160px;
            z-index: 100;
            padding: 4px 0;
            max-height: 70vh;
            overflow-y: auto;
        }
        .lang-menu.open {
            display: block;
        }
        .lang-menu a {
            display: block;
            padding: 7px 14px;
            font-size: 14px;
            color: var(--text-muted);
            text-decoration: none;
            transition: background 0.1s, color 0.1s;
            white-space: nowrap;
        }
        .lang-menu a:hover {
            background: var(--bg);
            color: var(--text);
        }
        .lang-menu a.active {
            color: var(--text);
            font-weight: 500;
        }
        .lang-link-active {
            border-color: var(--accent);
            background: var(--bg);
            font-weight: 500;
        }
        .lang-link-active .pnum {
            color: var(--accent);
        }
        @media (max-width: 560px) {
            .lang-btn span:first-of-type { display: none; }
            .lang-menu { right: 0; }
        }
