/* ==========================================================================
   Scribd Document Archiver - Editorial Command Deck & Bookshelf Design System
   Warm Terracotta / Editorial Amber Brand Identity (#EA580C -> #C2410C)
   Stitch UI Design System Tokens & High Density Typography Parity
   ========================================================================== */

#scribdWorkspaceRoot {
  font-family: 'Plus Jakarta Sans', Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--text-primary, #09090b);
}

html.dark #scribdWorkspaceRoot,
.dark #scribdWorkspaceRoot {
  color: #f4f4f5;
}

@media (max-width: 640px) {
  #scribdWorkspaceRoot {
    padding-bottom: calc(100px + env(safe-area-inset-bottom, 0px));
  }
}

/* ==========================================================================
   1. Bento Command Deck Top Card with Refined Top Accent Bar
   ========================================================================== */
.scribd-command-deck {
  position: relative;
  border-radius: 18px;
  background: var(--surface-card, #ffffff);
  border: 1px solid var(--border-subtle, rgba(0, 0, 0, 0.08));
  padding: 22px 18px;
  overflow: hidden;
  box-shadow: 0 4px 20px -2px rgba(234, 88, 12, 0.06), 0 1px 3px rgba(0, 0, 0, 0.03);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

@media (min-width: 640px) {
  .scribd-command-deck {
    padding: 28px 24px;
  }
}

html.dark .scribd-command-deck,
.dark .scribd-command-deck {
  background: #111114 !important;
  border: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.08));
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
}

/* Refined 3px Top Accent Bar */
.scribd-command-deck::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, #EA580C 0%, #F97316 100%);
  border-top-left-radius: 18px;
  border-top-right-radius: 18px;
  z-index: 10;
}

/* ==========================================================================
   2. Unified Stitch Command Omnibar & Input Bar
   ========================================================================== */
.scribd-input-bar,
.scribd-omnibar {
  display: flex;
  align-items: center;
  border-radius: 12px;
  height: 48px;
  min-height: 48px;
  padding: 0 14px;
  background: #F8F9FA;
  border: 1px solid var(--border-subtle, rgba(0, 0, 0, 0.12));
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.03);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

html.dark .scribd-input-bar,
html.dark .scribd-omnibar,
.dark .scribd-input-bar,
.dark .scribd-omnibar {
  background: #09090C;
  border: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.12));
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.4);
}

.scribd-input-bar:focus-within,
.scribd-omnibar:focus-within {
  border-color: #EA580C !important;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.03), 0 0 0 3px rgba(234, 88, 12, 0.16) !important;
}

html.dark .scribd-input-bar:focus-within,
html.dark .scribd-omnibar:focus-within,
.dark .scribd-input-bar:focus-within,
.dark .scribd-omnibar:focus-within {
  border-color: #F97316 !important;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.3), 0 0 0 3px rgba(249, 115, 22, 0.2) !important;
}

