:root {
  /* Content Layer Tokens (Light) */
  --bg: #F2F2F7;
  --card: #FFFFFF;
  --elevated: #FFFFFF;
  --card-pressed: #E5E5EA;
  --fill: rgba(120, 120, 128, 0.12);
  --fill-strong: rgba(120, 120, 128, 0.20);
  --sep: rgba(60, 60, 67, 0.12);
  --label: #000000;
  --secondary: #8E8E93;
  --tertiary: rgba(60, 60, 67, 0.32);

  /* Apple Semantic Colors (Light) */
  --blue: #007AFF;
  --red: #FF3B30;
  --orange: #FF9500;
  --green: #34C759;
  --indigo: #5856D6;
  --teal: #00C7BE;

  /* Liquid Glass Tokens (Controlled dynamically by Clear <-> Tinted slider: --glass-t = 0..1) */
  --glass-t: 0.38;
  --glass-blur: calc(22px + var(--glass-t) * 6px);
  --glass-bg-alpha: calc(0.52 + var(--glass-t) * 0.36);
  --glass-pill-alpha: calc(0.68 + var(--glass-t) * 0.26);
  --glass-bg: rgba(255, 255, 255, var(--glass-bg-alpha));
  --glass-bg-dense: rgba(248, 248, 252, calc(0.62 + var(--glass-t) * 0.30));
  --glass-pill-bg: rgba(255, 255, 255, var(--glass-pill-alpha));
  --glass-rim-outer: rgba(0, 0, 0, 0.08);
  --glass-rim-inner: rgba(255, 255, 255, 0.85);
  --glass-specular-top: rgba(255, 255, 255, 0.92);
  --glass-specular-soft: rgba(255, 255, 255, 0.45);
  --glass-shadow: 0 12px 32px rgba(0, 0, 0, 0.12), 0 2px 8px rgba(0, 0, 0, 0.05);

  --sheet-bg: #F2F2F7;
  --seg-bg: rgba(120, 120, 128, 0.14);
  --seg-active: #FFFFFF;

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --nav-h: 50px;
  --tab-h: 62px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #000000;
    --card: #1C1C1E;
    --elevated: #2C2C2E;
    --card-pressed: #2C2C2E;
    --fill: rgba(120, 120, 128, 0.24);
    --fill-strong: rgba(120, 120, 128, 0.36);
    --sep: rgba(84, 84, 88, 0.36);
    --label: #FFFFFF;
    --secondary: #8E8E93;
    --tertiary: rgba(235, 235, 245, 0.32);

    --blue: #0A84FF;
    --red: #FF453A;
    --orange: #FF9F0A;
    --green: #30D158;
    --indigo: #5E5CE6;
    --teal: #64D2FF;

    --glass-bg-alpha: calc(0.46 + var(--glass-t) * 0.38);
    --glass-pill-alpha: calc(0.16 + var(--glass-t) * 0.18);
    --glass-bg: rgba(34, 34, 38, var(--glass-bg-alpha));
    --glass-bg-dense: rgba(28, 28, 32, calc(0.56 + var(--glass-t) * 0.34));
    --glass-pill-bg: rgba(255, 255, 255, var(--glass-pill-alpha));
    --glass-rim-outer: rgba(0, 0, 0, 0.55);
    --glass-rim-inner: rgba(255, 255, 255, 0.22);
    --glass-specular-top: rgba(255, 255, 255, 0.36);
    --glass-specular-soft: rgba(255, 255, 255, 0.18);
    --glass-shadow: 0 16px 40px rgba(0, 0, 0, 0.55), 0 2px 10px rgba(0, 0, 0, 0.36);

    --sheet-bg: #1C1C1E;
    --seg-bg: rgba(120, 120, 128, 0.24);
    --seg-active: #3A3A3C;
  }
}

