:root {
  --primary: #0d6e6e;
  --primary-light: #e0f2f1;
  --primary-dark: #094d4d;
  --bg-color: #f7f9fa;
  --card-bg: #ffffff;
  --text-main: #1d1d1f;
  --text-secondary: #6e6e73;
  --border: #eaeaec;
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.04);
  --shadow-md: 0 8px 24px rgba(0,0,0,0.08);
  --shadow-lg: 0 16px 32px rgba(0,0,0,0.12);
  --radius-sm: 8px;
  --radius-md: 16px;
  --radius-lg: 24px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Inter', sans-serif;
  background-color: #e5e5e5; /* Desktop backdrop */
  color: var(--text-main);
  -webkit-tap-highlight-color: transparent;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
}

/* App Container constraint */
#app-container {
  width: 100%;
  max-width: 414px; /* iPhone Max width */
  height: 100vh;
  max-height: 896px;
  background-color: var(--bg-color);
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
}

@media (min-width: 480px) {
  #app-container {
    height: 90vh;
    border-radius: 32px;
  }
}

/* Screens */
.screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: calc(100% - 65px); /* minus bottom nav */
  overflow-y: auto;
  overflow-x: hidden;
  background-color: var(--bg-color);
  transition: transform 0.3s cubic-bezier(0.25, 0.8, 0.25, 1), opacity 0.3s ease;
  transform: translateX(20%);
  opacity: 0;
  pointer-events: none;
  z-index: 10;
  padding-bottom: 24px;
}

.screen.active {
  transform: translateX(0);
  opacity: 1;
  pointer-events: all;
}

.screen.previous {
  transform: translateX(-20%);
  opacity: 0;
}

.screen.full-screen {
  height: 100%;
  z-index: 30;
  transform: translateY(100%);
  background-color: var(--card-bg);
  padding-bottom: 0;
}

.screen.full-screen.active {
  transform: translateY(0);
}

/* Scrollbar hiding */
::-webkit-scrollbar {
  width: 0px;
  background: transparent;
}

/* Headers */
.whatsapp-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(135deg, #128C7E, #075E54);
  color: white;
  text-decoration: none;
  padding: 14px 18px;
  border-radius: 14px;
  position: relative;
  overflow: hidden;
  margin-bottom: 20px;
  box-shadow: 0 4px 20px rgba(37, 211, 102, 0.4);
  animation: bannerPulse 2.5s infinite;
  transition: transform 0.2s ease, filter 0.2s ease;
}

@keyframes bannerPulse {
  0% { box-shadow: 0 0 0 0 rgba(37, 211, 102, 0.6); }
  70% { box-shadow: 0 0 0 12px rgba(37, 211, 102, 0); }
  100% { box-shadow: 0 0 0 0 rgba(37, 211, 102, 0); }
}

.whatsapp-banner:active {
  transform: scale(0.97);
  animation: none;
}

.wa-content {
  display: flex;
  flex-direction: column;
  position: relative;
  z-index: 2;
}

.wa-badge {
  background-color: #25D366;
  color: #075E54;
  font-size: 10px;
  font-weight: 800;
  padding: 3px 8px;
  border-radius: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  align-self: flex-start;
  margin-bottom: 6px;
}

.wa-content strong {
  font-size: 16px;
  font-weight: 700;
  line-height: 1.2;
}

.wa-content span {
  font-size: 13px;
  opacity: 0.95;
  margin-top: 3px;
  line-height: 1.3;
}

.wa-content b {
  color: #a7f3d0;
  font-weight: 700;
}

.wa-icon-wrapper {
  background-color: #25D366;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  z-index: 2;
  box-shadow: 0 4px 10px rgba(0,0,0,0.2);
}

.wa-icon {
  font-size: 28px;
  color: white;
  animation: iconWiggle 3s infinite;
}

@keyframes iconWiggle {
  0%, 85% { transform: rotate(0deg); }
  88% { transform: rotate(15deg); }
  91% { transform: rotate(-15deg); }
  94% { transform: rotate(10deg); }
  97% { transform: rotate(-10deg); }
  100% { transform: rotate(0deg); }
}

/* Background watermark icon */
.whatsapp-banner::after {
  content: '\ebc2'; /* Phosphor whatsapp icon unicode */
  font-family: 'Phosphor';
  font-size: 140px;
  color: white;
  opacity: 0.05;
  position: absolute;
  right: -20px;
  bottom: -40px;
  pointer-events: none;
}

.home-header {
  padding: 24px 20px 16px;
  background-color: var(--bg-color);
  position: sticky;
  top: 0;
  z-index: 20;
}

.saved-header {
  padding: 24px 20px 16px;
  background-color: var(--bg-color);
  position: sticky;
  top: 0;
  z-index: 20;
}

