/* Elegant theme with distinctive typography and refined aesthetics */
@import url('https://fonts.googleapis.com/css2?family=DM+Sans:opsz,wght@9..40,400;9..40,500;9..40,600;9..40,700&family=Fraunces:opsz,wght@9..144,400;9..144,500;9..144,600&display=swap');

:root {
  --brand-primary: #2563eb; /* Deep blue */
  --brand-primary-700: #1d4ed8; /* Darker blue */
  --brand-primary-50: #eff6ff; /* Light blue background */
  --brand-accent: #f97316; /* Warm orange accent */
  --brand-success: #10b981; /* Emerald green */
  --text-color: #0f172a; /* Slate 900 - deep readable black */
  --text-secondary: #334155; /* Slate 700 */
  --muted-color: #64748b; /* Slate 500 */
  --muted-light: #94a3b8; /* Slate 400 */
  --surface: #ffffff;
  --surface-soft: #f8fafc; /* Slate 50 */
  --surface-elevated: #ffffff;
  --border-color: #e2e8f0; /* Slate 200 */
  --border-light: #f1f5f9; /* Slate 100 */
  --radius: 10px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.05);
  --focus-ring: 0 0 0 3px rgba(37, 99, 235, 0.15);
  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);

  /* Typography */
  --font-display: 'Fraunces', Georgia, serif;
  --font-body: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;

  /* Enhanced Pico tokens */
  --pico-font-family: var(--font-body);
  --pico-font-size: 15px;
  --pico-line-height: 1.65;
  --pico-primary: var(--brand-primary);
  --pico-primary-hover: var(--brand-primary-700);
  --pico-muted-color: var(--muted-color);
  --pico-border-radius: var(--radius);
  --pico-card-background-color: var(--surface-elevated);
  --pico-card-border-color: var(--border-color);
  --pico-card-padding: 1.5rem;
  --pico-form-element-background-color: var(--surface);
  --pico-form-element-border-color: var(--border-color);
  --pico-form-element-focus-border-color: var(--brand-primary);
  --pico-box-shadow: var(--shadow-sm);
}

body {
  color: var(--text-color);
  background: #f8fafc;
  background-image: 
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(37, 99, 235, 0.08), transparent),
    radial-gradient(ellipse 60% 40% at 100% 100%, rgba(249, 115, 22, 0.05), transparent);
  padding-bottom: 4rem;
  font-family: var(--font-body);
  font-weight: 400;
  letter-spacing: -0.01em;
  min-height: 100vh;
}

main.container {
  max-width: 820px;
  padding: 1.5rem 1rem 2rem;
}

/* Utilities */
.muted { color: var(--muted-color) !important; }
[x-cloak] { display: none !important; }

/* Elevated surfaces with refined styling */
.surface, article {
  background: var(--surface-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-md);
  padding: 1.5rem;
  margin-bottom: 1.25rem;
  transition: var(--transition);
}

.surface:hover, article:hover {
  box-shadow: var(--shadow-lg);
}