:root[data-theme="dark"] {
  --bg: #000000;
  --card: #1C1C1E;
  --elevated: #2C2C2E;
  --card-pressed: #2C2C2E;
  --fill: rgba(120, 120, 128, 0.24);
  --fill-strong: rgba(120, 120, 128, 0.36);
  --sep: rgba(84, 84, 88, 0.36);
  --label: #FFFFFF;
  --secondary: #8E8E93;
  --tertiary: rgba(235, 235, 245, 0.32);

  --blue: #0A84FF;
  --red: #FF453A;
  --orange: #FF9F0A;
  --green: #30D158;
  --indigo: #5E5CE6;
  --teal: #64D2FF;

  --glass-bg-alpha: calc(0.46 + var(--glass-t) * 0.38);
  --glass-pill-alpha: calc(0.16 + var(--glass-t) * 0.18);
  --glass-bg: rgba(34, 34, 38, var(--glass-bg-alpha));
  --glass-bg-dense: rgba(28, 28, 32, calc(0.56 + var(--glass-t) * 0.34));
  --glass-pill-bg: rgba(255, 255, 255, var(--glass-pill-alpha));
  --glass-rim-outer: rgba(0, 0, 0, 0.55);
  --glass-rim-inner: rgba(255, 255, 255, 0.22);
  --glass-specular-top: rgba(255, 255, 255, 0.36);
  --glass-specular-soft: rgba(255, 255, 255, 0.18);
  --glass-shadow: 0 16px 40px rgba(0, 0, 0, 0.55), 0 2px 10px rgba(0, 0, 0, 0.36);

  --sheet-bg: #1C1C1E;
  --seg-bg: rgba(120, 120, 128, 0.24);
  --seg-active: #3A3A3C;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--label);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overscroll-behavior-y: none;
  user-select: none;
  -webkit-user-select: none;
}

input, textarea, select, .task-details, .settings-hint {
  user-select: text;
  -webkit-user-select: text;
}

button, a, nav, header {
  user-select: none;
  -webkit-user-select: none;
}

.hidden {
  display: none !important;
}

.ios-app {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  max-width: 580px;
  margin: 0 auto;
  position: relative;
}

/* =========================================================
   FUNCTIONAL LAYER: LIQUID GLASS TOP NAVIGATION BAR (iOS 27)
   ========================================================= */
.ios-navbar {
  position: fixed;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 580px;
  z-index: 60;
  padding-top: calc(var(--safe-top) + 4px);
  padding-bottom: 4px;
  background: transparent;
  transition: background-color 0.24s ease, backdrop-filter 0.24s ease, box-shadow 0.24s ease, border-color 0.24s ease;
  border-bottom: 0.5px solid transparent;
}

.ios-navbar.scrolled,
.ios-navbar.detail-mode {
  background: var(--glass-bg-dense);
  backdrop-filter: blur(var(--glass-blur)) saturate(190%);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(190%);
  border-bottom-color: var(--glass-rim-outer);
  box-shadow:
    inset 0 1px 0.5px var(--glass-specular-soft),
    0 6px 24px rgba(0, 0, 0, 0.06);
}

.ios-navbar-inner {
  height: var(--nav-h);
  padding: 0 16px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px;
}

.nav-left {
  display: flex;
  align-items: center;
  justify-content: flex-start;
}

