.form-group { margin-bottom: var(--space-md); }

.form-group > label {
  display: block;
  margin-bottom: 6px;
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--text-primary);
}

.form-hint { font-size: var(--fs-xs); color: var(--text-muted); margin-top: 5px; }

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-sm);
}

.friend-link-row {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.friend-link-row select { flex: 1; min-width: 0; }
.friend-link-row .btn { flex-shrink: 0; white-space: nowrap; }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-md);
}

@media (max-width: 560px) {
  .form-row:not(.form-row-inline) { grid-template-columns: 1fr; }
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="date"],
input[type="number"],
input[type="search"],
textarea,
select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  color: var(--text-primary);
  font-family: inherit;
  font-size: var(--fs-md);
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
  appearance: none;
}

input::placeholder, textarea::placeholder { color: var(--text-muted); }

input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--ring);
}

textarea { min-height: 110px; resize: vertical; line-height: 1.5; }

.search-field input[type="search"],
.search-field input[type="text"] {
  padding-left: 2.5rem;
}

select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2398938a' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
  cursor: pointer;
}

select[multiple] { background-image: none; padding-right: 12px; }

input[type="color"] {
  width: 48px;
  height: 38px;
  padding: 3px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  cursor: pointer;
}
input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
input[type="color"]::-webkit-color-swatch { border: none; border-radius: var(--radius-xs); }

/* Custom checkbox */
.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
  font-size: var(--fs-md);
  color: var(--text-primary);
}

.checkbox-label input[type="checkbox"] { position: absolute; opacity: 0; width: 0; height: 0; }

.checkbox-custom {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border-strong);
  border-radius: var(--radius-xs);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: var(--bg-input);
  transition: background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}

.checkbox-label input:focus-visible + .checkbox-custom { box-shadow: 0 0 0 3px var(--ring); }
.checkbox-label input:checked + .checkbox-custom { background: var(--color-primary); border-color: var(--color-primary); }
.checkbox-label input:checked + .checkbox-custom::after {
  content: '';
  width: 5px;
  height: 9px;
  border: solid var(--color-on-primary);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
  margin-top: -2px;
}

/* Toggle switch — real track + knob elements (no pseudo-elements) */
label.toggle-label,
.form-group > label.toggle-label {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  width: 100%;
  margin-bottom: 0;
  cursor: pointer;
  font-size: var(--fs-md);
  font-weight: 500;
  user-select: none;
  position: relative;
}

.toggle-text {
  flex: 1;
  min-width: 0;
  line-height: 1.4;
}

.toggle-track {
  display: block;
  width: 46px;
  height: 26px;
  border-radius: var(--radius-pill);
  background: #9c9891;
  border: 1px solid #7a7670;
  position: relative;
  flex-shrink: 0;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease);
  box-sizing: border-box;
}

.toggle-knob {
  display: block;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #ffffff;
  border: 1px solid rgba(0, 0, 0, 0.1);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
  position: absolute;
  top: 2px;
  left: 2px;
  transition: transform var(--dur) var(--ease);
  box-sizing: border-box;
  pointer-events: none;
}

[data-theme="dark"] .toggle-track {
  background: #4f4f58;
  border-color: #696974;
}

[data-theme="dark"] .toggle-knob {
  background: #f5f3ee;
  border-color: rgba(255, 255, 255, 0.14);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.45);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .toggle-track {
    background: #4f4f58;
    border-color: #696974;
  }
  :root:not([data-theme="light"]) .toggle-knob {
    background: #f5f3ee;
    border-color: rgba(255, 255, 255, 0.14);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.45);
  }
}

