:root {
  /* System Colors - iOS Inspired */
  --bg-primary: #ffffff;
  --bg-secondary: #f2f2f7;
  --bg-tertiary: #e5e5ea;
  --text-primary: #000000;
  --text-secondary: #8e8e93;
  --accent: #ff3b30; /* Apple Books Red */
  --accent-soft: rgba(255, 59, 48, 0.1);
  --border: #d1d1d6;
  --card-bg: #ffffff;
  --glass: rgba(255, 255, 255, 0.8);
  
  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;
  
  /* Typography */
  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-serif: "New York", "Georgia", serif;
  
  /* Shadows */
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
  --shadow-lg: 0 10px 25px rgba(0,0,0,0.15);
  
  /* Safe Areas */
  --safe-top: 44px;
  --safe-bottom: 34px;
}

[data-theme="dark"] {
  --bg-primary: #000000;
  --bg-secondary: #1c1c1e;
  --bg-tertiary: #2c2c2e;
  --text-primary: #ffffff;
  --text-secondary: #8e8e93;
  --border: #38383a;
  --card-bg: #1c1c1e;
  --glass: rgba(0, 0, 0, 0.8);
}

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

body {
  margin: 0;
  font-family: var(--font-family);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* Layout Containers */
.app-container {
  max-width: 430px; /* Standard iPhone Pro Max width for wireframe feel */
  margin: 0 auto;
  min-height: 100vh;
  position: relative;
  background: var(--bg-primary);
  display: flex;
  flex-direction: column;
}

.scroll-content {
  flex: 1;
  padding-bottom: calc(var(--safe-bottom) + 80px);
  padding-top: var(--safe-top);
}

/* Header */
.header {
  padding: var(--space-lg) var(--space-md) var(--space-sm);
  position: sticky;
  top: 0;
  background: var(--glass);
  backdrop-filter: blur(20px);
  z-index: 100;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.header h1 {
  font-size: 34px;
  font-weight: 700;
  margin: 0;
  letter-spacing: -0.5px;
}

.header-actions {
  display: flex;
  gap: var(--space-md);
}

/* Sections */
section {
  margin-top: var(--space-xl);
  padding: 0 var(--space-md);
}

.section-title {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: var(--space-md);
}

.section-title h2 {
  font-size: 22px;
  font-weight: 700;
  margin: 0;
}

.section-title a {
  color: var(--accent);
  text-decoration: none;
  font-size: 15px;
  font-weight: 500;
}

/* Library Grid */
.book-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-lg);
}

.book-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  text-decoration: none;
  color: inherit;
}

.book-cover-wrapper {
  position: relative;
  width: 100%;
  aspect-ratio: 2/3;
  border-radius: 6px;
  box-shadow: var(--shadow-md);
  overflow: hidden;
  transition: transform 0.2s ease;
  background: var(--bg-tertiary);
}

.book-card:active .book-cover-wrapper {
  transform: scale(0.96);
}

.book-info h3 {
  font-size: 15px;
  font-weight: 600;
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.book-info p {
  font-size: 13px;
  color: var(--text-secondary);
  margin: 2px 0 0;
}

.progress-bar {
  height: 3px;
  background: var(--bg-tertiary);
  border-radius: 2px;
  margin-top: var(--space-xs);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--accent);
  width: 0%;
}

/* Horizontal Scroll Sections */
.horizontal-scroll {
  display: flex;
  overflow-x: auto;
  gap: var(--space-md);
  padding: var(--space-sm) 0 var(--space-lg);
  margin: 0 calc(-1 * var(--space-md));
  padding-left: var(--space-md);
  scrollbar-width: none;
}

.horizontal-scroll::-webkit-scrollbar {
  display: none;
}

.featured-card {
  flex: 0 0 280px;
  background: var(--card-bg);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border);
}

/* Reading Experience */
.reader-container {
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: #fbfaf8; /* Paper color */
  color: #1a1a1a;
  padding: var(--safe-top) var(--space-xl) var(--safe-bottom);
}

.reader-header-group {
  text-align: center;
}

.reader-header-title {
  font-weight: 600;
}

.reader-header-author {
  font-size: 10px;
}

.reader-header-actions {
  display: flex;
  gap: var(--space-md);
}

.reader-chapter-title {
  font-size: 24px;
  text-align: left;
  margin-bottom: var(--space-xl);
}

.reader-progress-container {
  width: 120px;
  height: 2px;
  background: rgba(0,0,0,0.1);
  position: relative;
}

.reader-progress-bar {
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  background: var(--text-primary);
}

.reader-floating-menu {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: white;
  border-radius: 40px;
  padding: 12px 24px;
  box-shadow: var(--shadow-lg);
  display: flex;
  gap: 32px;
  border: 1px solid var(--border);
}

.menu-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  color: var(--text-primary);
  text-decoration: none;
}

.menu-item.active {
  color: var(--accent);
}

.menu-item span {
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
}

.reader-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-md) 0;
  opacity: 0.5;
  font-size: 13px;
}

.reader-content {
  flex: 1;
  font-family: var(--font-serif);
  font-size: 19px;
  line-height: 1.6;
  text-align: justify;
  overflow-y: auto;
  padding: var(--space-lg) 0;
}

.reader-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-md) 0;
  font-size: 13px;
  color: var(--text-secondary);
}

/* Tab Bar */
.tab-bar {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 430px;
  background: var(--glass);
  backdrop-filter: blur(20px);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-around;
  padding: var(--space-sm) 0 var(--safe-bottom);
  z-index: 1000;
}

.tab-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  text-decoration: none;
  color: var(--text-secondary);
  font-size: 10px;
  font-weight: 500;
}

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

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

/* Utilities */
.placeholder-image {
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, #e5e5ea 0%, #d1d1d6 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  font-size: 12px;
  text-align: center;
  padding: var(--space-md);
}

.placeholder-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--bg-tertiary);
}

.badge {
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  background: var(--accent);
  color: white;
  position: absolute;
  top: 8px;
  right: 8px;
}

/* Animations */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.animate-in {
  animation: fadeIn 0.4s ease forwards;
}
