:root {
  --bg-app: #fcf9f2;
  --bg-surface: #ffffff;
  --bg-sidebar: #f7f3eb;
  --bg-canvas-wrapper: #ece5d8;
  --text-main: #2d241e;
  --text-muted: #786b5e;
  --text-heading: #1c140e;
  --accent: #b45309;
  --accent-hover: #92400e;
  --accent-light: #fef3c7;
  --accent-rose: #e11d48;
  --border: #e6ded1;
  --border-dark: #cfc4b2;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 12px rgba(45,36,30,0.08);
  --shadow-lg: 0 10px 25px rgba(45,36,30,0.12);
  --shadow-canvas: 0 12px 36px rgba(45,36,30,0.18), 0 2px 6px rgba(0,0,0,0.08);
  --font-sans: "Plus Jakarta Sans", ui-sans-serif, system-ui, sans-serif;
  --font-serif: "Playfair Display", Georgia, serif;
}

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

body {
  background-color: var(--bg-app);
  color: var(--text-main);
  font-family: var(--font-sans);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  overflow-x: hidden;
}

.scrapbook-app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background-color: var(--bg-app);
}

.drawer-section {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.export-dropdown {
  display: flex;
  align-items: center;
}

.field-group {
  margin-top: 0.75rem;
}

.frame-options {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.handle {
  user-select: none;
}

.hint-text {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.inspector-footer {
  margin-top: 1rem;
}

.row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.row-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}

.row-tight {
  display: flex;
  gap: 0.35rem;
}

.selection-border {
  width: 100%;
  height: 100%;
}

.spread-elements-container {
  position: relative;
  width: 100%;
  height: 100%;
}

.sticker-element-box {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tab-label {
  font-size: 0.7rem;
}

.thumb-preview {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* App Header */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.25rem;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
  flex-wrap: wrap;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand-logo {
  font-size: 1.8rem;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.1));
}

.brand-title {
  font-family: var(--font-serif);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--accent);
  line-height: 1.2;
}

.project-title-input {
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
  border: 1px dashed transparent;
  padding: 0.1rem 0.35rem;
  border-radius: var(--radius-sm);
  background: transparent;
  outline: none;
  transition: all 0.2s;
}

.project-title-input:hover,
.project-title-input:focus {
  border-color: var(--border-dark);
  background: var(--bg-app);
  color: var(--text-main);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.save-badge {
  font-size: 0.8rem;
  color: #059669;
  font-weight: 600;
  background: #ecfdf5;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  border: 1px solid #a7f3d0;
  animation: fadeIn 0.3s;
}

.view-mode-toggle {
  display: flex;
  background: var(--bg-sidebar);
  padding: 0.2rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}

.mode-btn {
  border: none;
  background: transparent;
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.825rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
}

.mode-btn.active {
  background: var(--bg-surface);
  color: var(--accent);
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.btn-craft {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 0.5rem 0.95rem;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 0.875rem;
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(180, 83, 9, 0.25);
  transition: all 0.15s;
}

.btn-craft:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
}

.btn-secondary-soft {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--bg-sidebar);
  color: var(--text-main);
  border: 1px solid var(--border);
  padding: 0.5rem 0.85rem;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-secondary-soft:hover {
  background: #ede6d8;
}

/* Studio Layout */
.studio-container {
  display: flex;
  height: calc(100vh - 65px);
  overflow: hidden;
  position: relative;
}

/* Tool Tabs Nav Bar */
.tool-tabs-bar {
  width: 76px;
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 0.75rem 0.35rem;
  gap: 0.4rem;
  flex-shrink: 0;
  z-index: 20;
}

.tab-nav-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0.6rem 0.2rem;
  border: none;
  background: transparent;
  border-radius: var(--radius-md);
  cursor: pointer;
  color: var(--text-muted);
  font-size: 0.725rem;
  font-weight: 600;
  position: relative;
  transition: all 0.15s;
  gap: 0.25rem;
}

.tab-icon {
  font-size: 1.25rem;
}

.tab-nav-btn:hover {
  background: var(--bg-sidebar);
  color: var(--text-main);
}

.tab-nav-btn.active {
  background: var(--accent-light);
  color: var(--accent);
}

.tab-highlight {
  border: 1px dashed var(--accent);
}

.store-pill {
  position: absolute;
  top: 2px;
  right: 4px;
  background: var(--accent-rose);
  color: #fff;
  font-size: 0.6rem;
  padding: 0.1rem 0.3rem;
  border-radius: 999px;
  font-weight: 800;
}

/* Tool Drawer Panel */
.tool-drawer {
  width: 330px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 1.25rem 1rem;
  flex-shrink: 0;
  z-index: 15;
}

.drawer-header {
  margin-bottom: 1.25rem;
}

.drawer-header h3 {
  font-family: var(--font-serif);
  font-size: 1.15rem;
  color: var(--text-heading);
  margin-bottom: 0.25rem;
}

.drawer-header p {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.section-title {
  font-size: 0.825rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin: 1.25rem 0 0.6rem;
}

/* Upload Box */
.upload-box {
  border: 2px dashed var(--border-dark);
  background: var(--bg-surface);
  border-radius: var(--radius-md);
  padding: 1.25rem 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  cursor: pointer;
  gap: 0.35rem;
  transition: all 0.2s;
}

.upload-box:hover {
  border-color: var(--accent);
  background: var(--accent-light);
}

.upload-icon {
  font-size: 1.75rem;
}

.upload-box strong {
  font-size: 0.875rem;
  color: var(--text-main);
}

.upload-box span {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.url-import-row {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.url-input {
  flex: 1;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  font-size: 0.825rem;
  font-family: inherit;
  outline: none;
}

.url-input:focus {
  border-color: var(--accent);
}

.btn-add-url {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 0.5rem 0.85rem;
  border-radius: var(--radius-sm);
  font-size: 0.825rem;
  font-weight: 600;
  cursor: pointer;
}

/* Photo Grid */
.photo-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.6rem;
}

.photo-card {
  position: relative;
  border-radius: var(--radius-md);
  overflow: hidden;
  height: 100px;
  cursor: pointer;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s;
}

.photo-card:hover {
  transform: scale(1.03);
}

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

.photo-tag {
  position: absolute;
  bottom: 4px;
  left: 4px;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  font-size: 0.65rem;
  padding: 0.1rem 0.4rem;
  border-radius: 999px;
  backdrop-filter: blur(2px);
}

/* Stickers / Clipart */
.stickers-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.6rem;
}

.sticker-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.6rem 0.35rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  min-height: 85px;
}

.sticker-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

.sticker-preview {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 50px;
  height: 50px;
}

.sticker-preview svg {
  max-width: 100%;
  max-height: 100%;
}

.sticker-name {
  font-size: 0.65rem;
  color: var(--text-muted);
  margin-top: 0.35rem;
  line-height: 1.1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

/* Text Presets */
.text-preset-buttons {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.preset-text-btn {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  text-align: left;
  cursor: pointer;
  transition: all 0.15s;
}

.preset-text-btn:hover {
  border-color: var(--accent);
  background: var(--accent-light);
}

.custom-font-form {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  padding: 0.75rem;
  border-radius: var(--radius-md);
  margin-bottom: 1rem;
}

.custom-font-form label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  display: block;
  margin-bottom: 0.35rem;
}

.font-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.font-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.6rem 0.85rem;
  cursor: pointer;
  transition: all 0.15s;
}

.font-card:hover {
  border-color: var(--accent);
  background: var(--accent-light);
}

.font-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  margin-bottom: 0.25rem;
}

