:root {

  --brand-primary: #6366f1;
  --brand-secondary: #8b5cf6;
  --brand-gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  --brand-glow: 0 0 20px rgba(99, 102, 241, 0.3);

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;

  --header-height: 56px;
  --toolbar-height: 44px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;

  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --duration-fast: 150ms;
  --duration-normal: 250ms;
  --duration-slow: 400ms;
}

[data-theme="light"] {
  --bg-primary: #f8f9fc;
  --bg-secondary: #ffffff;
  --bg-tertiary: #f1f3f9;
  --bg-hover: #e8ebf4;
  --bg-auth: #f0f2f8;
  --bg-input: #ffffff;
  --bg-notepad: #ffffff;

  --text-primary: #1a1d2e;
  --text-secondary: #5a5f7a;
  --text-tertiary: #8b90a8;
  --text-placeholder: #b0b4c8;

  --border-color: #e2e5f0;
  --border-focus: var(--brand-primary);

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.12);
  --shadow-card: 0 2px 12px rgba(0,0,0,0.06), 0 0 0 1px rgba(0,0,0,0.04);

  --status-saved: #22c55e;
  --status-saving: #f59e0b;
  --status-unsaved: #ef4444;
  --status-error: #ef4444;

  --toast-bg: #1a1d2e;
  --toast-text: #ffffff;

  --czn-tag-color: var(--czn-tag-color-override, #2563eb);
  --czn-tag-bg: var(--czn-tag-bg-override, rgba(37, 99, 235, 0.12));
  --czn-tag-border: var(--czn-tag-border-override, rgba(37, 99, 235, 0.25));
}

[data-theme="dark"] {
  --bg-primary: #0f1117;
  --bg-secondary: #181a24;
  --bg-tertiary: #1e2030;
  --bg-hover: #262840;
  --bg-auth: #0f1117;
  --bg-input: #1e2030;
  --bg-notepad: #13141e;

  --text-primary: #e8eaf0;
  --text-secondary: #a0a4b8;
  --text-tertiary: #6b6f88;
  --text-placeholder: #484c64;

  --border-color: #2a2d42;
  --border-focus: var(--brand-primary);

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.4);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.5);
  --shadow-card: 0 2px 12px rgba(0,0,0,0.3), 0 0 0 1px rgba(255,255,255,0.04);

  --status-saved: #4ade80;
  --status-saving: #fbbf24;
  --status-unsaved: #f87171;
  --status-error: #f87171;

  --toast-bg: #e8eaf0;
  --toast-text: #0f1117;

  --czn-tag-color: var(--czn-tag-color-override, #60a5fa);
  --czn-tag-bg: var(--czn-tag-bg-override, rgba(96, 165, 250, 0.18));
  --czn-tag-border: var(--czn-tag-border-override, rgba(96, 165, 250, 0.3));
}

*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  overflow: hidden;
  height: 100vh;
  transition: background var(--duration-normal) var(--ease-out),
              color var(--duration-normal) var(--ease-out);
}

a { color: var(--brand-primary); text-decoration: none; }
button { cursor: pointer; border: none; background: none; font-family: inherit; }
input, textarea { font-family: inherit; }

.screen {
  position: fixed;
  inset: 0;
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--duration-slow) var(--ease-out),
              visibility var(--duration-slow);
}

.screen.active {
  opacity: 1;
  visibility: visible;
}

#auth-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-auth);
  overflow: hidden;
}

.auth-bg {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.bg-blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.15;
  animation: float 20s ease-in-out infinite;
}

[data-theme="dark"] .bg-blob { opacity: 0.08; }

.blob-1 {
  width: 400px; height: 400px;
  background: #6366f1;
  top: -100px; left: -100px;
  animation-delay: 0s;
}
.blob-2 {
  width: 350px; height: 350px;
  background: #8b5cf6;
  bottom: -80px; right: -80px;
  animation-delay: -7s;
}
.blob-3 {
  width: 300px; height: 300px;
  background: #a78bfa;
  top: 50%; left: 60%;
  animation-delay: -14s;
}

@keyframes float {
  0%, 100% { transform: translate(0, 0) scale(1); }
  25% { transform: translate(30px, -30px) scale(1.05); }
  50% { transform: translate(-20px, 20px) scale(0.95); }
  75% { transform: translate(20px, 10px) scale(1.02); }
}

.auth-container {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 420px;
  padding: 40px 32px;
  background: var(--bg-secondary);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border-color);
  animation: slideUp var(--duration-slow) var(--ease-spring);
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(24px); }
  to { opacity: 1; transform: translateY(0); }
}

.auth-brand {
  text-align: center;
  margin-bottom: 28px;
}

.brand-icon {
  display: inline-flex;
  margin-bottom: 12px;
  animation: pulse-glow 3s ease-in-out infinite;
}

@keyframes pulse-glow {
  0%, 100% { filter: drop-shadow(0 0 0px transparent); }
  50% { filter: drop-shadow(0 0 12px rgba(99, 102, 241, 0.4)); }
}

