/* ==========================================================================
   CSS DESIGN SYSTEM & GENERAL STYLES
   ========================================================================== */

:root {
  /* iOS Dark Theme (Default) */
  --bg-color: #000000;
  --calc-btn-num-bg: #333333;
  --calc-btn-num-color: #ffffff;
  --calc-btn-act-bg: #a5a5a5;
  --calc-btn-act-color: #000000;
  --calc-btn-op-bg: #ff9f0a;
  --calc-btn-op-color: #ffffff;
  --calc-display-color: #ffffff;
  
  /* Vault Theme Variables (Glassmorphism) */
  --vault-bg: rgba(18, 18, 22, 0.7);
  --vault-card-bg: rgba(28, 28, 32, 0.45);
  --vault-card-border: rgba(255, 255, 255, 0.08);
  --text-primary: #ffffff;
  --text-secondary: #8e8e93;
  --accent-color: #ff9f0a; /* Dynamic orange iOS accent */
  --accent-color-rgb: 255, 159, 10;
  --danger-color: #ff453a;
  --success-color: #30d158;
  --safe-area-top: env(safe-area-inset-top, 0px);
  --safe-area-bottom: env(safe-area-inset-bottom, 0px);
}

/* Base resets */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

body, html {
  width: 100%;
  height: 100%;
  background-color: #000;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Icons", "Helvetica Neue", Helvetica, Arial, sans-serif;
  overflow: hidden;
  position: fixed; /* Prevents bounce scroll on mobile */
  color: var(--text-primary);
}

#app-container {
  width: 100%;
  height: var(--vh, 100%);
  position: relative;
  display: flex;
  flex-direction: column;
  max-width: 450px; /* Perfect mobile width on desktop screens */
  margin: 0 auto;
  background-color: var(--bg-color);
  box-shadow: 0 0 40px rgba(0, 0, 0, 0.8);
  overflow: hidden;
}

/* Screen Layouts */
.screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s cubic-bezier(0.16, 1, 0.3, 1), transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 10;
}

.screen.active {
  opacity: 1;
  pointer-events: auto;
  transform: scale(1);
}

.screen.hidden {
  display: none !important;
}

/* ==========================================================================
   CALCULATOR THEMES
   ========================================================================== */

/* iOS Light Theme */
#app-container.ios-light {
  --bg-color: #f1f2f6;
  --calc-btn-num-bg: #ffffff;
  --calc-btn-num-color: #000000;
  --calc-btn-act-bg: #d2d3d8;
  --calc-btn-act-color: #000000;
  --calc-btn-op-bg: #ff9500;
  --calc-btn-op-color: #ffffff;
  --calc-display-color: #000000;
  
  --vault-bg: rgba(245, 245, 247, 0.75);
  --vault-card-bg: rgba(255, 255, 255, 0.65);
  --vault-card-border: rgba(0, 0, 0, 0.06);
  --text-primary: #000000;
  --text-secondary: #8e8e93;
  --accent-color: #ff9500;
  --accent-color-rgb: 255, 149, 0;
}

/* Material You Theme */
#app-container.material-dark {
  --bg-color: #1a1c1e;
  --calc-btn-num-bg: #2f3033;
  --calc-btn-num-color: #e2e2e6;
  --calc-btn-act-bg: #43474e;
  --calc-btn-act-color: #d1e4ff;
  --calc-btn-op-bg: #adc6ff;
  --calc-btn-op-color: #002d6f;
  --calc-display-color: #e2e2e6;
  
  --vault-bg: rgba(26, 28, 30, 0.8);
  --vault-card-bg: rgba(47, 48, 51, 0.5);
  --vault-card-border: rgba(255, 255, 255, 0.05);
  --text-primary: #e2e2e6;
  --text-secondary: #909094;
  --accent-color: #adc6ff;
  --accent-color-rgb: 173, 198, 255;
  
  font-family: 'Outfit', 'Inter', sans-serif;
}