.font-cat {
  color: var(--text-muted);
}

.font-sample {
  font-size: 1.1rem;
  color: var(--text-main);
  line-height: 1.2;
}

/* Paper Textures */
.paper-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
}

.paper-swatch {
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  cursor: pointer;
  background: var(--bg-surface);
  transition: all 0.2s;
}

.paper-swatch.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-light);
}

.swatch-preview {
  height: 75px;
  width: 100%;
}

.swatch-title {
  display: block;
  padding: 0.4rem 0.5rem;
  font-size: 0.75rem;
  font-weight: 600;
  text-align: center;
  color: var(--text-main);
  background: var(--bg-surface);
}

/* Frames & Matting */
.frame-style-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.frame-btn {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  padding: 0.6rem 0.85rem;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  transition: all 0.15s;
}

.frame-btn.active {
  border-color: var(--accent);
  background: var(--accent-light);
  color: var(--accent);
}

.empty-prompt {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--text-muted);
}

.empty-prompt span {
  font-size: 2.5rem;
  display: block;
  margin-bottom: 0.5rem;
}

/* Marketplace Tab */
.market-filter-chips {
  display: flex;
  gap: 0.4rem;
  margin-bottom: 0.85rem;
  flex-wrap: wrap;
}

.filter-chip {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.25rem 0.6rem;
  font-size: 0.725rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
}