.brand-name {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.brand-name span {
  background: var(--brand-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.brand-tagline {
  font-size: 0.85rem;
  color: var(--text-tertiary);
  margin-top: 4px;
}

.auth-tabs {
  display: flex;
  position: relative;
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  padding: 3px;
  margin-bottom: 24px;
}

.auth-tab {
  flex: 1;
  padding: 8px 16px;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  border-radius: 6px;
  transition: color var(--duration-fast) var(--ease-out);
  position: relative;
  z-index: 1;
}

.auth-tab.active {
  color: var(--text-primary);
}

.tab-indicator {
  position: absolute;
  top: 3px;
  left: 3px;
  width: calc(50% - 3px);
  height: calc(100% - 6px);
  background: var(--bg-secondary);
  border-radius: 6px;
  box-shadow: var(--shadow-sm);
  transition: transform var(--duration-normal) var(--ease-spring);
}

.auth-tab[data-tab="register"].active ~ .tab-indicator,
.auth-tabs:has(.auth-tab[data-tab="register"].active) .tab-indicator {
  transform: translateX(100%);
}

.auth-form {
  display: none;
}

.auth-form.active {
  display: block;
  animation: fadeIn var(--duration-normal) var(--ease-out);
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.input-icon {
  position: absolute;
  left: 12px;
  width: 18px;
  height: 18px;
  color: var(--text-tertiary);
  pointer-events: none;
  transition: color var(--duration-fast);
}

.input-wrapper input {
  width: 100%;
  padding: 10px 12px 10px 40px;
  font-size: 0.9375rem;
  color: var(--text-primary);
  background: var(--bg-input);
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color var(--duration-fast),
              box-shadow var(--duration-fast),
              background var(--duration-fast);
}

.input-wrapper input::placeholder {
  color: var(--text-placeholder);
}

.input-wrapper input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.input-wrapper input:focus ~ .input-icon,
.input-wrapper:has(input:focus) .input-icon {
  color: var(--brand-primary);
}

.toggle-password {
  position: absolute;
  right: 8px;
  padding: 4px;
  color: var(--text-tertiary);
  transition: color var(--duration-fast);
}

.toggle-password:hover {
  color: var(--text-secondary);
}

.toggle-password svg {
  width: 18px;
  height: 18px;
}

.input-wrapper:has(.toggle-password) input {
  padding-right: 40px;
}

.form-hint {
  display: block;
  font-size: 0.75rem;
  color: var(--text-tertiary);
  margin-top: 4px;
}

.btn-primary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 11px 20px;
  font-size: 0.9375rem;
  font-weight: 600;
  color: #fff;
  background: var(--brand-gradient);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: transform var(--duration-fast) var(--ease-out),
              box-shadow var(--duration-fast) var(--ease-out),
              opacity var(--duration-fast);
  margin-top: 8px;
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: var(--brand-glow);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-arrow {
  width: 18px;
  height: 18px;
  transition: transform var(--duration-fast) var(--ease-out);
}

.btn-primary:hover .btn-arrow {
  transform: translateX(3px);
}

.form-error,
.form-success {
  margin-top: 12px;
  padding: 10px 14px;
  font-size: 0.8125rem;
  border-radius: var(--radius-sm);
  display: none;
  animation: fadeIn var(--duration-fast) var(--ease-out);
}

.form-error {
  color: #ef4444;
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.2);
}

.form-success {
  color: #22c55e;
  background: rgba(34, 197, 94, 0.08);
  border: 1px solid rgba(34, 197, 94, 0.2);
}

.form-error.visible,
.form-success.visible {
  display: block;
}

#app-screen {
  display: flex;
  flex-direction: column;
}

#app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--header-height);
  padding: 0 16px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 100;
  transition: background var(--duration-normal),
              border-color var(--duration-normal);
}

.header-left,
.header-center,
.header-right {
  display: flex;
  align-items: center;
}

.header-left { flex: 1; gap: 4px; }
.header-center { flex: 0; white-space: nowrap; }
.header-right { flex: 1; justify-content: flex-end; gap: 8px; }

.brand-mini {
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-mini-text {
  font-size: 0.9375rem;
  font-weight: 600;
  background: var(--brand-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.save-status {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 20px;
  background: var(--bg-tertiary);
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-secondary);
  transition: all var(--duration-fast);
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--status-saved);
  transition: background var(--duration-fast);
}

.save-status.saving .status-dot { background: var(--status-saving); }
.save-status.unsaved .status-dot {
  background: var(--status-unsaved);
  animation: blink 1.2s ease-in-out infinite;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  transition: all var(--duration-fast) var(--ease-out);
}

.icon-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.icon-btn svg {
  width: 20px;
  height: 20px;
}

.user-avatar {
  background: var(--brand-gradient);
  color: #fff !important;
  font-weight: 600;
  font-size: 0.8125rem;
  border-radius: 50%;
  width: 34px;
  height: 34px;
}

.user-avatar:hover {
  box-shadow: var(--brand-glow);
  background: var(--brand-gradient);
}

.user-menu {
  position: relative;
}

.dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 200px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px) scale(0.96);
  transform-origin: top right;
  transition: all var(--duration-normal) var(--ease-spring);
  z-index: 200;
}