/* ==========================================================================
   CALCULATOR COMPONENT STYLES
   ========================================================================== */

#calculator-screen {
  background-color: var(--bg-color);
  padding-top: var(--safe-area-top);
  padding-bottom: calc(var(--safe-area-bottom) + 16px);
  justify-content: flex-end;
}

.calc-header-safe-area {
  height: 24px;
}

.calc-display-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: flex-end;
  padding: 0 32px 16px 32px;
  overflow: hidden;
}

.calc-history {
  font-size: 1.1rem;
  color: var(--text-secondary);
  min-height: 1.5rem;
  margin-bottom: 8px;
  white-space: nowrap;
  letter-spacing: 0.5px;
}

.calc-display {
  font-size: 5.5rem;
  font-weight: 300;
  color: var(--calc-display-color);
  white-space: nowrap;
  letter-spacing: -1px;
  transition: font-size 0.1s ease;
  line-height: 1;
  text-align: right;
  width: 100%;
}

.calc-keyboard {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-gap: 14px;
  padding: 0 16px;
  justify-items: center;
  align-items: center;
}

.calc-btn {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  border: none;
  font-size: 2.2rem;
  font-weight: 400;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  outline: none;
  transition: filter 0.1s ease, transform 0.05s ease, background-color 0.2s;
}

/* Calculator Button States & Interactions */
.calc-btn.number {
  background-color: var(--calc-btn-num-bg);
  color: var(--calc-btn-num-color);
}

.calc-btn.action {
  background-color: var(--calc-btn-act-bg);
  color: var(--calc-btn-act-color);
  font-size: 1.8rem;
}

.calc-btn.operator {
  background-color: var(--calc-btn-op-bg);
  color: var(--calc-btn-op-color);
  font-size: 2.5rem;
}

.calc-btn.operator.active-op {
  background-color: #ffffff;
  color: var(--calc-btn-op-bg);
  transform: scale(0.96);
}

/* Zero button spanning two columns */
.calc-btn.zero {
  grid-column: span 2;
  width: 166px;
  border-radius: 38px;
  justify-content: flex-start;
  padding-left: 28px;
}

/* Material You style tweaks */
.material-dark .calc-btn {
  border-radius: 24px;
  height: 72px;
  width: 80px;
  font-size: 1.8rem;
}
.material-dark .calc-btn.zero {
  width: 174px;
}
.material-dark .calc-btn.operator {
  font-size: 2rem;
}

/* Scientific Buttons and Indicators */
.scientific {
  display: none !important;
}

.calc-rad-indicator {
  position: absolute;
  left: 24px;
  bottom: 8px;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--accent-color);
  background-color: rgba(255, 159, 10, 0.15);
  padding: 1px 6px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  z-index: 20;
}

.calc-rad-indicator.hidden {
  display: none;
}

@media (orientation: landscape) {
  #app-container {
    max-width: 850px;
  }

  .calc-display-container {
    position: relative;
    padding: 8px 24px;
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
  }

  .calc-display {
    font-size: 3.2rem;
  }

  .calc-keyboard {
    grid-template-columns: repeat(10, 1fr);
    grid-gap: 8px;
    padding: 0 16px 16px 16px;
  }

  .scientific {
    display: flex !important;
  }

  .calc-btn {
    width: 100%;
    height: 40px;
    border-radius: 20px;
    font-size: 1.1rem;
  }
  
  .calc-btn.zero {
    width: 100%;
    justify-content: center;
    padding-left: 0;
  }
  
  .calc-btn.action {
    font-size: 1.1rem;
  }
  
  .calc-btn.operator {
    font-size: 1.3rem;
  }
  
  .calc-btn.scientific {
    background-color: #212123;
    color: #fff;
    font-size: 1rem;
  }
  
  .calc-btn.scientific.active-scientific {
    background-color: #ffffff;
    color: #000000;
  }
}

/* Interactive click animation */
.calc-btn:active {
  filter: brightness(1.3);
  transform: scale(0.92);
}