/* Refined header */
.topnav {
  border: none;
  padding: 1.25rem 0 1.5rem 0;
  margin-bottom: 0.5rem;
  background-color: transparent;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

.topnav .brand { 
  margin: 0; 
  font-family: var(--font-display);
  font-size: 1.75rem; 
  font-weight: 500;
  color: var(--text-color);
  letter-spacing: -0.03em;
}

.topnav nav button,
.topnav nav a {
  border: none;
  background-color: transparent;
  color: var(--muted-color);
  font-weight: 500;
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
  transition: all 0.2s ease;
  border-radius: var(--radius);
}

.topnav nav button:hover,
.topnav nav a:hover {
  color: var(--text-color);
  background-color: var(--surface);
}

.topnav nav button[aria-current="true"],
.topnav nav a[aria-current="true"] {
  background: var(--text-color) !important;
  color: white !important;
  font-weight: 600;
}

/* Buttons */
button, a.button, input[type="submit"], input[type="button"] {
  border-radius: var(--radius);
  box-shadow: none !important;
  transform: none !important;
  transition: all 0.15s ease;
  border: 1px solid var(--pico-form-element-border-color);
  font-weight: 500;
  font-family: var(--font-body);
}

button.primary, button:not([class]),
input[type="submit"]:not([class]),
input[type="button"]:not([class]) {
  background-color: var(--brand-primary);
  border-color: var(--brand-primary);
  color: white;
}
button.primary:hover, button:not([class]):hover {
  background-color: var(--brand-primary-700);
  border-color: var(--brand-primary-700);
  transform: translateY(-1px);
}

button.secondary {
  background-color: var(--surface);
  border-color: var(--border-color);
  color: var(--text-color);
}
button.secondary:hover {
  background-color: var(--surface-soft);
  border-color: var(--muted-light);
}

button.contrast {
  background-color: transparent;
  border-color: transparent;
  color: var(--muted-color);
}
button.contrast:hover {
  background-color: var(--surface-soft);
  color: var(--text-color);
}

button.small {
  padding: 0.4rem 0.75rem;
  font-size: 0.8rem;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}


/* Forms */
input, select, textarea {
  border-radius: var(--radius);
  border: 1px solid var(--border-color);
  background-color: var(--surface);
  box-shadow: none !important;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--brand-primary);
  box-shadow: var(--focus-ring) !important;
}

/* Section headers */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
}

.section-header h3 {
  margin: 0;
}

/* Enhanced text cards */
.text-card {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  background: var(--surface-elevated);
  overflow: hidden;
  transition: var(--transition);
  box-shadow: var(--shadow-sm);
}

.text-card:hover {
  border-color: var(--brand-primary);
  box-shadow: var(--shadow-md);
}

.text-card.completed {
  background: var(--surface-soft);
  border-color: var(--border-light);
  opacity: 0.75;
}

.text-card.completed:hover {
  opacity: 1;
}

.text-card.custom-text-card {
  border-style: dashed;
}

.text-card-header {
  padding: 1.25rem 1.25rem 0.75rem;
}

.text-card-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.pack-badge {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.2rem 0.5rem;
  background: var(--brand-primary-50);
  color: var(--brand-primary);
  border-radius: 4px;
}

.pack-badge.custom {
  background: var(--surface-soft);
  color: var(--muted-color);
}

.progress-badge {
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--muted-color);
  background: var(--surface-soft);
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
}

.text-card-progress {
  padding: 0 1.25rem 0.75rem;
}

.progress-bar {
  height: 4px;
  background: var(--border-color);
  border-radius: 2px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--brand-primary), var(--brand-accent));
  border-radius: 2px;
  transition: width 0.3s ease;
}

.record-btn {
	background: var(--brand-primary);
	color: white;
	border: none;
	display: inline-flex;
	align-items: center;
	gap: 0.4rem;
	padding: 0.5rem 1rem;
	font-size: 0.85rem;
	font-weight: 600;
	border-radius: 50px;
	transition: all 0.2s ease;
}
.record-btn:hover:not(:disabled) {
	background: var(--brand-primary-700);
	transform: translateY(-1px);
}
.record-btn:disabled {
	background: var(--brand-success);
	cursor: default;
	opacity: 1;
}
.record-btn:disabled:hover {
	transform: none;
}

/* Modal */
.recorder-modal-overlay {
  background: rgba(0, 0, 0, 0.4);
}

.recorder-modal {
  box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05); /* Softer shadow for modal */
}

/* Archive Card */
.archive-card-new {
  border: 1px solid var(--border-color);
  box-shadow: none;
}
.archive-card-new:hover {
  transform: none;
  box-shadow: none;
  border-color: var(--brand-primary);
}

.heatmap-container {
	overflow-x: auto;
	margin: 1.5rem 0;
	padding: 1rem;
	background: var(--surface-soft);
	border-radius: var(--radius-lg);
	border: 1px solid var(--border-color);
}

.heatmap-container h4 {
	margin-top: 0;
	margin-bottom: 1rem;
}

#cal-heatmap {
	min-height: 120px;
}

