/* Login / shared chrome. Tokens live in theme.css (DESIGN.md). */

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

body {
    font-family: var(--font-sans, "IBM Plex Sans KR", "Apple SD Gothic Neo", sans-serif);
    background: var(--surface-canvas, #f3f5f4);
    min-height: 100dvh;
    display: flex;
    justify-content: center;
    align-items: center;
    align-items: safe center;
    padding: var(--space-3, 12px) var(--space-5, 20px);
    color: var(--text-primary, #fafafa);
    overflow-x: hidden;
}

.container {
    background: var(--surface-primary, #ffffff);
    border-radius: var(--radius-lg, 16px);
    border: 1px solid var(--border-default, #2e2e2e);
    max-width: 470px;
    width: 100%;
    padding: var(--space-8, 32px);
    position: relative;
    overflow: visible;
    flex-shrink: 0;
}

.container::before,
.container::after {
    content: '';
    position: absolute;
    border-radius: 50%;
    background: rgba(62, 207, 142, 0.08);
    filter: blur(40px);
    z-index: 0;
    pointer-events: none;
}

.container::before {
    width: 180px;
    height: 180px;
    top: -60px;
    right: -40px;
}

.container::after {
    width: 150px;
    height: 150px;
    bottom: -50px;
    left: -30px;
}

.header {
    text-align: center;
    margin-bottom: var(--space-5, 20px);
    position: relative;
    z-index: 1;
}

.brand-row {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 999px;
    background: rgba(62, 207, 142, 0.12);
    color: var(--accent-primary, #3ecf8e);
    font-weight: 500;
    font-size: 12px;
    font-family: var(--font-sans, "IBM Plex Sans KR", sans-serif);
    letter-spacing: 0.02em;
    text-transform: none;
}

.header h1 {
    font-size: clamp(28px, 5vw, 36px);
    font-weight: 600;
    line-height: 1.2;
    letter-spacing: 0;
    color: var(--text-primary, #fafafa);
    margin-bottom: 8px;
    text-wrap: pretty;
}

.header p {
    color: var(--text-secondary, #b4b4b4);
    font-size: 15px;
    line-height: 1.5;
    overflow-wrap: normal;
    word-break: keep-all;
}

.nowrap {
    white-space: nowrap;
}

.tabs {
    display: flex;
    gap: 10px;
    margin-bottom: var(--space-4, 16px);
    position: relative;
    z-index: 1;
}

.tab {
    flex: 1;
    padding: var(--space-3, 12px);
    background: var(--surface-primary, #ffffff);
    border: 1px solid var(--border-default, #2e2e2e);
    border-radius: 999px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary, #b4b4b4);
    cursor: pointer;
    transition: transform 140ms ease-out, border-color 140ms ease-out, color 140ms ease-out;
}

.tab.active {
    color: var(--accent-primary, #3ecf8e);
    background: rgba(62, 207, 142, 0.12);
    border-color: var(--border-accent, rgba(62, 207, 142, 0.3));
}

.tab:active {
    transform: scale(0.98);
}

.tab-content {
    display: none;
    position: relative;
    z-index: 1;
}

.tab-content.active {
    display: block;
}

.form-hint {
    color: var(--text-tertiary, #898989);
    font-size: 14px;
    line-height: 1.5;
    text-wrap: pretty;
    margin: 0 0 var(--space-3, 12px);
}

.login-code-row {
    display: flex;
    gap: 8px;
    align-items: stretch;
}

.login-code-row input {
    flex: 1;
    margin: 0;
}

.login-code-row .btn-secondary {
    width: auto;
    min-height: 44px;
    height: 44px;
    padding: 0 var(--space-4, 16px);
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    margin: 0;
    border-radius: var(--radius-sm, 6px);
}

.student-roster-list {
    display: grid;
    gap: 8px;
    margin: 0 0 16px;
    max-height: 40vh;
    overflow: auto;
}

.student-roster-list button {
    width: 100%;
    text-align: left;
    margin: 0;
}

.student-roster-list button[aria-pressed="true"] {
    border-color: var(--accent-primary, #3ecf8e);
    box-shadow: inset 0 0 0 1px var(--accent-primary, #3ecf8e);
}

.form-group {
    margin-bottom: var(--space-3, 12px);
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-secondary, #b4b4b4);
    font-weight: 500;
    font-size: 14px;
}

.form-group input,
.form-group select {
    width: 100%;
    border: 1px solid var(--border-default, #2e2e2e);
    border-radius: 6px;
    font-size: 16px;
    outline: none;
    background: var(--surface-canvas, #f3f5f4);
    color: var(--text-primary, #fafafa);
}

.form-group input {
    padding: 0 12px;
    line-height: normal;
}

.form-group select {
    padding: 12px 28px 12px 12px;
    line-height: 1.25;
}

.form-group input::placeholder {
    color: var(--text-tertiary, #898989);
    opacity: 1;
}

.form-group input:focus,
.form-group select:focus {
    border-color: var(--accent-primary, #3ecf8e);
}

.btn {
    width: 100%;
    padding: 8px 32px;
    min-height: 44px;
    background: var(--surface-primary, #ffffff);
    color: var(--text-primary, #fafafa);
    border: 1px solid var(--text-primary, #fafafa);
    border-radius: 999px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: transform 140ms ease-out, border-color 140ms ease-out, color 140ms ease-out;
}

.btn:hover {
    border-color: var(--accent-primary, #3ecf8e);
    color: var(--accent-primary, #3ecf8e);
}

.btn:active {
    transform: scale(0.98);
}

.btn-ghost {
    display: block;
    width: 100%;
    margin: var(--space-1, 4px) 0 0;
    padding: var(--space-3, 12px) var(--space-2, 8px);
    min-height: 44px;
    height: auto;
    background: transparent;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    color: var(--accent-link, #0b8a60);
    font-size: 14px;
    font-weight: 500;
    line-height: 1.4;
    text-align: center;
    cursor: pointer;
    appearance: none;
    overflow-wrap: normal;
    word-break: keep-all;
    transition: color var(--motion-micro, 140ms ease-out), transform var(--motion-micro, 140ms ease-out);
}

.btn-ghost:hover {
    color: var(--accent-hover, #12b37c);
    background: transparent;
    text-decoration: underline;
}

.btn-ghost:active {
    transform: scale(0.98);
}

.btn-ghost:focus-visible {
    box-shadow: var(--focus-ring);
    border-radius: var(--radius-sm, 6px);
}

.error-message {
    background: rgba(240, 113, 120, 0.12);
    color: var(--status-error, #f07178);
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 14px;
    display: none;
    border: 1px solid rgba(240, 113, 120, 0.35);
}

.error-message.show {
    display: block;
}

.success-message {
    background: rgba(62, 207, 142, 0.12);
    color: var(--accent-primary, #3ecf8e);
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 14px;
    display: none;
    border: 1px solid var(--border-accent, rgba(62, 207, 142, 0.3));
}

.success-message.show {
    display: block;
}

.loading {
    display: none;
    text-align: center;
    padding: 20px;
}

.loading.show {
    display: block;
}

.spinner {
    border: 3px solid var(--border-default, #2e2e2e);
    border-top: 3px solid var(--accent-primary, #3ecf8e);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto 10px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.divider {
    display: flex;
    align-items: center;
    text-align: center;
    margin: 20px 0;
    color: var(--text-tertiary, #898989);
}

.divider::before,
.divider::after {
    content: '';
    flex: 1;
    border-bottom: 1px solid var(--border-default, #2e2e2e);
}

.divider span {
    padding: 0 15px;
    font-size: 14px;
}

.btn-google {
    width: 100%;
    padding: 8px 32px;
    min-height: 44px;
    height: auto;
    background: var(--surface-primary, #ffffff);
    color: var(--text-primary, #fafafa);
    border: 1px solid var(--text-primary, #1c211f);
    border-radius: var(--radius-pill, 9999px);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: transform var(--motion-micro, 140ms ease-out), border-color var(--motion-micro, 140ms ease-out), color var(--motion-micro, 140ms ease-out);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin: var(--space-2, 8px) 0 0;
    appearance: none;
}

.btn-google:hover {
    border-color: var(--accent-primary, #3ecf8e);
    color: var(--accent-primary, #3ecf8e);
}

.btn-google:active {
    transform: scale(0.98);
}

.btn-google svg {
    width: 20px;
    height: 20px;
}

.school-search-container {
    position: relative;
}

.school-autocomplete {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--surface-elevated, #ffffff);
    border: 1px solid var(--border-default, #2e2e2e);
    border-top: none;
    border-radius: 0 0 8px 8px;
    max-height: 300px;
    overflow-y: auto;
    z-index: 1000;
    display: none;
}

.school-autocomplete.show {
    display: block;
}

.school-autocomplete-item {
    padding: 12px 15px;
    cursor: pointer;
    border-bottom: 1px solid var(--border-subtle, #e6ece8);
}

.school-autocomplete-item:hover {
    background-color: var(--surface-secondary, #1c1c1c);
}

.school-autocomplete-item:last-child {
    border-bottom: none;
}

.school-autocomplete-item .school-name {
    font-weight: 500;
    color: var(--text-primary, #fafafa);
    margin-bottom: 4px;
}

.school-autocomplete-item .school-info {
    font-size: 12px;
    color: var(--text-tertiary, #898989);
}

.school-autocomplete-loading,
.school-autocomplete-empty {
    padding: 15px;
    text-align: center;
    color: var(--text-tertiary, #898989);
}

@media (max-width: 640px) {
    .container {
        padding: 18px;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    h1 {
        font-size: 26px;
    }
}

.skeleton {
    background: linear-gradient(90deg, #1c1c1c 25%, #2e2e2e 50%, #1c1c1c 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: 4px;
}

.skeleton-text {
    height: 1em;
    margin-bottom: 0.5em;
}

.skeleton-block {
    height: 100px;
    width: 100%;
}

@keyframes skeleton-loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.toast-container {
    padding: 10px;
}

.toast {
    display: flex;
    align-items: center;
    min-width: 250px;
    font-size: 14px;
    background: var(--surface-elevated, #ffffff);
    border: 1px solid var(--border-default, #2e2e2e);
    color: var(--text-primary, #fafafa);
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeOut {
    from { opacity: 1; transform: translateY(0); }
    to { opacity: 0; transform: translateY(8px); }
}

@media (prefers-reduced-motion: reduce) {
    .spinner,
    .skeleton {
        animation: none;
    }
}