.dropdown.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

.dropdown-header {
  padding: 12px 16px;
}

.dropdown-user {
  display: block;
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--text-primary);
}

.dropdown-label {
  display: block;
  font-size: 0.75rem;
  color: var(--text-tertiary);
  margin-top: 2px;
}

.dropdown-divider {
  height: 1px;
  background: var(--border-color);
  margin: 0 12px;
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 16px;
  font-size: 0.8125rem;
  color: var(--text-secondary);
  transition: all var(--duration-fast);
}

.dropdown-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.dropdown-item svg {
  width: 16px;
  height: 16px;
}

#app-body {
  flex: 1;
  display: flex;
  overflow: hidden;
  position: relative;
}

.sidebar {
  width: 280px;
  min-width: 280px;
  display: flex;
  flex-direction: column;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  transition: background var(--duration-normal),
              border-color var(--duration-normal);
  overflow: hidden;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 8px;
}

.sidebar-title {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-tertiary);
}

.note-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--text-tertiary);
  background: var(--bg-tertiary);
  border-radius: 10px;
}

.btn-new-note {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 4px 12px 8px;
  padding: 8px 12px;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--brand-primary);
  background: var(--bg-tertiary);
  border: 1px dashed var(--border-color);
  border-radius: var(--radius-sm);
  transition: all var(--duration-fast) var(--ease-out);
}

.btn-new-note:hover {
  background: var(--bg-hover);
  border-color: var(--brand-primary);
  border-style: solid;
}

.note-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 8px 8px;
}

.note-list::-webkit-scrollbar {
  width: 4px;
}

.note-list::-webkit-scrollbar-track {
  background: transparent;
}

.note-list::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 2px;
}

.note-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-out);
  position: relative;
  margin-bottom: 2px;
}

.note-item:hover {
  background: var(--bg-hover);
}

.note-item.active {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
}

.note-item-content {
  flex: 1;
  min-width: 0;
}

.note-item-title {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}

.note-item-preview {
  font-size: 0.7rem;
  color: var(--text-tertiary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
  line-height: 1.3;
}

.note-item-time {
  font-size: 0.65rem;
  color: var(--text-tertiary);
  white-space: nowrap;
  margin-top: 3px;
  opacity: 0.7;
}

.note-item.is-pinned {
  border-left: 3px solid #f59e0b;
}

.note-item.is-pinned.active {
  border-left-color: #f59e0b;
}

.note-item-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
  margin-top: 2px;
}

.note-item-pin,
.note-item-delete {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 4px;
  color: var(--text-tertiary);
  opacity: 0;
  transition: all var(--duration-fast);
  background: transparent;
  border: none;
  cursor: pointer;
}

.note-item:hover .note-item-pin,
.note-item:hover .note-item-delete {
  opacity: 0.7;
}

.note-item-pin:hover {
  opacity: 1 !important;
  background: rgba(245, 158, 11, 0.15);
  color: #f59e0b;
}

.note-item-pin.pinned {
  opacity: 1 !important;
  color: #f59e0b;
}

.note-item-pin.pinned svg path {
  fill: currentColor;
}

.note-item-pin svg,
.note-item-delete svg {
  width: 14px;
  height: 14px;
}

.note-item-delete:hover {
  opacity: 1 !important;
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
}

.sidebar-overlay {
  display: none;
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 49;
  opacity: 0;
  transition: opacity var(--duration-normal) var(--ease-out);
}

.sidebar-overlay.visible {
  display: block;
  opacity: 1;
}

.note-list-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 16px;
  text-align: center;
  color: var(--text-tertiary);
}

.note-list-empty-icon {
  font-size: 2rem;
  margin-bottom: 8px;
  opacity: 0.5;
}

.note-list-empty-text {
  font-size: 0.8125rem;
}

#notepad-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

.notepad-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--toolbar-height);
  padding: 0 16px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  transition: background var(--duration-normal),
              border-color var(--duration-normal);
}

.toolbar-left,
.toolbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.toolbar-left {
  min-width: 0;
  overflow: hidden;
}

.toolbar-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-secondary);
  min-width: 0;
}

#toolbar-note-title {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.char-count {
  font-size: 0.75rem;
  color: var(--text-tertiary);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.btn-save {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  transition: all var(--duration-fast) var(--ease-out);
  white-space: nowrap;
}

.btn-save:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--brand-primary);
}

.btn-save:active {
  transform: scale(0.97);
}

.btn-save.has-changes {
  background: var(--brand-gradient);
  color: #fff;
  border-color: transparent;
}

