/* ========================================
   Novel Reader – iOS App Styles (Enhanced)
   ======================================== */

:root {
  /* iOS Safe Areas & Nav Heights */
  --sat: env(safe-area-inset-top, 0px);
  --sar: env(safe-area-inset-right, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);

  --header-height: calc(56px + var(--sat));
  --tab-bar-height: calc(49px + var(--sab));

  /* System Colors - Light Mode / Default */
  --bg: #F2F2F7;
  --bg-elevated: #FFFFFF;
  --surface: rgba(255, 255, 255, 0.85);
  --text: #000000;
  --text-secondary: #8E8E93;
  --line: rgba(60, 60, 67, 0.18);
  --accent: #007AFF;
  --accent-soft: rgba(0, 122, 255, 0.12);
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.08);
  --modal-bg: #F2F2F7;

  /* Reader Typography */
  --reader-font-size: 19px;
  --reader-line-height: 1.75;
  --reader-width: 780px;

  /* Fonts */
  --font-system: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-rounded: "Atkinson Hyperlegible", "Nunito", sans-serif;
  --reader-font: var(--font-system);
}

/* ================== Themes ================== */

html[data-theme="dark"] {
  --bg: #000000;
  --bg-elevated: #1C1C1E;
  --surface: rgba(28, 28, 30, 0.85);
  --text: #FFFFFF;
  --text-secondary: #98989D;
  --line: rgba(84, 84, 88, 0.35);
  --accent: #0A84FF;
  --accent-soft: rgba(10, 132, 255, 0.15);
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  --modal-bg: #1C1C1E;
}

html[data-theme="amoled"] {
  --bg: #000000;
  --bg-elevated: #000000;
  --surface: rgba(0, 0, 0, 0.9);
  --text: #F2F2F7;
  --text-secondary: #8E8E93;
  --line: rgba(84, 84, 88, 0.35);
  --accent: #0A84FF;
  --accent-soft: rgba(10, 132, 255, 0.15);
  --shadow: none;
  --modal-bg: #000000;
}

html[data-theme="sepia"] {
  --bg: #F4ECD8;
  --bg-elevated: #FFF6E5;
  --surface: rgba(255, 246, 229, 0.85);
  --text: #4A3C31;
  --text-secondary: #8E7C6E;
  --line: rgba(142, 124, 110, 0.2);
  --accent: #D07B28;
  --accent-soft: rgba(208, 123, 40, 0.15);
  --shadow: 0 8px 32px rgba(74, 60, 49, 0.08);
  --modal-bg: #F4ECD8;
}

html[data-theme="burmese-art"] {
  --bg: #EAE0C8;
  --bg-elevated: #F6EFDF;
  --surface: rgba(246, 239, 223, 0.85);
  --text: #3D261A;
  --text-secondary: #936049;
  --line: rgba(147, 96, 73, 0.25);
  --accent: #C78D3D;
  --accent-soft: rgba(199, 141, 61, 0.15);
  --shadow: 0 8px 32px rgba(61, 38, 26, 0.1);
  --modal-bg: #EAE0C8;
}

html[data-theme="night-blue"] {
  --bg: #0D1117;
  --bg-elevated: #161B22;
  --surface: rgba(22, 27, 34, 0.88);
  --text: #E6EDF3;
  --text-secondary: #7D8590;
  --line: rgba(48, 54, 61, 0.6);
  --accent: #58A6FF;
  --accent-soft: rgba(88, 166, 255, 0.15);
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
  --modal-bg: #0D1117;
}


/* ================== Reset & Base ================== */
* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  width: 100%;
  overflow: hidden;
}

body {
  background-color: var(--bg);
  color: var(--text);
  font-family: var(--font-system);
  font-size: 17px;
  transition: background-color 300ms ease, color 300ms ease;
}

h1,
h2,
h3,
h4,
p {
  margin: 0;
}

a {
  color: var(--accent);
  text-decoration: none;
}

.truncate {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}


