:root {
    color-scheme: light;
    --light: #d6c2a8;
    --dark: #3f3630;
    --page: #f3eee6;
    --surface: #faf7f2;
    --field: #fffdf9;
    --muted: #75675b;
    --line: #cdbda9;
    --radius: 12px;
    font-size: 16px;
}
* {
    box-sizing: border-box;
}
body {
    margin: 0;
    min-height: 100vh;
    min-height: 100dvh;
    display: grid;
    place-items: center;
    padding: 24px;
    background: var(--surface);
    color: var(--dark);
    font-family: "Segoe UI", Arial, sans-serif;
    line-height: 1.4;
}
button,
input {
    font: inherit;
}
button {
    cursor: pointer;
    touch-action: manipulation;
}
button:focus-visible,
a:focus-visible,
input:focus-visible {
    outline: 2px solid var(--dark);
    outline-offset: 3px;
}
.svg-definitions {
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;
    pointer-events: none;
}
.form-stack {
    display: flex;
    flex-direction: column;
    gap: 7px;
}
.form-stack > label {
    margin-top: 7px;
    font-size: 13px;
    font-weight: 650;
}
input:not([type="radio"]):not([type="hidden"]) {
    width: 100%;
    min-width: 0;
    min-height: 46px;
    padding: 11px 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--field);
    color: var(--dark);
    font-size: 16px;
    caret-color: var(--dark);
}
input:not([type="radio"]):not([type="hidden"]):focus {
    border-color: var(--dark);
}
.password-field {
    display: flex;
    align-items: center;
    min-width: 0;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--field);
}
.password-field:focus-within {
    outline: 2px solid var(--dark);
    outline-offset: 3px;
}
.password-field input:not([type="hidden"]) {
    flex: 1;
    border: none;
    background: transparent;
}
.password-field input:focus-visible {
    outline: none;
}
.button,
.eye-button {
    border: 1px solid var(--dark);
    border-radius: var(--radius);
    background: var(--dark);
    color: #faf7f2;
    transition:
        background-color 160ms ease,
        box-shadow 160ms ease;
}
.button {
    width: 100%;
    min-height: 44px;
    padding: 11px 12px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.045em;
    white-space: normal;
    overflow-wrap: anywhere;
}
.button:hover:not(:disabled) {
    background: #57483c;
    box-shadow: 0 3px 8px #3f363018;
}
.button:active:not(:disabled) {
    box-shadow: none;
}
.button:disabled {
    cursor: not-allowed;
    border-color: var(--line);
    background: #e1d6c8;
    color: var(--muted);
}
.eye-button {
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    margin-right: 3px;
    padding: 0;
    border-color: transparent;
    background: transparent;
    color: var(--muted);
}
.eye-button:hover,
.eye-button[aria-pressed="true"] {
    background: #eee5d9;
    color: var(--dark);
}
.eye-button svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.7;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.dialog-actions > [data-close] {
    background: transparent;
    border-color: var(--line);
    color: var(--dark);
}
.dialog-actions > [data-close]:hover { background: #e9ddcd; }
.error-message {
    margin: 7px 0 0;
    padding: 10px 12px;
    border-left: 3px solid #8c4935;
    border-radius: 6px;
    background: #f2e2d7;
    color: #763a2c;
    font-size: 13px;
    overflow-wrap: anywhere;
}
.form-note {
    margin: 10px 0;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.6;
    overflow-wrap: anywhere;
}
.form-note:empty {
    display: none;
}
/* Popup'lar kendi içinde kayar; native dialog odak ve Escape davranışını korur. */
dialog {
    width: min(480px, calc(100vw - 32px));
    max-width: calc(100vw - 32px);
    max-height: calc(100vh - 32px);
    max-height: calc(100dvh - 32px);
    margin: auto;
    padding: clamp(20px, 3vmin, 32px);
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: var(--line) var(--surface);
    border: 1px solid var(--line);
    border-radius: 20px;
    background: var(--surface);
    color: var(--dark);
    box-shadow: 0 24px 80px #241d1840;
}
dialog::backdrop {
    background: #30282199;
    backdrop-filter: blur(5px);
}
body:has(dialog[open]) {
    overflow: hidden;
}
.dialog-header {
    margin-bottom: 18px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--line);
}
.dialog-header h2 {
    margin: 0;
    font-size: 25px;
    font-weight: 650;
    line-height: 1.2;
    letter-spacing: -0.035em;
    overflow-wrap: anywhere;
}
.dialog-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 9px;
    margin-top: 16px;
}
.dialog-actions .button {
    flex: 1 1 150px;
}
.role-fieldset {
    min-width: 0;
    margin: 0 0 4px;
    padding: 0;
    border: none;
}
.role-fieldset legend {
    margin-bottom: 8px;
    font-size: 13px;
    font-weight: 650;
}
.role-options {
    display: flex;
    flex-wrap: wrap;
    gap: 9px;
}
.role-option {
    flex: 1 1 120px;
    display: flex;
    align-items: center;
    gap: 9px;
    min-height: 44px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--field);
    font-size: 14px;
    cursor: pointer;
}
.role-option:hover,
.role-option:has(input:checked) {
    background: #eee3d4;
}
.role-option:has(input:checked) {
    border-color: var(--dark);
}
input[type="radio"] {
    width: 16px;
    height: 16px;
    margin: 0;
    accent-color: var(--dark);
}
#teacher-invite-field[hidden] {
    display: none;
}
.verification-box {
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--line);
}
/* Login yerleşimi: iki kare, ortak zemin; yatayda 2:1, dikeyde 1:2. */
.login-card {
    width: min(1120px, 100%, calc((100dvh - 48px) * 2));
    aspect-ratio: 2 / 1;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    container-type: inline-size;
}
.visual-panel,
.form-panel {
    --unit: 0.5cqw;
    min-width: 0;
    min-height: 0;
    padding: 14% 6% 10%;
}
.visual-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
}
.scene {
    position: relative;
    width: 100%;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}
