/* CSS Custom Properties - Light Theme (default) */
:root {
  --bg-primary: #f1f3f4;
  --bg-secondary: #ffffff;
  --bg-tertiary: #f1f3f4;
  --text-primary: #202124;
  --text-secondary: #5f6368;
  --text-muted: #6a7076;
  --border-color: #e0e0e0;
  --border-light: #dadce0;
  --accent-primary: #1a73e8;
  --accent-primary-hover: #1557b0;
  --accent-secondary: #fef7e0;
  --accent-secondary-text: #b45300;
  --error-color: #c5221f;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.1);
  --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.15);
  --shadow-lg: 0 4px 24px rgba(0, 0, 0, 0.2);
  --overlay-bg: rgba(0, 0, 0, 0.5);
  --badge-shared-bg: #e8f0fe;
  --badge-shared-text: #1967d2;
  --label-bg: rgba(0, 0, 0, 0.08);
  --input-bg: #ffffff;
  --login-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  --note-white: #ffffff;
  --note-white-border: #dadce0;
}

/* Dark Theme */
[data-theme='dark'] {
  --bg-primary: #202124;
  --bg-secondary: #292a2d;
  --bg-tertiary: #35363a;
  --text-primary: #e8eaed;
  --text-secondary: #9aa0a6;
  --text-muted: #8c9399;
  --border-color: #3c4043;
  --border-light: #5f6368;
  --accent-primary: #8ab4f8;
  --accent-primary-hover: #aecbfa;
  --accent-secondary: #3c3000;
  --accent-secondary-text: #fdd663;
  --error-color: #f28b82;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 4px 24px rgba(0, 0, 0, 0.5);
  --overlay-bg: rgba(0, 0, 0, 0.7);
  --badge-shared-bg: #1a3a5c;
  --badge-shared-text: #8ab4f8;
  --label-bg: rgba(255, 255, 255, 0.1);
  --input-bg: #35363a;
  --login-gradient: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
  --note-white: #292a2d;
  --note-white-border: #5f6368;
}

/* Dark mode note colors - slightly muted versions */
[data-theme='dark'] .note[style*='background-color: #ffffff'] {
  background-color: var(--note-white) !important;
}

/* Reset and base styles */
*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  transition:
    background-color 0.3s,
    color 0.3s;
}

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

/* Hide app chrome until session is validated (class set in HTML; removed in index-page.js). */
html.app-loading .app-header,
html.app-loading .app-main,
html.app-loading .app-footer,
html.app-loading .install-banner,
html.app-loading .connection-banner,
html.app-loading #note-modal {
  visibility: hidden;
}

/* Form visibility helpers */
.form-hidden {
  display: none;
}

/* TOTP error spacing */
.totp-error-spacing {
  margin-top: 8px;
}

/* Danger button variant */
.btn-danger {
  background: var(--error-color);
}

/* Buttons */
.btn {
  padding: 8px 16px;
  border: none;
  border-radius: 4px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition:
    background-color 0.2s,
    box-shadow 0.2s;
}

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

[data-theme='dark'] .btn-primary {
  color: #202124;
}

.btn-primary:hover {
  background: var(--accent-primary-hover);
  box-shadow: var(--shadow-sm);
}

.btn-secondary {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border-light);
}

.btn-secondary:hover {
  background: var(--bg-tertiary);
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 2px solid var(--accent-primary);
  outline-offset: 2px;
}

.btn-icon {
  background: transparent;
  border: none;
  padding: 8px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 16px;
  opacity: 0;
  transition:
    opacity 0.2s,
    background 0.2s;
}

.btn-icon:hover {
  background: var(--label-bg);
}

/* Note action tooltips (match the color swatch hover style) */
.note-actions .btn-icon {
  position: relative;
}

.note-actions .btn-icon[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  left: 50%;
  bottom: calc(100% + 6px);
  transform: translateX(-50%);
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 6px 8px;
  font-size: 12px;
  line-height: 1.2;
  white-space: pre-line;
  opacity: 0;
  pointer-events: none;
  box-shadow: var(--shadow-sm);
  z-index: 2;
}

.note-actions .btn-icon:hover::after,
.note-actions .btn-icon:focus-visible::after {
  opacity: 1;
}