.btn-save.has-changes:hover {
  box-shadow: var(--brand-glow);
  color: #fff;
}

.notepad-wrapper {
  position: relative;
  flex: 1;
  width: 100%;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  background: var(--bg-notepad);
}

.notepad-backdrop,
#notepad {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  box-sizing: border-box;
  margin: 0;
  padding: 20px;
  font-family: var(--font-mono);
  font-size: 0.9375rem;
  font-weight: 400;
  line-height: 1.7;
  letter-spacing: normal;
  word-spacing: normal;
  tab-size: 4;
  -moz-tab-size: 4;
  text-align: left;
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow-wrap: break-word;
  word-break: break-word;
  font-variant-ligatures: none;
  font-feature-settings: "liga" 0, "calt" 0;
  border: none;
  border-radius: 0;
  overflow-y: scroll;
  overflow-x: hidden;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.notepad-backdrop {
  z-index: 1;
  pointer-events: none;
  background: var(--bg-notepad);
  color: var(--text-primary);
  user-select: none;
  -webkit-user-select: none;
  scrollbar-width: thin;
  scrollbar-color: transparent transparent;
  transition: background var(--duration-normal), color var(--duration-normal);
}

.notepad-backdrop::-webkit-scrollbar {
  width: 8px;
}

.notepad-backdrop::-webkit-scrollbar-track,
.notepad-backdrop::-webkit-scrollbar-thumb {
  background: transparent;
  border: none;
}

#notepad {
  z-index: 2;
  background: transparent;
  color: transparent;
  caret-color: var(--text-primary);
  outline: none;
  resize: none;
  scrollbar-width: thin;
  scrollbar-color: var(--border-color) transparent;
  transition: caret-color var(--duration-normal);
}

#notepad::placeholder {
  color: var(--text-placeholder);
}

#notepad::-webkit-scrollbar {
  width: 8px;
}

#notepad::-webkit-scrollbar-track {
  background: transparent;
}

#notepad::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 4px;
}

#notepad::-webkit-scrollbar-thumb:hover {
  background: var(--text-tertiary);
}

#notepad::selection {
  background: rgba(99, 102, 241, 0.35);
  color: transparent;
}

.notepad-wrapper.highlight-disabled .notepad-backdrop {
  display: none;
}

.notepad-wrapper.highlight-disabled #notepad {
  color: var(--text-primary);
  background: var(--bg-notepad);
}

.notepad-wrapper.highlight-disabled #notepad::selection {
  background: var(--brand-primary);
  color: #ffffff;
}

.notepad-wrapper.readonly .notepad-backdrop,
#notepad.readonly {
  background: var(--bg-primary);
  cursor: default;
  opacity: 0.95;
}

mark.czn-tag-bracket {
  background: transparent;
  color: var(--czn-tag-color);
  font-weight: 700;
  border-radius: 4px;
  padding: 0;
  margin: 0;
  text-decoration: none;
  transition: color var(--duration-fast), background var(--duration-fast);
}

[data-tag-bg="true"] mark.czn-tag-bracket {
  background: var(--czn-tag-bg);
  box-shadow: 0 0 0 2px var(--czn-tag-bg);
}

[data-tag-italic="true"] mark.czn-tag-bracket {
  font-style: italic;
}

.note-item-preview mark.czn-tag-bracket {
  background: transparent;
  box-shadow: none;
  color: var(--czn-tag-color);
  font-weight: 700;
  font-family: var(--font-mono);
  font-size: 0.8125rem;
}

.toast-container {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  flex-direction: column-reverse;
  gap: 8px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  background: var(--toast-bg);
  color: var(--toast-text);
  font-size: 0.8125rem;
  font-weight: 500;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  pointer-events: auto;
  animation: toastIn var(--duration-normal) var(--ease-spring);
  white-space: nowrap;
}

.toast.out {
  animation: toastOut var(--duration-normal) var(--ease-out) forwards;
}

.toast-icon {
  font-size: 1rem;
  line-height: 1;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(12px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes toastOut {
  from { opacity: 1; transform: translateY(0) scale(1); }
  to { opacity: 0; transform: translateY(-8px) scale(0.95); }
}

.modal-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.5);
  z-index: 10000;
  opacity: 0;
  visibility: hidden;
  transition: all var(--duration-normal) var(--ease-out);
  overflow-y: auto;
  padding: 20px 12px;
}

.modal-overlay.open {
  opacity: 1;
  visibility: visible;
}

.modal-box {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 28px;
  max-width: 360px;
  width: 90%;
  box-shadow: var(--shadow-lg);
  text-align: center;
  transform: scale(0.9) translateY(10px);
  transition: transform var(--duration-normal) var(--ease-spring);
}

.modal-overlay.open .modal-box {
  transform: scale(1) translateY(0);
}

.modal-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(239, 68, 68, 0.1);
  color: #ef4444;
  margin-bottom: 12px;
}

.modal-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.modal-desc {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  margin-bottom: 20px;
  line-height: 1.5;
}

