:root {
  --bg-primary:       #f2f2f7;
  --bg-secondary:     #ffffff;
  --bg-tertiary:      #f2f2f7;
  --bg-grouped:       #ffffff;
  --label-primary:    #000000;
  --label-secondary:  #3c3c43;
  --label-tertiary:   #3c3c4399;
  --label-quaternary: #3c3c432e;
  --separator:        #3c3c4349;
  --fill-primary:     #78788033;
  --fill-secondary:   #78788029;
  --accent:           #007aff;
  --accent-light:     #007aff1a;
  --green:            #34c759;
  --green-light:      #34c7591a;
  --red:              #ff3b30;
  --red-light:        #ff3b301a;
  --orange:           #ff9500;
  --orange-light:     #ff95001a;
  --radius-sm:        10px;
  --radius-md:        13px;
  --radius-lg:        16px;
  --shadow:           0 2px 12px rgba(0,0,0,0.08);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg-primary:       #000000;
    --bg-secondary:     #1c1c1e;
    --bg-tertiary:      #2c2c2e;
    --bg-grouped:       #1c1c1e;
    --label-primary:    #ffffff;
    --label-secondary:  #ebebf5;
    --label-tertiary:   #ebebf599;
    --label-quaternary: #ebebf52e;
    --separator:        #54545899;
    --fill-primary:     #7878805c;
    --fill-secondary:   #78788052;
    --accent:           #0a84ff;
    --accent-light:     #0a84ff1a;
    --green:            #30d158;
    --green-light:      #30d1581a;
    --red:              #ff453a;
    --red-light:        #ff453a1a;
    --orange:           #ff9f0a;
    --orange-light:     #ff9f0a1a;
    --shadow:           0 2px 12px rgba(0,0,0,0.4);
  }
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html {
  font-size: 17px;
  -webkit-text-size-adjust: 100%;
  height: 100%;
}

body {
  font-family: -apple-system, "SF Pro Text", "Helvetica Neue", sans-serif;
  background: var(--bg-primary);
  color: var(--label-primary);
  min-height: 100%;
  min-height: 100dvh;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 0 48px;
  justify-content: flex-start;
}

.page-header {
  width: 100%;
  max-width: 100%;
  padding: 56px 20px 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.page-header h1 {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.5px;
  word-break: break-word;
  overflow-wrap: break-word;
  color: var(--label-primary);
  font-family: -apple-system, "SF Pro Display", sans-serif;
}

.page-header p {
  font-size: 15px;
  color: var(--label-secondary);
  opacity: 0.8;
}

.section {
  width: 100%;
  max-width: 100%;
  padding: 20px 20px 0;
}

.section-label {
  font-size: 13px;
  font-weight: 400;
  color: var(--label-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0 4px 8px;
}

.card {
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.row {
  display: flex;
  align-items: center;
  padding: 13px 16px;
  gap: 12px;
  position: relative;
}

.row + .row::before {
  content: '';
  position: absolute;
  top: 0;
  left: 16px;
  right: 0;
  height: 0.5px;
  background: var(--separator);
}

.row-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 17px;
}

.row-icon.blue   { background: var(--accent-light);  color: var(--accent); }
.row-icon.green  { background: var(--green-light);   color: var(--green);  }
.row-icon.red    { background: var(--red-light);     color: var(--red);    }
.row-icon.orange { background: #ff95001a;            color: var(--orange); }

.row-content {
  flex: 1;
  min-width: 0;
}

.row-title {
  font-size: 17px;
  color: var(--label-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.row-subtitle {
  font-size: 13px;
  color: var(--label-tertiary);
  margin-top: 1px;
}

.row-value {
  font-size: 15px;
  color: var(--label-tertiary);
  flex-shrink: 0;
}

.row-chevron {
  color: var(--label-quaternary);
  font-size: 17px;
  font-weight: 600;
  flex-shrink: 0;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
}

.badge.success {
  background: var(--green-light);
  color: var(--green);
}

.badge.error {
  background: var(--red-light);
  color: var(--red);
}

.badge.warning {
  background: #ff95001a;
  color: var(--orange);
}

.badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: var(--radius-md);
  font-size: 17px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
  -webkit-user-select: none;
  user-select: none;
}

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

.btn-primary {
  background: var(--accent);
  color: #ffffff;
}

.btn-destructive {
  background: var(--red-light);
  color: var(--red);
}

.btn-plain {
  background: var(--fill-secondary);
  color: var(--label-primary);
}

.state-view {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 60dvh;
  padding: 40px 20px;
  text-align: center;
}

.state-icon {
  font-size: 56px;
  line-height: 1;
}

.state-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--label-primary);
  font-family: -apple-system, "SF Pro Display", sans-serif;
  letter-spacing: -0.3px;
}

.state-subtitle {
  font-size: 15px;
  color: var(--label-secondary);
  max-width: 280px;
  line-height: 1.5;
}

.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--fill-primary);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.divider {
  height: 0.5px;
  background: var(--separator);
  margin: 0;
}

.current-tag {
  font-size: 12px;
  font-weight: 500;
  color: var(--accent);
  background: var(--accent-light);
  padding: 2px 8px;
  border-radius: 20px;
  flex-shrink: 0;
}

.footer-note {
  width: 100%;
  max-width: 100%;
  padding: 12px 24px 0;
  font-size: 13px;
  color: var(--label-tertiary);
  line-height: 1.5;
  text-align: center;
}

.fade-in {
  animation: fadeIn 0.3s ease both;
}

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

.form-wrap {
  width: 100%;
  padding: 0 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.input-field {
  width: 100%;
  padding: 14px 16px;
  border: none;
  border-radius: var(--radius-md);
  background: var(--bg-secondary);
  color: var(--label-primary);
  font-size: 17px;
  font-family: inherit;
  outline: none;
  box-shadow: var(--shadow);
  -webkit-appearance: none;
}

.input-field::placeholder { color: var(--label-tertiary); }
.input-field:focus { box-shadow: 0 0 0 2px var(--accent); }

.forgot-link {
  font-size: 15px;
  color: var(--accent);
  text-align: right;
  text-decoration: none;
  font-weight: 500;
  padding: 0 2px;
}

.switch-link {
  font-size: 15px;
  color: var(--label-secondary);
  text-align: center;
}

.switch-link a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
}

.error-msg {
  display: none;
  font-size: 14px;
  color: var(--red);
  text-align: center;
  padding: 10px 14px;
  background: var(--red-light);
  border-radius: var(--radius-sm);
}

.error-link {
  display: none;
  margin-top: 8px;
  font-size: 15px;
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
}

.error-link:active { opacity: 0.7; }

.dismiss-hint {
  font-size: 13px;
  color: var(--label-tertiary);
  margin-top: 12px;
}

#code-input {
  font-family: 'SF Mono', 'Menlo', monospace;
  letter-spacing: 0.05em;
}