.nav-right {
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

.nav-inline-title {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.015em;
  text-align: center;
  opacity: 0;
  transform: translateY(4px) scale(0.97);
  transition: opacity 0.22s ease, transform 0.22s cubic-bezier(0.22, 1, 0.36, 1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 210px;
}

.ios-navbar.scrolled .nav-inline-title,
.ios-navbar.detail-mode .nav-inline-title {
  opacity: 1;
  transform: translateY(0) scale(1);
}

/* Liquid Glass Action Buttons */
.nav-glass-btn {
  border: 0.5px solid var(--glass-rim-inner);
  background: var(--glass-bg);
  backdrop-filter: blur(20px) saturate(190%);
  -webkit-backdrop-filter: blur(20px) saturate(190%);
  color: var(--label);
  font: inherit;
  font-size: 16px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  height: 36px;
  border-radius: 999px;
  cursor: pointer;
  box-shadow:
    0 2px 10px rgba(0, 0, 0, 0.08),
    inset 0 1px 0.5px var(--glass-specular-top),
    0 0 0 0.5px var(--glass-rim-outer);
  transition: transform 0.16s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.16s ease;
}

.nav-glass-btn:active {
  transform: scale(0.93);
  opacity: 0.85;
}

.nav-icon-btn,
.nav-add-btn {
  width: 36px;
  padding: 0;
}

.nav-add-btn {
  color: var(--blue);
}

.nav-back {
  padding: 0 13px 0 10px;
  color: var(--blue);
  font-weight: 500;
}

.sf-icon {
  width: 19px;
  height: 19px;
}

.sf-chevron-back {
  width: 10px;
  height: 17px;
}

/* =========================================================
   MAIN SCROLL & LARGE TITLE
   ========================================================= */
.ios-main {
  flex: 1;
  padding-top: calc(var(--safe-top) + var(--nav-h) + 12px);
  padding-bottom: calc(var(--safe-bottom) + var(--tab-h) + 34px);
  padding-left: 16px;
  padding-right: 16px;
}

.large-title-wrap {
  margin-bottom: 16px;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.large-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.large-title {
  margin: 0;
  font-size: 34px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.12;
}

.glass-pill {
  border: 0.5px solid var(--glass-rim-inner);
  background: var(--glass-bg);
  backdrop-filter: blur(20px) saturate(190%);
  -webkit-backdrop-filter: blur(20px) saturate(190%);
  box-shadow:
    0 2px 10px rgba(0, 0, 0, 0.06),
    inset 0 1px 0.5px var(--glass-specular-soft),
    0 0 0 0.5px var(--glass-rim-outer);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--blue);
  padding: 6px 12px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  transition: transform 0.16s cubic-bezier(0.22, 1, 0.36, 1);
}

.glass-pill:active {
  transform: scale(0.95);
}

/* Search Bar */
.ios-search {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--fill);
  border-radius: 14px;
  padding: 0 12px;
  height: 38px;
}

.search-icon {
  width: 16px;
  height: 16px;
  color: var(--secondary);
  flex-shrink: 0;
}

.ios-search input {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--label);
  font: inherit;
  font-size: 16px;
  outline: none;
  min-width: 0;
}

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

.search-clear {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: none;
  background: var(--tertiary);
  color: var(--card);
  font-size: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

/* =========================================================
   CONTENT LAYER: SOLID ADAPTIVE INSET GROUPED SURFACES
   ========================================================= */
.section-caption {
  font-size: 13px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: var(--secondary);
  margin: 20px 0 8px 16px;
}

.ios-grouped-card {
  background: var(--card);
  border-radius: 20px;
  overflow: hidden;
}

.summary-card {
  background: var(--card);
  border-radius: 20px;
  padding: 16px 18px;
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.summary-stats {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.summary-title {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.015em;
}

.summary-sub {
  font-size: 13px;
  color: var(--secondary);
  line-height: 1.35;
}

.progress-ring {
  width: 52px;
  height: 52px;
  position: relative;
  flex-shrink: 0;
}

.progress-ring svg {
  width: 52px;
  height: 52px;
  transform: rotate(-90deg);
}

.ring-track {
  fill: none;
  stroke: var(--fill-strong);
  stroke-width: 5.5;
}

.ring-fill {
  fill: none;
  stroke: var(--green);
  stroke-width: 5.5;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}

.ring-label {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
}

/* List Items with Squircle Icons & Tactile Spring Press */
.ios-list-item {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 13px 16px;
  position: relative;
  cursor: pointer;
  transition: transform 0.16s cubic-bezier(0.22, 1, 0.36, 1), background-color 0.12s ease;
}

.ios-list-item:active {
  transform: scale(0.97);
  background: var(--card-pressed);
}

.ios-list-item + .ios-list-item::before {
  content: "";
  position: absolute;
  top: 0;
  left: 67px;
  right: 0;
  height: 0.5px;
  background: var(--sep);
}

.squircle-icon {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: #FFFFFF;
  box-shadow: inset 0 1px 0.5px rgba(255, 255, 255, 0.32);
}

.squircle-icon svg {
  width: 20px;
  height: 20px;
}

.squircle-icon.sm {
  width: 30px;
  height: 30px;
  border-radius: 9px;
}

.squircle-icon.sm svg {
  width: 16px;
  height: 16px;
}

.teacher-avatar {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: linear-gradient(155deg, var(--blue), var(--indigo));
  color: #FFFFFF;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: inset 0 1px 0.5px rgba(255, 255, 255, 0.35);
}

.item-main {
  flex: 1;
  min-width: 0;
}

.item-title {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.28;
  margin-bottom: 5px;
}

.item-meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  align-items: center;
}

.ios-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--fill);
  color: var(--secondary);
}

