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

:root {
    --sand: #c8b99a;
    --stone: #8a7660;
    --dark: #2a2118;
    --cream: #f5f0e8;
    --gold: #b89a5e;
    --white: #fdfaf5;
}

body {
    min-height: 100vh;
    background-color: #1e1710;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='80' height='80' viewBox='0 0 80 80'%3E%3Ccircle fill='none' stroke='%233b5a7a' stroke-width='1' opacity='.25' cx='40' cy='40' r='18'/%3E%3Ccircle fill='none' stroke='%233b5a7a' stroke-width='1' opacity='.25' cx='40' cy='40' r='10'/%3E%3Cpath fill='none' stroke='%233b5a7a' stroke-width='1' opacity='.15' d='M22 40h36M40 22v36M28.7 28.7l22.6 22.6M51.3 28.7L28.7 51.3'/%3E%3Ccircle fill='none' stroke='%233b5a7a' stroke-width='1' opacity='.25' cx='0' cy='0' r='8'/%3E%3Ccircle fill='none' stroke='%233b5a7a' stroke-width='1' opacity='.25' cx='80' cy='0' r='8'/%3E%3Ccircle fill='none' stroke='%233b5a7a' stroke-width='1' opacity='.25' cx='0' cy='80' r='8'/%3E%3Ccircle fill='none' stroke='%233b5a7a' stroke-width='1' opacity='.25' cx='80' cy='80' r='8'/%3E%3Crect fill='none' stroke='%233b5a7a' stroke-width='1' opacity='.15' x='32' y='32' width='16' height='16' transform='rotate(45 40 40)'/%3E%3C/svg%3E");
    background-size: 80px 80px;
    font-family: "Noto Serif JP", "Cormorant Garamond", Georgia, serif;
    display: flex;
    align-items: center;
    justify-content: center;
}

.card {
    width: 600px;
    background: var(--cream);
    padding: 52px 44px 44px;
    position: relative;
    animation: fadeUp 0.5s cubic-bezier(0.22, 1, 0.36, 1) both;
}

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

.card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--gold), var(--stone), var(--gold));
}

.title {
    font-family: "Cormorant Garamond", "Noto Serif JP", Georgia, serif;
    font-size: 32px;
    font-weight: 600;
    color: var(--dark);
    letter-spacing: 0.02em;
    margin-bottom: 8px;
}

.subtitle {
    font-size: 13px;
    color: var(--stone);
    margin-bottom: 32px;
}

/* Error */
.error-banner {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(185, 28, 28, 0.08);
    border: 1px solid rgba(185, 28, 28, 0.2);
    padding: 0.75rem 1rem;
    margin-bottom: 1.5rem;
}

.error-banner svg {
    width: 16px;
    height: 16px;
    color: #b91c1c;
    flex-shrink: 0;
}

.error-banner span {
    font-size: 13px;
    color: #991b1b;
}

/* Success */
.success-banner {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(22, 101, 52, 0.08);
    border: 1px solid rgba(22, 101, 52, 0.2);
    padding: 0.75rem 1rem;
    margin-bottom: 1.5rem;
}

.success-banner span {
    font-size: 13px;
    color: #166534;
}

