.app {
  display: grid;
  grid-template-columns: 236px minmax(0, 1fr);
  gap: 14px;
  padding: 14px;
  min-height: 100vh;
  transition: grid-template-columns 0.36s cubic-bezier(0.16, 1, 0.3, 1);
}

.grid > *, main > *, .app > * { min-width: 0; }

aside {
  position: sticky;
  top: 14px;
  align-self: start;
  height: calc(100vh - 28px);
  padding: 18px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 30;
  transition: padding 0.32s cubic-bezier(0.16, 1, 0.3, 1);
}

.logo {
  text-align: center;
  padding: 4px 0 16px;
  color: var(--ac);
  text-decoration: none;
  display: block;
  white-space: nowrap;
}
.logo b { display: block; font: 400 40px/1 "Pinyon Script", cursive; }
.logo small { font-size: 8.5px; letter-spacing: 0.32em; font-weight: 500; }

/* Theme-Aware Custom Logo Switching + Safe Text Fallback */
.logo-full .lg-img {
  display: none;
  max-width: 164px;
  max-height: 54px;
  width: auto;
  height: auto;
  margin: 0 auto;
  object-fit: contain;
}
.logo-full .lg-fb { display: none; }

:root[data-wp="warm"] .logo-full .lg-warm { display: block; }
:root[data-wp="dusk"] .logo-full .lg-dusk { display: block; }
:root[data-wp="midnight"] .logo-full .lg-night { display: block; }

:root[data-wp="warm"] .logo-full.fb-warm .lg-fb,
:root[data-wp="dusk"] .logo-full.fb-dusk .lg-fb,
:root[data-wp="midnight"] .logo-full.fb-night .lg-fb { display: block; }

.logo-mini { display: none; }
.logo-mini .lg-m {
  display: none;
  width: 38px;
  height: 38px;
  margin: 0 auto;
  object-fit: contain;
}
.logo-mini .mono { display: none; font: 400 38px/1 "Pinyon Script", cursive; font-style: normal; }

:root[data-wp="warm"] .logo-mini .lg-m-warm { display: block; }
:root[data-wp="dusk"] .logo-mini .lg-m-dusk { display: block; }
:root[data-wp="midnight"] .logo-mini .lg-m-night { display: block; }

:root[data-wp="warm"] .logo-mini.fb-m-warm .mono,
:root[data-wp="dusk"] .logo-mini.fb-m-dusk .mono,
:root[data-wp="midnight"] .logo-mini.fb-m-night .mono { display: block; }

aside nav { display: flex; flex-direction: column; gap: 6px; }

nav a {
  display: flex;
  gap: 11px;
  align-items: center;
  padding: 10px 13px;
  border-radius: 13px;
  border: 1px solid transparent;
  cursor: pointer;
  color: var(--mu);
  font-weight: 600;
  transition: background 0.22s ease, color 0.22s ease, border-color 0.22s ease, transform 0.22s ease, box-shadow 0.22s ease;
  position: relative;
  text-decoration: none;
  white-space: nowrap;
}

aside nav a:hover:not(.on) {
  background: var(--in);
  border-color: var(--gb);
  color: var(--tx);
  transform: translateX(3px);
}

nav a.on {
  background: linear-gradient(135deg, var(--btn), color-mix(in srgb, var(--btn) 75%, var(--ac)));
  color: #fff;
  border-color: rgba(255, 255, 255, 0.16);
  box-shadow: 0 6px 18px rgba(106, 4, 15, 0.32);
}

nav a i { font-style: normal; width: 20px; height: 20px; display: grid; place-items: center; flex-shrink: 0; }
nav a i svg { display: block; }

.side-foot { margin-top: auto; padding-top: 12px; font-size: 11px; color: var(--mu); display: grid; gap: 8px; }

/* Sleek Single Theme Cycle Icon Button (shown in Mini Sidebar) */
.wp-cycle {
  display: none;
  width: 44px;
  height: 44px;
  margin: 0 auto;
  border-radius: 13px;
  border: 1px solid var(--gb);
  background: var(--in);
  color: var(--tx);
  place-items: center;
  cursor: pointer;
  position: relative;
  transition: background 0.2s, border-color 0.2s, color 0.2s, transform 0.2s;
}
.wp-cycle:hover {
  background: var(--btn);
  color: #fff;
  border-color: transparent;
  transform: scale(1.05);
}

