:root {
  --navy: #0f3559;
  --blue: #1669a8;
  --sky: #e6f5ff;
  --green: #19a974;
  --mint: #e5f8f1;
  --orange: #f59e0b;
  --red: #e5484d;
  --ink: #14202e;
  --muted: #718096;
  --line: #e5edf5;
  --bg: #eef4f8;
  --card: #ffffff;
  --shadow: 0 18px 45px rgba(15, 53, 89, 0.12);
  --radius: 22px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
  overflow-x: hidden;
}

body {
  background:
    radial-gradient(circle at 20% 0%, rgba(22, 105, 168, 0.14), transparent 28rem),
    linear-gradient(145deg, #f7fbff, var(--bg));
  color: var(--ink);
  font-family: "Plus Jakarta Sans", Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.app-shell {
  position: relative;
  width: 100%;
  max-width: 460px;
  min-height: 100svh;
  margin: 0 auto;
  overflow: hidden;
  background: #f7fbff;
  box-shadow: 0 0 0 1px rgba(15, 53, 89, 0.06), 0 30px 90px rgba(15, 53, 89, 0.18);
}

.app-view {
  min-height: 100svh;
  padding: calc(18px + var(--safe-top)) 18px calc(102px + var(--safe-bottom));
  animation: pageIn 260ms ease both;
}

.top-row,
.page-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--blue);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.brand-mark,
.avatar,
.doctor-avatar,
.mini-avatar {
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 50%;
  background: linear-gradient(145deg, #dff2ff, #ffffff);
  color: var(--blue);
  font-weight: 800;
}

.brand-mark {
  width: 34px;
  height: 34px;
}

.avatar {
  width: 54px;
  height: 54px;
  box-shadow: 0 10px 24px rgba(22, 105, 168, 0.18);
}

.avatar.large {
  width: 92px;
  height: 92px;
  margin: 0 auto 12px;
  font-size: 28px;
}

.icon-button {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 16px;
  background: #ffffff;
  color: var(--navy);
  box-shadow: 0 10px 24px rgba(15, 53, 89, 0.08);
  transition: transform 160ms ease, background 160ms ease;
}

.icon-button:active,
.primary-btn:active,
.secondary-btn:active,
.menu-card:active,
.nav-item:active {
  transform: scale(0.96);
}

.hero-card {
  margin-top: 18px;
  padding: 20px;
  border-radius: 28px;
  background: linear-gradient(145deg, var(--navy), #1669a8 72%, #2bbf89);
  color: #ffffff;
  box-shadow: var(--shadow);
}

.hero-main {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
  align-items: center;
}

.eyebrow,
.label,
.meta {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.hero-card .eyebrow {
  color: rgba(255, 255, 255, 0.78);
}

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

h1 {
  margin-top: 4px;
  font-size: 24px;
  line-height: 1.12;
}

h2 {
  font-size: 19px;
  line-height: 1.25;
}

h3 {
  font-size: 15px;
}

.hero-card p {
  margin-top: 8px;
  color: rgba(255, 255, 255, 0.82);
  font-size: 13px;
  line-height: 1.5;
}

.hero-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-top: 18px;
}

.hero-stat {
  padding: 12px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.14);
}

.hero-stat strong {
  display: block;
  margin-bottom: 4px;
  font-size: 22px;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 24px 0 12px;
}

.grid-menu {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.menu-card,
.metric-card,
.info-card,
.history-card,
.config-card,
.timer-card,
.tele-card,
.profile-card,
.empty-state {
  border: 1px solid rgba(229, 237, 245, 0.9);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: 0 12px 30px rgba(15, 53, 89, 0.07);
}

.menu-card {
  min-height: 112px;
  padding: 16px;
  text-align: left;
  transition: transform 160ms ease, box-shadow 160ms ease;
}

.menu-card:hover {
  box-shadow: 0 16px 36px rgba(15, 53, 89, 0.11);
}

.menu-icon {
  display: grid;
  width: 42px;
  height: 42px;
  margin-bottom: 16px;
  place-items: center;
  border-radius: 16px;
  color: var(--blue);
  background: var(--sky);
}

.menu-card small,
.history-card small,
.profile-row span,
.tele-card p,
.empty-state p {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.accent-green .menu-icon {
  color: var(--green);
  background: var(--mint);
}

.accent-orange .menu-icon {
  color: #b86b00;
  background: #fff3d8;
}

.accent-purple .menu-icon {
  color: #7756d9;
  background: #f0ebff;
}

.accent-red .menu-icon {
  color: var(--red);
  background: #ffe9ec;
}

.bottom-nav {
  position: fixed;
  bottom: max(12px, var(--safe-bottom));
  left: 50%;
  z-index: 20;
  display: grid;
  width: min(calc(100% - 24px), 436px);
  transform: translateX(-50%);
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  padding: 8px;
  border: 1px solid rgba(229, 237, 245, 0.9);
  border-radius: 26px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 16px 45px rgba(15, 53, 89, 0.16);
  backdrop-filter: blur(18px);
}

.nav-item {
  display: grid;
  min-width: 0;
  min-height: 58px;
  place-items: center;
  gap: 4px;
  border-radius: 19px;
  background: transparent;
  color: #7b8998;
  font-size: 11px;
  font-weight: 800;
  transition: background 160ms ease, color 160ms ease, transform 160ms ease;
}

.nav-item svg,
.icon-button svg,
.menu-icon svg {
  width: 20px;
  height: 20px;
}

.nav-item.active {
  background: var(--sky);
  color: var(--blue);
}

.page-title {
  display: flex;
  align-items: center;
  gap: 12px;
}

.page-title h1 {
  font-size: 22px;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 11px;
  border-radius: 999px;
  background: var(--sky);
  color: var(--blue);
  font-size: 12px;
  font-weight: 800;
}

.video-frame {
  position: relative;
  overflow: hidden;
  margin-top: 18px;
  border-radius: 22px;
  background: #0c2238;
  aspect-ratio: 16 / 9;
  box-shadow: var(--shadow);
}

.video-frame iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

.timer-card {
  margin-top: 14px;
  padding: 18px;
  transition: background 220ms ease, border-color 220ms ease;
}

.timer-card.work {
  border-color: rgba(25, 169, 116, 0.26);
  background: linear-gradient(180deg, #ffffff, #f0fff9);
}

.timer-card.rest {
  border-color: rgba(245, 158, 11, 0.28);
  background: linear-gradient(180deg, #ffffff, #fff8e8);
}

.timer-time {
  margin: 10px 0;
  color: var(--navy);
  font-size: 58px;
  font-weight: 800;
  line-height: 1;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.timer-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.progress-track {
  overflow: hidden;
  height: 10px;
  margin-top: 14px;
  border-radius: 999px;
  background: #e6edf4;
}

.progress-fill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--blue), var(--green));
  transition: width 260ms ease;
}

.config-card {
  display: grid;
  gap: 14px;
  margin-top: 14px;
  padding: 16px;
}

.stepper-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.stepper {
  display: grid;
  grid-template-columns: 38px 64px 38px;
  align-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #f8fbfe;
}

.stepper button {
  display: grid;
  height: 38px;
  place-items: center;
  background: transparent;
  color: var(--blue);
}

.stepper input {
  width: 100%;
  border: 0;
  border-right: 1px solid var(--line);
  border-left: 1px solid var(--line);
  background: #ffffff;
  color: var(--ink);
  font-weight: 800;
  text-align: center;
}

.action-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.primary-btn,
.secondary-btn,
.danger-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  gap: 8px;
  padding: 0 16px;
  border-radius: 17px;
  font-weight: 800;
  transition: transform 160ms ease, opacity 160ms ease;
}

.primary-btn {
  background: linear-gradient(135deg, var(--blue), #0f8f79);
  color: #ffffff;
  box-shadow: 0 12px 28px rgba(22, 105, 168, 0.22);
}

.secondary-btn {
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--navy);
}

.danger-btn {
  background: #ffe9ec;
  color: var(--red);
}

.full {
  grid-column: 1 / -1;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 16px 0;
}

.metric-card {
  padding: 14px 10px;
  text-align: center;
}

.metric-card strong {
  display: block;
  color: var(--navy);
  font-size: 20px;
}

.history-list {
  display: grid;
  gap: 10px;
}

.history-card,
.tele-card,
.profile-card,
.empty-state {
  padding: 16px;
}

.history-top,
.profile-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.history-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.filter-select,
.time-input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #ffffff;
  color: var(--ink);
  padding: 13px 14px;
}

.days {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 14px 0;
}

.day-chip {
  min-height: 40px;
  padding: 0 13px;
  border-radius: 999px;
  background: #ffffff;
  color: var(--muted);
  border: 1px solid var(--line);
  font-weight: 800;
}

.day-chip.active {
  background: var(--sky);
  color: var(--blue);
  border-color: #b9e2ff;
}

.toggle-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 14px 0;
}

.switch {
  position: relative;
  width: 58px;
  height: 32px;
}

.switch input {
  opacity: 0;
}

.switch span {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: #cbd5df;
  transition: background 180ms ease;
}

.switch span::after {
  position: absolute;
  top: 4px;
  left: 4px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #ffffff;
  content: "";
  transition: transform 180ms ease;
}

.switch input:checked + span {
  background: var(--green);
}

.switch input:checked + span::after {
  transform: translateX(26px);
}

.video-call {
  position: relative;
  min-height: calc(100svh - 135px);
  margin: calc(-18px - var(--safe-top)) -18px calc(-102px - var(--safe-bottom));
  padding: calc(18px + var(--safe-top)) 18px calc(112px + var(--safe-bottom));
  background: linear-gradient(180deg, #102c49, #091c30);
  color: #ffffff;
}

.call-main {
  display: grid;
  min-height: 56svh;
  margin-top: 18px;
  place-items: center;
  border-radius: 28px;
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.04));
}