.modal-actions {
  display: flex;
  gap: 10px;
}

.modal-btn {
  flex: 1;
  padding: 9px 16px;
  font-size: 0.8125rem;
  font-weight: 500;
  border-radius: var(--radius-sm);
  transition: all var(--duration-fast) var(--ease-out);
}

.modal-btn-cancel {
  color: var(--text-secondary);
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
}

.modal-btn-cancel:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.modal-btn-danger {
  color: #fff;
  background: #ef4444;
  border: 1px solid transparent;
}

.modal-btn-danger:hover {
  background: #dc2626;
}

.sidebar-tabs {
  display: flex;
  padding: 4px 10px 8px;
  gap: 4px;
  border-bottom: 1px solid var(--border-color);
}

.sidebar-tab {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 8px;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-tertiary);
  background: transparent;
  border-radius: var(--radius-sm);
  transition: all var(--duration-fast) var(--ease-out);
}

.sidebar-tab:hover {
  color: var(--text-primary);
  background: var(--bg-tertiary);
}

.sidebar-tab.active {
  color: var(--brand-primary);
  background: var(--bg-hover);
  font-weight: 600;
}

.tab-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  font-size: 0.625rem;
  font-weight: 600;
  border-radius: 8px;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
}

.sidebar-tab.active .tab-badge {
  background: var(--brand-primary);
  color: #fff;
}

.note-item-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
}

.note-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.65rem;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
  line-height: 1.2;
}

.note-badge-readonly {
  background: rgba(245, 158, 11, 0.15);
  color: #d97706;
  border: 1px solid rgba(245, 158, 11, 0.3);
}

[data-theme="dark"] .note-badge-readonly {
  background: rgba(245, 158, 11, 0.2);
  color: #fbbf24;
}

.note-badge-readwrite {
  background: rgba(16, 185, 129, 0.15);
  color: #059669;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

[data-theme="dark"] .note-badge-readwrite {
  background: rgba(16, 185, 129, 0.2);
  color: #34d399;
}

.note-badge-pinned {
  background: rgba(245, 158, 11, 0.15);
  color: #d97706;
  border: 1px solid rgba(245, 158, 11, 0.3);
}

[data-theme="dark"] .note-badge-pinned {
  background: rgba(245, 158, 11, 0.2);
  color: #fbbf24;
}

.note-badge-shared-count {
  background: rgba(99, 102, 241, 0.12);
  color: var(--brand-primary);
  border: 1px solid rgba(99, 102, 241, 0.25);
}

.note-owner-tag {
  font-size: 0.6875rem;
  color: var(--text-tertiary);
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.btn-toolbar-action {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  transition: all var(--duration-fast) var(--ease-out);
}

.btn-toolbar-action:hover {
  color: var(--brand-primary);
  background: var(--bg-hover);
  border-color: var(--brand-primary);
}

.btn-toolbar-action.pinned {
  color: #f59e0b;
  background: rgba(245, 158, 11, 0.12);
  border-color: rgba(245, 158, 11, 0.4);
}

.btn-toolbar-action.pinned:hover {
  background: rgba(245, 158, 11, 0.22);
  border-color: #f59e0b;
  color: #f59e0b;
}

.btn-toolbar-action.pinned svg path {
  fill: currentColor;
}

.share-badge-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  font-size: 0.65rem;
  font-weight: 700;
  border-radius: 9px;
  background: var(--brand-primary);
  color: #fff;
}

.note-perm-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
}

.note-perm-badge.perm-read {
  background: rgba(245, 158, 11, 0.15);
  color: #d97706;
  border: 1px solid rgba(245, 158, 11, 0.35);
}

[data-theme="dark"] .note-perm-badge.perm-read {
  background: rgba(245, 158, 11, 0.22);
  color: #fbbf24;
}

.note-perm-badge.perm-write {
  background: rgba(16, 185, 129, 0.15);
  color: #059669;
  border: 1px solid rgba(16, 185, 129, 0.35);
}

[data-theme="dark"] .note-perm-badge.perm-write {
  background: rgba(16, 185, 129, 0.22);
  color: #34d399;
}

#notepad.readonly {
  background: var(--bg-primary);
  cursor: default;
  opacity: 0.95;
}

#notepad.readonly::selection {
  background: rgba(99, 102, 241, 0.2);
}

.btn-save.disabled {
  opacity: 0.5;
  pointer-events: none;
  cursor: not-allowed;
}

.modal-box-wide {
  max-width: 520px;
  width: 95%;
  text-align: left;
  padding: 24px;
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 20px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border-color);
}

.modal-title-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.modal-header-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: var(--brand-gradient);
  color: #fff;
  flex-shrink: 0;
  box-shadow: var(--brand-glow);
}