.page-title {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: -0.5px;
}

.logo {
  font-size: 20px;
  font-weight: 700;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 20px;
  letter-spacing: -0.5px;
}

.logo i {
  font-size: 24px;
}

/* Search Bar */
.search-container {
  position: relative;
  width: 100%;
}

.search-icon {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-secondary);
  font-size: 20px;
}

.search-container input {
  width: 100%;
  padding: 14px 16px 14px 44px;
  background-color: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 15px;
  color: var(--text-main);
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  box-shadow: var(--shadow-sm);
}

.search-container input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

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

/* Sections */
.themes-section, .metaphors-section {
  padding: 0 20px;
  margin-top: 24px;
}

.section-title {
  font-size: 17px;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--text-main);
}

/* Theme Pills */
.theme-pills {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 8px;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

.theme-pill {
  padding: 8px 16px;
  background-color: var(--card-bg);
  color: var(--text-main);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.2s ease;
}

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

.theme-pill.active {
  background-color: var(--primary);
  color: white;
  border-color: var(--primary);
}

/* Metaphor Cards */
.metaphor-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.metaphor-card {
  background-color: var(--card-bg);
  border-radius: var(--radius-md);
  padding: 12px;
  display: flex;
  gap: 16px;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  border: 1px solid transparent;
}

.metaphor-card:active {
  transform: scale(0.98);
  background-color: #fcfcfc;
}

.card-img-wrapper {
  width: 80px;
  height: 80px;
  flex-shrink: 0;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background-color: var(--bg-color);
}

.card-img-wrapper img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.card-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0; /* for text truncation */
}

.card-theme {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  color: var(--primary);
  background-color: var(--primary-light);
  padding: 2px 8px;
  border-radius: 12px;
  margin-bottom: 6px;
  align-self: flex-start;
}

.card-title {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 4px;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-preview {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-arrow {
  display: flex;
  align-items: center;
  color: #c7c7cc;
  font-size: 20px;
}

/* Empty State */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px 20px;
  color: var(--text-secondary);
}

.empty-state.hidden {
  display: none;
}

.empty-icon-wrapper {
  width: 64px;
  height: 64px;
  background-color: #fff8e1;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
}

.empty-icon-wrapper i {
  font-size: 32px;
  color: #ffc107;
}

.empty-state p {
  font-size: 15px;
  line-height: 1.5;
}

/* Bottom Nav */
.bottom-nav {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 65px;
  background-color: var(--card-bg);
  display: flex;
  justify-content: space-around;
  align-items: center;
  border-top: 1px solid var(--border);
  z-index: 20;
  padding-bottom: env(safe-area-inset-bottom, 0); /* for iOS */
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  width: 60px;
  transition: color 0.2s ease;
}

.nav-item i {
  font-size: 24px;
}

.nav-item.active {
  color: var(--primary);
}

/* Detail Screen */
.detail-scroll-content {
  height: calc(100% - 90px); /* minus action bar */
  overflow-y: auto;
  padding-bottom: 40px;
  background-color: var(--card-bg);
}

.detail-header-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  z-index: 40;
  background: linear-gradient(to bottom, rgba(255,255,255,0.95) 0%, rgba(255,255,255,0) 100%);
  padding: 16px 20px;
}

.detail-top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: env(safe-area-inset-top, 0);
}

.back-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background-color: var(--card-bg);
  border: none;
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: var(--text-main);
  cursor: pointer;
  transition: transform 0.2s ease;
}

.back-btn:active {
  transform: scale(0.9);
}

.detail-theme-tag {
  background-color: var(--card-bg);
  color: var(--primary);
  font-weight: 600;
  font-size: 13px;
  padding: 6px 14px;
  border-radius: 20px;
  box-shadow: var(--shadow-sm);
}

.detail-card-visual {
  width: 100%;
  height: 350px;
  background-color: #f0f0f0;
}

.detail-card-visual img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.detail-text-container {
  padding: 24px 20px;
  background-color: var(--card-bg);
  border-radius: 24px 24px 0 0;
  margin-top: -24px;
  position: relative;
  z-index: 1;
}

.detail-title {
  font-size: 26px;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 4px;
  line-height: 1.2;
}

.detail-subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 24px;
}

.detail-text {
  font-size: 16px;
  line-height: 1.7;
  color: #333336;
}

.detail-text p {
  margin-bottom: 16px;
}

.socratic-section {
  margin-top: 32px;
}

.divider {
  border: none;
  height: 1px;
  background-color: var(--border);
  margin-bottom: 24px;
}

.socratic-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.socratic-title::before {
  content: '';
  display: block;
  width: 4px;
  height: 18px;
  background-color: var(--primary);
  border-radius: 2px;
}