.ch-container {
	--ch-bg-color: transparent;
	--ch-fg-color: var(--text-color);
	--ch-muted-color: var(--muted-color);
	--ch-day-bg-color: #e5e7eb;
	--ch-day-bg-color-hover: var(--brand-primary);
	--ch-day-bg-color-empty: #f1f5f9;
	--ch-day-radius: 2px;
	--ch-domain-gutter: .5rem;
}
.ch-tooltip {
	background: var(--text-color) !important;
	color: var(--surface) !important;
	border-radius: var(--radius) !important;
	padding: .25rem .5rem !important;
	font-size: .8rem !important;
}
.ch-tooltip:after {
	border-top-color: var(--text-color) !important;
}

.archive-list {
	display: flex;
	flex-direction: column;
	gap: .75rem;
}

.archive-item {
	border: 1px solid var(--border-color);
	border-radius: var(--radius);
	background: var(--surface);
}

.archive-item[open] {
	border-color: var(--brand-primary);
}

.archive-item-summary {
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: .75rem 1.25rem;
	cursor: pointer;
	list-style: none;
}
.archive-item-summary::-webkit-details-marker { display: none; }
.archive-item-summary:hover { background: var(--surface-soft); }

.summary-main {
	display: flex;
	align-items: center;
	gap: 1rem;
	flex: 1;
	min-width: 0;
}
.summary-main .summary-chevron {
	transition: transform 0.2s;
	color: var(--muted-color);
}
.archive-item[open] .summary-main .summary-chevron {
	transform: rotate(90deg);
}

.summary-main .item-date {
	color: var(--muted-color);
	font-size: .8rem;
	font-weight: 500;
	flex-shrink: 0;
	width: 50px;
}
.summary-main .item-prompt {
	font-weight: 600;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}
.summary-player {
	color: var(--muted-color);
	transition: color 0.2s;
}
.archive-item[open] .summary-player {
	color: var(--brand-primary);
}
.archive-item-summary:hover .summary-player {
	color: var(--text-color);
}


.archive-item-body {
	padding: 1rem 1.25rem;
	border-top: 1px solid var(--border-color);
}
.archive-item-body p {
	margin-top: 0;
}
.archive-item-body .recording-player {
	display: flex;
	align-items: center;
	gap: 1rem;
}
.archive-item-body audio {
	flex: 1;
}

.metrics-compact-grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
	gap: 1rem;
	margin-top: 1rem;
	padding-top: 1rem;
	border-top: 1px solid var(--border-color);
}
.metric-compact {
	text-align: center;
}
.metric-compact .metric-label {
	font-size: .8rem;
	color: var(--muted-color);
	display: block;
}
.metric-compact .metric-value {
	font-weight: 600;
	font-size: 1.1rem;
}

/* Re-add necessary styles that were removed */
.text-cards {
	display: flex;
	flex-direction: column;
	gap: 1rem;
	margin-top: 1rem;
}

.text-card-header {
	display: flex;
	align-items: flex-start;
	cursor: pointer;
	gap: 1rem;
}

.text-card-status {
	flex-shrink: 0;
	width: 24px;
	height: 24px;
	display: flex;
	align-items: center;
	justify-content: center;
}

.check-icon {
	color: #10b981;
}

.record-indicator {
	width: 12px;
	height: 12px;
	border-radius: 50%;
	background: var(--brand-primary);
	animation: pulse 2s infinite;
}

@keyframes pulse {
	0% { opacity: 1; }
	50% { opacity: 0.5; }
	100% { opacity: 1; }
}

.text-card-content {
	flex: 1;
	min-width: 0;
}

.text-card-content h4 {
	margin: 0 0 0.35rem 0;
	font-family: var(--font-display);
	font-size: 1.05rem;
	font-weight: 500;
	color: var(--text-color);
	letter-spacing: -0.01em;
	text-transform: none;
}

.text-preview {
	margin: 0;
	color: var(--muted-color);
	font-size: 0.9rem;
	line-height: 1.4;
}

.text-card-actions {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	flex-shrink: 0;
}

