/* ===== RESET & BASE ===== */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg: #0e1117;
    --bg-surface: #161b22;
    --bg-surface-hover: #1c222b;
    --bg-elevated: #21262d;
    --border: #30363d;
    --border-light: #3a424d;
    --text: #e6edf3;
    --text-muted: #8b949e;
    --text-subtle: #6e7681;
    --accent: #58a6ff;
    --accent-hover: #79b8ff;
    --green: #3fb950;
    --green-bg: rgba(63, 185, 80, .12);
    --amber: #d29922;
    --amber-bg: rgba(210, 153, 34, .12);
    --red: #f85149;
    --red-bg: rgba(248, 81, 73, .12);
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
    --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
    --radius: 8px;
    --radius-sm: 5px;
    --max-w: 680px;
    --transition: 150ms ease;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

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

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

code {
    font-family: var(--mono);
    font-size: .9em;
    background: var(--bg-elevated);
    padding: 2px 6px;
    border-radius: 4px;
}

img, svg {
    max-width: 100%;
    height: auto;
}

/* ===== HEADER ===== */
.site-header {
    border-bottom: 1px solid var(--border);
    background: var(--bg-surface);
}
.site-header__inner {
    max-width: var(--max-w);
    margin: 0 auto;
    padding: 14px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.site-logo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text);
    text-decoration: none;
}
.site-logo:hover {
    text-decoration: none;
    color: var(--accent);
}
.site-logo__icon {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
}
.site-logo__text {
    line-height: 1;
}
.site-header__nav {
    display: flex;
    gap: 20px;
}
.site-header__nav a {
    color: var(--text-muted);
    font-size: .9rem;
    font-weight: 500;
    transition: color var(--transition);
}
.site-header__nav a:hover {
    color: var(--text);
    text-decoration: none;
}

/* ===== MAIN ===== */
main {
    flex: 1;
    max-width: var(--max-w);
    margin: 0 auto;
    padding: 0 20px;
    width: 100%;
}

/* ===== CHECKER SECTION ===== */
.checker-section {
    padding: 56px 0 40px;
}
.checker-title {
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: -.02em;
    text-align: center;
}
.checker-subtitle {
    color: var(--text-muted);
    text-align: center;
    margin-top: 6px;
    font-size: 1.05rem;
}

/* ===== FORM ===== */
.check-form {
    margin-top: 28px;
}
.check-form__row {
    display: flex;
    gap: 0;
    border-radius: var(--radius);
    overflow: hidden;
    border: 2px solid var(--border);
    transition: border-color var(--transition);
    background: var(--bg-surface);
}
.check-form__row:focus-within {
    border-color: var(--accent);
}
.check-form__input {
    flex: 1;
    min-width: 0;
    background: transparent;
    border: none;
    color: var(--text);
    font-size: 1.1rem;
    padding: 14px 16px;
    font-family: var(--font);
    outline: none;
}
.check-form__input::placeholder {
    color: var(--text-subtle);
}
.check-form__btn {
    padding: 14px 28px;
    background: var(--accent);
    color: #fff;
    font-size: 1rem;
    font-weight: 600;
    font-family: var(--font);
    border: none;
    cursor: pointer;
    transition: background var(--transition);
    white-space: nowrap;
}
.check-form__btn:hover {
    background: var(--accent-hover);
}
.check-form__btn:disabled {
    opacity: .6;
    cursor: not-allowed;
}

/* Hints */
.check-form__hints {
    margin-top: 10px;
    text-align: center;
    color: var(--text-subtle);
    font-size: .85rem;
}
.hint-link {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font: inherit;
    font-size: .85rem;
    padding: 0 2px;
    text-decoration: underline;
    text-decoration-style: dotted;
    text-underline-offset: 2px;
    transition: color var(--transition);
}
.hint-link:hover {
    color: var(--accent);
}

/* ===== RESULT AREA ===== */
.result-area {
    margin-top: 32px;
}

/* Loading state */
.result-loading {
    text-align: center;
    padding: 32px 0;
    color: var(--text-muted);
}
.result-loading__spinner {
    display: inline-block;
    width: 28px;
    height: 28px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin .7s linear infinite;
}
@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Result card */
.result-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}
.result-card__header {
    padding: 20px 20px 16px;
    display: flex;
    align-items: flex-start;
    gap: 16px;
    flex-wrap: wrap;
}
.result-card__badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: .9rem;
    font-weight: 600;
    white-space: nowrap;
}
.result-card__badge--up {
    background: var(--green-bg);
    color: var(--green);
}
.result-card__badge--error {
    background: var(--amber-bg);
    color: var(--amber);
}
.result-card__badge--down {
    background: var(--red-bg);
    color: var(--red);
}
.result-card__badge--blocked {
    background: var(--red-bg);
    color: var(--red);
}
.result-card__summary {
    flex: 1;
    min-width: 200px;
}
.result-card__url {
    font-family: var(--mono);
    font-size: .95rem;
    word-break: break-all;
    color: var(--text);
}
.result-card__meta {
    margin-top: 6px;
    font-size: .85rem;
    color: var(--text-muted);
    display: flex;
    flex-wrap: wrap;
    gap: 6px 16px;
}