.ios-badge.exam {
  background: rgba(255, 149, 0, 0.14);
  color: var(--orange);
}

.ios-badge.zachet {
  background: rgba(52, 199, 89, 0.14);
  color: var(--green);
}

.ios-badge.coursework {
  background: rgba(88, 86, 214, 0.14);
  color: var(--indigo);
}

.ios-badge.urgent {
  background: rgba(255, 59, 48, 0.14);
  color: var(--red);
}

.teacher-mini {
  font-size: 12px;
  color: var(--secondary);
  margin-top: 5px;
  line-height: 1.35;
}

.item-trailing {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* Liquid Glass Status Pill inside Lists */
.glass-status-pill {
  font-size: 12px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  border: 0.5px solid var(--glass-rim-inner);
  backdrop-filter: blur(12px) saturate(180%);
  -webkit-backdrop-filter: blur(12px) saturate(180%);
  box-shadow: inset 0 1px 0.5px rgba(255, 255, 255, 0.45), 0 0 0 0.5px var(--glass-rim-outer);
}

.glass-status-pill.open {
  background: rgba(255, 149, 0, 0.16);
  color: var(--orange);
}

.glass-status-pill.urgent {
  background: rgba(255, 59, 48, 0.16);
  color: var(--red);
}

.glass-status-pill.done {
  background: rgba(52, 199, 89, 0.16);
  color: var(--green);
}

.glass-status-pill.empty {
  background: var(--fill);
  color: var(--secondary);
  border-color: transparent;
  box-shadow: none;
}

.sf-chevron {
  width: 7px;
  height: 13px;
  color: var(--tertiary);
}

/* Detail Hero Card */
.detail-hero {
  background: var(--card);
  border-radius: 20px;
  padding: 18px;
  margin-bottom: 16px;
}

.detail-hero-head {
  display: flex;
  align-items: flex-start;
  gap: 13px;
  margin-bottom: 10px;
}

.detail-hero-title {
  font-size: 21px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.24;
  margin: 0 0 8px 0;
}

.detail-actions-row {
  display: flex;
  gap: 10px;
  margin-top: 14px;
}

.ios-primary-btn {
  flex: 1;
  border: 0.5px solid rgba(255, 255, 255, 0.35);
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.16), rgba(0, 0, 0, 0.04)), var(--blue);
  color: #FFFFFF;
  font: inherit;
  font-size: 16px;
  font-weight: 600;
  padding: 12px 18px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  box-shadow:
    0 6px 18px rgba(0, 122, 255, 0.25),
    inset 0 1px 0.5px rgba(255, 255, 255, 0.45);
  transition: transform 0.16s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.15s ease;
}

.ios-primary-btn:active {
  transform: scale(0.97);
  opacity: 0.9;
}

/* Class rows inside detail */
.class-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 13px 16px;
  position: relative;
}

.class-row + .class-row::before {
  content: "";
  position: absolute;
  top: 0;
  left: 16px;
  right: 0;
  height: 0.5px;
  background: var(--sep);
}

.class-left {
  min-width: 0;
}

.class-kind {
  font-size: 13px;
  font-weight: 600;
  color: var(--blue);
}

.class-teacher {
  font-size: 16px;
  font-weight: 600;
  margin-top: 2px;
}

.class-rooms {
  font-size: 12px;
  color: var(--secondary);
  margin-top: 2px;
}

.mini-add-btn {
  border: 0.5px solid var(--glass-rim-inner);
  border-radius: 999px;
  background: var(--glass-bg);
  backdrop-filter: blur(14px) saturate(180%);
  -webkit-backdrop-filter: blur(14px) saturate(180%);
  color: var(--blue);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 7px 13px;
  cursor: pointer;
  flex-shrink: 0;
  box-shadow: inset 0 1px 0.5px var(--glass-specular-soft), 0 0 0 0.5px var(--glass-rim-outer);
  transition: transform 0.14s ease;
}