#app-container.ios-light .calc-btn:active {
  filter: brightness(0.85);
}

/* ==========================================================================
   BIOMETRIC TRANSITION OVERLAY
   ========================================================================== */

#security-transition {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle, #15161c 0%, #050508 100%);
  z-index: 100;
  display: flex;
  justify-content: center;
  align-items: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.5s ease;
}

#security-transition.active {
  opacity: 1;
  pointer-events: auto;
}

.transition-scanner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
}

.scan-grid {
  position: absolute;
  width: 140px;
  height: 140px;
  border: 1px solid rgba(var(--accent-color-rgb), 0.3);
  border-radius: 20px;
  background: radial-gradient(rgba(var(--accent-color-rgb), 0.05) 0%, transparent 80%);
  z-index: 1;
}

.scan-grid::before {
  content: '';
  position: absolute;
  width: 100%;
  height: 3px;
  background-color: var(--accent-color);
  top: 0;
  box-shadow: 0 0 15px var(--accent-color);
  animation: scan-move 2s infinite ease-in-out;
}

.biometric-icon {
  width: 90px;
  height: 90px;
  z-index: 2;
  position: relative;
}

.biometric-icon svg {
  width: 100%;
  height: 100%;
}

.transition-status {
  margin-top: 32px;
  font-size: 1rem;
  color: var(--text-secondary);
  font-weight: 500;
  letter-spacing: 1px;
  text-transform: uppercase;
  animation: pulse 1.5s infinite;
}

@keyframes scan-move {
  0% { top: 0%; }
  50% { top: 100%; }
  100% { top: 0%; }
}

@keyframes pulse {
  0% { opacity: 0.5; }
  50% { opacity: 1; }
  100% { opacity: 0.5; }
}

/* ==========================================================================
   SECRET VAULT PANEL STYLES (GLASSMORPHISM)
   ========================================================================== */

#vault-screen {
  background: linear-gradient(135deg, #101116 0%, #08080a 100%);
  color: var(--text-primary);
  display: flex;
  flex-direction: column;
  padding-top: var(--safe-area-top);
  padding-bottom: var(--safe-area-bottom);
}

/* Glassmorphism components */
.glass-panel {
  background: var(--vault-card-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--vault-card-border);
  border-radius: 20px;
}

/* Vault Header */
.vault-header {
  height: 64px;
  padding: 0 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--vault-card-border);
  background: rgba(8, 8, 10, 0.5);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 20;
}

.vault-title-section {
  display: flex;
  align-items: center;
  gap: 10px;
}

.vault-status-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--success-color);
  box-shadow: 0 0 8px var(--success-color);
}

.vault-decoy-active .vault-status-indicator {
  background-color: var(--accent-color);
  box-shadow: 0 0 8px var(--accent-color);
}

.vault-header h1 {
  font-size: 1.4rem;
  font-weight: 600;
  letter-spacing: -0.5px;
}

#vault-panic-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 8px;
  border-radius: 50%;
  transition: background-color 0.2s, color 0.2s;
}

#vault-panic-btn:active {
  background-color: rgba(255, 255, 255, 0.08);
  color: var(--danger-color);
}

/* Vault Main Content Area */
.vault-content {
  flex: 1;
  overflow-y: auto;
  position: relative;
  padding-bottom: 90px; /* Space for absolute floating elements/navigation */
  -webkit-overflow-scrolling: touch;
}

.vault-panel {
  display: none;
  flex-direction: column;
  height: 100%;
  padding: 16px 20px;
  animation: fade-slide 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.vault-panel.active {
  display: flex;
}

@keyframes fade-slide {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Panel Header Elements */
.panel-header {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 16px;
}

.panel-header-photo {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

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

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

/* Search bar styling */
.search-bar-container {
  position: relative;
  width: 100%;
}

.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-secondary);
  pointer-events: none;
}

.search-bar-container input {
  width: 100%;
  padding: 12px 16px 12px 42px;
  border-radius: 12px;
  border: 1px solid var(--vault-card-border);
  background-color: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
  font-size: 0.95rem;
  outline: none;
  transition: background-color 0.2s, border-color 0.2s;
}

.search-bar-container input:focus {
  background-color: rgba(255, 255, 255, 0.08);
  border-color: rgba(var(--accent-color-rgb), 0.5);
}

/* Category Tabs */
.category-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: none; /* Firefox */
}