/* Dynamic Monospace ID / Source Badge */
.scribd-id-badge {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 4px 8px;
  border-radius: 8px;
  background: var(--surface-hover, #EBECEF);
  color: var(--text-muted, #71717A);
  border: 1px solid var(--border-subtle, rgba(0, 0, 0, 0.09));
  white-space: nowrap;
  user-select: none;
  transition: all 0.2s ease;
}

html.dark .scribd-id-badge,
.dark .scribd-id-badge {
  background: #18181B;
  color: #A1A1AA;
  border-color: rgba(255, 255, 255, 0.10);
}

.scribd-id-badge.active {
  background: rgba(234, 88, 12, 0.12) !important;
  color: #EA580C !important;
  border-color: rgba(234, 88, 12, 0.35) !important;
}

html.dark .scribd-id-badge.active,
.dark .scribd-id-badge.active {
  background: rgba(249, 115, 22, 0.18) !important;
  color: #FB923C !important;
  border-color: rgba(251, 146, 60, 0.45) !important;
}

/* Terracotta Action Button inside Omnibar */
.btn-omnibar-action {
  background: #EA580C !important;
  color: #ffffff !important;
  border: 1px solid rgba(251, 146, 60, 0.4) !important;
  box-shadow: 0 2px 8px rgba(234, 88, 12, 0.3) !important;
  transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1) !important;
}

.btn-omnibar-action:hover {
  background: #C2410C !important;
  box-shadow: 0 4px 14px rgba(234, 88, 12, 0.45) !important;
  transform: translateY(-0.5px);
}

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

/* ==========================================================================
   3. Integrated Progress Panel & Segmented Steps
   ========================================================================== */
.scribd-progress-panel {
  border-radius: 16px;
  background: #FFFFFF;
  border: 1px solid rgba(234, 88, 12, 0.20);
  box-shadow: 0 4px 16px -2px rgba(234, 88, 12, 0.08);
  overflow: hidden;
  transition: all 0.25s ease;
}

html.dark .scribd-progress-panel,
.dark .scribd-progress-panel {
  background: #111114 !important;
  border: 1px solid rgba(249, 115, 22, 0.22);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.4);
}

/* Segmented Step Indicator */
.scribd-step-container {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.scribd-step-item {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 10px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid rgba(0, 0, 0, 0.08);
  background: #F8F9FA;
  color: #71717A;
  transition: all 0.2s ease;
  user-select: none;
}

html.dark .scribd-step-item,
.dark .scribd-step-item {
  background: #18181B;
  border-color: rgba(255, 255, 255, 0.08);
  color: #A1A1AA;
}

.scribd-step-item.step-active {
  background: rgba(234, 88, 12, 0.12);
  border-color: rgba(234, 88, 12, 0.35);
  color: #EA580C;
}

html.dark .scribd-step-item.step-active,
.dark .scribd-step-item.step-active {
  background: rgba(249, 115, 22, 0.16);
  border-color: rgba(251, 146, 60, 0.4);
  color: #FB923C;
}

.scribd-step-item.step-done {
  background: rgba(234, 88, 12, 0.08);
  border-color: rgba(234, 88, 12, 0.25);
  color: #EA580C;
}

html.dark .scribd-step-item.step-done,
.dark .scribd-step-item.step-done {
  background: rgba(249, 115, 22, 0.12);
  border-color: rgba(251, 146, 60, 0.3);
  color: #FB923C;
}

/* Big Percentage Readout */
.scribd-progress-pct-big {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 1.5rem;
  font-weight: 800;
  line-height: 1;
  color: #EA580C;
}

html.dark .scribd-progress-pct-big,
.dark .scribd-progress-pct-big {
  color: #FB923C;
}

/* 4-Line Collapsible Log Ticker (Generous Internal Padding: 12px 16px) */
.scribd-ticker-box {
  padding: 12px 16px !important;
  max-height: 110px;
  overflow-y: auto;
  border-radius: 12px;
  background: #09090C !important;
  border: 1px solid rgba(255, 255, 255, 0.08);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 11.5px;
  line-height: 1.55;
  color: #E4E4E7;
  scroll-padding-top: 8px;
  scroll-padding-bottom: 8px;
}

.scribd-ticker-box::-webkit-scrollbar {
  width: 5px;
}
.scribd-ticker-box::-webkit-scrollbar-track {
  background: transparent;
}
.scribd-ticker-box::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 4px;
}

/* ==========================================================================
   4. Stitch Bookshelf & Book-Spine Document Cards
   ========================================================================== */
.scribd-bookshelf {
  border-radius: 18px;
  background: #FFFFFF;
  border: 1px solid rgba(0, 0, 0, 0.08);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.03);
  padding: 16px 12px;
  transition: all 0.2s ease;
}

@media (min-width: 640px) {
  .scribd-bookshelf {
    padding: 22px 20px;
  }
}

html.dark .scribd-bookshelf,
.dark .scribd-bookshelf {
  background: #111114 !important;
  border-color: rgba(255, 255, 255, 0.09);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
}