/* Quick stats row */
.result-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 1px;
    background: var(--border);
    border-top: 1px solid var(--border);
}
.result-stat {
    background: var(--bg-surface);
    padding: 12px 16px;
}
.result-stat__label {
    font-size: .75rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--text-subtle);
    margin-bottom: 2px;
}
.result-stat__value {
    font-size: .95rem;
    font-weight: 600;
    font-family: var(--mono);
    word-break: break-all;
}

/* Actions row */
.result-actions {
    padding: 12px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
.result-actions__btn {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    font: inherit;
    font-size: .85rem;
    cursor: pointer;
    transition: all var(--transition);
}
.result-actions__btn:hover {
    background: var(--bg-surface-hover);
    color: var(--text);
    border-color: var(--border-light);
}

/* Advanced details toggle */
.result-details {
    border-top: 1px solid var(--border);
}
.result-details__toggle {
    width: 100%;
    background: none;
    border: none;
    color: var(--text-muted);
    padding: 10px 20px;
    font: inherit;
    font-size: .85rem;
    cursor: pointer;
    text-align: left;
    transition: color var(--transition);
    display: flex;
    align-items: center;
    gap: 6px;
}
.result-details__toggle:hover {
    color: var(--text);
}
.result-details__toggle::before {
    content: '▸';
    display: inline-block;
    transition: transform var(--transition);
}
.result-details__toggle[aria-expanded="true"]::before {
    transform: rotate(90deg);
}
.result-details__body {
    padding: 0 20px 16px;
    display: none;
}
.result-details__body[data-open="true"] {
    display: block;
}

/* Detail sub-sections */
.detail-group {
    margin-bottom: 16px;
}
.detail-group:last-child {
    margin-bottom: 0;
}
.detail-group__title {
    font-size: .8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--text-subtle);
    margin-bottom: 6px;
    padding-bottom: 4px;
    border-bottom: 1px solid var(--border);
}
.detail-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .85rem;
}
.detail-table td {
    padding: 4px 0;
    vertical-align: top;
}
.detail-table td:first-child {
    color: var(--text-muted);
    white-space: nowrap;
    padding-right: 16px;
    width: 1%;
}
.detail-table td:last-child {
    font-family: var(--mono);
    font-size: .83rem;
    word-break: break-all;
}

/* Redirect chain */
.redirect-chain {
    list-style: none;
    font-size: .85rem;
}
.redirect-chain li {
    padding: 4px 0;
    display: flex;
    align-items: baseline;
    gap: 8px;
}
.redirect-chain li::before {
    content: '→';
    color: var(--text-subtle);
    flex-shrink: 0;
}
.redirect-chain__code {
    font-family: var(--mono);
    font-size: .8rem;
    background: var(--bg-elevated);
    padding: 1px 6px;
    border-radius: 3px;
    flex-shrink: 0;
}
.redirect-chain__url {
    word-break: break-all;
    font-family: var(--mono);
    font-size: .82rem;
    color: var(--text-muted);
}

/* Error display */
.result-error {
    padding: 20px;
    text-align: center;
    color: var(--text-muted);
}
.result-error__msg {
    font-size: .95rem;
}

/* HTTP fallback notice */
.result-card__notice {
    padding: 8px 20px;
    background: var(--amber-bg);
    color: var(--amber);
    font-size: .83rem;
    border-top: 1px solid rgba(210, 153, 34, .2);
}

/* ===== RECENT CHECKS ===== */
.recent-checks {
    margin-top: 36px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}
.recent-checks__title {
    font-size: .9rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 10px;
}
.recent-checks__list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.recent-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background var(--transition);
    font-size: .88rem;
}
.recent-item:hover {
    background: var(--bg-surface-hover);
}
.recent-item__dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}
.recent-item__dot--up { background: var(--green); }
.recent-item__dot--error { background: var(--amber); }
.recent-item__dot--down { background: var(--red); }
.recent-item__dot--blocked { background: var(--red); }
.recent-item__url {
    flex: 1;
    font-family: var(--mono);
    font-size: .83rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.recent-item__time {
    color: var(--text-subtle);
    font-size: .78rem;
    white-space: nowrap;
}

/* ===== ABOUT SECTION ===== */
.about-section {
    padding: 48px 0 40px;
    border-top: 1px solid var(--border);
}
.about-section h2 {
    font-size: 1.3rem;
    font-weight: 700;
    margin-bottom: 20px;
}
.about-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}
.about-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
}
.about-card h3 {
    font-size: .95rem;
    font-weight: 600;
    margin-bottom: 6px;
}
.about-card p {
    font-size: .88rem;
    color: var(--text-muted);
    line-height: 1.55;
}

