/* ============================================================
   Global reset & base
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --clr-bg:        #f0f4f8;
  --clr-surface:   #ffffff;
  --clr-primary:   #4f6ef7;
  --clr-primary-h: #3b59e8;
  --clr-danger:    #e74c3c;
  --clr-success:   #27ae60;
  --clr-border:    #d1d9e6;
  --clr-text:      #1a1a2e;
  --clr-muted:     #6b7280;
  --radius:        12px;
  --shadow:        0 4px 24px rgba(0,0,0,.10);
  --font:          'Segoe UI', system-ui, sans-serif;
}

html { font-size: 16px; }
body { background: var(--clr-bg); color: var(--clr-text); font-family: var(--font); min-height: 100vh; display: flex; flex-direction: column; }
a { color: var(--clr-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.auth-wrapper { flex: 1; display: flex; align-items: center; justify-content: center; padding: 2rem 1rem; }
.auth-card { background: var(--clr-surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 2.5rem 2rem; width: 100%; max-width: 440px; }
.auth-card h1 { font-size: 1.6rem; font-weight: 700; margin-bottom: .25rem; }
.auth-card .subtitle { color: var(--clr-muted); font-size: .875rem; margin-bottom: 1.75rem; }

.form-group { margin-bottom: 1.1rem; }
label { display: block; font-size: .85rem; font-weight: 600; margin-bottom: .35rem; }

input[type="text"], input[type="email"], input[type="password"], input[type="tel"], select, textarea {
  width: 100%; padding: .65rem .9rem; border: 1.5px solid var(--clr-border); border-radius: 8px;
  font-size: .95rem; font-family: inherit; transition: border-color .2s; background: #fafbfc; color: var(--clr-text);
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--clr-primary); background: #fff; }

.input-row { display: flex; gap: .5rem; }
.input-row input { flex: 1; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: .45rem; padding: .7rem 1.3rem; border: none; border-radius: 8px; font-size: .95rem; font-weight: 600; cursor: pointer; transition: background .18s, transform .1s; font-family: inherit; text-decoration: none; }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--clr-primary); color: #fff; }
.btn-primary:hover { background: var(--clr-primary-h); }
.btn-outline { background: transparent; color: var(--clr-primary); border: 1.5px solid var(--clr-primary); }
.btn-outline:hover { background: #eef1ff; }
.btn-ghost { background: transparent; color: var(--clr-muted); border: 1.5px solid var(--clr-border); }
.btn-ghost:hover { background: var(--clr-bg); color: var(--clr-text); }
.btn-danger { background: var(--clr-danger); color: #fff; }
.btn-full { width: 100%; }
.btn-passkey { background: #1a1a2e; color: #fff; }
.btn-passkey:hover { background: #2d2d4e; }

.divider { display: flex; align-items: center; gap: .75rem; margin: 1.25rem 0; color: var(--clr-muted); font-size: .8rem; }
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--clr-border); }

.alert { padding: .75rem 1rem; border-radius: 8px; font-size: .875rem; margin-bottom: 1rem; }
.alert-error   { background: #fde8e8; color: #991b1b; border: 1px solid #fca5a5; }
.alert-success { background: #d1fae5; color: #065f46; border: 1px solid #6ee7b7; }
.alert-info    { background: #dbeafe; color: #1e40af; border: 1px solid #93c5fd; }

.strength-bar { height: 4px; border-radius: 4px; background: var(--clr-border); margin-top: .35rem; overflow: hidden; }
.strength-bar-fill { height: 100%; width: 0; border-radius: 4px; transition: width .25s, background .25s; }
.strength-label { font-size: .75rem; color: var(--clr-muted); margin-top: .25rem; }

.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: flex; align-items: center; justify-content: center; z-index: 1000; opacity: 0; pointer-events: none; transition: opacity .2s; }
.modal-backdrop.open { opacity: 1; pointer-events: all; }
.modal-box { background: var(--clr-surface); border-radius: var(--radius); padding: 2rem; max-width: 350px; width: 90%; text-align: center; box-shadow: 0 20px 60px rgba(0,0,0,.25); transform: translateY(16px); transition: transform .2s; }
.modal-backdrop.open .modal-box { transform: translateY(0); }
.modal-box h2 { font-size: 1.1rem; margin-bottom: .5rem; }
.modal-box p  { font-size: .85rem; color: var(--clr-muted); margin-bottom: 1rem; }

.dash-nav { background: var(--clr-surface); box-shadow: 0 2px 8px rgba(0,0,0,.07); padding: 0 1.5rem; display: flex; align-items: center; gap: 1.25rem; height: 60px; }
.dash-nav .brand { font-weight: 700; font-size: 1.1rem; flex: 1; }
.dash-nav .nav-user { font-size: .85rem; color: var(--clr-muted); }

.dash-main { max-width: 780px; margin: 2.5rem auto; padding: 0 1rem; width: 100%; }
.dash-section { background: var(--clr-surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.75rem 1.5rem; margin-bottom: 1.75rem; }
.dash-section h2 { font-size: 1.1rem; font-weight: 700; padding-bottom: .65rem; border-bottom: 1.5px solid var(--clr-border); }

/* ウェルカムヘッダー */
.dash-welcome { background: linear-gradient(135deg, #4f6ef7 0%, #7c3aed 100%); border-radius: var(--radius); padding: 1.5rem 1.75rem; margin-bottom: 1.75rem; display: flex; align-items: center; justify-content: space-between; gap: 1rem; box-shadow: var(--shadow); }
.dash-welcome-inner { display: flex; align-items: center; gap: 1rem; }
.dash-welcome-avatar { width: 52px; height: 52px; border-radius: 50%; background: rgba(255,255,255,.25); color: #fff; font-size: 1.5rem; font-weight: 700; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.dash-welcome-label { font-size: .8rem; color: rgba(255,255,255,.75); margin-bottom: .1rem; }
.dash-welcome-name { font-size: 1.25rem; font-weight: 700; color: #fff; }
.dash-badge { background: rgba(255,255,255,.2); color: #fff; font-size: .78rem; font-weight: 600; padding: .35rem .85rem; border-radius: 999px; border: 1px solid rgba(255,255,255,.35); white-space: nowrap; }

/* セクションヘッダー（タイトル + ボタン横並び） */
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.25rem; padding-bottom: .65rem; border-bottom: 1.5px solid var(--clr-border); }
.section-header h2 { border: none; padding: 0; margin: 0; }
.btn-sm { padding: .35rem .85rem; font-size: .82rem; }

/* 情報表示グリッド（ビューモード） */
.info-grid { display: flex; flex-direction: column; gap: .1rem; }
.info-row { display: flex; align-items: baseline; gap: 1rem; padding: .65rem 0; border-bottom: 1px solid var(--clr-border); }
.info-row:last-child { border-bottom: none; }
.info-label { font-size: .8rem; font-weight: 600; color: var(--clr-muted); min-width: 120px; flex-shrink: 0; }
.info-value { font-size: .95rem; color: var(--clr-text); }

/* 編集フォームのボタン行 */
.form-actions { display: flex; gap: .75rem; margin-top: 1.25rem; }

/* Activation code display box */
.activation-code-box { display: flex; align-items: center; gap: 1rem; background: var(--clr-bg); border: 1.5px solid var(--clr-border); border-radius: var(--radius); padding: .85rem 1.1rem; max-width: 480px; }
.activation-code-text { font-family: 'Courier New', Courier, monospace; font-size: 1.1rem; font-weight: 700; letter-spacing: .12em; color: var(--clr-text); flex: 1; word-break: break-all; }
.act-code-meta { font-size: .8rem; color: var(--clr-muted); margin-top: .55rem; }

.code-status { display: flex; align-items: center; gap: .55rem; margin-top: .55rem; flex-wrap: wrap; }
.badge { display: inline-flex; align-items: center; justify-content: center; padding: .18rem .6rem; border-radius: 999px; font-size: .72rem; font-weight: 800; letter-spacing: .02em; border: 1px solid transparent; white-space: nowrap; }
.badge-success { background: #d1fae5; color: #065f46; border-color: #6ee7b7; }
.badge-danger  { background: #fde8e8; color: #991b1b; border-color: #fca5a5; }
.badge-warning { background: #fffbeb; color: #92400e; border-color: #fcd34d; }

.passkey-list { list-style: none; }
.passkey-item { display: flex; align-items: center; gap: .75rem; padding: .65rem 0; border-bottom: 1px solid var(--clr-border); }
.passkey-item:last-child { border-bottom: none; }
.passkey-icon { font-size: 1.4rem; }
.passkey-info { flex: 1; }
.passkey-info strong { display: block; font-size: .9rem; }
.passkey-info span   { font-size: .75rem; color: var(--clr-muted); }

.spinner { width: 20px; height: 20px; border: 2.5px solid rgba(255,255,255,.4); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 480px) { .auth-card { padding: 1.75rem 1.25rem; } }