.expand-btn {
	background: none;
	border: none;
	color: var(--muted-color);
	cursor: pointer;
	padding: 0.35rem;
	border-radius: var(--radius);
	transition: all 0.2s ease;
	display: flex;
	align-items: center;
	justify-content: center;
}

.expand-btn:hover {
	background: var(--surface-soft);
	color: var(--text-color);
}

.expand-btn svg {
	transition: transform 0.2s ease;
}

.expand-btn.rotated svg {
	transform: rotate(180deg);
}

.text-card-body {
	padding: 1rem 1.25rem 1.25rem;
	border-top: 1px solid var(--border-light);
	background: var(--surface-soft);
}

.text-full-content {
	color: var(--text-color);
	line-height: 1.75;
	white-space: pre-wrap;
	font-size: 0.95rem;
}

.add-custom-text details {
	border: 1px dashed var(--border-color);
	border-radius: var(--radius);
	padding: 1rem;
}

.add-custom-text summary {
	cursor: pointer;
	font-weight: 500;
	color: var(--brand-primary);
}

/* Modal Styles */
.recorder-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: 1rem;
}

.recorder-modal {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
  width: 100%;
  max-width: 800px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.recorder-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
  background: var(--surface-soft);
}

.recorder-modal-header h2 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-color);
}