.patient-preview {
  position: absolute;
  right: 18px;
  bottom: calc(120px + var(--safe-bottom));
  display: grid;
  width: 104px;
  height: 142px;
  place-items: center;
  border: 2px solid rgba(255, 255, 255, 0.32);
  border-radius: 22px;
  background: #183d61;
}

.call-controls {
  position: absolute;
  right: 18px;
  bottom: calc(28px + var(--safe-bottom));
  left: 18px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.call-controls button {
  display: grid;
  height: 54px;
  place-items: center;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.16);
  color: #ffffff;
}

.call-controls button.off,
.call-controls .end-call {
  background: var(--red);
}

.profile-card {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}

.profile-row {
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.profile-row:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.sheet-backdrop {
  position: absolute;
  inset: 0;
  z-index: 40;
  background: rgba(8, 22, 36, 0.44);
  animation: fadeIn 180ms ease both;
}

.bottom-sheet {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 50;
  max-height: 92svh;
  overflow: auto;
  padding: 10px 18px calc(20px + var(--safe-bottom));
  border-radius: 30px 30px 0 0;
  background: #ffffff;
  box-shadow: 0 -24px 60px rgba(15, 53, 89, 0.24);
  animation: sheetIn 240ms ease both;
}

.sheet-handle {
  width: 44px;
  height: 5px;
  margin: 2px auto 16px;
  border-radius: 999px;
  background: #d8e1ea;
}

.range-line {
  display: grid;
  gap: 8px;
  margin-top: 16px;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--blue);
}