/* ================== App Shell Layout ================== */
.app-shell {
  height: 100vh;
  width: 100vw;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

/* Reader View (Main layer underneath modals) */
.reader-view {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  position: relative;
  -webkit-overflow-scrolling: touch;
}

/* Spacers to prevent content hiding behind glassy navs */
.bottom-spacer {
  height: var(--tab-bar-height);
  width: 100%;
}


/* ================== Glassmorphic Header ================== */
.ios-header {
  position: sticky;
  top: 0;
  left: 0;
  width: 100%;
  height: var(--header-height);
  z-index: 10;
  transition: transform 380ms cubic-bezier(0.4, 0, 0.2, 1);
}

.ios-header-blur {
  position: absolute;
  inset: 0;
  background: var(--surface);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 0.5px solid var(--line);
}

.ios-header-content {
  position: absolute;
  inset: 0;
  padding-top: var(--sat);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-left: max(12px, var(--sal));
  padding-right: max(12px, var(--sar));
}

.header-left,
.header-right {
  display: flex;
  align-items: center;
  gap: 4px;
}

.header-titles {
  flex: 1;
  text-align: center;
  overflow: hidden;
  padding: 0 12px;
}

.header-titles h1 {
  font-size: 16px;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.3px;
}

.meta-text {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 2px;
  letter-spacing: 0.2px;
}

/* Immersive reading hides header & footer */
body.immersive-mode .ios-header {
  transform: translateY(-100%);
}

body.immersive-mode .ios-tab-bar {
  transform: translateY(100%);
}

/* Reading Progress Line directly attached to bottom of header */
.reading-progress-bar {
  position: absolute;
  bottom: -0.5px;
  left: 0;
  height: 2.5px;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), color-mix(in srgb, var(--accent) 70%, #fff 30%));
  z-index: 11;
  border-radius: 0 3px 3px 0;
  transition: width 120ms linear;
  box-shadow: 0 0 6px 0 var(--accent-soft);
}


/* ================== Bottom Tab Bar ================== */
.ios-tab-bar {
  display: none;
}

/* ================== Scroll to Top FAB ================== */
.fab-scroll-top {
  position: fixed;
  bottom: calc(24px + var(--sab));
  right: max(24px, var(--sar));
  width: 48px;
  height: 48px;
  border-radius: 24px;
  background: var(--surface);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  color: var(--accent);
  border: 0.5px solid var(--line);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 15;
  transition: opacity 300ms ease,
    transform 420ms cubic-bezier(0.34, 1.56, 0.64, 1),
    box-shadow 200ms ease;
}

.fab-scroll-top[hidden] {
  opacity: 0;
  pointer-events: none;
  transform: translateY(20px) scale(0.8);
  display: flex;
  /* keep flex even when "hidden" to allow transition */
}

.fab-scroll-top:not([hidden]) {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.fab-scroll-top:hover {
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.2);
  transform: translateY(-2px) scale(1.05);
}

.fab-scroll-top:active {
  transform: scale(0.9);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

.ios-tab-bar-blur {
  position: absolute;
  inset: 0;
  background: var(--surface);
  backdrop-filter: saturate(200%) blur(30px);
  -webkit-backdrop-filter: saturate(200%) blur(30px);
}

.ios-tab-items {
  position: absolute;
  inset: 0;
  display: flex;
  justify-content: space-around;
  align-items: center;
  padding: 0 12px;
}

.tab-btn {
  background: none;
  border: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 600;
  padding: 6px;
  min-width: 64px;
  cursor: pointer;
  position: relative;
  transition: color 250ms cubic-bezier(0.32, 0.72, 0, 1);
  border-radius: 16px;
}

.tab-btn svg {
  margin-bottom: 4px;
  transition: transform 250ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

.tab-btn:active {
  transform: scale(0.90);
}

.tab-btn:hover {
  color: var(--text);
}

.tab-btn.active {
  color: var(--accent);
}

.tab-btn.active svg {
  transform: scale(1.15) translateY(-2px);
}

/* Active Bookmarked State */
.bookmark-btn.saved {
  color: var(--accent);
}

.bookmark-btn.saved svg {
  fill: var(--accent);
}


/* ================== Reader Content Layout ================== */
.content {
  width: min(var(--reader-width), calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 72px;
  font-family: var(--reader-font);
  font-size: var(--reader-font-size);
  line-height: var(--reader-line-height);
  color: var(--text);
}

.content p {
  margin-bottom: 1.3em;
  text-wrap: pretty;
}

/* Drop cap on the first paragraph */
.content>p:first-of-type::first-letter {
  font-size: 3.4em;
  line-height: 0.8;
  float: left;
  margin: 0.06em 0.08em 0 0;
  font-weight: 700;
  color: var(--accent);
}

.content h1,
.content h2,
.content h3 {
  font-weight: 700;
  margin-top: 2em;
  margin-bottom: 0.65em;
  letter-spacing: -0.4px;
}

.content h1 {
  font-size: 1.6em;
  border-bottom: 1px solid var(--line);
  padding-bottom: 0.4em;
}

.content h2 {
  font-size: 1.25em;
}

.content hr {
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 2.5em 0;
  gap: 10px;
  color: var(--text-secondary);
}

.content hr::before {
  content: "✦ ✦ ✦";
  font-size: 12px;
  letter-spacing: 6px;
  color: var(--text-secondary);
  opacity: 0.5;
}

/* Empty Welcome State */
.welcome-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 60vh;
  text-align: center;
  color: var(--text-secondary);
  padding: 0 24px;
}

.welcome-icon {
  width: 88px;
  height: 88px;
  background: var(--accent-soft);
  border-radius: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  margin-bottom: 20px;
  animation: welcome-pulse 3s ease-in-out infinite;
}

@keyframes welcome-pulse {

  0%,
  100% {
    transform: scale(1);
    box-shadow: 0 0 0 0 var(--accent-soft);
  }

  50% {
    transform: scale(1.04);
    box-shadow: 0 0 0 12px transparent;
  }
}

.welcome-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 8px;
  letter-spacing: -0.4px;
}

.welcome-hint {
  font-size: 15px;
  line-height: 1.5;
  max-width: 260px;
  color: var(--text-secondary);
}


/* ================== Full-Screen Slide Modals ================== */
.ios-modal {
  position: fixed;
  top: 16px;
  left: 16px;
  width: calc(100% - 32px);
  height: calc(100vh - 32px - var(--sab, 0px));
  background: var(--modal-bg);
  border-radius: 36px;
  z-index: 50;
  display: flex;
  flex-direction: column;
  transform: translateY(120%);
  transition: transform 480ms cubic-bezier(0.32, 0.72, 0, 1);
  box-shadow: 0 40px 80px rgba(0, 0, 0, 0.4), 0 0 0 0.5px var(--line);
  overflow: hidden;
}

.ios-modal.is-open {
  transform: translateY(0);
}

.ios-modal-header {
  position: relative;
  flex-shrink: 0;
}

.ios-modal-header-blur {
  position: absolute;
  inset: 0;
  background: var(--surface);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  z-index: 0;
}

.ios-modal-header-content {
  position: relative;
  z-index: 1;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 16px;
}

.ios-modal-header-content h1 {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.cancel-btn {
  position: absolute;
  right: 16px;
  font-size: 16px;
  font-weight: 600;
  color: var(--accent);
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 8px;
  transition: background 200ms ease;
}

.cancel-btn:hover {
  background: var(--accent-soft);
}

.ios-modal-content {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  position: relative;
  z-index: 0;
}

/* Grouped List Background padding */
.bg-grouped {
  padding: 24px 16px;
}


/* ================== Segmented Control (Filter Chips) ================== */
.segmented-control-wrapper {
  padding: 8px 16px 12px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  position: relative;
  z-index: 1;
}

.segmented-control-wrapper::-webkit-scrollbar {
  display: none;
}

.segmented-control {
  display: inline-flex;
  background: rgba(118, 118, 128, 0.12);
  padding: 2px;
  border-radius: 10px;
  gap: 2px;
}

.filter-chip {
  background: transparent;
  border: none;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.22s cubic-bezier(0.32, 0.72, 0, 1);
}

.filter-chip.active {
  background: var(--bg-elevated);
  color: var(--text);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.06), 0 4px 10px rgba(0, 0, 0, 0.1);
  transform: scale(1.02);
}

/* Search Bar in Header */
.ios-search-bar {
  position: relative;
  z-index: 1;
  padding: 8px 16px;
}

.search-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 10px;
  color: var(--text-secondary);
}

.search-input-wrap input {
  width: 100%;
  background: rgba(118, 118, 128, 0.12);
  border: none;
  border-radius: 10px;
  padding: 9px 12px 9px 34px;
  font-size: 16px;
  color: var(--text);
  outline: none;
  transition: background 200ms ease;
}

.search-input-wrap input:focus {
  background: rgba(118, 118, 128, 0.18);
}

.search-input-wrap input::placeholder {
  color: var(--text-secondary);
}


/* ================== Native iOS Form Elements ================== */
.ios-form-group {
  background: var(--bg-elevated);
  border-radius: 12px;
  overflow: hidden;
}

.ios-form-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 16px;
  min-height: 44px;
  border-bottom: 0.5px solid var(--line);
}

