:root {
  --bg-primary: #fff8f7;
  --bg-secondary: #ffffff;
  --bg-tertiary: #f3f3f4;
  --bg-glass: rgba(255, 255, 255, 0.85);
  --bg-glass-hover: rgba(227, 27, 35, 0.05);
  --border-color: #000000;
  --border-focus: #e31b23;
  
  --accent-primary: #e31b23;
  --accent-primary-hover: #b90014;
  --accent-glow: rgba(227, 27, 35, 0.1);
  --accent-secondary: #1a1c1c;
  
  --text-main: #1a1c1c;
  --text-muted: #5d5f5f;
  --text-dim: #926e6b;
  
  --danger: #ba1a1a;
  --danger-hover: #93000a;
  --success: #008000;
  
  --sidebar-width: 260px;
  --notes-list-width: 320px;
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --shadow-main: 4px 4px 0px 0px rgba(0, 0, 0, 0.1);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Montserrat', 'Inter', -apple-system, sans-serif;
  background-color: var(--bg-primary);
  background-image: radial-gradient(#F2F2F2 1px, transparent 1px);
  background-size: 32px 32px;
  color: var(--text-main);
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* Background Glowing Elements */
.glow-bg {
  display: none;
}

.glow-bg-secondary {
  display: none;
}

/* Storage Allocation Bar */
.storage-bar-container {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 240px;
  background: var(--bg-tertiary);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
}

.storage-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.725rem;
}

.storage-label {
  color: var(--text-muted);
  font-weight: 600;
}

.storage-text {
  color: var(--accent-secondary);
  font-weight: 700;
}

.storage-progress-track {
  height: 6px;
  background: var(--bg-primary);
  border-radius: 3px;
  overflow: hidden;
}

.storage-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary));
  border-radius: 3px;
  transition: width 0.4s ease;
}

/* App Header */
.header {
  height: 60px;
  background: var(--bg-glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  z-index: 10;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--text-main);
  letter-spacing: -0.5px;
}

.brand-icon {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 15px var(--accent-glow);
}

.header-user {
  display: flex;
  align-items: center;
  gap: 16px;
}

.btn {
  background: var(--bg-tertiary);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s ease;
}

.btn:hover {
  background: var(--bg-glass-hover);
  border-color: rgba(255, 255, 255, 0.2);
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-primary-hover));
  color: white;
  border: none;
  box-shadow: 0 4px 14px var(--accent-glow);
}

.btn-primary:hover {
  opacity: 0.95;
  transform: translateY(-1px);
}

.btn-danger {
  background: rgba(239, 68, 68, 0.15);
  color: var(--danger);
  border-color: rgba(239, 68, 68, 0.3);
}

.btn-danger:hover {
  background: var(--danger);
  color: white;
}

.user-badge {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-tertiary);
  padding: 4px 12px 4px 4px;
  border-radius: 30px;
  border: 1px solid var(--border-color);
}

.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
}

/* Layout Container */
.main-container {
  display: flex;
  flex: 1;
  overflow: hidden;
  z-index: 1;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  border-right: 1px solid var(--border-color);
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.nav-section {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.15s ease;
}

.nav-item:hover, .nav-item.active {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-main);
}

.nav-item.active {
  border-left: 3px solid var(--accent-primary);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

/* Notes List Panel */
.notes-panel {
  width: var(--notes-list-width);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
}

.notes-header {
  padding: 16px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.search-bar {
  position: relative;
}

.search-input {
  width: 100%;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 8px 12px 8px 36px;
  color: var(--text-main);
  font-size: 0.875rem;
  outline: none;
  transition: border-color 0.2s;
}

.search-input:focus {
  border-color: var(--accent-primary);
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-dim);
}

.notes-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.note-card {
  background: var(--bg-glass);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 14px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.note-card:hover {
  background: var(--bg-glass-hover);
  border-color: rgba(255, 255, 255, 0.15);
  transform: translateY(-1px);
}

.note-card.active {
  border-color: var(--accent-primary);
  background: rgba(99, 102, 241, 0.1);
}

.note-card-title {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text-main);
  margin-bottom: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.note-card-snippet {
  font-size: 0.8rem;
  color: var(--text-muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.4;
}

.note-card-date {
  font-size: 0.7rem;
  color: var(--text-dim);
  margin-top: 8px;
}

/* Editor Panel */
.editor-panel {
  flex: 1;
  background: var(--bg-primary);
  display: flex;
  flex-direction: column;
}

.editor-toolbar {
  height: 56px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  background: var(--bg-secondary);
}

.editor-status {
  font-size: 0.8rem;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: 6px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
}

.editor-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 32px 48px;
  overflow-y: auto;
}

.editor-title {
  background: transparent;
  border: none;
  color: var(--text-main);
  font-size: 2.2rem;
  font-weight: 800;
  outline: none;
  margin-bottom: 20px;
  width: 100%;
}

.editor-title::placeholder {
  color: var(--text-dim);
}

.editor-content {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-main);
  font-size: 1.1rem;
  line-height: 1.7;
  outline: none;
  resize: none;
  font-family: inherit;
}

.editor-content::placeholder {
  color: var(--text-dim);
}

.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  gap: 16px;
  text-align: center;
}