.filter-chip.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.market-items-list {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.market-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.85rem;
  box-shadow: var(--shadow-sm);
}

.market-card-top {
  display: flex;
  gap: 0.65rem;
  margin-bottom: 0.5rem;
}

.market-thumb {
  width: 60px;
  height: 60px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  flex-shrink: 0;
}

.market-info h4 {
  font-size: 0.875rem;
  line-height: 1.2;
  color: var(--text-heading);
}

.market-author {
  font-size: 0.7rem;
  color: var(--text-muted);
  display: block;
}

.market-badge {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--accent-rose);
  background: #ffe4e6;
  padding: 0.1rem 0.35rem;
  border-radius: var(--radius-sm);
  margin-bottom: 0.2rem;
}

.market-rating {
  font-size: 0.7rem;
  color: #d97706;
  margin-top: 0.2rem;
}

.market-desc {
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.35;
  margin-bottom: 0.75rem;
}

.market-card-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--border);
  padding-top: 0.5rem;
}

.market-price {
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--accent);
}

.btn-buy {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
}

.btn-unlocked {
  background: #ecfdf5;
  color: #059669;
  border: 1px solid #a7f3d0;
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 600;
}

/* Pages Drawer */
.pages-list-drawer {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.page-row-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  padding: 0.6rem 0.85rem;
  border-radius: var(--radius-md);
  cursor: pointer;
}

.page-row-card.active {
  border-color: var(--accent);
  background: var(--accent-light);
}

.page-num-badge {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.8rem;
}

.page-details strong {
  font-size: 0.85rem;
  display: block;
}

.page-details span {
  font-size: 0.725rem;
  color: var(--text-muted);
}

.page-action-buttons {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.btn-craft-full {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 0.6rem;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
}

.btn-secondary-full {
  background: var(--bg-surface);
  color: var(--text-main);
  border: 1px solid var(--border);
  padding: 0.6rem;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
}

.btn-danger-full {
  background: #fee2e2;
  color: #dc2626;
  border: 1px solid #fca5a5;
  padding: 0.6rem;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
}

/* Canvas Workspace */
.canvas-workspace {
  flex: 1;
  background: var(--bg-canvas-wrapper);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

.canvas-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 1.25rem;
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--border);
  z-index: 10;
}

.page-nav-controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.icon-nav-btn {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 0.75rem;
  font-weight: bold;
}

.icon-nav-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.page-counter-text {
  font-size: 0.85rem;
  color: var(--text-main);
}

.canvas-dimensions-pill {
  font-size: 0.75rem;
  color: var(--text-muted);
  background: var(--bg-surface);
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  border: 1px solid var(--border);
}

/* The Scrapbook Paper Sheet */
.sheet-frame-wrapper {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
  padding: 2rem;
}

.scrapbook-canvas-sheet {
  position: relative;
  box-shadow: var(--shadow-canvas);
  border-radius: 4px;
  overflow: hidden;
  user-select: none;
  touch-action: none;
}

/* Canvas Elements */
.canvas-element-wrapper {
  position: absolute;
  top: 0;
  left: 0;
  cursor: grab;
  user-select: none;
}

.canvas-element-wrapper:active {
  cursor: grabbing;
}

.canvas-element-wrapper.selected {
  z-index: 999 !important;
}