/* Form */
.form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.field label {
    font-size: 11px;
    font-weight: 500;
    color: var(--stone);
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.field-error {
    font-size: 13px;
    color: #991b1b;
    margin-top: -4px;
}

/* Password toggle */
.password-wrapper {
    position: relative;
}

.password-wrapper input {
    padding-right: 44px;
}

.password-toggle {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    color: var(--stone);
    transition: color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.password-toggle:hover {
    color: var(--dark);
}

.password-toggle svg {
    width: 20px;
    height: 20px;
}

.field input {
    width: 100%;
    padding: 12px 14px;
    background: var(--white);
    border: 1px solid rgba(138, 118, 96, 0.2);
    border-bottom: 1.5px solid var(--sand);
    color: var(--dark);
    font-family: inherit;
    font-size: 14px;
    outline: none;
    transition: border-color 0.25s, box-shadow 0.25s;
    -webkit-appearance: none;
}

.field input::placeholder {
    color: rgba(138, 118, 96, 0.4);
}

.field input:hover {
    border-color: rgba(138, 118, 96, 0.35);
}

.field input:focus {
    border-color: rgba(138, 118, 96, 0.4);
    border-bottom-color: var(--gold);
    box-shadow: 0 3px 10px rgba(184, 154, 94, 0.08);
}

/* Buttons */
.btn {
    width: 100%;
    padding: 13px;
    border: none;
    font-family: inherit;
    font-size: 14px;
    letter-spacing: 0.05em;
    cursor: pointer;
    transition: background 0.25s, border-color 0.25s;
    text-decoration: none;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--dark);
    color: var(--cream);
    font-weight: 500;
}

.btn:hover {
    background: #3d2f1e;
}

.btn:active {
    background: #1a140e;
}

.btn:focus-visible {
    outline: 2px solid var(--gold);
    outline-offset: 2px;
}

.btn-secondary {
    background: var(--white);
    color: var(--dark);
    border: 1px solid rgba(138, 118, 96, 0.3);
    font-weight: 400;
}

.btn-secondary:hover {
    background: var(--cream);
    border-color: var(--gold);
}

.btn-secondary:active {
    background: #ede7db;
}

.btn-secondary:focus-visible {
    outline-color: var(--gold);
}

/* Passkey button */
.btn-passkey {
    background: var(--white);
    color: var(--dark);
    border: 1px solid rgba(138, 118, 96, 0.3);
    font-weight: 400;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.btn-passkey:hover {
    background: var(--cream);
    border-color: var(--gold);
}

.btn-passkey svg {
    width: 17px;
    height: 17px;
    flex-shrink: 0;
}

/* Divider */
.divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 18px 0;
}

.divider::before, .divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: rgba(138, 118, 96, 0.2);
}

.divider span {
    font-size: 11px;
    color: rgba(138, 118, 96, 0.5);
    letter-spacing: 0.1em;
}

/* Register / footer links */
.register {
    margin-top: 24px;
    text-align: center;
    font-size: 13px;
    color: var(--stone);
}

.register a {
    color: var(--dark);
    text-decoration: none;
    border-bottom: 1px solid var(--sand);
    padding-bottom: 1px;
    transition: color 0.2s, border-color 0.2s;
}

.register a:hover {
    color: var(--gold);
    border-bottom-color: var(--gold);
}

/* User info */
.user-info {
    font-size: 11px;
    font-weight: 500;
    color: var(--stone);
    letter-spacing: 0.1em;
    text-transform: uppercase;
    margin-bottom: 8px;
}

.username {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--dark);
    letter-spacing: -0.01em;
}

/* App list */
.app-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.app-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    background: var(--white);
    border: 1px solid rgba(138, 118, 96, 0.15);
    text-decoration: none;
    color: var(--dark);
    transition: border-color 0.15s, background 0.15s;
}

.app-card:hover {
    border-color: var(--gold);
    background: #faf7f2;
}

.app-name {
    font-size: 1rem;
    font-weight: 500;
}

.app-card svg {
    color: var(--stone);
    flex-shrink: 0;
    transition: color 0.15s;
}

.app-card:hover svg {
    color: var(--gold);
}

.no-clients {
    font-size: 0.875rem;
    color: var(--stone);
    margin-bottom: 1rem;
}

/* Error page */
.error-code {
    font-family: "Cormorant Garamond", Georgia, serif;
    font-size: 6rem;
    font-weight: 700;
    font-style: italic;
    color: rgba(184, 154, 94, 0.25);
    line-height: 1;
    margin-bottom: 0.25rem;
    letter-spacing: -0.02em;
}

.error-detail {
    background: var(--white);
    border: 1px solid rgba(138, 118, 96, 0.15);
    padding: 1.25rem 1.5rem;
    margin-bottom: 2rem;
}

.error-detail p {
    font-size: 0.875rem;
    color: var(--stone);
    line-height: 1.6;
}

/* Consent page */
.consent-description {
    font-size: 15px;
    color: var(--stone);
    line-height: 1.6;
    margin-bottom: 2rem;
}

.consent-description .highlight {
    color: var(--gold);
    font-weight: 600;
}

