* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* ── iOS: disable pinch/double-tap zoom, prevent input auto-zoom ── */
body {
  touch-action: manipulation;
}
input, select, textarea {
  font-size: max(16px, 1em);
}

/* ── iOS: disable long-press context menu and drag on links/images ── */
a, img, button {
  -webkit-touch-callout: none;
  -webkit-user-drag: none;
  user-drag: none;
}
* {
  -webkit-user-select: none;
  user-select: none;
}
input, textarea, [contenteditable] {
  -webkit-user-select: text;
  user-select: text;
}

button, a, [role="button"] { touch-action: manipulation; }

:root {
  --bg-page:       #F5F5F7;
  --bg-card:       #ffffff;
  --bg-input:      #FAFAFA;
  --bg-subtle:     #F5F5F7;
  --border:        #E0E0E0;
  --border-input:  #D0D0D0;
  --text-primary:  #1C1C1E;
  --text-secondary:#888888;
  --text-tertiary: #C0C0C0;
  --text-label:    #555555;
  --btn-bg:        #1C1C1E;
  --btn-color:     #ffffff;
}

html { font-size: 106.25%; } /* 17px base — scales with system accessibility settings */



[data-theme="dark"] {
  --bg-page:       #111113;
  --bg-card:       #1C1C1E;
  --bg-input:      #2C2C2E;
  --bg-subtle:     #2C2C2E;
  --border:        #3A3A3C;
  --border-input:  #3A3A3C;
  --text-primary:  #F5F5F7;
  --text-secondary:#8E8E93;
  --text-tertiary: #48484A;
  --text-label:    #AEAEB2;
  --btn-bg:        #F5F5F7;
  --btn-color:     #1C1C1E;
}

@media (prefers-color-scheme: dark) {
  [data-theme-mode="auto"] {
    --bg-page:       #111113;
    --bg-card:       #1C1C1E;
    --bg-input:      #2C2C2E;
    --bg-subtle:     #2C2C2E;
    --border:        #3A3A3C;
    --border-input:  #3A3A3C;
    --text-primary:  #F5F5F7;
    --text-secondary:#8E8E93;
    --text-tertiary: #48484A;
    --text-label:    #AEAEB2;
    --btn-bg:        #F5F5F7;
    --btn-color:     #1C1C1E;
  }
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg-page);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  padding-bottom: max(1rem, env(safe-area-inset-bottom));
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  transition: background 0.2s ease;
}

.auth-container {
  width: 100%;
  max-width: 400px;
  margin: auto;
}

.auth-card .lang-wrap {
  position: absolute;
  top: calc(1.25rem - 3px);
  inset-inline-end: calc(1.25rem + 64px + 12px);
}

.auth-card {
  background: var(--bg-card);
  border-radius: 16px;
  padding: 2.5rem 2rem;
  border: 0.5px solid var(--border);
  transition: background 0.2s ease, border-color 0.2s ease;
  position: relative;
}

.theme-icon--sun  { display: block; }
.theme-icon--moon { display: none;  }
.theme-icon--auto { display: none;  }
[data-theme="dark"] .theme-icon--sun  { display: none;  }
[data-theme="dark"] .theme-icon--moon { display: block; }
[data-theme-mode="auto"] .theme-icon--sun  { display: none;  }
[data-theme-mode="auto"] .theme-icon--moon { display: none;  }
[data-theme-mode="auto"] .theme-icon--auto { display: block; }

.settings-hub-row {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 14px;
  border-radius: 12px;
  border: 0.5px solid var(--border);
  background: var(--bg-subtle);
  color: var(--text-primary);
  font-size: 0.875rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s ease, border-color 0.15s ease;
  box-sizing: border-box;
}

.settings-hub-row:hover { background: var(--border); }

.settings-hub-icon {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  border: 0.5px solid var(--border);
  background: var(--bg-card);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--text-secondary);
}

.settings-hub-label { flex: 1; }

.theme-switch {
  position: absolute;
  top: 1.25rem;
  inset-inline-end: 1.25rem;
  width: 64px;
  height: 26px;
  background: #D0D0D0;
  border-radius: 100px;
  cursor: pointer;
  transition: background 0.2s ease;
}

[data-theme="dark"] .theme-switch {
  background: #F5F5F7;
}