/* Photo Box Styles */
.photo-element-box {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  position: relative;
}

.scrap-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.frame-polaroid {
  background: #ffffff;
  padding: 10px 10px 42px 10px;
  box-shadow: 0 4px 10px rgba(0,0,0,0.15);
  border: 1px solid #e2e8f0;
}

.frame-polaroid .scrap-img {
  height: calc(100% - 30px);
}

.polaroid-caption {
  font-family: "Caveat", cursive;
  font-size: 1.15rem;
  color: #334155;
  text-align: center;
  margin-top: 6px;
  line-height: 1;
}

.gold-foil-border {
  position: absolute;
  top: 6px;
  left: 6px;
  right: 6px;
  bottom: 6px;
  border: 2px solid #d97706;
  box-shadow: 0 0 6px rgba(245, 158, 11, 0.6);
  pointer-events: none;
}

.brass-corner {
  position: absolute;
  width: 24px;
  height: 24px;
  border: 3px solid #b45309;
  pointer-events: none;
}

.brass-corner.top-left {
  top: 0;
  left: 0;
  border-right: none;
  border-bottom: none;
}

.brass-corner.top-right {
  top: 0;
  right: 0;
  border-left: none;
  border-bottom: none;
}

.brass-corner.bottom-left {
  bottom: 0;
  left: 0;
  border-right: none;
  border-top: none;
}

.brass-corner.bottom-right {
  bottom: 0;
  right: 0;
  border-left: none;
  border-top: none;
}

/* Washi tape */
.washi-tape-box {
  width: 100%;
  height: 100%;
  opacity: 0.88;
  position: relative;
  box-shadow: 0 2px 5px rgba(0,0,0,0.12);
}

.washi-texture-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  border-top: 1px dashed rgba(0,0,0,0.15);
  border-bottom: 1px dashed rgba(0,0,0,0.15);
}

/* Text Element Box */
.text-element-box {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  word-break: break-word;
  white-space: pre-wrap;
  padding: 0.25rem;
}

/* Selection overlay */
.element-selection-overlay {
  position: absolute;
  top: -6px;
  left: -6px;
  right: -6px;
  bottom: -6px;
  border: 2px dashed var(--accent);
  border-radius: 4px;
  pointer-events: none;
}

.rotate-handle {
  position: absolute;
  top: -26px;
  left: 50%;
  transform: translateX(-50%);
  width: 22px;
  height: 22px;
  background: var(--bg-surface);
  border: 1px solid var(--accent);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  box-shadow: var(--shadow-sm);
  pointer-events: auto;
  cursor: grab;
}

/* Bottom pages strip */
.bottom-pages-strip {
  height: 80px;
  background: var(--bg-surface);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0.5rem 1.25rem;
  gap: 0.75rem;
  overflow-x: auto;
  z-index: 10;
}

.page-thumbnail-card {
  height: 60px;
  min-width: 90px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-sidebar);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 0.35rem 0.5rem;
  cursor: pointer;
  transition: all 0.15s;
}

.page-thumbnail-card.active {
  border-color: var(--accent);
  background: var(--accent-light);
}

.thumb-num {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-heading);
  display: block;
}

.thumb-count {
  font-size: 0.65rem;
  color: var(--text-muted);
}

.thumb-title {
  font-size: 0.65rem;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.add-page-thumb-btn {
  height: 60px;
  min-width: 90px;
  border: 2px dashed var(--border-dark);
  background: transparent;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
}

.add-page-thumb-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* Right Inspector Panel */
.inspector-panel {
  width: 290px;
  background: var(--bg-surface);
  border-left: 1px solid var(--border);
  overflow-y: auto;
  padding: 1.25rem 1rem;
  flex-shrink: 0;
  z-index: 15;
}

.inspector-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

.inspector-header h3 {
  font-family: var(--font-serif);
  font-size: 1.1rem;
  color: var(--text-heading);
}

.close-inspector-btn {
  background: transparent;
  border: none;
  font-size: 1rem;
  color: var(--text-muted);
  cursor: pointer;
}

.inspector-section {
  margin-bottom: 1.25rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.inspector-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 0.6rem;
}

.inspector-btn-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.4rem;
  margin-bottom: 0.75rem;
}