.hedgehog {
    position: absolute;
    width: 100%;
    height: 125%;
    top: -11.5%;
    left: 0;
    object-fit: contain;
    user-select: none;
    pointer-events: none;
}
.brand-heading {
    margin: 0;
    width: 100%;
    font-size: calc(4.15 * var(--unit));
    line-height: 1.3;
    font-weight: 700;
    letter-spacing: -0.035em;
}
.brand {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: calc(1.6 * var(--unit));
    color: var(--dark);
    text-decoration: none;
    white-space: nowrap;
}
.brand-logo {
    width: calc(5.5 * var(--unit));
    height: calc(5.5 * var(--unit));
    flex: 0 0 auto;
}
.welcome { color: #6b5032; }
.form-panel { padding-inline: 12%; }
.form-panel > .form-stack {
    height: 100%;
    gap: calc(1.5 * var(--unit));
}
.form-panel .form-stack > label {
    margin: 0;
    font-size: calc(3.4 * var(--unit));
    font-weight: 400;
    line-height: 1.2;
}
.form-panel label[for="login-password"] {
    margin-top: calc(3.5 * var(--unit));
}
.form-panel input:not([type="hidden"]),
.form-panel .password-field {
    min-height: 0;
    height: calc(9 * var(--unit));
    flex-shrink: 0;
    background: transparent;
    border-radius: calc(1.2 * var(--unit));
}
.form-panel input:not([type="hidden"]) {
    padding: calc(1.5 * var(--unit)) calc(2 * var(--unit));
    font-size: max(16px, calc(3.4 * var(--unit)));
}
.form-panel .password-field input {
    height: 100%;
}
.form-panel .eye-button {
    width: calc(7 * var(--unit));
    height: calc(7 * var(--unit));
    margin-right: calc(0.5 * var(--unit));
}
.form-panel .eye-button svg {
    width: calc(4 * var(--unit));
    height: calc(4 * var(--unit));
}
.text-button {
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--muted);
    font: inherit;
    font-size: calc(3.3 * var(--unit));
    line-height: 1.3;
    white-space: nowrap;
}
.text-button:hover { color: var(--dark); text-decoration: underline; }
.forgot-link { align-self: flex-end; }
.login-actions {
    display: grid;
    flex: 1;
    min-height: 0;
    margin-top: calc(2 * var(--unit));
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: 1fr 1fr calc(5.5 * var(--unit));
    gap: calc(2 * var(--unit));
}
.login-actions > .button {
    grid-column: 1 / -1;
    min-height: 0;
    padding: calc(1 * var(--unit));
    font-size: calc(3.3 * var(--unit));
    letter-spacing: 0;
    white-space: nowrap;
    border-radius: calc(1.2 * var(--unit));
}
.login-actions > .text-button {
    text-align: left;
    align-self: center;
}
.login-actions > .text-button:last-child { text-align: right; }
.login-actions > [form="guest-login-form"] {
    background: var(--light);
    border-color: var(--light);
    color: var(--dark);
}
.login-actions > [form="guest-login-form"]:hover { background: #e9ddcd; }
.form-panel > .form-note { margin: 0 0 8px; }
.form-panel:has(> .form-note) { display: flex; flex-direction: column; }
.form-panel:has(> .form-note) > .form-stack { flex: 1; min-height: 0; }
@media (orientation: portrait) {
    body { padding: 4px; }
    .login-card {
        width: min(100%, calc((100dvh - 8px) / 2));
        aspect-ratio: 1 / 2;
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: repeat(2, minmax(0, 1fr));
    }
    .visual-panel, .form-panel { --unit: 1cqw; }
    .visual-panel { padding-top: 8%; padding-bottom: 6%; }
    .form-panel { padding-top: 6%; padding-bottom: 10%; }
}
@media (orientation: landscape) and (max-height: 600px) {
    body { padding: 8px; }
    .login-card { width: min(1120px, 100%, calc((100dvh - 16px) * 2)); }
}
@media (prefers-reduced-motion: reduce) {
    .button,
    .eye-button {
        transition: none;
    }
}