.mini-add-btn:active {
  transform: scale(0.94);
}

/* =========================================================
   TASK / DEBT SWIPE ROW & GLASS CHECKBOX
   ========================================================= */
.task-swipe-wrap {
  position: relative;
  overflow: hidden;
  background: var(--card);
}

.task-swipe-wrap + .task-swipe-wrap::before {
  content: "";
  position: absolute;
  top: 0;
  left: 56px;
  right: 0;
  height: 0.5px;
  background: var(--sep);
  z-index: 3;
}

.task-actions {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: stretch;
  z-index: 1;
}

.task-swipe-btn {
  width: 60px;
  border: none;
  color: #FFFFFF;
  font: inherit;
  font-size: 11px;
  font-weight: 600;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 0 4px;
  cursor: pointer;
}

.task-swipe-btn svg {
  width: 18px;
  height: 18px;
}

.task-swipe-btn:active {
  filter: brightness(0.88);
}

.task-swipe-btn.toggle {
  background: var(--green);
}

.task-swipe-btn.toggle.reopen {
  background: var(--blue);
}

.task-swipe-btn.edit {
  background: var(--orange);
}

.task-swipe-btn.delete {
  background: var(--red);
}

.task-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 13px 16px;
  position: relative;
  z-index: 2;
  background: var(--card);
  touch-action: pan-y;
  will-change: transform;
  transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1), background-color 0.14s ease;
}

.task-swipe-wrap.dragging .task-row {
  transition: none;
}

/* Glass Checkbox */
.task-check {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1.5px solid var(--tertiary);
  background: var(--glass-bg);
  backdrop-filter: blur(10px) saturate(160%);
  -webkit-backdrop-filter: blur(10px) saturate(160%);
  box-shadow: inset 0 1px 0.5px var(--glass-specular-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 1px;
  cursor: pointer;
  padding: 0;
  transition: transform 0.22s cubic-bezier(0.32, 1.4, 0.55, 1), background-color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.task-check:active {
  transform: scale(0.86);
}

.task-check.urgent-ring:not(.checked) {
  border-color: var(--red);
  background: rgba(255, 59, 48, 0.10);
}

.task-check.checked {
  background: var(--green);
  border-color: var(--green);
  transform: scale(1.06);
  box-shadow: 0 3px 10px rgba(52, 199, 89, 0.34), inset 0 1px 0.5px rgba(255, 255, 255, 0.55);
}

.task-check svg {
  width: 14px;
  height: 14px;
  color: #FFFFFF;
  opacity: 0;
  transform: scale(0.6);
  transition: opacity 0.16s ease, transform 0.2s cubic-bezier(0.32, 1.4, 0.55, 1);
}

.task-check.checked svg {
  opacity: 1;
  transform: scale(1);
}

.task-body {
  flex: 1;
  min-width: 0;
  cursor: pointer;
}

.task-title-row {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
}

.task-title {
  font-size: 16px;
  font-weight: 500;
  line-height: 1.3;
  word-break: break-word;
}

.task-row.done .task-title {
  text-decoration: line-through;
  color: var(--secondary);
}

.task-details {
  font-size: 14px;
  color: var(--secondary);
  margin-top: 3px;
  line-height: 1.38;
  white-space: pre-wrap;
  word-break: break-word;
}

.task-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 7px;
}

.task-tag {
  font-size: 11px;
  font-weight: 600;
  color: var(--secondary);
  background: var(--fill);
  padding: 3px 8px;
  border-radius: 999px;
}

.task-tag.subject-accent {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.tag-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

/* =========================================================
   PROGRESS & STATISTICS VIEW
   ========================================================= */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 18px;
}

.stat-card {
  background: var(--card);
  border-radius: 20px;
  padding: 15px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: transform 0.16s cubic-bezier(0.22, 1, 0.36, 1);
}

.stat-card:active {
  transform: scale(0.97);
}

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

.stat-value {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.1;
}

.stat-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--secondary);
}

.progress-row {
  padding: 13px 16px;
  position: relative;
}

.progress-row + .progress-row::before {
  content: "";
  position: absolute;
  top: 0;
  left: 58px;
  right: 0;
  height: 0.5px;
  background: var(--sep);
}