.ios-form-row:last-child {
  border-bottom: none;
}

.ios-form-row label {
  font-size: 16px;
  font-weight: 500;
}

/* Select Inputs */
.ios-select {
  appearance: none;
  -webkit-appearance: none;
  background: none;
  border: none;
  font-size: 16px;
  color: var(--text-secondary);
  text-align: right;
  direction: rtl;
  padding-right: 20px;
  cursor: pointer;
  outline: none;
}

/* Fake iOS chevron */
.ios-select {
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' width='8' height='12' viewBox='0 0 8 12' fill='none' stroke='%238E8E93' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpath d='M2 2l4 4-4 4'/%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right center;
}

/* Range Sliders */
.slider-block {
  width: 100%;
}

.slider-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 10px;
  font-size: 14px;
  font-weight: 500;
}

.value-badge {
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 20px;
  min-width: 38px;
  text-align: center;
}

.ios-slider {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  height: 4px;
  background: linear-gradient(to right,
      var(--accent) 0%,
      var(--accent) var(--slider-fill, 50%),
      var(--line) var(--slider-fill, 50%),
      var(--line) 100%);
  border-radius: 4px;
  outline: none;
  transition: background 50ms linear;
}

.ios-slider::-webkit-slider-thumb {
  appearance: none;
  -webkit-appearance: none;
  width: 26px;
  height: 26px;
  background: #FFF;
  border-radius: 50%;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2), 0 0 1px rgba(0, 0, 0, 0.1);
  cursor: pointer;
  transition: transform 150ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