.toggle-label input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.toggle-label input:focus-visible + .toggle-track {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

.toggle-label input:checked + .toggle-track {
  background: var(--color-primary);
  border-color: var(--color-primary);
}

.toggle-label input:checked + .toggle-track .toggle-knob {
  transform: translateX(20px);
}

/* Star rating */
.star-rating { display: inline-flex; align-items: center; gap: 4px; }

.star-rating button {
  background: none;
  border: none;
  font-size: 1.35rem;
  color: var(--border-strong);
  cursor: pointer;
  padding: 2px;
  line-height: 1;
  transition: color var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}

.star-rating button:hover { transform: scale(1.12); }
.star-rating button.active { color: #e0a33a; }

.rating-row {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.core-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-secondary);
  font-size: var(--fs-xs);
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
}

.core-toggle.icon-only {
  padding: 7px 9px;
  font-size: 1rem;
}

.core-toggle.active { background: var(--color-primary-soft); color: var(--color-primary); border-color: transparent; }

.person-picker-selected {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.person-picker-selected:empty { display: none; }

.person-search-results {
  margin-top: 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  max-height: 180px;
  overflow-y: auto;
  background: var(--bg-surface);
}

.person-search-result {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  width: 100%;
  padding: 8px 12px;
  border: none;
  background: transparent;
  color: var(--text-primary);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.person-search-result:hover:not(:disabled) { background: var(--bg-hover); }

.person-search-result:disabled {
  opacity: 0.45;
  cursor: default;
}

.chip .btn-icon.btn-sm {
  width: 22px;
  height: 22px;
  padding: 0;
  margin-right: -2px;
}

/* File dropzone */
.file-dropzone {
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius-md);
  padding: var(--space-lg);
  text-align: center;
  color: var(--text-secondary);
  cursor: pointer;
  background: var(--bg-elevated);
  transition: border-color var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}

.file-dropzone i { font-size: 1.3rem; display: block; margin-bottom: 6px; color: var(--text-muted); }
.file-dropzone p { font-size: var(--fs-sm); margin: 0; }
.file-dropzone:hover,
.file-dropzone.dragover {
  border-color: var(--color-primary);
  color: var(--color-primary);
  background: var(--color-primary-soft);
}
.file-dropzone.dragover i, .file-dropzone:hover i { color: var(--color-primary); }
.file-dropzone input { display: none; }

.person-photo-preview {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.person-photo-preview img {
  width: 84px;
  height: 84px;
  border-radius: var(--radius-md);
  object-fit: cover;
  border: 1px solid var(--border);
  background: var(--bg-sunken);
}

.person-photo-remove {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-surface);
  color: var(--color-danger);
  font-family: inherit;
  font-size: var(--fs-sm);
  font-weight: 600;
  cursor: pointer;
  transition: border-color var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease);
}

.person-photo-remove:hover {
  border-color: var(--color-danger);
  background: var(--color-danger-soft);
}

/* Media action buttons (audio / images) */
.media-actions {
  display: flex;
  gap: var(--space-sm);
}

.media-action-btn {
  flex: 1;
  justify-content: center;
}

/* Custom audio player */
.audio-player {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-top: var(--space-sm);
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
}

.audio-player audio { display: none; }

.audio-play-btn {
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  border: none;
  border-radius: var(--radius-pill);
  background: var(--color-primary);
  color: var(--color-on-primary);
  font-size: 0.9rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}
.audio-play-btn:hover { background: var(--color-primary-hover); }
.audio-play-btn:active { transform: scale(0.94); }

.audio-waveform {
  flex: 1;
  min-width: 0;
  height: 40px;
  display: flex;
  align-items: center;
  gap: 2px;
  cursor: pointer;
  touch-action: none;
}
.audio-waveform:focus-visible { outline: 2px solid var(--ring); outline-offset: 3px; border-radius: var(--radius-xs); }

.wave-bar {
  flex: 1;
  min-width: 0;
  height: 30%;
  border-radius: var(--radius-pill);
  background: var(--border-strong);
  transition: height var(--dur) var(--ease), background var(--dur-fast) var(--ease);
}
.wave-bar.is-played { background: var(--color-primary); }

.audio-time {
  flex-shrink: 0;
  font-size: var(--fs-xs);
  font-variant-numeric: tabular-nums;
  color: var(--text-secondary);
  min-width: 2.5rem;
  text-align: right;
}

.audio-delete-btn {
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  border: none;
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.audio-delete-btn:hover { background: var(--color-danger-soft); color: var(--color-danger); }

.memory-image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
  gap: var(--space-sm);
  margin-top: var(--space-sm);
}

.memory-image-thumb {
  position: relative;
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--bg-sunken);
}

.memory-image-open {
  display: block;
  width: 100%;
  height: 100%;
  padding: 0;
  border: none;
  background: transparent;
  cursor: zoom-in;
}

.memory-image-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
}

.memory-image-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  z-index: 2;
  width: 22px;
  height: 22px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.62);
  color: #fff;
  font-size: 0.65rem;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}

.memory-image-remove:hover {
  background: rgba(0, 0, 0, 0.82);
  transform: scale(1.06);
}

/* Password strength */
.password-strength {
  height: 5px;
  background: var(--bg-sunken);
  border-radius: var(--radius-pill);
  margin-top: 8px;
  overflow: hidden;
}

.password-strength-bar { height: 100%; width: 0; border-radius: var(--radius-pill); transition: width var(--dur) var(--ease), background var(--dur) var(--ease); }
.strength-weak { background: var(--color-danger); width: 33%; }
.strength-medium { background: var(--color-warning); width: 66%; }
.strength-strong { background: var(--color-success); width: 100%; }

.form-error { color: var(--color-danger); font-size: var(--fs-sm); margin-top: 6px; }

/* Suggestion pills */
.suggestion-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.suggestion-list .chip { cursor: pointer; }
.suggestion-list .chip:hover { border-color: var(--color-primary); color: var(--color-primary); }

/* Auth pages */
.auth-page {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-lg);
  background:
    radial-gradient(1100px 520px at 50% -10%, var(--color-primary-soft), transparent 70%),
    var(--bg-base);
}

.auth-card {
  width: 100%;
  max-width: 416px;
  padding: var(--space-xl);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
}

.auth-logo { text-align: center; margin-bottom: var(--space-lg); }
.auth-logo .mark {
  width: 52px;
  height: 52px;
  margin: 0 auto var(--space-sm);
  border-radius: var(--radius-md);
  background: var(--color-primary);
  color: var(--color-on-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  box-shadow: var(--shadow-sm);
}
.auth-logo h1 { font-size: var(--fs-xl); }
.auth-logo p { color: var(--text-secondary); font-size: var(--fs-sm); margin-top: 2px; }

.auth-links { text-align: center; margin-top: var(--space-lg); font-size: var(--fs-sm); color: var(--text-secondary); }
.input-affix { display: flex; gap: 8px; }
.input-affix > input { flex: 1; }