.modal-close-btn {
  background: none;
  border: none;
  color: var(--muted-color);
  padding: 0.5rem;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-close-btn:hover {
  background: var(--surface-soft);
  color: var(--text-color);
  transform: scale(1.1);
}

.recorder-modal-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-text-content {
  flex: 1;
  padding: 1.5rem;
  overflow: hidden;
}

.modal-text-content .text-display {
  height: 100%;
  overflow-y: auto;
  padding: 1rem;
  background: var(--surface-soft);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  font-size: 1.1rem;
  line-height: 1.7;
  white-space: pre-wrap;
  color: var(--text-color);
}

.modal-recording-controls {
  background: var(--surface);
  border-top: 1px solid var(--border-color);
  padding: 1.5rem;
}

.modal-recording-controls .status-display {
  text-align: center;
  font-weight: 600;
  color: var(--muted-color);
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.modal-recording-controls .controls-container {
  display: flex;
  justify-content: center;
  margin-bottom: 1.5rem;
}

.modal-recording-controls .record-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 1rem 2rem;
  font-size: 1.1rem;
  font-weight: 600;
  border-radius: 50px;
  border: none;
  cursor: pointer;
  transition: all 0.3s ease;
  background: var(--brand-primary);
  color: white;
}

.modal-recording-controls .record-btn.recording {
  background: #dc2626;
  animation: pulse-recording 2s infinite;
}

@keyframes pulse-recording {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

.modal-recording-controls .visualizer-container {
  margin-bottom: 1.5rem;
  display: flex;
  justify-content: center;
}

.modal-recording-controls .visualizer-canvas {
  width: 100%;
  max-width: 400px;
  height: 120px;
  border-radius: var(--radius);
  background: var(--surface-soft);
  border: 1px solid var(--border-color);
}

.modal-recording-controls .review-section {
  border-top: 1px solid var(--border-color);
  padding-top: 1.5rem;
  display: grid;
  gap: 1.5rem;
}

.modal-recording-controls .audio-player {
  width: 100%;
  border-radius: var(--radius);
  border: 1px solid var(--border-color);
  background: var(--surface-soft);
}

.modal-recording-controls .action-buttons {
  display: flex;
  gap: 1rem;
  justify-content: center;
}

/* Toasts */
#toast-container {
  position: fixed;
  inset: auto 0 1rem 0;
  display: grid;
  gap: 0.5rem;
  width: min(560px, 92vw);
  margin: 0 auto;
  z-index: 1000;
}
.toast {
  border-radius: var(--radius);
  padding: 0.6rem 0.9rem;
  border: 1px solid var(--border-color);
  background: #ffffff;
  color: var(--text-color);
  box-shadow: var(--shadow-md);
  transform: translateY(6px);
  opacity: 0;
  transition: transform 180ms ease, opacity 180ms ease;
}
.toast.is-visible { transform: translateY(0); opacity: 1; }
.toast--success { border-color: #10b98133; background: #ecfdf5; }
.toast--warning { border-color: #f59e0b33; background: #fffbeb; }
.toast--error { border-color: #ef444433; background: #fef2f2; }


/* Feed Styles */
.feed-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.feed-item {
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
}

.feed-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.25rem;
  background: var(--surface-soft);
  border-bottom: 1px solid var(--border-color);
}

.feed-author {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
}

.feed-date {
  color: var(--muted-color);
  font-size: 0.8rem;
}

.feed-item-content {
  padding: 1.25rem;
}

.feed-stats {
  margin: 0.75rem 0;
}

.feed-actions {
  margin-top: 1rem;
}

.shared-recordings {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-color);
}

.shared-recording {
  padding: 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  margin-bottom: 0.5rem;
  background: var(--surface-soft);
}

.recording-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.recording-title {
  font-weight: 500;
}

.recording-date {
  color: var(--muted-color);
  font-size: 0.8rem;
}

/* Friends Styles */
.add-friend-section {
  margin-bottom: 2rem;
  padding: 1.25rem;
  background: var(--surface-soft);
  border-radius: var(--radius);
  border: 1px solid var(--border-color);
}

.friend-form {
  display: flex;
  gap: 0.75rem;
  align-items: end;
  margin-top: 0.75rem;
}

.friend-form label {
  flex: 1;
  margin: 0;
}

.friend-requests,
.friends-list,
.pending-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 0.75rem;
}

.friend-request,
.friend-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem;
  background: var(--surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
}

.friend-item.pending {
  background: var(--surface-soft);
  border-style: dashed;
}

.request-info,
.friend-info {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: 1;
}

.request-actions,
.friend-actions {
  display: flex;
  gap: 0.5rem;
}

.friend-request strong,
.friend-item strong {
  color: var(--text-color);
}

/* Small button variant */
button.small {
  padding: 0.4rem 0.8rem;
  font-size: 0.8rem;
  line-height: 1.2;
}

/* Button group layout for tabs */
.button-row {
  display: flex;
  gap: 0.25rem;
  align-items: center;
  flex-wrap: wrap;
}

/* Enhanced typography */
h3 {
  font-size: 1.4rem;
  font-weight: 600;
  color: var(--text-color);
  margin-bottom: 1rem;
  letter-spacing: -0.02em;
}

h4 {
  margin: 0 0 0.75rem 0;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted-color);
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

p {
  color: var(--text-secondary);
  line-height: 1.65;
}

.muted {
  color: var(--muted-color) !important;
  font-size: 0.9rem;
}

/* Better spacing for nested sections */
.add-friend-section + div,
.friend-requests + div,
.friends-list + div {
  margin-top: 2rem;
}

/* Responsive adjustments for friends/feed */
@media (max-width: 768px) {
  .friend-form {
    flex-direction: column;
    align-items: stretch;
  }

  .friend-request,
  .friend-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }

  .request-actions,
  .friend-actions {
    align-self: stretch;
    justify-content: stretch;
  }

  .feed-item-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }
  
  .button-row {
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: center;
  }
}

/* Mobile Overrides */
@media (max-width: 768px) {
  .recorder-modal-overlay {
    padding: 0;
  }

  .recorder-modal {
    width: 100%;
    height: 100vh;
    max-height: none;
    border-radius: 0;
  }
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 3rem 2rem;
  background: var(--surface-soft);
  border-radius: var(--radius-lg);
  border: 2px dashed var(--border-color);
}

.empty-state svg {
  color: var(--muted-light);
  margin-bottom: 1rem;
}

.empty-state h4 {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 500;
  margin-bottom: 0.5rem;
  color: var(--text-color);
  text-transform: none;
}

.empty-state p {
  margin-bottom: 1.5rem;
}

.empty-state button {
  margin-top: 0.5rem;
}

/* Generic Modal Styles */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: 1rem;
  animation: fadeIn 0.15s ease;
}

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

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
  background: var(--surface);
}

.modal-header h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 500;
  color: var(--text-color);
}