.ios-slider::-webkit-slider-thumb:active {
  transform: scale(1.2);
}

.ios-slider::-moz-range-thumb {
  width: 26px;
  height: 26px;
  background: #FFF;
  border: none;
  border-radius: 50%;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  cursor: pointer;
}

.margin-top-large {
  margin-top: 28px;
}

/* Buttons inside Modals */
.ios-action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  background: none;
  border: none;
  padding: 14px;
  font-size: 16px;
  font-weight: 500;
  color: var(--accent);
  cursor: pointer;
  transition: opacity 150ms ease;
  border-radius: 0;
}

.ios-action-btn:active {
  background: var(--line);
}

.icon-wrap {
  margin-right: 8px;
  display: inline-flex;
}

.form-hint {
  font-size: 13px;
  color: var(--text-secondary);
  text-align: center;
  margin-top: 8px;
  padding: 0 16px;
  line-height: 1.5;
}

/* Reading Stats Section */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  padding: 14px 16px;
}

.stat-card {
  background: var(--bg-elevated);
  border-radius: 12px;
  padding: 12px 8px;
  text-align: center;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

.stat-card .stat-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: -0.5px;
  line-height: 1;
  margin-bottom: 4px;
}

.stat-card .stat-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.settings-section-title {
  padding: 20px 20px 8px;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-secondary);
  letter-spacing: 0.5px;
}


/* ================== Inset Grouped Lists (iOS Style) ================== */
.ios-list-group {
  background: var(--bg-elevated);
  border-radius: 16px;
  margin: 8px 16px 20px;
  overflow: hidden;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.05);
}

.ios-cell {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 0.5px solid var(--line);
  background: transparent;
  cursor: pointer;
  transition: background-color 180ms ease, transform 200ms cubic-bezier(0.32, 0.72, 0, 1);
  overflow: hidden;
}

.ios-cell:last-child {
  border-bottom: none;
}

.ios-cell:active {
  background-color: var(--line);
  transform: scale(0.99);
}

.ios-cell.active {
  background-color: var(--accent-soft);
}

.ios-cell.active .cell-title {
  color: var(--accent);
}

/* Per-cell reading progress mini-bar */
.cell-progress-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 2px;
  background: var(--accent);
  opacity: 0.6;
  border-radius: 0 2px 2px 0;
  transition: width 400ms ease;
}

.cell-progress-bar.completed {
  background: #34C759;
  opacity: 0.8;
}

.cell-progress-bar.in-progress {
  background: #FF9500;
  opacity: 0.7;
}

.list-group-title {
  padding: 20px 20px 8px;
  font-size: 12px;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--text-secondary);
  letter-spacing: 0.6px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.list-group-title::after {
  content: "";
  flex: 1;
  height: 0.5px;
  background: var(--line);
  border-radius: 1px;
}

.cell-content {
  flex: 1;
  min-width: 0;
  padding-right: 12px;
}

.cell-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 3px;
  letter-spacing: -0.2px;
}

.cell-subtitle {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 1px;
}