.tool-btn {
  background: var(--bg-sidebar);
  border: 1px solid var(--border);
  padding: 0.4rem 0.5rem;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
}

.tool-btn:hover {
  background: #eadecd;
}

.slider-control {
  margin-bottom: 0.75rem;
}

.slider-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--text-main);
  margin-bottom: 0.25rem;
}

.slider-control input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.filter-chips-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.4rem;
  margin-bottom: 0.75rem;
}

.filter-chip-btn {
  background: var(--bg-sidebar);
  border: 1px solid var(--border);
  padding: 0.35rem 0.5rem;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  cursor: pointer;
}

.filter-chip-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.inspector-textarea {
  width: 100%;
  min-height: 70px;
  padding: 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.85rem;
  margin-bottom: 0.75rem;
  resize: vertical;
}

.color-picker-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.6rem;
  font-size: 0.8rem;
}

.color-picker-row input[type="color"] {
  width: 32px;
  height: 28px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.btn-clear-color {
  background: transparent;
  border: 1px solid var(--border);
  padding: 0.15rem 0.4rem;
  border-radius: var(--radius-sm);
  font-size: 0.7rem;
  cursor: pointer;
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.8rem;
}

.btn-delete-element {
  width: 100%;
  background: #fee2e2;
  color: #dc2626;
  border: 1px solid #fca5a5;
  padding: 0.5rem;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}

/* Book Spread / Flipbook Mode */
.flipbook-view-container {
  padding: 2rem 1.5rem;
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.flipbook-header {
  text-align: center;
  margin-bottom: 1.5rem;
}

.flipbook-header h2 {
  font-family: var(--font-serif);
  font-size: 1.75rem;
  color: var(--text-heading);
}

.book-spread-wrapper {
  display: flex;
  background: #451a03;
  padding: 1.25rem;
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 50px rgba(0,0,0,0.35);
  position: relative;
  gap: 4px;
}

.book-spread-spine {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 8px;
  transform: translateX(-50%);
  background: linear-gradient(90deg, rgba(0,0,0,0.4), rgba(255,255,255,0.1), rgba(0,0,0,0.4));
  z-index: 30;
}

.spread-page {
  position: relative;
  background: #faf5ea;
  box-shadow: inset 0 0 15px rgba(0,0,0,0.06);
  overflow: hidden;
}

.left-page {
  border-radius: 6px 0 0 6px;
}

.right-page {
  border-radius: 0 6px 6px 0;
}

.spread-page-number {
  position: absolute;
  bottom: 8px;
  left: 14px;
  font-size: 0.7rem;
  color: rgba(0,0,0,0.4);
  font-weight: 600;
  z-index: 10;
}

.right-page .spread-page-number {
  left: auto;
  right: 14px;
}

.empty-spread {
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f5ede0;
}

.empty-spread-inner {
  text-align: center;
  color: var(--text-muted);
}

.empty-spread-inner span {
  font-size: 2.5rem;
}

.spread-navigation {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  margin-top: 1.5rem;
  font-weight: 600;
  font-size: 0.9rem;
}

/* Print Mode */
.print-view-container {
  padding: 2rem;
  max-width: 1000px;
  margin: 0 auto;
}

.print-controls-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2rem;
  background: var(--bg-surface);
  padding: 1.25rem;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  flex-wrap: wrap;
  gap: 1rem;
}

.printable-album-flow {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2.5rem;
}

.printable-sheet {
  position: relative;
  box-shadow: var(--shadow-canvas);
  border: 1px solid var(--border);
  page-break-after: always;
}

.print-page-badge {
  position: absolute;
  top: 10px;
  left: 14px;
  font-size: 0.75rem;
  color: rgba(0,0,0,0.4);
  font-weight: 700;
  z-index: 20;
}

/* Print CSS */
@media print {
  .no-print,
  .app-header,
  .tool-tabs-bar,
  .tool-drawer,
  .inspector-panel,
  .bottom-pages-strip,
  .canvas-topbar {
    display: none !important;
  }

  body {
    background: #ffffff !important;
  }

  .print-view-container {
    padding: 0 !important;
  }

  .printable-sheet {
    box-shadow: none !important;
    border: none !important;
    page-break-after: always !important;
    margin: 0 auto !important;
  }
}

/* Responsive & Mobile First */
@media (max-width: 900px) {
  .tool-drawer {
    position: absolute;
    left: 76px;
    top: 0;
    bottom: 0;
    box-shadow: var(--shadow-lg);
  }

  .inspector-panel {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    box-shadow: var(--shadow-lg);
  }

  .book-spread-wrapper {
    flex-direction: column;
  }

  .book-spread-spine {
    display: none;
  }
}

/* Template Picker & Cards Styles */
.tab-highlight-template {
  position: relative;
  background: linear-gradient(135deg, rgba(238, 209, 138, 0.25) 0%, rgba(198, 122, 107, 0.15) 100%);
  border-bottom: 2px solid var(--accent);
}

.template-pill {
  background: var(--accent);
  color: #3b200b;
  font-weight: 700;
}

.template-cards-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: 14px;
}