.progress-row-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.progress-row-title {
  flex: 1;
  min-width: 0;
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.progress-row-count {
  font-size: 13px;
  font-weight: 600;
  color: var(--secondary);
}

.progress-bar-track {
  height: 7px;
  border-radius: 999px;
  background: var(--fill);
  overflow: hidden;
  margin-left: 42px;
}

.progress-bar-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.38s cubic-bezier(0.22, 1, 0.36, 1);
}

/* =========================================================
   FILTER PILLS & SEGMENTED CONTROL
   ========================================================= */
.segmented-wrap {
  padding: 10px 12px;
}

.ios-segmented {
  display: flex;
  background: var(--seg-bg);
  border-radius: 12px;
  padding: 3px;
  gap: 3px;
}

.seg-btn {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--label);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 7px 8px;
  border-radius: 9px;
  cursor: pointer;
  transition: background-color 0.18s ease, box-shadow 0.18s ease, transform 0.14s ease;
}

.seg-btn:active {
  transform: scale(0.97);
}

.seg-btn.active {
  background: var(--seg-active);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.10), inset 0 1px 0.5px rgba(255, 255, 255, 0.45);
}

.teacher-filter-strip {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 2px 14px;
  margin-bottom: 2px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.teacher-filter-strip::-webkit-scrollbar {
  display: none;
}

.filter-pill {
  border: 0.5px solid var(--glass-rim-inner);
  background: var(--glass-bg);
  backdrop-filter: blur(18px) saturate(180%);
  -webkit-backdrop-filter: blur(18px) saturate(180%);
  color: var(--label);
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  padding: 7px 13px;
  border-radius: 999px;
  white-space: nowrap;
  cursor: pointer;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05), inset 0 1px 0.5px var(--glass-specular-soft), 0 0 0 0.5px var(--glass-rim-outer);
  transition: transform 0.14s ease, background-color 0.18s ease;
}

.filter-pill:active {
  transform: scale(0.95);
}

.filter-pill .pill-kind {
  font-size: 11px;
  font-weight: 600;
  color: var(--secondary);
}

.filter-pill.active {
  background: var(--blue);
  border-color: rgba(255, 255, 255, 0.32);
  color: #FFFFFF;
  font-weight: 600;
  box-shadow: 0 4px 14px rgba(0, 122, 255, 0.28), inset 0 1px 0.5px rgba(255, 255, 255, 0.45);
}

.filter-pill.active .pill-kind {
  color: rgba(255, 255, 255, 0.86);
}

/* Empty State & Install Banner */
.empty-state {
  background: var(--card);
  border-radius: 20px;
  padding: 28px 18px;
  text-align: center;
  color: var(--secondary);
  font-size: 15px;
  line-height: 1.45;
}

.install-banner {
  background: var(--card);
  border-radius: 20px;
  padding: 13px 16px;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 13px;
  line-height: 1.38;
}

.install-close {
  border: none;
  background: var(--fill);
  color: var(--secondary);
  width: 26px;
  height: 26px;
  border-radius: 50%;
  font-size: 12px;
  flex-shrink: 0;
  cursor: pointer;
}

/* =========================================================
   FLOATING LIQUID GLASS CAPSULE TAB BAR (iOS 27)
   ========================================================= */
.ios-tabbar {
  position: fixed;
  bottom: calc(12px + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 28px);
  max-width: 460px;
  height: var(--tab-h);
  padding: 5px;
  z-index: 60;
  border-radius: 999px;
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur)) saturate(190%);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(190%);
  border: 0.5px solid var(--glass-rim-inner);
  box-shadow:
    var(--glass-shadow),
    inset 0 1px 0.5px var(--glass-specular-top),
    inset 0 -1px 1px rgba(0, 0, 0, 0.05),
    0 0 0 0.5px var(--glass-rim-outer);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  align-items: stretch;
  overflow: hidden;
}