.theme-switch-knob {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s ease;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

[data-theme="dark"] .theme-switch-knob {
  transform: translateX(38px);
  background: #1C1C1E;
}

.knob-icon {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.15s ease;
  line-height: 0;
}

.knob-icon--sun  { color: #888; opacity: 1; }
.knob-icon--moon { color: #888; opacity: 0; }
.knob-icon--auto { color: #888; opacity: 0; }

[data-theme="dark"] .knob-icon--sun  { opacity: 0; }
[data-theme="dark"] .knob-icon--moon { opacity: 1; }

[data-theme-mode="auto"] .theme-switch { background: linear-gradient(90deg, #D0D0D0 0%, #F5F5F7 100%); }
[data-theme-mode="auto"] .theme-switch-knob { transform: translateX(19px); }
[data-theme-mode="auto"] .knob-icon--sun  { opacity: 0; }
[data-theme-mode="auto"] .knob-icon--moon { opacity: 0; }
[data-theme-mode="auto"] .knob-icon--auto { opacity: 1; }

.theme-switch-icon {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 0;
}

.theme-switch-icon--sun {
  left: 6px;
  color: #888;
}

.theme-switch-icon--moon {
  right: 5px;
  color: #888;
}

.app-logo {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: 2rem;
}


.tab-row {
  display: flex;
  gap: 4px;
  background: var(--bg-subtle);
  border-radius: 10px;
  padding: 3px;
  margin-bottom: 1.75rem;
}

.tab {
  flex: 1;
  height: 34px;
  border-radius: 8px;
  border: none;
  background: transparent;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: inherit;
}

.tab.active {
  background: var(--bg-card);
  color: var(--text-primary);
  border: 0.5px solid var(--border);
}

.form-title {
  font-size: 1.375rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.form-sub {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-bottom: 1.75rem;
  line-height: 1.5;
}

.field-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-label);
  margin-bottom: 6px;
  letter-spacing: 0.02em;
}

.field-input {
  width: 100%;
  height: 46px;
  border: 0.5px solid var(--border-input);
  border-radius: 10px;
  background: var(--bg-input);
  padding: 0 14px;
  font-size: 1rem;
  color: var(--text-primary);
  outline: none;
  margin-bottom: 1rem;
  transition: border-color 0.15s ease, background 0.15s ease;
  font-family: inherit;
}

.field-input:focus {
  border-color: var(--text-primary);
  background: var(--bg-card);
}

.field-input::placeholder {
  color: var(--text-tertiary);
}

.error-msg {
  font-size: 0.8125rem;
  color: #E24B4A;
  margin-bottom: 0.75rem;
  min-height: 18px;
}

.btn-primary {
  width: 100%;
  height: 48px;
  background: var(--btn-bg);
  color: var(--btn-color);
  border: none;
  border-radius: 10px;
  font-size: 0.9375rem;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.15s ease;
  font-family: inherit;
}

.btn-primary:hover { opacity: 0.85; }
.btn-primary:active { opacity: 0.7; }

.divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 1.25rem 0;
}

.divider-line {
  flex: 1;
  height: 0.5px;
  background: var(--border);
}

.divider-text {
  font-size: 0.75rem;
  color: var(--text-tertiary);
}

.btn-secondary {
  width: 100%;
  height: 46px;
  background: transparent;
  color: var(--text-label);
  border: 0.5px solid var(--border-input);
  border-radius: 10px;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background 0.15s ease;
  font-family: inherit;
}

.btn-secondary:hover { background: var(--bg-subtle); }

.switch-link {
  text-align: center;
  font-size: 0.8125rem;
  color: var(--text-secondary);
  margin-top: 1.5rem;
}

.switch-link a {
  color: var(--text-primary);
  font-weight: 500;
  text-decoration: none;
}

.switch-link a:hover { text-decoration: underline; }

#rc-login, #rc-register, #rc-token { margin-bottom: 1rem; }

.toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--btn-bg);
  color: var(--btn-color);
  padding: 12px 20px;
  border-radius: 10px;
  font-size: 0.875rem;
  font-weight: 500;
  opacity: 0;
  transition: all 0.25s ease;
  pointer-events: none;
  white-space: nowrap;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@media (max-width: 440px) {
  .auth-card {
    padding: 2rem 1.5rem;
    border-radius: 12px;
  }
}