.category-tabs::-webkit-scrollbar {
  display: none; /* Safari / Chrome */
}

.cat-tab {
  padding: 6px 14px;
  border-radius: 16px;
  font-size: 0.85rem;
  font-weight: 500;
  white-space: nowrap;
  background-color: rgba(255, 255, 255, 0.05);
  border: 1px solid transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
}

.cat-tab.active {
  background-color: var(--accent-color);
  color: #000000;
  font-weight: 600;
}

/* ==========================================================================
   NOTES MODULE STYLES
   ========================================================================== */

.notes-grid-container {
  flex: 1;
  position: relative;
}

.notes-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  grid-gap: 12px;
  padding-bottom: 24px;
}

.note-card {
  background: var(--vault-card-bg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--vault-card-border);
  border-radius: 16px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: 150px;
  cursor: pointer;
  position: relative;
  transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
}

.note-card:active {
  transform: scale(0.97);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.note-card.pinned {
  border-color: rgba(var(--accent-color-rgb), 0.3);
}

.note-card.pinned::before {
  content: '';
  position: absolute;
  top: 12px;
  right: 12px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: var(--accent-color);
  box-shadow: 0 0 6px var(--accent-color);
}

.note-card-title {
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.3;
  margin-bottom: 6px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  color: var(--text-primary);
}

.note-card-excerpt {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 8px;
  flex: 1;
}

.note-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: auto;
}

.note-card-date {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.note-card-category {
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 8px;
  font-weight: 600;
  background-color: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
}

/* Empty states */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  text-align: center;
  color: var(--text-secondary);
  gap: 16px;
  height: 100%;
}

.empty-state p {
  font-size: 0.95rem;
}

/* Float Action Button (FAB) */
.fab {
  position: absolute;
  bottom: 100px;
  right: 20px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background-color: var(--accent-color);
  color: #000000;
  border: none;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  z-index: 50;
  transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.fab:active {
  transform: scale(0.9) rotate(45deg);
}

/* ==========================================================================
   PHOTOS GALLERY MODULE
   ========================================================================== */

.photos-grid-container {
  flex: 1;
  overflow-y: auto;
}

.photos-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-gap: 8px;
  padding-bottom: 24px;
}

.photo-thumb {
  aspect-ratio: 1;
  border-radius: 12px;
  overflow: hidden;
  background-color: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--vault-card-border);
  cursor: pointer;
  position: relative;
  transition: transform 0.2s;
}

.photo-thumb:active {
  transform: scale(0.95);
}

.photo-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ==========================================================================
   PASSWORDS MODULE
   ========================================================================== */

.passwords-list-container {
  flex: 1;
}

.passwords-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-bottom: 24px;
}

.password-card {
  background: var(--vault-card-bg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--vault-card-border);
  border-radius: 16px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.pwd-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.pwd-card-title-sec {
  display: flex;
  flex-direction: column;
}

.pwd-card-title {
  font-size: 1.05rem;
  font-weight: 600;
}

.pwd-card-url {
  font-size: 0.75rem;
  color: var(--accent-color);
  text-decoration: none;
  margin-top: 2px;
  display: block;
}

.pwd-card-delete-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px;
  border-radius: 50%;
  transition: color 0.2s, background-color 0.2s;
}

.pwd-card-delete-btn:active {
  color: var(--danger-color);
  background-color: rgba(255, 255, 255, 0.05);
}

.pwd-card-details {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-gap: 8px;
  background-color: rgba(0, 0, 0, 0.15);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 0.85rem;
}

.pwd-field-label {
  color: var(--text-secondary);
  font-size: 0.75rem;
  grid-column: 1 / 3;
}