/* Segmented Pill Switcher in Header (100% full width, never wrap) */
.scribd-segmented-switcher {
  display: grid;
  grid-template-columns: 1fr 1fr;
  width: 100%;
  padding: 3px;
  border-radius: 12px;
  background: #F4F4F6;
  border: 1px solid rgba(0, 0, 0, 0.08);
  box-sizing: border-box;
  white-space: nowrap;
}

@media (min-width: 640px) {
  .scribd-segmented-switcher {
    display: inline-flex !important;
    width: auto !important;
    grid-template-columns: none !important;
    height: 44px;
    padding: 3px;
    align-items: center;
  }

  .scribd-segmented-tab {
    flex: 0 0 auto !important;
    height: 38px !important;
    min-height: 38px !important;
    padding: 6px 14px !important;
  }
}

html.dark .scribd-segmented-switcher,
.dark .scribd-segmented-switcher {
  background: #18181B;
  border-color: rgba(255, 255, 255, 0.08);
}

.scribd-segmented-tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 9px;
  font-size: 13px;
  font-weight: 500;
  color: #52525B;
  transition: all 0.16s ease;
  user-select: none;
  cursor: pointer;
  border: 1px solid transparent;
  min-height: 40px;
  touch-action: manipulation;
  white-space: nowrap !important;
  flex: 1;
}

.scribd-segmented-tab span {
  white-space: nowrap !important;
}

.scribd-sort-select {
  white-space: nowrap !important;
  flex-shrink: 0;
  max-width: 130px;
}

html.dark .scribd-segmented-tab,
.dark .scribd-segmented-tab {
  color: #A1A1AA;
}

.scribd-segmented-tab:hover {
  color: #09090B;
}

html.dark .scribd-segmented-tab:hover,
.dark .scribd-segmented-tab:hover {
  color: #FAFAFA;
}

.scribd-segmented-tab.active {
  background: #EA580C !important;
  color: #FFFFFF !important;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(234, 88, 12, 0.35);
}

html.dark .scribd-segmented-tab.active,
.dark .scribd-segmented-tab.active {
  background: #EA580C !important;
  color: #FFFFFF !important;
  box-shadow: 0 2px 8px rgba(234, 88, 12, 0.45);
}

/* Book-Spine Document Card (Spacious 16px internal padding, 12px gap) */
.scribd-book-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  border-radius: 14px;
  background: #FFFFFF;
  border: 1px solid rgba(0, 0, 0, 0.08);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.02);
  overflow: hidden;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@media (min-width: 640px) {
  .scribd-book-card {
    flex-direction: row !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 16px !important;
    padding: 12px 18px 12px 20px !important;
    min-height: 64px !important;
  }

  .scribd-book-card .file-actions {
    width: auto !important;
    padding-top: 0 !important;
    flex-shrink: 0 !important;
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
  }

  .scribd-book-card .btn-book-action {
    height: 38px !important;
    min-height: 38px !important;
    padding: 0 14px !important;
    font-size: 13px !important;
  }

  .scribd-book-card .btn-book-action.btn-del {
    width: 38px !important;
    min-width: 38px !important;
    padding: 0 !important;
  }
}

html.dark .scribd-book-card,
.dark .scribd-book-card {
  background: #151519 !important;
  border-color: rgba(255, 255, 255, 0.08);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

.scribd-book-card:hover {
  border-color: rgba(234, 88, 12, 0.35);
  box-shadow: 0 4px 16px -2px rgba(234, 88, 12, 0.10);
  transform: translateY(-1px);
}

html.dark .scribd-book-card:hover,
.dark .scribd-book-card:hover {
  border-color: rgba(249, 115, 22, 0.4);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.45);
}

/* 4px Vertical Terracotta Book-Spine Accent Bar */
.scribd-book-spine {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: #EA580C;
  border-top-left-radius: 14px;
  border-bottom-left-radius: 14px;
}