/* Theme Toggle */
.theme-toggle {
  background: transparent;
  border: 1px solid var(--border-light);
  border-radius: 20px;
  padding: 6px 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  color: var(--text-secondary);
  transition: background-color 0.2s;
}

.theme-toggle:hover {
  background: var(--bg-tertiary);
}

.theme-toggle .icon {
  font-size: 16px;
}

/* Login Page */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--login-gradient);
}

.login-main {
  width: 100%;
  display: flex;
  justify-content: center;
}

.login-container {
  width: 100%;
  max-width: 420px;
  padding: clamp(16px, 4vw, 24px);
}

.login-card {
  background: var(--bg-secondary);
  border-radius: 12px;
  padding: clamp(28px, 6vw, 44px);
  box-shadow: var(--shadow-lg);
}

.login-card .subtitle {
  margin: 0 0 clamp(24px, 5vw, 36px);
  color: var(--text-secondary);
  font-size: 16px;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Login only: room between field groups and actions; reliable touch spacing on small screens */
.login-card .auth-form {
  gap: clamp(20px, 4vw, 26px);
}

.login-card .form-group {
  gap: 10px;
}

.login-card .auth-form .btn-primary,
.login-card .auth-form .btn-secondary {
  min-height: 44px;
  padding: 10px 18px;
}

/* Override .auth-form display when hidden (same specificity, order matters) */
.auth-form.form-hidden {
  display: none;
}

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

.form-group label {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
}

.form-group input {
  padding: 12px 16px;
  border: 1px solid var(--border-light);
  border-radius: 8px;
  font-size: 16px;
  background: var(--input-bg);
  color: var(--text-primary);
  transition:
    border-color 0.2s,
    box-shadow 0.2s;
}

.form-group input:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 2px rgba(26, 115, 232, 0.2);
}

[data-theme='dark'] .form-group input:focus {
  box-shadow: 0 0 0 2px rgba(138, 180, 248, 0.2);
}

.form-group input#code,
.form-group input#totp-code {
  text-align: center;
  font-size: 24px;
  letter-spacing: 8px;
  font-weight: 600;
}

.form-group input#recovery-code {
  text-align: center;
  font-size: 18px;
  letter-spacing: 2px;
  font-weight: 600;
  text-transform: uppercase;
}

.form-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin: 4px 0 0;
}

.auth-choice-label {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.btn-link {
  background: none;
  border: none;
  color: var(--accent-primary);
  font-size: 13px;
  cursor: pointer;
  padding: 8px 0;
  text-decoration: none;
  display: inline-block;
}

.btn-link:hover {
  text-decoration: underline;
}

.error-message {
  color: var(--error-color);
  font-size: 14px;
  min-height: 20px;
}

/* App Header */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  transition:
    background-color 0.3s,
    border-color 0.3s;
}

/* Brand */
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.brand-logo {
  width: 28px;
  height: 28px;
  flex: 0 0 auto;
}

.brand-title {
  margin: 0;
  font-size: 22px;
  font-weight: 500;
  color: var(--text-secondary);
  letter-spacing: 0.2px;
}

.brand--login {
  justify-content: center;
  margin-bottom: 8px;
}

.brand-logo--login {
  width: 44px;
  height: 44px;
}

.brand-title--login {
  font-size: 32px;
  color: var(--text-primary);
  font-weight: 700;
}