.cell-indicators {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.cell-chevron {
  color: var(--text-secondary);
  opacity: 0.4;
  display: flex;
  align-items: center;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-dot.unread {
  background: var(--line);
}

.status-dot.in-progress {
  background: #FF9500;
  box-shadow: 0 0 0 2px rgba(255, 149, 0, 0.2);
}

.status-dot.completed {
  background: #34C759;
  box-shadow: 0 0 0 2px rgba(52, 199, 89, 0.2);
}

.downloaded-icon {
  color: #34C759;
}

.saved-icon {
  color: var(--accent);
}


/* ================== Base Buttons ================== */
.ios-icon-btn {
  background: none;
  border: none;
  padding: 8px;
  color: var(--accent);
  cursor: pointer;
  display: flex;
  align-items: center;
  border-radius: 10px;
  transition: background 200ms ease;
}

.ios-icon-btn:hover {
  background: var(--accent-soft);
}

.ios-icon-btn:disabled {
  color: var(--text-secondary);
  opacity: 0.4;
  pointer-events: none;
}


/* ================== Toasts ================== */
.toast-container {
  position: fixed;
  top: calc(var(--header-height) + 8px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: max-content;
  max-width: calc(100vw - 48px);
}

.toast {
  background: var(--bg-elevated);
  color: var(--text);
  padding: 11px 18px;
  border-radius: 14px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12), 0 0 0 0.5px var(--line);
  font-size: 14px;
  font-weight: 500;
  border-left: 3px solid var(--accent);
  animation: slide-down 0.38s cubic-bezier(0.34, 1.56, 0.64, 1);
  min-width: 200px;
  max-width: 340px;
}

.toast.hiding {
  animation: fade-out 0.28s forwards;
}

.toast-progress {
  width: 100%;
  height: 3px;
  background: var(--line);
  margin-top: 8px;
  border-radius: 3px;
  overflow: hidden;
}

.toast-progress-bar {
  height: 100%;
  background: var(--accent);
  width: 0%;
  transition: width 0.2s ease;
  border-radius: 3px;
}

@keyframes slide-down {
  from {
    transform: translateY(-16px) scale(0.95);
    opacity: 0;
  }

  to {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

@keyframes fade-out {
  to {
    opacity: 0;
    transform: translateY(-8px) scale(0.95);
  }
}


/* ================== Tablet/Desktop Accommodations ================== */
@media (min-width: 981px) {
  .app-shell {
    flex-direction: row;
  }

  /* Show tab bar on desktop/tablet */
  .ios-tab-bar {
    display: flex;
    position: fixed;
    top: 50%;
    left: 24px;
    bottom: auto;
    transform: translateY(-50%);
    flex-direction: column;
    width: 80px;
    height: auto;
    max-height: 80vh;
    border-radius: 40px;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.18), 0 0 0 0.5px var(--line);
    overflow: hidden;
    transition: transform 380ms cubic-bezier(0.4, 0, 0.2, 1), opacity 300ms;
    z-index: 20;
  }

  body.immersive-mode .ios-tab-bar {
    transform: translateY(-50%) translateX(-120px);
    opacity: 0;
  }

  .ios-tab-items {
    position: relative;
    padding: 28px 0;
    flex-direction: column;
    justify-content: center;
    gap: 8px;
  }

  .tab-btn {
    margin-top: 0;
    position: relative;
    width: 60px;
    padding: 8px 6px;
  }

  /* Active pill behind icon on desktop */
  .tab-btn::before {
    content: "";
    position: absolute;
    inset: 4px;
    background: var(--accent-soft);
    border-radius: 14px;
    opacity: 0;
    transition: opacity 250ms ease, transform 250ms cubic-bezier(0.34, 1.56, 0.64, 1);
    transform: scale(0.8);
  }

  .tab-btn.active::before {
    opacity: 1;
    transform: scale(1);
  }

  /* Hide the redundant header buttons on Desktop */
  #headerLibraryBtn,
  #headerSettingsBtn {
    display: none;
  }

  .ios-modal {
    width: 440px;
    left: auto;
    right: 24px;
    top: 24px;
    height: calc(100vh - 48px);
    border-radius: 36px;
    border: none;
    transform: translateX(120%);
    opacity: 0;
    pointer-events: none;
    transition: transform 480ms cubic-bezier(0.32, 0.72, 0, 1), opacity 280ms ease;
  }

  .ios-modal.is-open {
    transform: translateX(0);
    opacity: 1;
    pointer-events: auto;
  }

  .ios-header {
    border-bottom: none;
  }

  .toast-container {
    top: calc(var(--header-height) + 12px);
    left: calc(50% + 80px);
  }
}