.consent-description .principal {
    color: var(--dark);
    font-weight: 600;
}

.scope-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 2rem;
}

.scope-item {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    padding: 1rem 1.25rem;
    background: var(--white);
    border: 1px solid rgba(138, 118, 96, 0.15);
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}

.scope-item:hover {
    border-color: var(--gold);
    background: #faf7f2;
}

.scope-item input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border: 1.5px solid var(--sand);
    background: var(--white);
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.2s, border-color 0.2s;
    position: relative;
}

.scope-item input[type="checkbox"]:checked {
    background: var(--gold);
    border-color: var(--gold);
}

.scope-item input[type="checkbox"]:checked::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 5px;
    width: 5px;
    height: 9px;
    border-right: 1.5px solid white;
    border-bottom: 1.5px solid white;
    transform: rotate(45deg);
}

.scope-item label {
    font-size: 1rem;
    font-weight: 500;
    color: var(--dark);
    cursor: pointer;
    flex: 1;
    text-transform: none;
    letter-spacing: normal;
}

.consent-actions {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.consent-footer {
    margin-top: 2rem;
    font-size: 13px;
    color: var(--stone);
    line-height: 1.6;
}

.consent-footer a {
    color: var(--dark);
    text-decoration: none;
    border-bottom: 1px solid var(--sand);
    padding-bottom: 1px;
    transition: color 0.2s, border-color 0.2s;
}

.consent-footer a:hover {
    color: var(--gold);
    border-bottom-color: var(--gold);
}

/* Passkeys management */
.passkeys-card {
    background: var(--white);
    border: 1px solid rgba(138, 118, 96, 0.15);
    overflow: hidden;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid rgba(138, 118, 96, 0.12);
}

.card-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--dark);
}

.btn-add {
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    color: var(--gold);
    background: transparent;
    border: 1px solid rgba(184, 154, 94, 0.3);
    padding: 0.5rem 1rem;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}

.btn-add:hover {
    background: rgba(184, 154, 94, 0.08);
    border-color: var(--gold);
}

.passkey-list {
    display: flex;
    flex-direction: column;
}

.passkey-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid rgba(138, 118, 96, 0.08);
}

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

.passkey-info {
    flex: 1;
}

.passkey-name {
    font-size: 15px;
    font-weight: 500;
    color: var(--dark);
    margin-bottom: 0.25rem;
}

.passkey-meta {
    font-size: 12px;
    color: var(--stone);
}

.passkey-actions {
    flex-shrink: 0;
    margin-left: 1rem;
}

.action-btn {
    font-family: inherit;
    font-size: 12px;
    font-weight: 500;
    color: #b91c1c;
    background: transparent;
    border: 1px solid rgba(185, 28, 28, 0.2);
    padding: 0.375rem 0.75rem;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}

.action-btn:hover {
    background: rgba(185, 28, 28, 0.06);
    border-color: rgba(185, 28, 28, 0.35);
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    padding: 2.5rem 1.5rem;
}

.empty-state-text {
    font-size: 0.875rem;
    color: var(--stone);
}

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(30, 23, 16, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.modal {
    background: var(--cream);
    border: 1px solid rgba(138, 118, 96, 0.2);
    width: 100%;
    max-width: 420px;
    padding: 1.5rem;
    position: relative;
}

.modal::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--gold), var(--stone), var(--gold));
}

.modal-header {
    margin-bottom: 1.5rem;
}

.modal-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--dark);
}

.modal-body {
    margin-bottom: 1.5rem;
}

.modal-body .field input,
.modal-body .form-input {
    width: 100%;
    padding: 12px 14px;
    font-size: 14px;
    font-family: inherit;
    color: var(--dark);
    background: var(--white);
    border: 1px solid rgba(138, 118, 96, 0.2);
    border-bottom: 1.5px solid var(--sand);
    transition: border-color 0.25s, box-shadow 0.25s;
    outline: none;
}

.modal-body .field input:focus,
.modal-body .form-input:focus {
    border-color: rgba(138, 118, 96, 0.4);
    border-bottom-color: var(--gold);
    box-shadow: 0 3px 10px rgba(184, 154, 94, 0.08);
}

.modal-footer {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
}