.header-nav {
  display: flex;
  gap: 8px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.nav-btn {
  padding: 8px 20px;
  background: transparent;
  border: none;
  border-radius: 24px;
  font-size: 14px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background-color 0.2s;
}

.nav-btn:hover {
  background: var(--bg-tertiary);
}

.nav-btn.active {
  background: var(--accent-secondary);
  color: var(--accent-secondary-text);
}

/* App Main */
.app-main {
  max-width: 900px;
  margin: 0 auto;
  padding: 24px;
}

.app-footer {
  max-width: 900px;
  margin: 0 auto 24px;
  padding: 0 24px;
  color: var(--text-muted);
  font-size: 12px;
}

.app-footer a {
  color: inherit;
}

.connection-banner {
  max-width: 900px;
  margin: 12px auto 0;
  padding: 10px 16px;
  border-radius: 10px;
  border: 1px solid var(--border-color);
  background: var(--bg-secondary);
  color: var(--text-secondary);
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.connection-banner.is-offline {
  border-color: rgba(180, 83, 0, 0.35);
  background: var(--accent-secondary);
  color: var(--accent-secondary-text);
}

.connection-banner.is-syncing {
  border-color: rgba(26, 115, 232, 0.35);
}

.btn-small {
  padding: 6px 12px;
  font-size: 13px;
}

.install-banner {
  max-width: 900px;
  margin: 12px auto 0;
  padding: 10px 16px;
  border-radius: 10px;
  border: 1px solid var(--border-color);
  background: var(--bg-secondary);
  color: var(--text-secondary);
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.install-banner-actions {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  flex: 0 0 auto;
}

/* Ensure `hidden` always hides banners (UA stylesheet can be overridden by our flex rules). */
.install-banner[hidden],
.connection-banner[hidden] {
  display: none !important;
}

.policy-card {
  background: var(--bg-secondary);
  border-radius: 8px;
  border: 1px solid var(--border-color);
  padding: 20px;
}

.policy-card h2 {
  margin-top: 0;
}

.policy-card h3 {
  margin-top: 20px;
}

/* New Note Form */
.new-note-container {
  margin-bottom: 32px;
}

.new-note-form {
  background: var(--bg-secondary);
  border-radius: 8px;
  box-shadow:
    var(--shadow-sm),
    0 2px 6px rgba(0, 0, 0, 0.05);
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: background-color 0.3s;
}

.new-note-title {
  border: none;
  font-size: 16px;
  font-weight: 500;
  padding: 4px 0;
  outline: none;
  background: transparent;
  color: var(--note-fg, var(--text-primary));
}

.new-note-title::placeholder {
  color: var(--note-fg-secondary, var(--text-muted));
}

.new-note-content {
  border: none;
  font-size: 14px;
  padding: 4px 0;
  outline: none;
  resize: none;
  min-height: 24px;
  background: transparent;
  color: var(--note-fg, var(--text-primary));
}

.new-note-content::placeholder {
  color: var(--note-fg-secondary, var(--text-muted));
}

.new-note-options {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border-color);
}

/* Color Picker */
.color-picker {
  display: flex;
  gap: 4px;
}

.color-picker .color-swatch {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  padding: 0;
  background: transparent;
  position: relative;
  transition:
    border-color 0.2s,
    transform 0.2s;
}

.color-picker .color-swatch:hover {
  transform: scale(1.1);
}

.color-picker .color-swatch::after {
  content: attr(data-color-name);
  position: absolute;
  left: 50%;
  bottom: calc(100% + 6px);
  transform: translateX(-50%);
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 4px 6px;
  font-size: 12px;
  line-height: 1;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  box-shadow: var(--shadow-sm);
  z-index: 2;
}

.color-picker .color-swatch:focus-visible {
  outline: 2px solid var(--accent-primary);
  outline-offset: 2px;
}

.color-picker .color-swatch:focus-visible::after,
.color-picker .color-swatch:hover::after {
  opacity: 1;
}
.color-picker .color-swatch[aria-checked='true'] {
  border-color: var(--accent-primary);
}

.color-picker .color-swatch[data-color='#ffffff'] {
  border: 2px solid var(--note-white-border);
}

.color-picker .color-swatch[aria-checked='true'][data-color='#ffffff'] {
  border-color: var(--accent-primary);
}

/* Notes Grid */
.notes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}

/* Hide stale grid content during view switch so wrong list doesn't flash */
.notes-grid.notes-grid-loading {
  visibility: hidden;
}

/* Note Card */
.note {
  background: var(--bg-secondary);
  /* Defaults for note text that work in both light/dark themes. */
  --note-fg: var(--text-primary);
  --note-fg-secondary: var(--text-secondary);
  --note-label-fg: var(--text-secondary);
  display: flex;
  flex-direction: column;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  /* Allow tooltips (note info) to escape the card bounds. */
  overflow: visible;
  transition:
    box-shadow 0.2s,
    background-color 0.3s;
}

/* Note color classes - CSP compliant (no inline styles needed) */
.note-color-white,
.note.note-color-white,
.modal-content.note-color-white {
  background-color: var(--note-white);
}

.note-color-red,
.note.note-color-red,
.modal-content.note-color-red {
  background-color: #f28b82;
  --note-fg: #202124;
  --note-fg-secondary: #3c4043;
  --note-label-fg: #3c4043;
}

.note-color-orange,
.note.note-color-orange,
.modal-content.note-color-orange {
  background-color: #fbbc04;
  --note-fg: #202124;
  --note-fg-secondary: #3c4043;
  --note-label-fg: #3c4043;
}

.note-color-yellow,
.note.note-color-yellow,
.modal-content.note-color-yellow {
  background-color: #fff475;
  --note-fg: #202124;
  --note-fg-secondary: #3c4043;
  --note-label-fg: #3c4043;
}

.note-color-green,
.note.note-color-green,
.modal-content.note-color-green {
  background-color: #ccff90;
  --note-fg: #202124;
  --note-fg-secondary: #3c4043;
  --note-label-fg: #3c4043;
}

.note-color-teal,
.note.note-color-teal,
.modal-content.note-color-teal {
  background-color: #a7ffeb;
  --note-fg: #202124;
  --note-fg-secondary: #3c4043;
  --note-label-fg: #3c4043;
}

.note-color-blue,
.note.note-color-blue,
.modal-content.note-color-blue {
  background-color: #cbf0f8;
  --note-fg: #202124;
  --note-fg-secondary: #3c4043;
  --note-label-fg: #3c4043;
}

.note-color-darkblue,
.note.note-color-darkblue,
.modal-content.note-color-darkblue {
  background-color: #aecbfa;
  --note-fg: #202124;
  --note-fg-secondary: #3c4043;
  --note-label-fg: #3c4043;
}

.note-color-purple,
.note.note-color-purple,
.modal-content.note-color-purple {
  background-color: #d7aefb;
  --note-fg: #202124;
  --note-fg-secondary: #3c4043;
  --note-label-fg: #3c4043;
}

.note-color-pink,
.note.note-color-pink,
.modal-content.note-color-pink {
  background-color: #fdcfe8;
  --note-fg: #202124;
  --note-fg-secondary: #3c4043;
  --note-label-fg: #3c4043;
}

.note-color-brown,
.note.note-color-brown,
.modal-content.note-color-brown {
  background-color: #e6c9a8;
  --note-fg: #202124;
  --note-fg-secondary: #3c4043;
  --note-label-fg: #3c4043;
}

.note-color-grey,
.note.note-color-grey,
.modal-content.note-color-grey {
  background-color: #e8eaed;
  --note-fg: #202124;
  --note-fg-secondary: #3c4043;
  --note-label-fg: #3c4043;
}

/* Color picker swatches */
.color-swatch[data-color="#ffffff"] { background-color: #ffffff; border: 2px solid var(--border-color); }
.color-swatch[data-color="#f28b82"] { background-color: #f28b82; }
.color-swatch[data-color="#fbbc04"] { background-color: #fbbc04; }
.color-swatch[data-color="#fff475"] { background-color: #fff475; }
.color-swatch[data-color="#ccff90"] { background-color: #ccff90; }
.color-swatch[data-color="#a7ffeb"] { background-color: #a7ffeb; }
.color-swatch[data-color="#cbf0f8"] { background-color: #cbf0f8; }
.color-swatch[data-color="#aecbfa"] { background-color: #aecbfa; }
.color-swatch[data-color="#d7aefb"] { background-color: #d7aefb; }
.color-swatch[data-color="#fdcfe8"] { background-color: #fdcfe8; }
.color-swatch[data-color="#e6c9a8"] { background-color: #e6c9a8; }
.color-swatch[data-color="#e8eaed"] { background-color: #e8eaed; }

.note:hover {
  box-shadow: var(--shadow-md);
}

.note:hover .btn-icon {
  opacity: 1;
}

.note:focus-within {
  box-shadow: var(--shadow-md);
}

.note:focus-within .btn-icon {
  opacity: 1;
}

.note.pinned {
  border: 2px solid var(--accent-primary);
}

.note.favourite .note-header {
  position: relative;
}

.note-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px 0;
  min-height: 24px;
}

.pin-icon {
  font-size: 14px;
}

.note-content {
  padding: 8px 12px;
  cursor: pointer;
  background: transparent;
  border: none;
  width: 100%;
  text-align: left;
  flex: 1 1 auto;
}

.note-title {
  margin: 0 0 8px;
  font-size: 16px;
  font-weight: 500;
  color: var(--note-fg);
}

.note-body {
  font-size: 14px;
  color: var(--note-fg-secondary);
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 8;
  -webkit-box-orient: vertical;
}

.note-info-btn {
  margin-left: auto;
}

.note-labels {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 0 12px 8px;
}

.label {
  font-size: 11px;
  padding: 2px 8px;
  background: var(--label-bg);
  border-radius: 12px;
  color: var(--note-label-fg);
}

.note-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px 8px;
  margin-top: auto;
}

.badge {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 500;
}

.badge-shared {
  background: var(--badge-shared-bg);
  color: var(--badge-shared-text);
}

/* Empty State */
.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 48px 24px;
  color: var(--text-secondary);
  font-size: 16px;
}

/* Loading */
.loading {
  grid-column: 1 / -1;
  text-align: center;
  padding: 48px 24px;
  color: var(--text-secondary);
}

/* Error */
.error {
  color: var(--error-color);
  padding: 16px;
  text-align: center;
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  background: var(--overlay-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal:empty {
  display: none;
}

.modal-content {
  background: var(--bg-secondary);
  border-radius: 8px;
  width: 100%;
  max-width: 600px;
  max-height: 80vh;
  overflow-y: auto;
  margin: 20px;
  box-shadow: var(--shadow-lg);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
}

.modal-header h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 500;
}

.modal-body {
  padding: 20px;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 16px 20px;
  border-top: 1px solid var(--border-color);
}

/* Responsive */
@media (max-width: 600px) {
  .app-header {
    flex-wrap: wrap;
    gap: 12px;
  }

  .header-nav {
    order: 3;
    width: 100%;
    justify-content: center;
  }

  .header-right {
    gap: 8px;
  }

  .app-main {
    padding: 16px;
  }

  .notes-grid {
    grid-template-columns: 1fr;
  }

  .new-note-options {
    flex-direction: column;
    gap: 12px;
    align-items: stretch;
  }

  .color-picker {
    justify-content: center;
  }

  .theme-toggle span:not(.icon) {
    display: none;
  }
}

/* Hidden textarea for clipboard fallback (CSP-compliant) */
.clipboard-fallback {
  position: fixed !important;
  left: -9999px !important;
  top: 0 !important;
}

/* Animations */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.note {
  animation: fadeIn 0.2s ease-out;
}

/* HTMX indicators */
.htmx-request .htmx-indicator {
  display: inline;
}

.htmx-indicator {
  display: none;
}

/* Dark mode transition */
body,
.app-header,
.new-note-form,
.note,
.modal-content,
.login-card {
  transition:
    background-color 0.3s ease,
    border-color 0.3s ease,
    color 0.3s ease;
}

/* Settings Styles */
.settings-section {
  background: var(--bg-secondary);
  border-radius: 8px;
  border: 1px solid var(--border-color);
  padding: 20px;
  margin-bottom: 24px;
}

.settings-section h3 {
  margin: 0 0 16px;
  font-size: 16px;
  font-weight: 500;
  color: var(--text-primary);
}

.settings-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-color);
}

.settings-row:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.settings-label {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.settings-label strong {
  font-size: 14px;
  color: var(--text-primary);
}

.settings-label span {
  font-size: 12px;
  color: var(--text-muted);
}

.settings-warning {
  font-size: 12px;
  color: var(--error-color);
}

.offline-toggle {
  display: flex;
  align-items: center;
}

.offline-toggle-label {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--text-primary);
  cursor: pointer;
  position: relative;
}

.offline-toggle-label input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.offline-toggle-slider {
  width: 40px;
  height: 22px;
  border-radius: 999px;
  background: var(--label-bg);
  border: 1px solid var(--border-color);
  position: relative;
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

.offline-toggle-slider::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--bg-primary);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
  transition: transform 0.2s ease;
}

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

.offline-toggle-label input:checked + .offline-toggle-slider::after {
  transform: translateX(18px);
}

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

.totp-status {
  display: flex;
  align-items: center;
  gap: 8px;
}

.connection-status {
  display: flex;
  align-items: center;
  gap: 10px;
}

.settings-hint {
  font-size: 12px;
  color: var(--text-muted);
}

.status-badge {
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 12px;
  font-weight: 500;
}

.status-badge.enabled {
  background: #c8e6c9;
  color: #1f6f25;
}

[data-theme='dark'] .status-badge.enabled {
  background: #1b5e20;
  color: #a5d6a7;
}

.status-badge.disabled {
  background: var(--label-bg);
  color: var(--text-secondary);
}

/* TOTP Setup Modal */
.totp-setup-container {
  text-align: center;
}

.qr-code-container {
  background: white;
  padding: 16px;
  border-radius: 8px;
  display: inline-block;
  margin: 16px 0;
}

.qr-code-container img {
  display: block;
  width: 200px;
  height: 200px;
}

.manual-key {
  background: var(--bg-tertiary);
  padding: 12px;
  border-radius: 8px;
  margin: 16px 0;
}

.manual-key label {
  font-size: 12px;
  color: var(--text-muted);
  display: block;
  margin-bottom: 4px;
}

.manual-key code {
  font-family: monospace;
  font-size: 14px;
  letter-spacing: 2px;
  word-break: break-all;
  color: var(--text-primary);
}

.verify-totp-form {
  margin-top: 16px;
}

.verify-totp-form input {
  width: 100%;
  max-width: 200px;
  padding: 12px;
  font-size: 24px;
  text-align: center;
  letter-spacing: 8px;
  border: 1px solid var(--border-light);
  border-radius: 8px;
  background: var(--input-bg);
  color: var(--text-primary);
}

.verify-totp-form input:focus {
  outline: none;
  border-color: var(--accent-primary);
}

/* Recovery Codes Display */
.recovery-codes-container {
  background: var(--bg-tertiary);
  padding: 16px;
  border-radius: 8px;
  margin: 16px 0;
}

.recovery-codes-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin: 12px 0;
}

.recovery-code {
  font-family: monospace;
  font-size: 14px;
  padding: 8px;
  background: var(--bg-secondary);
  border-radius: 4px;
  text-align: center;
}

.recovery-warning {
  font-size: 13px;
  color: var(--error-color);
  margin-top: 12px;
}

/* Settings View */
.settings-view {
  max-width: 600px;
  margin: 0 auto;
}

.hidden {
  display: none !important;
}

/* Edit Modal */
.edit-note-title {
  border: none;
  background: transparent;
  font-size: 18px;
  font-weight: 500;
  padding: 0;
  flex: 1;
  outline: none;
  color: var(--note-fg, var(--text-primary));
}

.edit-note-content {
  width: 100%;
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 4px;
  padding: 12px;
  font-size: 14px;
  resize: vertical;
  min-height: 100px;
  background: rgba(255, 255, 255, 0.65);
  color: var(--note-fg, var(--text-primary));
}

[data-theme='dark'] .edit-note-content {
  border-color: rgba(255, 255, 255, 0.18);
  background: rgba(0, 0, 0, 0.25);
}

.edit-section {
  margin-top: 16px;
}

.edit-section label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.edit-section input[type='text'],
.edit-section input[type='email'] {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 4px;
  font-size: 14px;
  background: rgba(255, 255, 255, 0.65);
  color: var(--note-fg, var(--text-primary));
}

[data-theme='dark'] .edit-section input[type='text'],
[data-theme='dark'] .edit-section input[type='email'] {
  border-color: rgba(255, 255, 255, 0.18);
  background: rgba(0, 0, 0, 0.25);
}

.share-form {
  display: flex;
  gap: 8px;
}

.share-form input {
  flex: 1;
}

.shared-users {
  margin-top: 12px;
  font-size: 14px;
}

.shared-user {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid rgba(0, 0, 0, 0.12);
}

[data-theme='dark'] .shared-user {
  border-bottom-color: rgba(255, 255, 255, 0.18);
}

.btn-remove-share {
  background: none;
  border: none;
  color: #d93025;
  cursor: pointer;
  font-size: 12px;
}

.btn-close {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--text-secondary);
  padding: 0 8px;
}