.tab-glass-pill {
  position: absolute;
  top: 5px;
  bottom: 5px;
  left: 5px;
  width: calc((100% - 10px) / 4);
  border-radius: 999px;
  pointer-events: none;
  z-index: 1;
  transform: translateX(calc(var(--active-tab, 0) * 100%));
  transition: transform 0.4s cubic-bezier(0.32, 1.18, 0.54, 1);
  background: var(--glass-pill-bg);
  border: 0.5px solid var(--glass-rim-inner);
  box-shadow:
    0 4px 14px rgba(0, 0, 0, 0.10),
    inset 0 1px 0.5px var(--glass-specular-top),
    inset 0 -1px 2px rgba(0, 122, 255, 0.08);
}

.tab-item {
  position: relative;
  z-index: 2;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--secondary);
  font: inherit;
  font-size: 10px;
  font-weight: 600;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  cursor: pointer;
  padding: 4px 0;
  transition: color 0.2s ease, transform 0.16s cubic-bezier(0.22, 1, 0.36, 1);
}

.tab-item + .tab-item::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 0.5px;
  height: 20px;
  background: var(--sep);
  opacity: 0.7;
  pointer-events: none;
  transition: opacity 0.18s ease;
}

.tab-item.active::before,
.tab-item.active + .tab-item::before {
  opacity: 0;
}

.tab-item:active {
  transform: scale(0.93);
}

.tab-item.active {
  color: var(--blue);
}

.tab-icon-wrap {
  position: relative;
  display: inline-flex;
}

.tab-icon {
  width: 22px;
  height: 22px;
}

.tab-badge {
  position: absolute;
  top: -3px;
  right: -9px;
  min-width: 17px;
  height: 17px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--red);
  color: #FFFFFF;
  font-size: 10px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(255, 59, 48, 0.35);
}

/* =========================================================
   iOS 27 BOTTOM SHEET (28px corners + Liquid Glass buttons)
   ========================================================= */
.ios-sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0, 0, 0, 0.38);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.24s ease;
}

.ios-sheet-backdrop.open {
  opacity: 1;
}

.ios-sheet {
  width: 100%;
  max-width: 580px;
  max-height: 92dvh;
  background: var(--sheet-bg);
  border-top-left-radius: 28px;
  border-top-right-radius: 28px;
  display: flex;
  flex-direction: column;
  transform: translateY(100%);
  transition: transform 0.34s cubic-bezier(0.32, 0.72, 0, 1);
  padding-bottom: calc(var(--safe-bottom) + 16px);
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.22);
}

.ios-sheet-backdrop.open .ios-sheet {
  transform: translateY(0);
}

.sheet-grabber {
  width: 40px;
  height: 5px;
  border-radius: 999px;
  background: var(--tertiary);
  margin: 10px auto 4px;
}

.sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px 12px;
  border-bottom: 0.5px solid var(--sep);
  gap: 8px;
}

.sheet-spacer {
  width: 72px;
}

.sheet-title {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.015em;
}

.sheet-glass-btn {
  border: 0.5px solid var(--glass-rim-inner);
  background: var(--glass-bg);
  backdrop-filter: blur(18px) saturate(180%);
  -webkit-backdrop-filter: blur(18px) saturate(180%);
  color: var(--label);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  padding: 7px 14px;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: inset 0 1px 0.5px var(--glass-specular-soft), 0 0 0 0.5px var(--glass-rim-outer);
  transition: transform 0.14s ease, opacity 0.14s ease;
}

.sheet-glass-btn:active {
  transform: scale(0.94);
}

.sheet-glass-btn.primary {
  background: var(--blue);
  color: #FFFFFF;
  border-color: rgba(255, 255, 255, 0.35);
  box-shadow: 0 4px 12px rgba(0, 122, 255, 0.28), inset 0 1px 0.5px rgba(255, 255, 255, 0.45);
}

.sheet-body {
  overflow-y: auto;
  padding: 16px;
  -webkit-overflow-scrolling: touch;
}

.form-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 16px;
  position: relative;
}

.form-row + .form-row::before {
  content: "";
  position: absolute;
  top: 0;
  left: 16px;
  right: 0;
  height: 0.5px;
  background: var(--sep);
}

.form-row label {
  font-size: 16px;
  flex-shrink: 0;
}

.form-row select {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--blue);
  font: inherit;
  font-size: 16px;
  text-align: right;
  text-align-last: right;
  outline: none;
  min-width: 0;
  max-width: 68%;
}