html.dark .scribd-book-spine,
.dark .scribd-book-spine {
  background: #F97316;
}

/* Sleek Compact 38x38px Document Icon Badge (aligned with title) */
.scribd-book-badge {
  width: 38px;
  height: 38px;
  min-width: 38px;
  min-height: 38px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #FFF7ED 0%, #FFEDD5 100%);
  border: 1px solid rgba(234, 88, 12, 0.25);
  box-shadow: 0 1px 3px rgba(234, 88, 12, 0.10);
  flex-shrink: 0;
  user-select: none;
  position: relative;
  overflow: hidden;
}

html.dark .scribd-book-badge,
.dark .scribd-book-badge {
  background: linear-gradient(135deg, #1C1917 0%, #292524 100%);
  border-color: rgba(251, 146, 60, 0.3);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
}

/* Highlighted Download Button on Card */
.btn-dl-highlight {
  background: #EA580C !important;
  color: #FFFFFF !important;
  border: 1px solid rgba(251, 146, 60, 0.5) !important;
  box-shadow: 0 2px 6px rgba(234, 88, 12, 0.25) !important;
  transition: all 0.18s ease !important;
  white-space: nowrap !important;
}

.btn-dl-highlight:hover {
  background: #C2410C !important;
  box-shadow: 0 4px 12px rgba(234, 88, 12, 0.4) !important;
  transform: translateY(-0.5px);
}

html.dark .btn-dl-highlight,
.dark .btn-dl-highlight {
  background: #EA580C !important;
  border-color: rgba(251, 146, 60, 0.6) !important;
}

html.dark .btn-dl-highlight:hover,
.dark .btn-dl-highlight:hover {
  background: #F97316 !important;
}

/* Secondary Action Button on Card (44px touch ergonomics & nowrap) */
.btn-book-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 11px;
  font-size: 13.5px;
  font-weight: 600;
  background: #F4F4F6;
  color: #27272A;
  border: 1px solid rgba(0, 0, 0, 0.08);
  transition: all 0.16s ease;
  min-height: 44px;
  height: 44px;
  cursor: pointer;
  user-select: none;
  white-space: nowrap !important;
}

html.dark .btn-book-action,
.dark .btn-book-action {
  background: #18181B;
  color: #D4D4D8;
  border-color: rgba(255, 255, 255, 0.08);
}

.btn-book-action:hover {
  background: #E4E4E7;
  color: #09090B;
  border-color: rgba(0, 0, 0, 0.15);
}

html.dark .btn-book-action:hover,
.dark .btn-book-action:hover {
  background: #27272A;
  color: #FAFAFA;
  border-color: rgba(255, 255, 255, 0.15);
}

/* ==========================================================================
   5. Refined Empty State
   ========================================================================== */
.scribd-bookshelf-empty {
  min-height: 140px;
  border-radius: 14px;
  border: 1px dashed rgba(0, 0, 0, 0.12);
  background: rgba(0, 0, 0, 0.015);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 16px 96px 16px;
  text-align: center;
  gap: 6px;
}

html.dark .scribd-bookshelf-empty,
.dark .scribd-bookshelf-empty {
  border-color: rgba(255, 255, 255, 0.10);
  background: rgba(255, 255, 255, 0.02);
}

/* ==========================================================================
   6. Highlighted Downloaded State for Book-Spine Cards (Scribd Orange Tone)
   ========================================================================== */
.scribd-book-card.file-item-downloaded {
  border: 1.5px solid #EA580C !important;
  background-color: rgba(234, 88, 12, 0.035) !important;
  box-shadow: 0 0 0 2px rgba(234, 88, 12, 0.18), 0 2px 10px rgba(234, 88, 12, 0.08) !important;
  position: relative;
}