.pwd-field-value {
  font-family: monospace;
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  align-items: center;
}

.pwd-action-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  transition: color 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.pwd-action-btn:active {
  color: #ffffff;
  background-color: rgba(255, 255, 255, 0.05);
}

/* ==========================================================================
   SETTINGS MODULE
   ========================================================================== */

#panel-settings {
  gap: 24px;
}

#panel-settings h2 {
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 4px;
}

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

.settings-group h3 {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  padding-left: 6px;
  margin-bottom: 4px;
}

.settings-item, .settings-item-danger {
  background: var(--vault-card-bg);
  border: 1px solid var(--vault-card-border);
  border-radius: 16px;
  padding: 14px 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.item-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}

.item-title {
  font-size: 0.95rem;
  font-weight: 600;
}

.item-desc {
  font-size: 0.78rem;
  color: var(--text-secondary);
  line-height: 1.3;
}

/* Settings Controls Input UI */
.input-setting {
  background-color: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--vault-card-border);
  color: var(--text-primary);
  padding: 8px 12px;
  border-radius: 10px;
  width: 110px;
  text-align: center;
  font-family: monospace;
  font-size: 0.95rem;
  outline: none;
}

.input-setting:focus {
  border-color: var(--accent-color);
  background-color: rgba(255, 255, 255, 0.08);
}

.select-setting {
  background-color: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--vault-card-border);
  color: var(--text-primary);
  padding: 8px 12px;
  border-radius: 10px;
  outline: none;
  font-size: 0.85rem;
}

/* Custom CSS Switch iOS look */
.switch {
  position: relative;
  display: inline-block;
  width: 51px;
  height: 31px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(120, 120, 128, 0.32);
  transition: .4s;
  border-radius: 34px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 27px;
  width: 27px;
  left: 2px;
  bottom: 2px;
  background-color: white;
  transition: .4s;
  border-radius: 50%;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.15);
}

input:checked + .slider {
  background-color: var(--success-color);
}

input:checked + .slider:before {
  transform: translateX(20px);
}

/* Footer in Settings */
.settings-info-footer {
  text-align: center;
  font-size: 0.72rem;
  color: var(--text-secondary);
  margin-top: 16px;
  margin-bottom: 24px;
}

/* ==========================================================================
   NAVIGATION BAR FOR VAULT
   ========================================================================== */

.vault-nav {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: calc(64px + var(--safe-area-bottom));
  padding-bottom: var(--safe-area-bottom);
  background: rgba(18, 18, 22, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--vault-card-border);
  display: flex;
  justify-content: space-around;
  align-items: center;
  z-index: 80;
}

.nav-item {
  background: none;
  border: none;
  color: var(--text-secondary);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  font-size: 0.65rem;
  font-weight: 500;
  cursor: pointer;
  flex: 1;
  height: 100%;
  transition: color 0.2s;
}

.nav-item.active {
  color: var(--accent-color);
}

.nav-item svg {
  transition: transform 0.2s;
}

.nav-item:active svg {
  transform: scale(0.9);
}

/* ==========================================================================
   BUTTONS AND COMMON FORMS UI
   ========================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: 12px;
  font-size: 0.9rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-primary {
  background-color: var(--accent-color);
  color: #000000;
}
.btn-primary:active {
  filter: brightness(0.85);
  transform: scale(0.98);
}

.btn-secondary {
  background-color: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
  border: 1px solid var(--vault-card-border);
}
.btn-secondary:active {
  background-color: rgba(255, 255, 255, 0.12);
}

.btn-danger {
  background-color: var(--danger-color);
  color: #ffffff;
}
.btn-danger:active {
  filter: brightness(0.85);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.8rem;
  border-radius: 8px;
}

.btn-block {
  width: 100%;
  padding: 14px;
}

/* ==========================================================================
   MODALS AND DIALOG OVERLAYS
   ========================================================================== */

.modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.7);
  z-index: 150;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  justify-content: center;
  align-items: flex-end; /* iOS sheet style opens from bottom */
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.modal-container {
  width: 100%;
  background-color: #1c1c1e;
  border-top-left-radius: 20px;
  border-top-right-radius: 20px;
  padding: 20px 24px calc(24px + var(--safe-area-bottom)) 24px;
  box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.5);
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
}

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

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

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

.icon-btn-close, .icon-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px;
  border-radius: 50%;
}

.icon-btn-close:active, .icon-btn:active {
  background-color: rgba(255, 255, 255, 0.05);
  color: #fff;
}

.modal-body {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.note-modal-container {
  height: 85%; /* High sheet for notes typing, leaves gap at top */
  max-height: 680px; /* Prevents long tube stretch on desktop screens */
}

.select-category {
  background-color: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--vault-card-border);
  color: var(--text-primary);
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  outline: none;
}

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

#note-pin-btn.active {
  color: var(--accent-color);
}

.note-body {
  flex: 1;
}

.input-note-title {
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 1.5rem;
  font-weight: 700;
  outline: none;
  width: 100%;
}

.note-time {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: -8px;
}

.textarea-note-content {
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 1.05rem;
  line-height: 1.5;
  resize: none;
  outline: none;
  width: 100%;
  flex: 1;
  min-height: 100px;
  margin-top: 8px;
  font-family: inherit;
}

/* Password Form styling */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-transform: uppercase;
  padding-left: 2px;
}

.form-group input {
  background-color: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--vault-card-border);
  border-radius: 10px;
  padding: 12px 14px;
  color: var(--text-primary);
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s;
}

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

.pwd-input-wrapper {
  display: flex;
  width: 100%;
}

.pwd-input-wrapper input {
  flex: 1;
}

/* Photo Lightbox specific styling */
.modal-overlay.lightbox {
  background-color: rgba(0, 0, 0, 0.95);
  justify-content: center;
  align-items: center;
}

.lightbox-content {
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
}

.lightbox-content img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 4px 30px rgba(0, 0, 0, 0.7);
}

.lightbox-close {
  position: absolute;
  top: calc(16px + var(--safe-area-top));
  left: 20px;
  background: rgba(0, 0, 0, 0.5);
  border: none;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  z-index: 180;
}

.lightbox-delete {
  position: absolute;
  top: calc(16px + var(--safe-area-top));
  right: 20px;
  background: rgba(0, 0, 0, 0.5);
  border: none;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  z-index: 180;
}

.lightbox-download {
  position: absolute;
  top: calc(16px + var(--safe-area-top));
  right: 70px;
  background: rgba(0, 0, 0, 0.5);
  border: none;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  z-index: 180;
}

/* ==========================================================================
   PWA INSTALLATION DRAWERS
   ========================================================================== */

.install-drawer {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  background-color: #1c1c1e;
  border-top-left-radius: 20px;
  border-top-right-radius: 20px;
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.6);
  z-index: 200;
  padding: 16px 24px calc(24px + var(--safe-area-bottom)) 24px;
  transform: translateY(100%);
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
  gap: 16px;
  border: 1px solid var(--vault-card-border);
}

.install-drawer.active {
  transform: translateY(0);
}

.drawer-handle {
  width: 36px;
  height: 5px;
  background-color: rgba(255, 255, 255, 0.15);
  border-radius: 2.5px;
  align-self: center;
}

.drawer-header {
  display: flex;
  align-items: center;
  gap: 14px;
}

.app-icon-dummy {
  width: 50px;
  height: 50px;
}

.app-icon-dummy svg,
.app-icon-dummy img {
  width: 100%;
  height: 100%;
  border-radius: 11px;
  object-fit: cover;
}

.app-info {
  flex: 1;
}

.app-info h3 {
  font-size: 1.05rem;
  font-weight: 600;
  margin-bottom: 2px;
}

.app-info p {
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.3;
}

.btn-drawer-close {
  background: rgba(255, 255, 255, 0.08);
  border: none;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background-color 0.2s, transform 0.1s;
}