/* Native iOS Toggle Switch */
.ios-switch {
  position: relative;
  display: inline-block;
  width: 51px;
  height: 31px;
  cursor: pointer;
}

.ios-switch input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.ios-switch-track {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: var(--fill-strong);
  transition: background-color 0.22s ease;
}

.ios-switch-track::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 27px;
  height: 27px;
  border-radius: 50%;
  background: #FFFFFF;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.22);
  transition: transform 0.24s cubic-bezier(0.32, 1.15, 0.55, 1);
}

.ios-switch input:checked + .ios-switch-track {
  background: var(--red);
}

.ios-switch input:checked + .ios-switch-track::after {
  transform: translateX(20px);
}

/* Glass Opacity Slider (Clear <-> Tinted) */
.glass-slider-row {
  padding: 12px 16px 14px;
}

.glass-slider-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 15px;
  font-weight: 500;
  margin-bottom: 10px;
}

.glass-mode-badge {
  font-size: 12px;
  font-weight: 600;
  color: var(--blue);
  background: var(--fill);
  padding: 3px 9px;
  border-radius: 999px;
}

.glass-slider-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.slider-end-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--secondary);
}

.ios-range {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(0, 122, 255, 0.22), var(--blue));
  outline: none;
}

.ios-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #FFFFFF;
  border: 0.5px solid rgba(0, 0, 0, 0.12);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.22);
  cursor: pointer;
}

.form-textarea-wrap {
  padding: 12px 16px;
}

.border-top {
  border-top: 0.5px solid var(--sep);
}

.form-textarea-wrap input,
.form-textarea-wrap textarea {
  width: 100%;
  border: none;
  background: transparent;
  color: var(--label);
  font: inherit;
  font-size: 16px;
  outline: none;
  resize: none;
}

.form-textarea-wrap input::placeholder,
.form-textarea-wrap textarea::placeholder {
  color: var(--secondary);
}

.quick-chips-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--secondary);
  margin: 16px 0 8px 6px;
}

.quick-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip-btn {
  border: 0.5px solid var(--glass-rim-inner);
  background: var(--card);
  color: var(--blue);
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  padding: 7px 13px;
  border-radius: 999px;
  cursor: pointer;
  transition: transform 0.14s ease, background-color 0.12s ease;
}

.chip-btn:active {
  transform: scale(0.95);
  background: var(--card-pressed);
}

.ios-destructive-btn,
.ios-row-btn {
  width: 100%;
  border: none;
  background: transparent;
  font: inherit;
  font-size: 16px;
  padding: 14px 16px;
  cursor: pointer;
  text-align: center;
}

.ios-destructive-btn {
  color: var(--red);
  font-weight: 600;
}

.ios-row-btn {
  color: var(--blue);
  font-weight: 500;
}

.ios-row-btn:active,
.ios-destructive-btn:active {
  background: var(--card-pressed);
}

.settings-hint {
  font-size: 13px;
  color: var(--secondary);
  line-height: 1.4;
  padding: 0 16px 13px;
}

/* =========================================================
   FLOATING LIQUID GLASS TOAST
   ========================================================= */
.ios-toast {
  position: fixed;
  bottom: calc(var(--safe-bottom) + var(--tab-h) + 22px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  background: var(--glass-bg-dense);
  color: var(--label);
  font-size: 14px;
  font-weight: 600;
  padding: 10px 18px;
  border-radius: 999px;
  backdrop-filter: blur(var(--glass-blur)) saturate(190%);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(190%);
  border: 0.5px solid var(--glass-rim-inner);
  box-shadow: var(--glass-shadow), inset 0 1px 0.5px var(--glass-specular-top), 0 0 0 0.5px var(--glass-rim-outer);
  display: inline-flex;
  align-items: center;
  gap: 12px;
  max-width: calc(100vw - 32px);
  pointer-events: none;
}

.ios-toast.has-action {
  pointer-events: auto;
}

.toast-undo {
  border: none;
  background: transparent;
  color: var(--blue);
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  padding: 2px 4px;
  cursor: pointer;
}

.toast-undo:active {
  opacity: 0.6;
}
