:root {
  --bg-primary: #0d111a;
  --bg-secondary: #131b2e;
  --bg-card: #18223a;
  --text-main: #f0f3fa;
  --text-muted: #8c9bb5;
  --accent-blue: #3b82f6;
  --accent-indigo: #2563eb;
  --accent-red: #ef4444;
  --border-color: #23314d;
  --radius-lg: 16px;
  --radius-md: 10px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

body, html {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-main);
}

#app {
  width: 100%;
  height: 100%;
  position: relative;
  overflow: hidden;
}

/* Écrans */
.screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: none;
  flex-direction: column;
}

.screen.active {
  display: flex;
}

/* Écran de verrouillage / Token */
#screen-lock {
  justify-content: center;
  align-items: center;
  background: radial-gradient(circle at center, #172340 0%, #0c101a 100%);
  padding: 24px;
}

.lock-card {
  background: rgba(22, 32, 56, 0.85);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-color);
  padding: 36px 28px;
  border-radius: 24px;
  width: 100%;
  max-width: 380px;
  text-align: center;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
}

.lock-icon {
  font-size: 54px;
  margin-bottom: 16px;
}

.lock-title {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 8px;
  color: #fff;
}

.lock-subtitle {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 24px;
  line-height: 1.4;
}

.lock-input {
  width: 100%;
  padding: 14px 16px;
  border-radius: 12px;
  border: 1px solid var(--border-color);
  background: #0f1626;
  color: #fff;
  font-size: 16px;
  margin-bottom: 16px;
  outline: none;
  text-align: center;
  user-select: text;
}

.lock-input:focus {
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.25);
}

.btn-primary {
  width: 100%;
  padding: 14px;
  border-radius: 12px;
  background: #2563eb;
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-primary:active {
  background: #1d4ed8;
}

/* Écran Bibliothèque */
#screen-library {
  background: var(--bg-primary);
}

.lib-header {
  padding: 20px 20px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-secondary);
}

.lib-title {
  font-size: 20px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.lib-actions {
  display: flex;
  gap: 12px;
  align-items: center;
}

.btn-icon {
  background: #1b2640;
  border: 1px solid var(--border-color);
  color: var(--text-main);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 18px;
}

.lib-content {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

.book-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 20px;
}

.book-card {
  display: flex;
  flex-direction: column;
  cursor: pointer;
  transition: transform 0.15s;
}

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

.book-cover-wrapper {
  width: 100%;
  aspect-ratio: 2 / 3;
  border-radius: 12px;
  overflow: hidden;
  background: #18223a;
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.4);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

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

.book-cover-placeholder {
  padding: 16px;
  text-align: center;
  font-size: 14px;
  font-weight: 600;
  color: #a4b3d1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
}

.book-progress-badge {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(13, 17, 26, 0.85);
  backdrop-filter: blur(4px);
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 600;
  color: #60a5fa;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.book-title {
  margin-top: 10px;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.3;
  color: #fff;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.book-author {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Empty State */
.empty-library {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.empty-icon {
  font-size: 56px;
  margin-bottom: 16px;
}

/* Toast */
#toast {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(8px);
  color: #fff;
  padding: 12px 22px;
  border-radius: 30px;
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 10px 25px rgba(0,0,0,0.5);
  border: 1px solid var(--border-color);
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  z-index: 10000;
  pointer-events: none;
}

#toast.show {
  transform: translateX(-50%) translateY(0);
}