.socratic-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.socratic-list li {
  background-color: var(--bg-color);
  padding: 16px;
  border-radius: var(--radius-md);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text-main);
  border-left: 3px solid var(--primary-light);
}

/* Detail Actions Bar */
.detail-actions {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 90px;
  background-color: var(--card-bg);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-around;
  align-items: center;
  padding: 0 10px;
  padding-bottom: env(safe-area-inset-bottom, 10px);
}

.action-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: transform 0.2s ease;
}

.action-btn:active {
  transform: scale(0.95);
}

.icon-circle {
  width: 46px;
  height: 46px;
  background-color: var(--bg-color);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  color: var(--text-main);
  transition: background-color 0.2s ease, color 0.2s ease;
}

#btn-save.saved .icon-circle {
  background-color: #fff8e1;
  color: #ffc107;
}

.action-btn span {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-secondary);
}

/* Modals */
.overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0,0,0,0.5);
  z-index: 45;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.overlay.active {
  opacity: 1;
  pointer-events: all;
}

.modal {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  background-color: var(--card-bg);
  border-radius: 24px 24px 0 0;
  z-index: 50;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
  padding: 12px 24px 32px;
  box-shadow: 0 -4px 24px rgba(0,0,0,0.1);
}

.modal.active {
  transform: translateY(0);
}

.modal-handle {
  width: 40px;
  height: 5px;
  background-color: #e0e0e0;
  border-radius: 3px;
  margin: 0 auto 16px;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.modal-header h3 {
  font-size: 18px;
  font-weight: 600;
}

.close-modal {
  background: none;
  border: none;
  font-size: 24px;
  color: var(--text-secondary);
  cursor: pointer;
}

.modal-body textarea {
  width: 100%;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 15px;
  resize: none;
  margin-bottom: 16px;
  background-color: var(--bg-color);
  outline: none;
}

.modal-body textarea:focus {
  border-color: var(--primary);
}

.primary-btn {
  width: 100%;
  padding: 16px;
  background-color: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius-md);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.primary-btn:active {
  background-color: var(--primary-dark);
}

.secondary-btn {
  width: 100%;
  padding: 14px;
  background-color: var(--bg-color);
  color: var(--primary);
  border: none;
  border-radius: var(--radius-md);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
}

.modal-search {
  margin-bottom: 16px;
}

.patient-list {
  list-style: none;
  margin-bottom: 16px;
  max-height: 200px;
  overflow-y: auto;
}

.patient-list li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}

.patient-list li:last-child {
  border-bottom: none;
}

.patient-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 16px;
}

/* Locked Section */
.locked-section {
  margin-top: 32px;
  padding: 32px 16px;
  background: linear-gradient(180deg, transparent, rgba(224, 242, 241, 0.4));
  border-radius: var(--radius-md);
  text-align: center;
  border-top: 1px dashed var(--border);
}

.locked-icon {
  width: 56px;
  height: 56px;
  background-color: var(--card-bg);
  color: var(--primary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  margin: 0 auto 16px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--primary-light);
}

.locked-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 8px;
}

.locked-subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 24px;
}

.locked-cards-preview {
  display: flex;
  flex-direction: column;
  gap: 16px;
  opacity: 0.6;
}

.locked-card {
  pointer-events: none;
  filter: grayscale(100%);
  border: 1px solid var(--border);
  box-shadow: none;
  background-color: rgba(255,255,255,0.5);
}

.locked-bg {
  background-color: #e0e0e0;
}

.locked-line {
  height: 12px;
  background-color: #e0e0e0;
  border-radius: 6px;
  margin-bottom: 8px;
}

.locked-line.short { width: 30%; margin-bottom: 12px; }
.locked-line.long { width: 90%; }
.locked-line.medium { width: 60%; }

/* Create Metaphor Form & Card */
.create-card {
  border: 2px dashed var(--primary);
  background-color: var(--primary-light);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--primary);
  padding: 24px;
  box-shadow: none;
  cursor: pointer;
  border-radius: var(--radius-md);
  margin-bottom: 16px;
  transition: transform 0.2s ease, background-color 0.2s ease;
}

.create-card:active {
  transform: scale(0.98);
  background-color: #d0ebe9;
}

.create-card i {
  font-size: 24px;
}

.create-card span {
  font-weight: 600;
  font-size: 16px;
}

.input-group {
  margin-bottom: 16px;
  text-align: left;
}

.input-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-input {
  width: 100%;
  padding: 14px 16px;
  background-color: var(--bg-color);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 15px;
  color: var(--text-main);
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  resize: none;
}

.form-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.mt-16 { margin-top: 16px; }