/* MINI ICON RAIL SIDEBAR (74px) */
html.nh .app {
  grid-template-columns: 74px minmax(0, 1fr);
}
html.nh aside {
  padding: 16px 10px;
  overflow: visible;
}
html.nh aside .logo { padding: 4px 0 14px; }
html.nh aside .logo b,
html.nh aside .logo small,
html.nh aside nav a span,
html.nh aside .wp-full {
  display: none;
}
html.nh aside .logo .mono { display: block; }
html.nh aside .wp-cycle { display: grid; }
html.nh aside nav a { justify-content: center; padding: 11px 0; }
html.nh aside nav a:hover:not(.on) { transform: scale(1.05); }

html.nh aside .logo-full,
html.nh aside nav a span,
html.nh aside .wp-full {
  display: none;
}
html.nh aside .logo-mini { display: block; }
html.nh aside .wp-cycle { display: grid; }

/* Sleek Glass Tooltip for Mini Sidebar icons & theme button */
html.nh aside nav a::after,
html.nh aside .wp-cycle::after {
  content: attr(data-tip);
  position: absolute;
  left: calc(100% + 14px);
  top: 50%;
  transform: translateY(-50%) translateX(-6px);
  padding: 6px 12px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--tx);
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border: 1px solid var(--gb);
  box-shadow: var(--sh);
  opacity: 0;
  pointer-events: none;
  white-space: nowrap;
  z-index: 80;
  transition: opacity 0.2s ease, transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}
html.nh aside nav a:hover::after,
html.nh aside .wp-cycle:hover::after {
  opacity: 1;
  transform: translateY(-50%) translateX(0);
}

main { min-width: 0; display: flex; flex-direction: column; gap: 14px; }

header {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 10px 14px;
  position: sticky;
  top: 14px;
  z-index: 25;
  flex-wrap: wrap;
}
header h1 { margin: 0; font: 600 28px/1 "Cormorant Garamond", serif; flex: 1; min-width: 110px; letter-spacing: 0.01em; }

/* Sidebar Toggle Button */
.nav-toggle {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  border: 1px solid var(--gb);
  background: var(--in);
  color: var(--tx);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background 0.2s, transform 0.2s, border-color 0.2s, color 0.2s;
  flex-shrink: 0;
}
.nav-toggle:hover {
  background: var(--btn);
  color: #fff;
  border-color: transparent;
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(106, 4, 15, 0.28);
}
.nav-toggle .tg-arrow {
  transform-origin: 14px 12px;
  transition: transform 0.34s cubic-bezier(0.16, 1, 0.3, 1);
}
html.nh .nav-toggle .tg-arrow { transform: rotate(180deg); }
html.nh .nav-toggle { background: var(--btn); color: #fff; border-color: transparent; }

.sr { position: relative; flex: 1 1 180px; max-width: 280px; }
.sr kbd { position: absolute; right: 10px; top: 8px; font-size: 10px; color: var(--mu); }

.bell { position: relative; cursor: pointer; font-size: 18px; padding: 6px 8px; border-radius: 10px; transition: 0.2s; }
.bell:hover { background: var(--in); }
.bell svg { width: 21px; height: 21px; display: block; }
.bell b { position: absolute; top: 0; right: 1px; background: var(--er); color: #fff; font-size: 10px; border-radius: 9px; padding: 0 5px; }

/* Profile Trigger & Dropdown */
.prof-wrap { position: relative; }
.prof-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px 4px 4px;
  border-radius: 99px;
  border: 1px solid var(--gb);
  background: var(--in);
  color: var(--tx);
  cursor: pointer;
  font: inherit;
  transition: 0.2s;
}
.prof-btn:hover { border-color: var(--ac); background: var(--gl); transform: translateY(-1px); }

.avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--btn), var(--c2));
  color: #fff;
  font-weight: 700;
  font-size: 12px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  letter-spacing: 0.04em;
  box-shadow: 0 4px 12px rgba(106, 4, 15, 0.25);
}
.avatar.lg { width: 42px; height: 42px; font-size: 15px; }