.modal-title {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.modal-subtitle {
  font-size: 0.8125rem;
  color: var(--text-tertiary);
  max-width: 340px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.modal-close-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  color: var(--text-tertiary);
  background: transparent;
  transition: all var(--duration-fast);
}

.modal-close-btn:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.share-add-form {
  margin-bottom: 24px;
}

.share-form-grid {
  display: flex;
  gap: 12px;
  align-items: flex-end;
}

.share-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.share-field label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.share-field.username-field {
  flex: 1.2;
}

.share-field.perm-field {
  flex: 1;
  min-width: 170px;
}

.share-field.btn-field {
  flex-shrink: 0;
}

.select-wrapper {
  position: relative;
}

.select-wrapper select {
  width: 100%;
  padding: 9px 12px;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-primary);
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  outline: none;
  cursor: pointer;
  transition: border-color var(--duration-fast);
}

.select-wrapper select:focus {
  border-color: var(--border-focus);
}

.btn-primary-sm {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 14px;
  font-size: 0.8125rem;
  font-weight: 600;
  color: #fff;
  background: var(--brand-gradient);
  border-radius: var(--radius-sm);
  white-space: nowrap;
  transition: all var(--duration-fast) var(--ease-out);
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.25);
}

.btn-primary-sm:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

.btn-primary-sm:disabled {
  opacity: 0.6;
  pointer-events: none;
}

.share-feedback {
  margin-top: 8px;
  font-size: 0.78125rem;
  display: none;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
}

.share-feedback.error {
  display: block;
  color: #ef4444;
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.2);
}

.share-feedback.success {
  display: block;
  color: #10b981;
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.share-list-section {
  border-top: 1px solid var(--border-color);
  padding-top: 16px;
}

.share-list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.share-list-title {
  font-size: 0.8125rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-tertiary);
}

.share-users-list {
  max-height: 220px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.share-user-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  transition: all var(--duration-fast);
}

.share-user-item:hover {
  border-color: var(--brand-primary);
  background: var(--bg-hover);
}

.share-user-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.share-user-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--brand-gradient);
  color: #fff;
  font-size: 0.8125rem;
  font-weight: 700;
}

.share-user-details {
  display: flex;
  flex-direction: column;
}

.share-user-name {
  font-size: 0.84375rem;
  font-weight: 600;
  color: var(--text-primary);
}

.share-user-time {
  font-size: 0.6875rem;
  color: var(--text-tertiary);
}

.share-user-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.share-perm-select {
  padding: 4px 8px;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-primary);
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  outline: none;
  cursor: pointer;
}

.btn-revoke-share {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  color: var(--text-tertiary);
  background: transparent;
  transition: all var(--duration-fast);
}

.btn-revoke-share:hover {
  color: #ef4444;
  background: rgba(239, 68, 68, 0.1);
}

.share-empty-state {
  text-align: center;
  padding: 20px 10px;
  color: var(--text-tertiary);
  font-size: 0.8125rem;
  font-style: italic;
}

.modal-box-conflict {
  max-width: 820px;
  width: 95%;
  text-align: left;
  padding: 24px;
}

.modal-header-icon.icon-warning {
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  box-shadow: 0 0 20px rgba(245, 158, 11, 0.35);
}

.conflict-diff-container {
  display: flex;
  gap: 16px;
  margin-bottom: 16px;
}

@media (max-width: 768px) {
  .conflict-diff-container {
    flex-direction: column;
  }
}

.conflict-pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.conflict-pane-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
}

.pane-badge {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 4px;
}

.badge-local {
  background: rgba(99, 102, 241, 0.15);
  color: var(--brand-primary);
  border: 1px solid rgba(99, 102, 241, 0.3);
}

.badge-server {
  background: rgba(245, 158, 11, 0.15);
  color: #d97706;
  border: 1px solid rgba(245, 158, 11, 0.3);
}

[data-theme="dark"] .badge-server {
  color: #fbbf24;
}

.pane-meta {
  font-size: 0.6875rem;
  color: var(--text-tertiary);
}

.conflict-diff-textarea {
  width: 100%;
  height: 200px;
  padding: 10px 12px;
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  line-height: 1.5;
  color: var(--text-primary);
  background: transparent;
  border: none;
  resize: none;
  outline: none;
}

.conflict-actions-guide {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.conflict-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.btn-conflict {
  flex: 1;
  min-width: 180px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 14px;
  font-size: 0.8125rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  transition: all var(--duration-fast) var(--ease-out);
}

.btn-conflict.btn-overwrite {
  background: #ef4444;
  color: #ffffff;
  border: 1px solid transparent;
}

.btn-conflict.btn-overwrite:hover {
  background: #dc2626;
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

.btn-conflict.btn-merge {
  background: var(--brand-gradient);
  color: #ffffff;
  border: 1px solid transparent;
  box-shadow: var(--brand-glow);
}

.btn-conflict.btn-merge:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(99, 102, 241, 0.4);
}

.btn-conflict.btn-server {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.btn-conflict.btn-server:hover {
  background: var(--bg-hover);
  border-color: var(--text-secondary);
}

.modal-box-backup {
  max-width: 780px;
  width: 95%;
  text-align: left;
  padding: 24px;
}

.modal-header-icon.icon-backup {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  box-shadow: 0 0 20px rgba(16, 185, 129, 0.35);
}

.backup-status-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding: 14px 18px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  margin-bottom: 20px;
}

.backup-health-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-primary);
}