/* Auth Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 400px;
  padding: 32px;
  box-shadow: var(--shadow-main);
  transform: translateY(20px);
  transition: transform 0.25s ease;
}

.modal-overlay.active .modal-card {
  transform: translateY(0);
}

.modal-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.modal-subtitle {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-bottom: 24px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}

.form-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
}

.form-input {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  color: var(--text-main);
  font-size: 0.95rem;
  outline: none;
}

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

.form-toggle {
  margin-top: 16px;
  font-size: 0.85rem;
  color: var(--text-muted);
  text-align: center;
}

.form-toggle span {
  color: var(--accent-primary);
  cursor: pointer;
  font-weight: 600;
}

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-main);
  display: flex;
  align-items: center;
  gap: 10px;
  z-index: 200;
  transform: translateY(100px);
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.toast.active {
  transform: translateY(0);
}

/* Mobile Responsive Styling (iPhone & Touch Devices) */
.sidebar-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 85;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.sidebar-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

@media (max-width: 768px) {
  html, body {
    height: 100dvh;
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden !important;
    position: relative;
  }

  .glow-bg, .glow-bg-secondary {
    display: none !important;
  }

  * {
    max-width: 100vw;
    box-sizing: border-box;
  }

  /* Prevent iOS input auto-zoom */
  input, textarea, select, button {
    font-size: 16px !important;
  }

  .header {
    height: 54px;
    padding: 0 12px;
    background: rgba(18, 22, 31, 0.95);
    width: 100vw;
    max-width: 100vw;
    box-sizing: border-box;
  }

  .brand span {
    font-size: 1.05rem;
  }

  .brand-icon {
    width: 28px;
    height: 28px;
  }

  .header-user .btn {
    padding: 6px 10px;
    font-size: 0.8rem;
  }

  .user-badge span {
    display: none;
  }

  .user-badge {
    padding: 4px;
    border-radius: 50%;
  }

  #storageBarHeader {
    display: none !important;
  }

  .sidebar-storage-mobile {
    display: block !important;
  }

  .mobile-sidebar-toggle {
    display: inline-flex !important;
  }

  .mobile-back-btn {
    display: inline-flex !important;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 90;
    transform: translateX(-100%);
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    width: 280px;
    max-width: 85vw;
    box-shadow: 10px 0 30px rgba(0, 0, 0, 0.6);
    background: #12161f;
  }

  .sidebar.mobile-open {
    transform: translateX(0);
  }

  .main-container {
    height: calc(100dvh - 54px);
    width: 100vw;
    max-width: 100vw;
    position: relative;
    overflow-x: hidden;
  }

  .notes-panel {
    width: 100%;
    height: 100%;
    flex: 1;
    border-right: none;
    position: relative;
  }

  .notes-header {
    padding: 12px 16px;
  }

  .notes-list {
    padding: 12px 16px 80px 16px;
  }

  .mobile-fab {
    display: flex !important;
    position: fixed;
    bottom: 24px;
    right: 20px;
    width: 56px;
    height: 56px;
    border-radius: 28px;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-primary-hover));
    color: white;
    border: none;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 24px var(--accent-glow);
    z-index: 50;
    cursor: pointer;
    transition: transform 0.2s ease;
  }

  .mobile-fab:active {
    transform: scale(0.92);
  }

  .editor-panel {
    display: none;
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-primary);
    z-index: 10;
  }

  body.mobile-show-editor .editor-panel {
    display: flex;
  }

  .editor-toolbar {
    height: 52px;
    padding: 0 16px;
  }

  .editor-body {
    padding: 16px;
  }

  .editor-title {
    font-size: 1.4rem;
    padding-bottom: 8px;
    margin-bottom: 12px;
  }

  .modal-card {
    margin: 16px;
    padding: 24px 20px;
    width: calc(100% - 32px);
    max-width: 380px;
  }

  .toast {
    bottom: 20px;
    left: 16px;
    right: 16px;
    justify-content: center;
  }
}