.prof-meta { display: grid; text-align: left; line-height: 1.15; }
.prof-meta b { font-size: 12px; font-weight: 700; max-width: 110px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.prof-meta small { font-size: 10px; color: var(--mu); text-transform: capitalize; }
.prof-chev { color: var(--mu); transition: transform 0.25s; }
.prof-wrap.open .prof-chev { transform: rotate(180deg); }

.prof-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 10px);
  width: 248px;
  padding: 10px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(26px) saturate(180%);
  -webkit-backdrop-filter: blur(26px) saturate(180%);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px) scale(0.97);
  transform-origin: top right;
  transition: 0.22s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 60;
}
.prof-wrap.open .prof-menu { opacity: 1; visibility: visible; transform: none; }

.prof-head { display: flex; align-items: center; gap: 10px; padding: 6px; }
.prof-sep { height: 1px; background: var(--gb); margin: 8px 4px; }

.prof-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 12px;
  border: 0;
  background: transparent;
  color: var(--tx);
  font: 600 13px inherit;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
  transition: 0.18s;
  text-align: left;
}
.prof-item:hover { background: var(--in); }
.prof-item.er { color: var(--er); }
.prof-item.er:hover { background: rgba(179, 38, 30, 0.12); }
.prof-theme { padding: 6px 10px; display: flex; justify-content: space-between; align-items: center; gap: 8px; }

/* Custom Themed Alert & Confirm Dialog (Replaces ugly browser alert/confirm) */
.dlg-ov {
  position: fixed;
  inset: 0;
  z-index: 95;
  display: none;
  place-items: center;
  padding: 16px;
  background: rgba(14, 4, 7, 0.56);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.dlg-ov.on { display: grid; }

.dlg-box {
  width: min(410px, 100%);
  padding: 24px 22px 20px;
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  animation: dlgPop 0.28s cubic-bezier(0.16, 1, 0.3, 1) both;
}
@keyframes dlgPop {
  from { opacity: 0; transform: translateY(14px) scale(0.95); }
  to   { opacity: 1; transform: none; }
}

.dlg-top { display: flex; align-items: flex-start; gap: 14px; }
.dlg-ico {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  background: var(--in);
  border: 1px solid var(--gb);
  display: grid;
  place-items: center;
  flex-shrink: 0;
  color: var(--ac);
}
.dlg-ico.wn { color: var(--c2); }
.dlg-ico.er { color: var(--er); }
.dlg-ico.ok { color: var(--ok); }

.dlg-title { margin: 0 0 4px; font: 600 22px/1.1 "Cormorant Garamond", serif; }
.dlg-msg { margin: 0; font-size: 13.5px; color: var(--mu); line-height: 1.5; }
.dlg-acts { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }
.btn.danger { background: var(--er); color: #fff; }

/* Signature Mivora Splash Loader */
#ld {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 16px;
  background: var(--bg);
  color: var(--ac);
  transition: opacity 0.7s ease, visibility 0.7s ease;
}
#ld.out { opacity: 0; visibility: hidden; pointer-events: none; }
#ld b { font: 400 84px/1.1 "Pinyon Script", cursive; clip-path: inset(0 100% 0 0); animation: rv 1.45s 0.15s cubic-bezier(0.6, 0, 0.2, 1) forwards; }
#ld small { font-size: 11px; letter-spacing: 0.5em; opacity: 0; animation: fi 0.9s 0.9s forwards; }
#ld i { width: 155px; height: 2px; background: var(--in); border-radius: 2px; overflow: hidden; position: relative; }
#ld i:after { content: ""; position: absolute; inset: 0; background: var(--ac); transform: translateX(-100%); animation: ld 1.75s ease-in-out forwards; }

@keyframes rv { to { clip-path: inset(0 0 0 0); } }
@keyframes fi { to { opacity: 1; } }
@keyframes ld { to { transform: none; } }

/* Toast Notification */
#toast {
  position: fixed;
  right: 18px;
  bottom: 22px;
  z-index: 110;
  padding: 11px 16px;
  border-radius: 14px;
  font-weight: 600;
  font-size: 13px;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  opacity: 0;
  transform: translateY(16px);
  pointer-events: none;
  transition: 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}