.status-pulse-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
  animation: pulse-green 2s infinite;
}

@keyframes pulse-green {
  0% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
  }
  70% {
    transform: scale(1);
    box-shadow: 0 0 0 6px rgba(16, 185, 129, 0);
  }
  100% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
  }
}

.backup-quick-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.btn-backup-cta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  font-size: 0.8125rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-out);
}

.btn-primary-backup {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: #ffffff;
  border: 1px solid transparent;
  box-shadow: 0 2px 10px rgba(16, 185, 129, 0.25);
}

.btn-primary-backup:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.4);
}

.btn-secondary-backup {
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.btn-secondary-backup:hover {
  background: var(--bg-hover);
  border-color: var(--text-secondary);
}

.backup-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.backup-section-label {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.btn-icon-subtle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: var(--radius-sm);
  color: var(--text-tertiary);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: all var(--duration-fast);
}

.btn-icon-subtle:hover {
  color: var(--brand-primary);
  background: var(--bg-hover);
}

.backup-table-wrapper {
  max-height: 250px;
  overflow-y: auto;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
}

.backup-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8125rem;
}

.backup-table th {
  background: var(--bg-tertiary);
  padding: 10px 14px;
  text-align: left;
  font-weight: 600;
  color: var(--text-tertiary);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 2;
}

.backup-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-primary);
}

.backup-row:last-child td {
  border-bottom: none;
}

.backup-row:hover {
  background: var(--bg-hover);
}

.backup-filename-cell {
  font-family: var(--font-mono);
  font-size: 0.78125rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
}

.backup-badge-tag {
  font-family: var(--font-sans);
  font-size: 0.6875rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 4px;
}

.tag-auto {
  background: rgba(99, 102, 241, 0.15);
  color: var(--brand-primary);
}

.tag-manual {
  background: rgba(16, 185, 129, 0.15);
  color: #059669;
}

[data-theme="dark"] .tag-manual {
  color: #34d399;
}

.tag-pre-restore {
  background: rgba(245, 158, 11, 0.15);
  color: #d97706;
}

[data-theme="dark"] .tag-pre-restore {
  color: #fbbf24;
}

.backup-actions-cell {
  text-align: right;
  white-space: nowrap;
}

.btn-table-action {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 4px;
  cursor: pointer;
  transition: all var(--duration-fast);
  text-decoration: none;
}

.btn-action-download {
  color: var(--brand-primary);
  background: rgba(99, 102, 241, 0.1);
  border: 1px solid rgba(99, 102, 241, 0.2);
  margin-right: 6px;
}

.btn-action-download:hover {
  background: rgba(99, 102, 241, 0.2);
}

.btn-action-restore {
  color: #d97706;
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.2);
}

[data-theme="dark"] .btn-action-restore {
  color: #fbbf24;
}

.btn-action-restore:hover {
  background: rgba(245, 158, 11, 0.2);
}

.backup-empty {
  text-align: center;
  padding: 30px;
  color: var(--text-tertiary);
  font-style: italic;
}

.backup-tips-box {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: rgba(99, 102, 241, 0.08);
  border: 1px dashed rgba(99, 102, 241, 0.3);
  border-radius: var(--radius-sm);
  font-size: 0.78125rem;
  color: var(--text-secondary);
  margin-top: 18px;
}

.backup-tips-box svg {
  color: var(--brand-primary);
  flex-shrink: 0;
}

.backup-tips-box code {
  font-family: var(--font-mono);
  background: var(--bg-tertiary);
  padding: 2px 5px;
  border-radius: 4px;
  font-weight: 600;
  color: var(--text-primary);
}

@media (max-width: 768px) {

  .sidebar {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 50;
    transform: translateX(-100%);
    transition: transform var(--duration-normal) var(--ease-out),
                background var(--duration-normal);
    box-shadow: none;
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow-lg);
  }
}

@media (max-width: 600px) {
  .auth-container {
    margin: 16px;
    padding: 28px 20px;
    border-radius: var(--radius-lg);
  }

  .brand-name {
    font-size: 1.25rem;
  }

  #app-header {
    padding: 0 12px;
  }

  .brand-mini-text {
    display: none;
  }

  .save-status {
    padding: 4px 10px;
    font-size: 0.7rem;
  }

  .notepad-toolbar {
    padding: 0 12px;
    gap: 8px;
  }

  .toolbar-label svg {
    display: none;
  }

  .toolbar-label {
    font-size: 0.75rem;
  }

  .char-count {
    font-size: 0.7rem;
  }

  .btn-save span {
    display: none;
  }

  .btn-save {
    padding: 6px 10px;
  }

  #notepad,
  .notepad-backdrop {
    padding: 16px;
    font-size: 0.875rem;
  }

  .toast {
    font-size: 0.75rem;
    padding: 8px 14px;
  }
}