.btn-drawer-close:active {
  background: rgba(255, 255, 255, 0.18);
  transform: scale(0.95);
}

.drawer-body {
  background-color: rgba(0, 0, 0, 0.2);
  border-radius: 12px;
  padding: 14px 18px;
}

.install-guide-item ol {
  padding-left: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 0.9rem;
  line-height: 1.4;
}

.inline-svg {
  display: inline-block;
  vertical-align: middle;
  margin: 0 2px;
  color: var(--accent-color);
}

/* ==========================================================================
   DASHBOARD & NEW MODULES STYLES
   ========================================================================== */

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  grid-gap: 16px;
  padding-bottom: 24px;
}

.dashboard-card {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-radius: 18px;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: space-between;
  min-height: 140px;
  cursor: pointer;
  transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1), background-color 0.2s, box-shadow 0.2s;
  box-shadow: 0 4px 30px rgba(0, 0, 0, 0.2);
}

.dashboard-card:active {
  transform: scale(0.96);
  background: rgba(255, 255, 255, 0.08);
}

.card-icon-wrapper {
  border-radius: 12px;
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
}

.card-title {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-top: auto;
  margin-bottom: 4px;
}

.card-badge {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

/* Vibrancy Colors */
.notes-color { background: linear-gradient(135deg, #ff9f0a, #ffb340); color: #fff; }
.photos-color { background: linear-gradient(135deg, #0a84ff, #409eff); color: #fff; }
.videos-color { background: linear-gradient(135deg, #af52de, #c57beb); color: #fff; }
.passwords-color { background: linear-gradient(135deg, #30d158, #5ee083); color: #fff; }
.recordings-color { background: linear-gradient(135deg, #ff453a, #ff6961); color: #fff; }
.documents-color { background: linear-gradient(135deg, #64d2ff, #90e0ff); color: #fff; }
.contacts-color { background: linear-gradient(135deg, #ffd60a, #ffe040); color: #fff; }

/* Panel Back Header Styles */
.panel-back-header {
  display: flex;
  align-items: center;
  position: relative;
  height: 44px;
  margin-bottom: 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding-bottom: 8px;
}

.panel-back-header h2 {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  font-size: 1.15rem;
  font-weight: 600;
  margin: 0;
  pointer-events: none;
}

.btn-back-dashboard {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: none;
  border: none;
  color: var(--accent-color);
  font-size: 1rem;
  font-weight: 400;
  cursor: pointer;
  padding: 0;
  transition: opacity 0.2s;
  z-index: 10;
}

.btn-back-dashboard:active {
  opacity: 0.6;
}

/* Videos Overlay */
.video-thumb {
  aspect-ratio: 1;
  border-radius: 12px;
  overflow: hidden;
  background-color: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--vault-card-border);
  cursor: pointer;
  position: relative;
  transition: transform 0.2s;
}

.video-thumb:active {
  transform: scale(0.95);
}

.video-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.video-thumb::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 36px;
  height: 36px;
  background: rgba(0, 0, 0, 0.6);
  border-radius: 50%;
  border: 2px solid #fff;
  z-index: 2;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23fff'%3E%3Cpolygon points='5 3 19 12 5 21 5 3'/%3E%3C/svg%3E");
  background-size: 16px;
  background-repeat: no-repeat;
  background-position: center center;
  transition: background-color 0.2s, transform 0.2s;
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
}

.video-thumb:active::after {
  background-color: var(--accent-color);
  transform: translate(-50%, -50%) scale(1.1);
}

/* Audio Dictaphone & Player Styles */
.audio-card {
  background: var(--vault-card-bg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--vault-card-border);
  border-radius: 16px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.audio-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.audio-card-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
}

.audio-card-date {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.audio-player-container {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 10px;
  padding: 8px 12px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.audio-play-btn {
  background: var(--accent-color);
  border: none;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  cursor: pointer;
  transition: transform 0.1s;
}

.audio-play-btn:active {
  transform: scale(0.9);
}

.audio-play-btn svg {
  width: 14px;
  height: 14px;
  fill: currentColor;
}

.audio-timeline-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.audio-slider {
  -webkit-appearance: none;
  width: 100%;
  height: 4px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.2);
  outline: none;
}

.audio-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent-color);
  cursor: pointer;
}

.audio-time-info {
  display: flex;
  justify-content: space-between;
  font-size: 0.7rem;
  color: var(--text-secondary);
  font-family: monospace;
}

.record-wave-container.recording .wave-bar {
  animation: wave-pulse 1.2s ease-in-out infinite;
}

.record-wave-container.recording .wave-bar:nth-child(1) { animation-delay: 0.1s; }
.record-wave-container.recording .wave-bar:nth-child(2) { animation-delay: 0.3s; }
.record-wave-container.recording .wave-bar:nth-child(3) { animation-delay: 0.5s; }
.record-wave-container.recording .wave-bar:nth-child(4) { animation-delay: 0.2s; }
.record-wave-container.recording .wave-bar:nth-child(5) { animation-delay: 0.4s; }

@keyframes wave-pulse {
  0%, 100% { transform: scaleY(1); }
  50% { transform: scaleY(2.2); }
}

/* Documents Module Styles */
.doc-card {
  background: var(--vault-card-bg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--vault-card-border);
  border-radius: 16px;
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 16px;
  cursor: pointer;
  transition: transform 0.2s, background-color 0.2s;
}

.doc-card:active {
  transform: scale(0.98);
  background: rgba(255, 255, 255, 0.06);
}

.doc-icon-wrapper {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.05);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-color);
}

.doc-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0; /* allows text truncation inside flexbox */
}

.doc-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.doc-meta {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.doc-delete-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 8px;
  border-radius: 50%;
  transition: color 0.2s, background 0.2s;
}

.doc-delete-btn:active {
  background: rgba(255, 69, 58, 0.15);
  color: var(--danger-color);
}

/* Contacts Module Styles */
.contact-card {
  background: var(--vault-card-bg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--vault-card-border);
  border-radius: 16px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

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

.contact-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--accent-color);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 1.1rem;
}

.contact-details {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.contact-name {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
}

.contact-note-small {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.contact-actions {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

.contact-btn {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 8px 0;
  color: var(--text-primary);
  font-size: 0.85rem;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.2s;
}

.contact-btn:active {
  background: rgba(255, 255, 255, 0.12);
}

.contact-btn.delete {
  flex: 0 0 40px;
  color: var(--danger-color);
  border-color: rgba(255, 69, 58, 0.2);
}

.contact-btn.delete:active {
  background: rgba(255, 69, 58, 0.1);
}

/* Markdown Rendering Styles in Note Editor */
.note-rendered-content h1 {
  font-size: 1.35rem;
  margin-top: 14px;
  margin-bottom: 8px;
  font-weight: 600;
  color: var(--text-primary);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding-bottom: 4px;
}

.note-rendered-content h2 {
  font-size: 1.2rem;
  margin-top: 12px;
  margin-bottom: 6px;
  font-weight: 600;
  color: var(--text-primary);
}

.note-rendered-content h3 {
  font-size: 1.05rem;
  margin-top: 10px;
  margin-bottom: 4px;
  font-weight: 600;
  color: var(--text-primary);
}

.note-rendered-content p {
  margin-bottom: 8px;
  font-size: 0.95rem;
  line-height: 1.5;
  color: rgba(255, 255, 255, 0.85);
}

.markdown-checklist-item {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 6px 0;
  padding: 2px 0;
}

.markdown-todo-checkbox {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  accent-color: var(--accent-color);
  cursor: pointer;
  margin: 0;
}

.markdown-todo-text {
  font-size: 0.95rem;
  color: var(--text-primary);
  transition: color 0.2s, text-decoration 0.2s;
}

.markdown-todo-text.completed {
  text-decoration: line-through;
  color: var(--text-secondary);
}
