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

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: #f5f5f7;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    color: #1a1a2e;
    line-height: 1.5;
}

/* === Card === */
.card {
    background: #fff;
    border-radius: 1rem;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
    max-width: 420px;
    width: 100%;
    overflow: hidden;
}

.card-header {
    text-align: center;
    padding: 2rem 1.5rem 1rem;
}

.card-header svg {
    width: 56px;
    height: 56px;
}

.card-header h1 {
    font-size: 1.35rem;
    font-weight: 700;
    color: #1a1a2e;
    margin-top: 0.75rem;
    line-height: 1.3;
}

.ssid {
    color: #667eea;
    font-weight: 600;
    font-size: 0.95rem;
    margin-top: 0.25rem;
}

.card-body {
    padding: 0 1.5rem 2rem;
}

/* === Feature List === */
.features {
    list-style: none;
    margin: 1.25rem 0 1.5rem;
}

.features li {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 0;
    color: #4a4a6a;
    font-size: 0.95rem;
}

.features li svg {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
    fill: #667eea;
}

/* === Buttons === */
.btn {
    display: block;
    width: 100%;
    padding: 1rem;
    border: none;
    border-radius: 0.75rem;
    font-size: 1.05rem;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    text-decoration: none;
    min-height: 56px;
    line-height: 1.4;
    transition: background-color 0.2s, opacity 0.2s;
    -webkit-appearance: none;
}

.btn-primary {
    background: #667eea;
    color: #fff;
}

.btn-primary:hover,
.btn-primary:focus {
    background: #5a6fd6;
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-secondary {
    background: #f0f0f5;
    color: #4a4a6a;
    margin-top: 0.75rem;
}

.btn-secondary:hover,
.btn-secondary:focus {
    background: #e4e4ed;
}

.link-secondary {
    display: block;
    text-align: center;
    margin-top: 0.75rem;
    color: #667eea;
    font-size: 0.9rem;
    text-decoration: none;
    padding: 0.5rem;
    min-height: 44px;
    line-height: 2;
}

.link-secondary:hover {
    text-decoration: underline;
}

/* === Modal === */
.modal {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    z-index: 100;
    visibility: hidden;
    opacity: 0;
    transition: opacity 0.3s, visibility 0.3s;
}

.modal.modal-open {
    visibility: visible;
    opacity: 1;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
}

.modal-content {
    position: relative;
    background: #fff;
    border-radius: 1rem 1rem 0 0;
    padding: 1.5rem;
    width: 100%;
    max-width: 420px;
    max-height: 90vh;
    overflow-y: auto;
    z-index: 1;
    transform: translateY(100%);
    transition: transform 0.3s ease-out;
}

.modal.modal-open .modal-content {
    transform: translateY(0);
}

@media (min-height: 600px) {
    .modal {
        align-items: center;
    }

    .modal-content {
        border-radius: 1rem;
        max-height: 80vh;
    }
}

.modal-content h2 {
    font-size: 1.15rem;
    font-weight: 700;
    color: #1a1a2e;
    margin-bottom: 0.75rem;
    padding-right: 2rem;
}

.modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #999;
    line-height: 1;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    color: #333;
}

/* === ToS Text === */
.tos-text {
    max-height: 200px;
    overflow-y: auto;
    padding: 1rem;
    background: #f8f8fc;
    border-radius: 0.5rem;
    margin-bottom: 1rem;
    font-size: 0.82rem;
    line-height: 1.6;
    color: #555;
    -webkit-overflow-scrolling: touch;
}

.tos-text h3 {
    font-size: 0.88rem;
    color: #333;
    margin: 0.75rem 0 0.25rem;
}

.tos-text h3:first-child {
    margin-top: 0;
}

.tos-text p {
    margin-bottom: 0.5rem;
}

/* === Checkbox === */
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin: 1rem 0;
    cursor: pointer;
    font-size: 0.92rem;
    color: #333;
    min-height: 44px;
    -webkit-user-select: none;
    user-select: none;
}

.checkbox-label input[type="checkbox"] {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
    accent-color: #667eea;
    cursor: pointer;
}

/* === Spinner === */
.btn-spinner {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn-spinner::before {
    content: '';
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 2.5px 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);
    }
}

/* === Error Page === */
.error-icon svg {
    width: 56px;
    height: 56px;
}

.error-message {
    text-align: center;
    color: #666;
    margin: 0.5rem 0 1.5rem;
    font-size: 0.95rem;
    line-height: 1.5;
}

.error-hint {
    text-align: center;
    color: #999;
    font-size: 0.82rem;
    margin-bottom: 1.5rem;
    line-height: 1.5;
}

/* === Success Page === */
.success-icon svg {
    width: 64px;
    height: 64px;
}

.success-text {
    text-align: center;
    color: #4a4a6a;
    margin: 0.5rem 0 0.5rem;
    font-size: 1rem;
}

.hint {
    color: #999;
    font-size: 0.85rem;
    text-align: center;
    margin: 0.25rem 0 1.5rem;
}