.modal-body {
  padding: 1.5rem;
  overflow-y: auto;
  max-height: calc(90vh - 80px);
}

/* Subscription Modal */
.subscription-modal {
  background: var(--surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: slideUp 0.2s ease;
}

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

/* Packs List */
.packs-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.pack-card {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  background: var(--surface);
  transition: var(--transition);
}

.pack-card:hover {
  border-color: var(--brand-primary);
  box-shadow: var(--shadow-sm);
}

.pack-card.subscribed {
  border-color: var(--brand-success);
  background: linear-gradient(to right, rgba(16, 185, 129, 0.03), transparent);
}

.pack-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.pack-header h4 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 500;
  color: var(--text-color);
  text-transform: none;
}

.item-count {
  font-size: 0.8rem;
  color: var(--muted-color);
  background: var(--surface-soft);
  padding: 0.2rem 0.6rem;
  border-radius: 20px;
}

.pack-description {
  color: var(--muted-color);
  font-size: 0.9rem;
  margin: 0 0 1rem 0;
  line-height: 1.5;
}

.pack-progress {
  margin-bottom: 1rem;
  padding: 0.75rem;
  background: var(--surface-soft);
  border-radius: var(--radius);
}

.progress-info {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
}

.progress-percent {
  font-weight: 600;
  color: var(--brand-success);
}

.pack-actions {
  display: flex;
  gap: 0.5rem;
}

.subscribed-actions {
  display: flex;
  gap: 0.5rem;
}

/* Loading State */
.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem;
  color: var(--muted-color);
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border-color);
  border-top-color: var(--brand-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 1rem;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Simple Heatmap Fallback */
.simple-heatmap {
  overflow-x: auto;
  padding: 0.5rem 0;
}

.heatmap-months {
  display: flex;
  gap: 2rem;
  margin-bottom: 0.5rem;
  font-size: 0.7rem;
  color: var(--muted-color);
  padding-left: 2px;
}

.heatmap-grid {
  display: grid;
  grid-template-rows: repeat(7, 12px);
  grid-auto-flow: column;
  gap: 3px;
}

.heatmap-day {
  width: 12px;
  height: 12px;
  border-radius: 2px;
  background: var(--border-light);
}

.heatmap-day.level-1 { background: #bbf7d0; }
.heatmap-day.level-2 { background: #4ade80; }
.heatmap-day.level-3 { background: #22c55e; }
.heatmap-day.level-4 { background: #15803d; }

/* Add custom text section */
.add-custom-text details {
  border: 1px dashed var(--border-color);
  border-radius: var(--radius-lg);
  background: var(--surface-soft);
  overflow: hidden;
}

.add-custom-text summary {
  cursor: pointer;
  padding: 1rem 1.25rem;
  font-weight: 500;
  color: var(--muted-color);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: color 0.2s ease;
}

.add-custom-text summary:hover {
  color: var(--text-color);
}

.add-custom-text details[open] summary {
  border-bottom: 1px solid var(--border-color);
  background: var(--surface);
}

.add-custom-text details[open] {
  background: var(--surface);
}

.add-custom-text label {
  display: block;
  padding: 0 1.25rem;
}

.add-custom-text textarea {
  border-radius: var(--radius);
}

.add-custom-text .button-row {
  padding: 0 1.25rem 1.25rem;
}

/* Typography improvements */
h3 {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 500;
  color: var(--text-color);
  margin-bottom: 0.75rem;
  letter-spacing: -0.02em;
}

/* Responsive adjustments for subscription modal */
@media (max-width: 640px) {
  .subscription-modal {
    max-height: 100vh;
    border-radius: 0;
    height: 100%;
  }
  
  .modal-overlay {
    padding: 0;
  }
  
  .pack-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }
  
  .pack-actions {
    flex-direction: column;
    width: 100%;
  }
  
  .pack-actions button,
  .subscribed-actions {
    width: 100%;
  }
  
  .subscribed-actions {
    flex-direction: column;
  }
  
  .subscribed-actions button {
    width: 100%;
  }
}