.template-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
}

.template-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--accent);
}

.template-card-cover {
  position: relative;
  width: 100%;
  height: 140px;
  background: #f0e6dc;
  overflow: hidden;
  cursor: pointer;
}

.template-card-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.template-card:hover .template-card-cover img {
  transform: scale(1.05);
}

.template-badge-pill {
  position: absolute;
  top: 8px;
  left: 8px;
  background: var(--primary);
  color: white;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.template-pages-count-tag {
  position: absolute;
  bottom: 8px;
  right: 8px;
  background: rgba(43, 30, 22, 0.82);
  backdrop-filter: blur(4px);
  color: white;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 6px;
}

.template-card-hover-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s ease;
  color: white;
  font-size: 12px;
  font-weight: 600;
  text-align: center;
  padding: 8px;
}

.template-card-cover:hover .template-card-hover-overlay {
  opacity: 1;
}

.template-card-body {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.template-card-title {
  font-family: "Playfair Display", serif;
  font-size: 15px;
  font-weight: 700;
  color: var(--text-main);
  margin: 0;
}

.template-card-desc {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.4;
  margin: 0;
}

.template-tags-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.template-tag-chip {
  font-size: 10px;
  background: #f4ede4;
  color: #785a44;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 500;
}

.template-card-actions {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 6px;
  margin-top: 4px;
}

/* Template Preview Modal */
.template-preview-modal {
  max-width: 820px;
  width: 95%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.template-modal-title-area {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.template-modal-title-area h2 {
  font-family: "Playfair Display", serif;
  font-size: 22px;
  margin: 4px 0 0 0;
  color: var(--text-main);
}

.template-modal-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin: 0;
}

.template-modal-body {
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: #f8f4ee;
}

.template-pages-selector-bar {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.template-pages-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.template-page-tabs-scroll {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.template-page-tab-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 6px 12px;
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
}

.template-page-tab-btn:hover {
  border-color: var(--primary);
}

.template-page-tab-btn.active {
  background: #fff8f5;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(198, 122, 107, 0.2);
}

.tab-page-num {
  font-size: 10px;
  font-weight: 700;
  color: var(--primary);
  text-transform: uppercase;
}

.tab-page-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-main);
}

.template-live-preview-viewport {
  width: 100%;
  height: 460px;
  background: #e5ddd3;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  display: flex;
  justify-content: center;
  align-items: flex-start;
  overflow: hidden;
  padding-top: 12px;
  box-shadow: inset 0 2px 6px rgba(0,0,0,0.08);
}

.template-preview-canvas {
  position: relative;
  box-shadow: var(--shadow-lg);
  border-radius: 4px;
}

.template-features-bar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
}

.feature-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-main);
  background: white;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}

.feature-icon {
  font-size: 16px;
}

.template-modal-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  background: white;
  border-top: 1px solid var(--border);
  padding: 12px 20px;
}

.footer-left-info {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
}

.footer-buttons-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}