@media (max-width: 380px) {
  .auth-container {
    padding: 24px 16px;
  }

  .auth-tab {
    font-size: 0.8125rem;
    padding: 7px 12px;
  }

  .input-wrapper input {
    font-size: 0.875rem;
    padding: 9px 12px 9px 36px;
  }
}

:focus-visible {
  outline: 2px solid var(--brand-primary);
  outline-offset: 2px;
}

.btn-primary.loading {
  position: relative;
  color: transparent;
}

.btn-primary.loading::after {
  content: '';
  position: absolute;
  width: 20px;
  height: 20px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

::selection {
  background: rgba(99, 102, 241, 0.3);
  color: inherit;
}

.modal-box-settings {
  max-width: 520px;
  width: 95%;
  max-height: calc(100vh - 40px);
  max-height: calc(100dvh - 40px);
  display: flex;
  flex-direction: column;
  text-align: left;
  padding: 20px 24px;
  overflow: hidden;
}

.modal-box-settings .modal-header {
  flex-shrink: 0;
  margin-bottom: 12px;
  padding-bottom: 12px;
}

.modal-box-settings .modal-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding-right: 6px;
  margin-right: -4px;
  overscroll-behavior: contain;
}

.modal-box-settings .modal-body::-webkit-scrollbar {
  width: 6px;
}

.modal-box-settings .modal-body::-webkit-scrollbar-track {
  background: transparent;
}

.modal-box-settings .modal-body::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 3px;
}

.modal-box-settings .modal-body::-webkit-scrollbar-thumb:hover {
  background: var(--text-tertiary);
}

.modal-header-icon.icon-settings {
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  box-shadow: 0 0 20px rgba(59, 130, 246, 0.35);
  color: #ffffff;
}

.settings-group {
  margin-bottom: 14px;
}

.settings-group:last-child {
  margin-bottom: 0;
}

.settings-item-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 12px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
}

.settings-item-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
}

.settings-item-desc {
  font-size: 0.8125rem;
  color: var(--text-tertiary);
  margin-top: 2px;
  line-height: 1.45;
}

.settings-item-desc code {
  background: var(--bg-hover);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--brand-primary);
}

.settings-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.switch-control {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
  cursor: pointer;
}

.switch-control input {
  opacity: 0;
  width: 0;
  height: 0;
}

.switch-slider {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: var(--border-color);
  border-radius: 24px;
  transition: background var(--duration-normal);
}

.switch-slider::before {
  content: '';
  position: absolute;
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  border-radius: 50%;
  transition: transform var(--duration-normal) var(--ease-spring);
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.switch-control input:checked + .switch-slider {
  background: var(--brand-primary);
}

.switch-control input:checked + .switch-slider::before {
  transform: translateX(20px);
}

.settings-color-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.color-option {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color var(--duration-fast), background var(--duration-fast);
}

.color-option:hover {
  background: var(--bg-hover);
  border-color: var(--border-focus);
}

.color-option input[type="radio"] {
  display: none;
}

.color-option.active,
.color-option:has(input[type="radio"]:checked) {
  border-color: var(--brand-primary);
  background: rgba(99, 102, 241, 0.08);
  box-shadow: 0 0 0 1px var(--brand-primary);
}

.color-chip {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.1);
}

.chip-blue { background: #3b82f6; }
.chip-purple { background: #8b5cf6; }
.chip-emerald { background: #10b981; }
.chip-amber { background: #f59e0b; }
.chip-rose { background: #f43f5e; }
.chip-cyan { background: #06b6d4; }

.color-name {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-primary);
}

.settings-options-row {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
}

.checkbox-control {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 0.875rem;
  color: var(--text-primary);
}

.checkbox-control input {
  display: none;
}

.checkbox-custom {
  width: 18px;
  height: 18px;
  border: 2px solid var(--border-color);
  border-radius: 4px;
  background: var(--bg-input);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all var(--duration-fast);
}

.checkbox-custom::after {
  content: '';
  width: 5px;
  height: 9px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg) scale(0);
  margin-top: -2px;
  transition: transform var(--duration-fast);
}

.checkbox-control input:checked + .checkbox-custom {
  background: var(--brand-primary);
  border-color: var(--brand-primary);
}

.checkbox-control input:checked + .checkbox-custom::after {
  transform: rotate(45deg) scale(1);
}

.checkbox-control input:disabled + .checkbox-custom {
  opacity: 0.7;
  cursor: not-allowed;
}

.settings-preview-box {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  line-height: 1.55;
  color: var(--text-primary);
  white-space: pre-wrap;
  user-select: none;
}

.settings-preview-box .preview-line {
  margin: 0;
}

.modal-box-settings .settings-modal-actions {
  flex-shrink: 0;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