#toast.on { opacity: 1; transform: none; }
#toast.ok { border-color: var(--ok); color: var(--ok); }
#toast.er { border-color: var(--er); color: var(--er); }

/* Mobile Bottom Nav */
#bn {
  display: none;
  position: fixed;
  left: 10px;
  right: 10px;
  bottom: calc(10px + env(safe-area-inset-bottom, 0px));
  z-index: 30;
  padding: 6px;
  border-radius: 24px;
  overflow-x: auto;
  gap: 4px;
  scrollbar-width: none;
  transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s;
}
#bn::-webkit-scrollbar { display: none; }
#bn a { flex-direction: column; gap: 2px; padding: 7px 12px; font-size: 10px; min-width: 64px; justify-content: center; flex: 0 0 auto; }
#bn a span { display: block; }
html.nh #bn { transform: translateY(150%); opacity: 0; pointer-events: none; }

/* Login Screen */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-box { width: min(400px, 100%); padding: 32px 26px; text-align: center; }
.login-box .logo b { font-size: 62px; }
.login-box form { display: grid; gap: 12px; margin-top: 18px; text-align: left; }

/* Seamless Zero-White-Flash View Transitions */
aside { view-transition-name: mv-sidebar; }
header { view-transition-name: mv-topbar; }
#view { view-transition-name: mv-content; }

::view-transition-old(root),
::view-transition-new(root),
::view-transition-old(mv-sidebar),
::view-transition-new(mv-sidebar),
::view-transition-old(mv-topbar),
::view-transition-new(mv-topbar) {
  animation: none;
}

::view-transition-old(mv-content) { animation: vtOut 0.18s ease forwards; }
::view-transition-new(mv-content) { animation: vtIn 0.24s ease-out forwards; }
@keyframes vtOut { to { opacity: 0; transform: translateY(6px); } }
@keyframes vtIn  { from { opacity: 0; } to { opacity: 1; } }

.hdr-acts {
  display: flex;
  align-items: center;
  gap: 8px;
}

@media (max-width: 900px) {
  .app, html.nh .app { grid-template-columns: 68px minmax(0, 1fr); padding: 8px; gap: 8px; }
  aside { padding: 12px 6px; top: 8px; height: calc(100vh - 16px); }
  aside .logo-full, aside nav a span, aside .wp-full { display: none; }
  aside .logo-mini { display: block; }
  aside .wp-cycle { display: grid; }
  aside nav a { justify-content: center; padding: 10px 0; }
  .c2 { grid-template-columns: 1fr; }
  header { top: 8px; }
}

@media (max-width: 700px) {
  body { font-size: 15px; }
  .app, html.nh .app { grid-template-columns: minmax(0, 1fr); padding: 10px 10px 96px; gap: 10px; }
  html.nh .app { padding-bottom: 20px; }
  aside { display: none; }
  #bn { display: flex; }

  /* Clean 3-Row Symmetrical Mobile Header */
  header { top: 8px; gap: 8px; padding: 10px 12px; }
  .nav-toggle { order: 1; width: 36px; height: 36px; }
  header h1 { order: 2; font-size: 24px; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  #sy { display: none; }
  .bell { order: 3; padding: 6px; }
  .prof-wrap { order: 4; }
  .prof-meta, .prof-chev { display: none; }
  .prof-btn { padding: 3px; }

  .hdr-acts { order: 5; flex: 1 1 100%; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .hdr-acts .btn { width: 100%; padding: 9px 10px; font-size: 12.5px; }

  .sr { order: 6; flex: 1 1 100%; max-width: none; }
  .sr kbd { display: none; }
  input, select, textarea { font-size: 16px; }
  #toast { bottom: 88px; left: 14px; right: 14px; text-align: center; }
}