/* === Reset & Base === */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg: #fafaf8;
  --surface: #ffffff;
  --surface-hover: #f5f5f2;
  --border: #e8e8e4;
  --border-light: #f0f0ec;
  --text: #1a1a1a;
  --text-secondary: #6b6b6b;
  --text-muted: #999999;
  --accent: #2c2c2c;
  --accent-hover: #404040;
  --danger: #c0392b;
  --danger-hover: #a93226;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.06);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.1);
  --transition: 150ms ease;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

body {
  font-family: 'Lora', Georgia, serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

h1, h2, h3, h4, h5, h6,
label,
button,
.topbar-title,
.auth-title,
.auth-subtitle,
.notes-header h2,
.editor-header h2,
.note-card-title,
.empty-hint {
  font-family: 'Montserrat', 'Helvetica Neue', Arial, sans-serif;
}

/* === Utility === */
.hidden { display: none !important; }

.view {
  min-height: 100vh;
}

/* === Buttons === */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius);
  font-family: 'Montserrat', sans-serif;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
}

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

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}
.btn-ghost:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.btn-danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--danger);
}
.btn-danger:hover {
  background: var(--danger);
  color: #fff;
}

.btn-sm {
  padding: 6px 14px;
  font-size: 0.8rem;
}

.btn-icon {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-muted);
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all var(--transition);
}
.btn-icon:hover {
  background: var(--surface-hover);
  color: var(--text);
}

/* === Auth === */
.auth-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
}

.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 48px 40px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-md);
}

.auth-title {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 4px;
}

.auth-subtitle {
  font-size: 0.9rem;
  color: var(--text-muted);
  font-weight: 400;
  margin-bottom: 32px;
}

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

.auth-form label {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.auth-form input {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: 'Lora', serif;
  font-size: 1rem;
  color: var(--text);
  background: var(--bg);
  transition: border-color var(--transition);
  outline: none;
}

.auth-form input:focus {
  border-color: var(--accent);
}

.auth-form input::placeholder {
  color: var(--text-muted);
}

.auth-form .btn {
  margin-top: 8px;
  width: 100%;
}

.code-info {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.code-info span {
  font-weight: 500;
  color: var(--text);
}

.error-msg {
  margin-top: 16px;
  padding: 12px 16px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: var(--radius);
  color: var(--danger);
  font-size: 0.875rem;
}

.loading {
  display: flex;
  justify-content: center;
  margin-top: 16px;
}

.spinner {
  width: 24px;
  height: 24px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

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

/* === Topbar === */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 32px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar-title {
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.user-email {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-family: 'Montserrat', sans-serif;
}

/* === Notes === */
.main-content {
  max-width: 720px;
  margin: 0 auto;
  padding: 32px 24px;
}

.notes-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.notes-header h2 {
  font-size: 1.25rem;
  font-weight: 600;
}

.notes-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.note-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  cursor: pointer;
  transition: all var(--transition);
  box-shadow: var(--shadow-sm);
}

.note-card:hover {
  border-color: #d0d0cc;
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.note-card-title {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text);
}

.note-card-preview {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.note-card-date {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 10px;
  font-family: 'Montserrat', sans-serif;
}

/* === Empty state === */
.empty-state {
  text-align: center;
  padding: 64px 24px;
  color: var(--text-muted);
}

.empty-state p {
  font-size: 1rem;
  margin-bottom: 8px;
}

.empty-hint {
  font-size: 0.85rem;
}

/* === Modal === */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(2px);
}

.modal-content {
  position: relative;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.editor-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 0;
}

.editor-header h2 {
  font-size: 1.1rem;
  font-weight: 600;
}

.editor-form {
  display: flex;
  flex-direction: column;
  padding: 16px 24px 24px;
  gap: 12px;
  flex: 1;
}

.editor-input-title {
  width: 100%;
  padding: 10px 0;
  border: none;
  border-bottom: 1px solid var(--border-light);
  font-family: 'Montserrat', sans-serif;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
  outline: none;
  background: transparent;
}

.editor-input-title:focus {
  border-bottom-color: var(--accent);
}

.editor-input-title::placeholder {
  color: var(--text-muted);
  font-weight: 400;
}

.editor-textarea {
  width: 100%;
  min-height: 200px;
  padding: 12px 0;
  border: none;
  font-family: 'Lora', serif;
  font-size: 1rem;
  color: var(--text);
  line-height: 1.7;
  resize: vertical;
  outline: none;
  background: transparent;
}

.editor-textarea::placeholder {
  color: var(--text-muted);
}

.editor-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 16px;
  border-top: 1px solid var(--border-light);
}

.editor-actions-right {
  display: flex;
  gap: 8px;
  margin-left: auto;
}

/* === Responsive === */
@media (max-width: 600px) {
  .auth-card {
    padding: 32px 24px;
  }

  .topbar {
    padding: 12px 16px;
  }

  .main-content {
    padding: 24px 16px;
  }

  .modal-content {
    max-height: 100vh;
    border-radius: 0;
    height: 100%;
  }

  .modal {
    padding: 0;
  }

  .user-email {
    display: none;
  }
}