.pain-value {
  display: inline-grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 15px;
  color: #ffffff;
  background: var(--green);
  font-weight: 800;
}

textarea {
  min-height: 86px;
  resize: vertical;
}

.loading-overlay {
  position: absolute;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(247, 251, 255, 0.88);
  backdrop-filter: blur(12px);
}

.loading-card {
  display: grid;
  place-items: center;
  gap: 16px;
  color: var(--navy);
  font-weight: 800;
}

.mascot-wrap {
  position: relative;
  display: grid;
  width: 118px;
  height: 118px;
  place-items: center;
  border-radius: 34px;
  background: #ffffff;
  box-shadow: var(--shadow);
  animation: floatMascot 1500ms ease-in-out infinite;
}

.mascot-wrap img {
  position: absolute;
  max-width: 86px;
  max-height: 86px;
  object-fit: contain;
}

.mascot-fallback {
  display: none;
  width: 82px;
  height: 82px;
  place-items: center;
  border-radius: 26px;
  background: linear-gradient(145deg, var(--blue), var(--green));
  color: #ffffff;
  font-size: 28px;
  font-weight: 800;
}

.toast {
  position: absolute;
  right: 18px;
  bottom: calc(92px + var(--safe-bottom));
  left: 18px;
  z-index: 90;
  padding: 14px 16px;
  border-radius: 18px;
  background: #102c49;
  color: #ffffff;
  font-size: 13px;
  font-weight: 800;
  opacity: 0;
  transform: translateY(16px);
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

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

@keyframes sheetIn {
  from {
    transform: translateY(100%);
  }
  to {
    transform: translateY(0);
  }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes floatMascot {
  0%, 100% {
    transform: translateY(0) scale(1);
  }
  50% {
    transform: translateY(-10px) scale(1.03);
  }
}

@media (max-width: 430px) {
  .app-shell {
    width: 100%;
    box-shadow: none;
  }

  .grid-menu {
    gap: 10px;
  }

  .menu-card {
    min-height: 106px;
    padding: 14px;
  }

  .timer-time {
    font-size: 52px;
  }
}

@media (max-width: 370px) {
  .app-view {
    padding-right: 14px;
    padding-left: 14px;
  }

  .action-row,
  .grid-menu {
    grid-template-columns: 1fr;
  }

  .metric-grid {
    grid-template-columns: 1fr;
  }
}
