/* ==========================================================================
   1. GLOBAL ARCHITECTURE & VARS
   ========================================================================== */
:root {
  --marian-blue: #3456A4;
  --marian-blue-light: #5F7DCB;
  --marian-gold: #D4AF37;
  
  /* System Adaptive Colors */
  --bg-system: #F2F2F7;
  --bg-card: #FFFFFF;
  --text-primary: #1C1C1E;
  --text-secondary: #8E8E93;
  --border-color: #E5E5EA;
  --shadow: rgba(0, 0, 0, 0.04);
  
  /* Mystery Visual Type Codes */
  --joyful: #5F7DCB;
  --sorrowful: #FF3B30;
  --glorious: #D4AF37;
  --luminous: #FF9500;
  
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);

  color-scheme: light dark;
}

body.dark {
  --bg-system: #0F111A;
  --bg-card: #1A1D27;
  --text-primary: #FFFFFF;    
  --text-secondary: #AEAEB2;  
  --border-color: #2C2C2E;
  --shadow: rgba(0, 0, 0, 0.3);
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  width: 100%;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-color: var(--bg-system);
  color: var(--text-primary);
  transition: background-color 0.2s ease, color 0.2s ease;
}

.app-container {
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

/* ==========================================================================
   2. HEADER & NAVIGATION OVERLAYS
   ========================================================================== */
.app-navbar {
  background-color: var(--marian-blue);
  color: #FFFFFF;
  padding: calc(12px + var(--safe-top)) 20px 12px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 4px solid var(--marian-gold);
  flex-shrink: 0;
}

.nav-branding { display: flex; align-items: center; gap: 10px; }
.nav-branding h1 { margin: 0; font-size: 1.3rem; font-weight: 700; color: #FFFFFF; }
.app-logo { font-size: 1.4rem; }

.desktop-nav { display: flex; gap: 8px; }
.desktop-nav .nav-link {
  background: none; border: none; color: rgba(255, 255, 255, 0.75);
  padding: 8px 16px; font-size: 0.95rem; font-weight: 600; cursor: pointer;
  border-radius: 6px; transition: all 0.2s;
}
.desktop-nav .nav-link.active, 
.desktop-nav .nav-link:hover {
  color: #FFFFFF; background-color: rgba(255, 255, 255, 0.15);
}

.icon-btn { background: none; border: none; font-size: 1.2rem; cursor: pointer; padding: 6px; color: #FFFFFF; }

/* ==========================================================================
   3. INTERNAL VIEWS & SCROLL TRACK ARCHITECTURE
   ========================================================================== */
.app-stage {
  flex: 1;
  position: relative;
  overflow: hidden;
  height: 100%; 
}

.app-view {
  position: absolute; top: 0; left: 0; right: 0; bottom: 0;
  display: none; flex-direction: column;
}
.app-view.active { display: flex; }

.scroll-layer {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  -webkit-overflow-scrolling: touch;
  max-width: 650px;
  width: 100%;
  box-sizing: border-box;
  margin: 0 auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.scroll-layer::-webkit-scrollbar {
  display: none !important;
  width: 0 !important;
  height: 0 !important;
  background: transparent !important;
}

/* ==========================================================================
   4. CONTENT LAYOUT CARDS & HAIKU TEXT CORE
   ========================================================================== */
.about-hero-card {
  background: linear-gradient(135deg, var(--marian-blue), var(--marian-blue-light));
  color: #FFFFFF; border-radius: 14px; padding: 20px; margin-bottom: 20px;
}
.about-hero-card h2 { margin: 0 0 8px 0; font-size: 1.35rem; color: #FFFFFF; }
.about-hero-card p { margin: 0; font-size: 0.95rem; line-height: 1.4; opacity: 0.9; }

.day-title-banner { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.day-title-banner h2 { margin: 0; font-size: 1.45rem; color: var(--text-primary); }

.badge { padding: 4px 12px; border-radius: 20px; font-size: 0.75rem; font-weight: bold; color: #fff; text-transform: uppercase; }
.badge.joyful { background-color: var(--joyful); }
.badge.sorrowful { background-color: var(--sorrowful); }
.badge.glorious { background-color: var(--glorious); color: #000000; }
.badge.luminous { background-color: var(--luminous); }

.card {
  background-color: var(--bg-card); border-radius: 12px; padding: 18px;
  margin-bottom: 12px; border: 1px solid var(--border-color); display: flex; gap: 14px;
  box-shadow: 0 4px 12px var(--shadow); transition: background-color 0.2s;
}
.card-num { font-size: 1.1rem; font-weight: bold; color: var(--text-secondary); }

.card h2, 
.card-main h3 { 
  margin: 0 0 6px 0; 
  font-size: 1.15rem; 
  font-weight: 700;
  color: var(--text-primary); 
}

.haiku,
.card .haiku {
  margin: 0;
  padding: 0;
  line-height: 1.6;
  font-size: 1.05rem;
  font-style: normal;
  font-weight: 400;
  color: var(--text-primary) !important;
  opacity: 0.95;
}

/* ==========================================================================
   5. PORTFOLIO & DYNAMIC AD PLACEMENTS
   ========================================================================== */
.selector-wrapper { padding: 14px 20px 0 20px; max-width: 650px; width: 100%; box-sizing: border-box; margin: 0 auto; flex-shrink: 0; }
.native-dropdown { width: 100%; padding: 12px; border-radius: 10px; background-color: var(--bg-card); color: var(--text-primary); border: 1px solid var(--border-color); font-size: 1rem; }

.section-intro { margin: 0 0 20px 0; font-size: 0.95rem; color: var(--text-secondary); line-height: 1.5; }
.project-card {
  background-color: var(--bg-card); border-radius: 14px; padding: 18px;
  margin-bottom: 16px; border: 1px solid var(--border-color); display: flex; gap: 16px; box-shadow: 0 4px 12px var(--shadow);
}
.project-icon { font-size: 2rem; display: flex; align-items: center; }
.project-details h3 { margin: 0 0 4px 0; font-size: 1.15rem; color: var(--text-primary); }
.project-details p { margin: 0 0 12px 0; font-size: 0.9rem; color: var(--text-secondary); line-height: 1.4; }
.project-btn {
  display: inline-block; background-color: var(--marian-blue); color: #FFFFFF; text-decoration: none;
  padding: 6px 14px; border-radius: 20px; font-size: 0.8rem; font-weight: 600;
}

.ad-placeholder {
  background-color: var(--bg-card); 
  border: 1px dashed var(--marian-blue-light);
  border-radius: 12px; 
  position: relative; 
  display: flex; 
  flex-direction: column;
  box-sizing: border-box;
}

.ad-badge {
  position: absolute; 
  top: 12px;                  
  left: 12px;                 
  font-size: 0.55rem;
  background-color: var(--border-color); 
  color: var(--text-secondary);
  padding: 2px 6px; 
  border-radius: 4px; 
  font-weight: bold;
}

.banner-ad { 
  height: auto; 
  margin: 16px auto; 
  width: 100%; 
  max-width: 650px; 
  flex-shrink: 0; 
  padding: 34px 18px 18px 18px; 
  text-align: left;
  box-shadow: 0 4px 12px var(--shadow);
}

.ad-content {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: 10px;
  letter-spacing: 0.3px;
}

.banner-ad h4 {
  margin: 0 0 8px 0;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--marian-blue);
  line-height: 1.3;
}
body.dark .banner-ad h4 {
  color: var(--marian-blue-light);
}

.banner-ad p {
  margin: 0 0 14px 0;
  font-size: 0.9rem;
  color: var(--text-primary);
  line-height: 1.45;
}

.banner-ad a {
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--marian-gold);
  transition: opacity 0.2s ease;
}
.banner-ad a:hover {
  opacity: 0.8;
}

.inline-card-ad {
  position: relative;         
  border: 1px solid var(--marian-gold); 
  background: linear-gradient(to bottom right, var(--bg-card), rgba(212, 175, 55, 0.05));
  padding: 28px 20px 20px 20px; 
  border-radius: 14px; 
  text-align: left; 
  align-items: flex-start; 
  margin-bottom: 16px; 
  display: block; 
  box-shadow: 0 4px 12px var(--shadow);
}

.ad-card-body h4 { margin: 12px 0 6px 0; color: var(--marian-gold); font-size: 1.1rem; }
.ad-card-body p { margin: 0 0 12px 0; font-size: 0.9rem; color: var(--text-primary); }
.ad-mock-link { font-size: 0.85rem; font-weight: bold; color: var(--marian-blue); }
body.dark .ad-mock-link { color: var(--marian-blue-light); }

/* ==========================================================================
   6. SETTINGS, CONTROLS & NAVIGATION TAB BAR
   ========================================================================== */
.settings-list { display: flex; flex-direction: column; gap: 20px; }
.settings-group h3 { text-transform: uppercase; font-size: 0.7rem; color: var(--text-secondary); margin: 0 0 6px 6px; letter-spacing: 0.5px; }
.settings-row {
  background-color: var(--bg-card); padding: 14px 16px; display: flex; justify-content: space-between;
  align-items: center; border: none; border-bottom: 1px solid var(--border-color); font-size: 1rem;
  text-align: left; width: 100%; box-sizing: border-box; color: var(--text-primary); font-family: inherit;
}
.settings-row:first-of-type { border-top-left-radius: 12px; border-top-right-radius: 12px; }
.settings-row:last-of-type { border-bottom-left-radius: 12px; border-bottom-right-radius: 12px; border-bottom: none; }
button.settings-row { cursor: pointer; }
button.settings-row:active { background-color: var(--border-color); }
.native-input { border: 1px solid var(--border-color); background: var(--bg-system); color: var(--text-primary); padding: 6px; border-radius: 6px; }
.arrow { color: var(--text-secondary); }
.app-version-tag { text-align: center; font-size: 0.75rem; color: var(--text-secondary); margin-top: 16px; margin-bottom: 4px; }

.mobile-tab-bar {
  background-color: var(--bg-card); border-top: 1px solid var(--border-color);
  display: flex; padding-bottom: calc(6px + var(--safe-bottom)); padding-top: 8px; flex-shrink: 0;
}
.tab-item {
  flex: 1; background: none; border: none; display: flex; flex-direction: column; align-items: center;
  gap: 4px; color: var(--text-secondary); cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.tab-item.active { color: var(--marian-blue); font-weight: bold; }
body.dark .tab-item.active { color: var(--marian-blue-light); }
.tab-icon { font-size: 1.25rem; }
.tab-label { font-size: 0.65rem; }

/* ==========================================================================
   7. MODAL OVERLAYS & RICH TEXT PANELS
   ========================================================================== */
.modal-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0; background-color: rgba(0,0,0,0.5);
  z-index: 500; display: none; align-items: flex-end; justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal-sheet {
  background-color: var(--bg-card); width: 100%; max-width: 550px; border-top-left-radius: 16px;
  border-top-right-radius: 16px; padding: 20px 20px calc(20px + var(--safe-bottom)) 20px;
  box-sizing: border-box; max-height: 80vh; display: flex; flex-direction: column;
}
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.modal-header h2 { margin: 0; font-size: 1.2rem; color: var(--text-primary); }
.close-btn { background: var(--bg-system); border: none; font-size: 0.85rem; padding: 6px 12px; border-radius: 20px; cursor: pointer; color: var(--text-primary); }
.modal-body-content { flex: 1; overflow-y: auto; line-height: 1.5; font-size: 0.95rem; color: var(--text-primary); }

/* ==========================================================================
   8. APPLICATION SCOPED VIEW FOOTERS
   ========================================================================== */
.app-footer {
  margin: 32px auto 16px auto;
  padding: 16px 8px 8px 8px;
  text-align: center;
  width: 100%;
  box-sizing: border-box;
  border-top: 1px dashed var(--border-color);
}

.app-footer p {
  margin: 0 0 10px 0;
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.app-footer p small {
  font-size: 0.78rem;
  opacity: 0.9;
}

.app-footer a,
.footer-link-btn {
  color: var(--marian-blue-light);
  text-decoration: none;
  font-weight: 600;
  background: none;
  border: none;
  padding: 0;
  font-family: inherit;
  font-size: 0.82rem;
  cursor: pointer;
  display: inline;
}

.app-footer a:hover,
.footer-link-btn:hover {
  text-decoration: underline;
  opacity: 0.8;
}

/* ==========================================================================
   9. RESPONSIVE BREAKPOINT TUNING
   ========================================================================== */
@media (min-width: 768px) {
  .mobile-tab-bar { display: none; }
  .scroll-layer { padding: 30px 20px; }
  .modal-overlay { align-items: center; }
  .modal-sheet { border-radius: 12px; max-height: 65vh; }
}

@media (max-width: 767px) {
  .desktop-nav { display: none; }
}