.scribd-book-card.file-item-downloaded:hover {
  border-color: #C2410C !important;
  background-color: rgba(234, 88, 12, 0.06) !important;
  box-shadow: 0 0 0 2.5px rgba(234, 88, 12, 0.28), 0 4px 14px rgba(234, 88, 12, 0.12) !important;
}

html.dark .scribd-book-card.file-item-downloaded,
.dark .scribd-book-card.file-item-downloaded {
  border: 1.5px solid #F97316 !important;
  background-color: rgba(249, 115, 22, 0.08) !important;
  box-shadow: 0 0 0 2px rgba(249, 115, 22, 0.24), 0 2px 12px rgba(0, 0, 0, 0.4) !important;
}

html.dark .scribd-book-card.file-item-downloaded:hover,
.dark .scribd-book-card.file-item-downloaded:hover {
  border-color: #FB923C !important;
  background-color: rgba(249, 115, 22, 0.12) !important;
  box-shadow: 0 0 0 2.5px rgba(251, 146, 60, 0.35), 0 4px 16px rgba(0, 0, 0, 0.5) !important;
}

.scribd-book-card.file-item-just-downloaded {
  animation: scribd-download-pulse 2.2s cubic-bezier(0.16, 1, 0.3, 1) !important;
}

@keyframes scribd-download-pulse {
  0% {
    box-shadow: 0 0 0 4px rgba(234, 88, 12, 0.5), 0 4px 16px rgba(234, 88, 12, 0.35) !important;
    transform: scale(1.008);
  }
  50% {
    box-shadow: 0 0 0 2.5px rgba(234, 88, 12, 0.3), 0 2px 10px rgba(234, 88, 12, 0.2) !important;
  }
  100% {
    box-shadow: 0 0 0 2px rgba(234, 88, 12, 0.18), 0 2px 10px rgba(234, 88, 12, 0.08) !important;
    transform: scale(1);
  }
}

/* Document Card Typography & Balanced Full-Width Actions */
.scribd-book-card .meta-user {
  color: #c2410c;
  border-color: rgba(234, 88, 12, 0.25);
  background: rgba(234, 88, 12, 0.08);
}

html.dark .scribd-book-card .meta-user,
.dark .scribd-book-card .meta-user {
  color: #fb923c;
  border-color: rgba(249, 115, 22, 0.25);
  background: rgba(249, 115, 22, 0.08);
}

.scribd-book-card .file-name {
  font-size: 15.5px !important;
  line-height: 1.4 !important;
  font-weight: 600;
  letter-spacing: -0.01em;
  word-break: break-word;
}

.scribd-book-card .file-actions {
  display: flex;
  align-items: center;
  width: 100%;
  gap: 8px;
}

.scribd-book-card .file-actions .btn-book-action {
  height: 42px;
  min-height: 42px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  padding: 0 12px;
  box-sizing: border-box;
  position: relative;
  touch-action: manipulation;
}

@media (max-width: 640px) {
  .scribd-book-card .file-actions .btn-book-action::after {
    content: '';
    position: absolute;
    top: -2px;
    bottom: -2px;
    left: -1px;
    right: -1px;
  }
}

.scribd-book-card .file-actions .btn-view {
  flex: 1;
}

.scribd-book-card .file-actions .btn-dl {
  flex: 1.2;
}

.scribd-book-card .file-actions .btn-restore {
  flex: 1;
}

.scribd-book-card .file-actions .btn-del {
  flex: 0 0 42px;
  width: 42px;
  min-width: 42px;
  height: 42px;
  min-height: 42px;
  padding: 0;
}

@media (min-width: 640px) {
  .scribd-book-card .file-actions {
    width: auto;
  }
  .scribd-book-card .file-actions .btn-view,
  .scribd-book-card .file-actions .btn-dl,
  .scribd-book-card .file-actions .btn-restore {
    flex: initial;
    padding: 0 16px;
  }
}

/* Touch Targets: minimum 44px ergonomics */
@media (max-width: 640px) {
  .scribd-book-card {
    padding: 14px 14px 14px 16px;
  }
}