/* ===== STATUS EXPLANATION ===== */
.status-explain {
    padding: 40px 0;
    border-top: 1px solid var(--border);
}
.status-explain h2 {
    font-size: 1.3rem;
    font-weight: 700;
    margin-bottom: 20px;
}
.status-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.status-card {
    padding: 16px 20px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}
.status-card--up { background: var(--green-bg); border-color: rgba(63,185,80,.2); }
.status-card--error { background: var(--amber-bg); border-color: rgba(210,153,34,.2); }
.status-card--down { background: var(--red-bg); border-color: rgba(248,81,73,.2); }
.status-card__badge {
    display: inline-block;
    font-size: .85rem;
    font-weight: 700;
    margin-bottom: 4px;
}
.status-card--up .status-card__badge { color: var(--green); }
.status-card--error .status-card__badge { color: var(--amber); }
.status-card--down .status-card__badge { color: var(--red); }
.status-card p {
    font-size: .88rem;
    color: var(--text-muted);
    line-height: 1.55;
}

/* ===== DETAILS SECTION ===== */
.details-section {
    padding: 40px 0;
    border-top: 1px solid var(--border);
}
.details-section h2 {
    font-size: 1.3rem;
    font-weight: 700;
    margin-bottom: 16px;
}
.details-list {
    display: flex;
    flex-direction: column;
    gap: 0;
}
.details-item {
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}
.details-item:last-child {
    border-bottom: none;
}
.details-item dt {
    font-weight: 600;
    font-size: .92rem;
    margin-bottom: 2px;
}
.details-item dd {
    font-size: .87rem;
    color: var(--text-muted);
    line-height: 1.5;
}

/* ===== NOTES SECTION ===== */
.notes-section {
    padding: 40px 0 56px;
    border-top: 1px solid var(--border);
}
.notes-section h2 {
    font-size: 1.3rem;
    font-weight: 700;
    margin-bottom: 14px;
}
.notes-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.notes-list li {
    position: relative;
    padding-left: 18px;
    font-size: .9rem;
    color: var(--text-muted);
    line-height: 1.55;
}
.notes-list li::before {
    content: '·';
    position: absolute;
    left: 0;
    font-weight: 700;
    color: var(--text-subtle);
    font-size: 1.4em;
    line-height: 1;
    top: 2px;
}

/* ===== FOOTER ===== */
.site-footer {
    border-top: 1px solid var(--border);
    background: var(--bg-surface);
    margin-top: auto;
}
.site-footer__inner {
    max-width: var(--max-w);
    margin: 0 auto;
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
}
.site-footer__copy {
    font-size: .82rem;
    color: var(--text-subtle);
}
.site-footer__links {
    display: flex;
    gap: 18px;
}
.site-footer__links a {
    font-size: .82rem;
    color: var(--text-muted);
    transition: color var(--transition);
}
.site-footer__links a:hover {
    color: var(--text);
    text-decoration: none;
}

/* ===== LEGAL / CONTENT PAGES ===== */
.page-content {
    padding: 48px 0 56px;
    max-width: var(--max-w);
    margin: 0 auto;
}
.page-content h1 {
    font-size: 1.6rem;
    font-weight: 700;
    margin-bottom: 8px;
}
.page-content .page-updated {
    font-size: .85rem;
    color: var(--text-subtle);
    margin-bottom: 28px;
}
.page-content h2 {
    font-size: 1.15rem;
    font-weight: 600;
    margin: 28px 0 8px;
}
.page-content p,
.page-content li {
    font-size: .92rem;
    color: var(--text-muted);
    line-height: 1.65;
}
.page-content ul {
    margin: 8px 0;
    padding-left: 22px;
}
.page-content li {
    margin-bottom: 4px;
}
.page-content a {
    color: var(--accent);
}

/* ===== CONTACT PAGE ===== */
.contact-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    margin-top: 20px;
}
.contact-card p {
    font-size: .92rem;
    color: var(--text-muted);
    margin-bottom: 6px;
}
.contact-card a {
    font-size: 1rem;
    font-weight: 600;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 600px) {
    .checker-title {
        font-size: 1.5rem;
    }
    .checker-subtitle {
        font-size: .95rem;
    }
    .check-form__row {
        flex-direction: column;
        border-radius: var(--radius);
    }
    .check-form__input {
        border-bottom: 1px solid var(--border);
    }
    .check-form__btn {
        padding: 14px;
    }
    .about-grid {
        grid-template-columns: 1fr;
    }
    .result-card__header {
        padding: 16px;
    }
    .result-stats {
        grid-template-columns: repeat(2, 1fr);
    }
    .result-actions {
        padding: 10px 16px;
    }
    .result-details__toggle {
        padding: 10px 16px;
    }
    .result-details__body {
        padding: 0 16px 14px;
    }
    .site-footer__inner {
        flex-direction: column;
        text-align: center;
    }
}
