:root {
  --background: #ffffff;
  --card: #fafafa;
  --text: #1d1d1f;
  --subtext: #86868b;
  --line: #e8e8e8;
  --pearl: #efefed;
  --silver: #d4d7da;
  --mist: #e4e8ea;
  --stone: #d9d5d0;
  --smoke: #bcc1c5;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
  padding: 6px;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  overflow: hidden;
  background: var(--background);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", Pretendard, sans-serif;
}

button, input, select { font: inherit; }
button { color: inherit; }

.widget {
  position: relative;
  width: min(100%, 430px);
  height: 260px;
  padding: 16px 18px 12px;
  overflow: hidden;
  background: rgba(250, 250, 250, .94);
  border: 1px solid rgba(0, 0, 0, .018);
  border-radius: 16px;
  box-shadow: 0 12px 28px rgba(0, 0, 0, .055);
}

.header,
.brand,
.editor-head,
.add-row {
  display: flex;
  align-items: center;
}

.header { justify-content: space-between; }
.brand { gap: 11px; }
.brand strong { font-size: 16px; font-weight: 650; }
.brand span { color: var(--subtext); font-size: 12px; }

.quiet-button,
.card-close,
.add-row button,
.editor-row button {
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.quiet-button { color: var(--subtext); font-size: 12px; }
.quiet-button:hover { color: var(--text); }

.shelf-scene {
  position: absolute;
  inset: 50px 14px 10px;
  display: flex;
  align-items: flex-end;
  padding: 0 12px 17px;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
}

.shelf-scene::-webkit-scrollbar { display: none; }

.books {
  height: 163px;
  min-width: max-content;
  display: flex;
  align-items: flex-end;
  gap: 2px;
  z-index: 2;
}

.book {
  --book-color: var(--pearl);
  --book-height: 116px;
  position: relative;
  width: 44px;
  height: var(--book-height);
  flex: 0 0 44px;
  padding: 9px 6px 8px;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
  border: 0;
  border-radius: 4px 5px 2px 2px;
  background:
    linear-gradient(90deg, rgba(255,255,255,.52), transparent 15%, transparent 83%, rgba(0,0,0,.075)),
    var(--book-color);
  box-shadow: inset 0 1px rgba(255,255,255,.72), 1px 2px 2px rgba(0,0,0,.075);
  cursor: pointer;
  transform-origin: center bottom;
  transition: transform .34s cubic-bezier(.2,.85,.3,1.15), box-shadow .3s ease, filter .3s ease;
}

.book::before {
  content: "";
  position: absolute;
  top: 4px;
  bottom: 4px;
  left: 4px;
  width: 1px;
  background: rgba(255,255,255,.58);
}

.book:hover,
.book:focus-visible {
  z-index: 8;
  outline: 0;
  transform: translateY(-20px) rotate(-1.3deg) scale(1.025);
  filter: brightness(1.035);
  box-shadow: 0 14px 13px rgba(0,0,0,.13), inset 0 1px rgba(255,255,255,.5);
}

.book.selected {
  z-index: 9;
  transform: translateY(-25px) rotate(-1.8deg) scale(1.035);
  box-shadow: 0 17px 15px rgba(0,0,0,.15), inset 0 1px rgba(255,255,255,.5);
}

.book-pages {
  position: absolute;
  top: 4px;
  right: 2px;
  bottom: 4px;
  width: 3px;
  border-radius: 1px;
  background: repeating-linear-gradient(90deg, rgba(255,255,255,.52) 0 1px, rgba(255,255,255,.12) 1px 2px);
  opacity: .55;
}

.spine-title {
  max-height: calc(var(--book-height) - 20px);
  overflow: hidden;
  color: rgba(70, 72, 75, .82);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.08;
  letter-spacing: .1px;
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  text-overflow: ellipsis;
  white-space: nowrap;
  text-shadow: 0 1px rgba(255,255,255,.45);
}

.book[data-color="pearl"] { --book-color: var(--pearl); }
.book[data-color="silver"] { --book-color: var(--silver); }
.book[data-color="mist"] { --book-color: var(--mist); }
.book[data-color="stone"] { --book-color: var(--stone); }
.book[data-color="smoke"] { --book-color: var(--smoke); }
.book[data-color="smoke"] .spine-title { color: rgba(53, 56, 59, .84); }

.shelf {
  position: absolute;
  left: 3px;
  right: 3px;
  bottom: 10px;
  height: 11px;
  z-index: 6;
  border-radius: 2px 2px 4px 4px;
  background: linear-gradient(#c8c9cb, #a5a7aa);
  box-shadow: 0 5px 7px rgba(0,0,0,.12), inset 0 1px rgba(255,255,255,.62);
}

.plant {
  position: relative;
  width: 47px;
  height: 80px;
  flex: 0 0 47px;
  margin-right: 8px;
  z-index: 3;
}

.pot {
  position: absolute;
  left: 8px;
  bottom: 0;
  width: 32px;
  height: 35px;
  border-radius: 3px 3px 9px 9px;
  background: linear-gradient(90deg, #c4c5c7, #e3e3e2 45%, #b1b3b6);
  box-shadow: inset 0 2px rgba(255,255,255,.55), 0 2px 3px rgba(0,0,0,.06);
}

.plant::after {
  content: "";
  position: absolute;
  left: 22px;
  bottom: 30px;
  width: 2px;
  height: 38px;
  background: #a3a6a7;
  transform: rotate(-5deg);
}

.leaf {
  position: absolute;
  width: 15px;
  height: 22px;
  z-index: 2;
  border-radius: 70% 35% 70% 35%;
  background: linear-gradient(135deg, #f5f5f3, #cfd1d2);
  box-shadow: inset -2px -2px 3px rgba(0,0,0,.05);
  transform-origin: bottom center;
}

.leaf-one { left: 11px; top: 10px; transform: rotate(-28deg); }
.leaf-two { left: 24px; top: 3px; transform: rotate(12deg); }
.leaf-three { left: 31px; top: 17px; transform: rotate(44deg) scale(.88); }

.plainy {
  position: relative;
  width: 72px;
  height: 72px;
  flex: 0 0 72px;
  margin: 0 0 -3px 8px;
  z-index: 3;
  display: flex;
  align-items: flex-end;
  pointer-events: none;
}

.plainy img {
  display: block;
  width: 72px;
  height: 72px;
  object-fit: contain;
  filter: drop-shadow(0 5px 5px rgba(0,0,0,.09));
}

.book-card {
  position: absolute;
  top: 42px;
  right: 13px;
  width: 174px;
  min-height: 124px;
  z-index: 20;
  padding: 14px 15px 12px;
  border: 1px solid rgba(0,0,0,.06);
  border-radius: 12px;
  background: rgba(255,255,255,.94);
  box-shadow: 0 13px 28px rgba(0,0,0,.13);
  backdrop-filter: blur(14px);
  animation: cardIn .28s ease;
}

.card-label { display: block; color: var(--subtext); font-size: 10px; text-transform: uppercase; letter-spacing: .9px; }
.book-card strong { display: block; margin-top: 7px; font-size: 15px; line-height: 1.2; }
.book-card > span:not(.card-label) { display: block; margin-top: 4px; color: var(--subtext); font-size: 11px; }
.card-close { position: absolute; top: 6px; right: 9px; color: var(--subtext); font-size: 17px; }
.progress-track { height: 3px; margin-top: 11px; overflow: hidden; border-radius: 3px; background: #ececef; }
.progress-track i { display: block; width: 0; height: 100%; border-radius: inherit; background: #646468; transition: width .5s ease; }
.book-card small { display: block; margin-top: 6px; color: var(--subtext); font-size: 10px; }

.editor {
  position: absolute;
  inset: 37px 9px 9px;
  z-index: 40;
  padding: 11px;
  border: 1px solid rgba(0,0,0,.05);
  border-radius: 13px;
  background: rgba(255,255,255,.97);
  box-shadow: 0 12px 28px rgba(0,0,0,.1);
  backdrop-filter: blur(18px);
}

.editor-head { justify-content: space-between; margin-bottom: 7px; }
.editor-head strong { font-size: 13px; }
.editor-head span { color: var(--subtext); font-size: 10px; }
.editor-list { height: 111px; overflow-y: auto; scrollbar-width: thin; }
.editor-row { display: grid; grid-template-columns: minmax(80px, 1.5fr) minmax(60px, 1fr) 55px 17px 17px 17px; gap: 4px; align-items: center; padding: 3px 0; border-bottom: 1px solid var(--line); }
.editor-row input,
.editor-row select,
.add-row input {
  min-width: 0;
  height: 22px;
  padding: 3px 5px;
  border: 1px solid var(--line);
  border-radius: 5px;
  outline: none;
  background: #fff;
  color: var(--text);
  font-size: 11px;
}
.editor-row input:focus,
.editor-row select:focus,
.add-row input:focus { border-color: #aaaab0; }
.editor-row button { color: var(--subtext); font-size: 13px; }
.editor-row button:disabled { opacity: .2; }
.delete-book { font-size: 15px !important; }
.add-row { gap: 6px; margin-top: 7px; }
.add-row input { flex: 1; }
.add-row button { color: var(--text); font-size: 11px; }
.add-row button:disabled { color: var(--subtext); opacity: .4; }

@keyframes cardIn {
  from { opacity: 0; transform: translateY(5px) scale(.97); }
  to { opacity: 1; transform: none; }
}

@media (max-width: 340px) {
  .brand span, .plainy { display: none; }
  .book { width: 40px; flex-basis: 40px; }
  .editor-row { grid-template-columns: minmax(80px, 1fr) 48px 16px 16px 16px; }
  .edit-author { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* v4 — long shelf, progress manager and Eternal Shelf */

.header {
  position: relative;
  z-index: 50;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 12px;
}

.quiet-button { justify-self: end; }

.shelf-tabs {
  display: flex;
  align-items: center;
  gap: 12px;
}

.shelf-tab {
  padding: 2px 0 5px;
  border: 0;
  border-bottom: 1px solid transparent;
  background: transparent;
  color: #b2b2b6;
  font-size: 11px;
  cursor: pointer;
}

.shelf-tab.active {
  border-color: var(--text);
  color: var(--text);
  font-weight: 600;
}

.shelf-scene {
  display: block;
  padding: 0;
}

.shelf-track {
  position: relative;
  width: max-content;
  min-width: 100%;
  height: 100%;
  padding: 0 12px 17px;
  display: flex;
  align-items: flex-end;
}

.shelf-track .shelf {
  left: 0;
  right: 0;
}

.book-editor-card {
  padding: 6px 0 7px;
  border-bottom: 1px solid var(--line);
}

.book-editor-main {
  display: grid;
  grid-template-columns: minmax(86px, 1.35fr) minmax(66px, 1fr) 57px 18px;
  gap: 5px;
  align-items: center;
}

.book-editor-main input,
.book-editor-main select {
  min-width: 0;
  height: 23px;
  padding: 3px 5px;
  border: 1px solid var(--line);
  border-radius: 5px;
  outline: none;
  background: #fff;
  color: var(--text);
  font-size: 10px;
}

.progress-editor {
  margin-top: 5px;
  display: grid;
  grid-template-columns: 45px minmax(80px, 1fr) 35px 20px 20px;
  gap: 5px;
  align-items: center;
  color: var(--subtext);
  font-size: 9px;
}

.edit-progress {
  width: 100%;
  height: 3px;
  accent-color: #55575a;
  cursor: pointer;
}

.progress-output {
  color: var(--text);
  font-size: 10px;
  text-align: right;
}

.book-editor-card button {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--subtext);
  font-size: 13px;
  cursor: pointer;
}

.book-editor-card button:disabled { opacity: .2; cursor: default; }
.editor-list { height: 139px; }

.eternal-view {
  position: absolute;
  inset: 54px 18px 14px;
  overflow: hidden;
}

.eternal-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding-bottom: 9px;
  border-bottom: 1px solid var(--line);
}

.eternal-head strong { font-size: 13px; }
.eternal-head span { color: var(--subtext); font-size: 9px; }

.eternal-list {
  height: 166px;
  overflow-y: auto;
  scrollbar-width: none;
}

.eternal-list::-webkit-scrollbar { display: none; }

.eternal-item {
  min-height: 52px;
  padding: 8px 2px;
  display: grid;
  grid-template-columns: 20px 1fr 24px;
  gap: 7px;
  align-items: start;
  border-bottom: 1px solid var(--line);
}

.eternal-dot { color: var(--text); font-size: 13px; }
.eternal-item strong { display: block; font-size: 12px; }
.eternal-meta { display: block; margin-top: 2px; color: var(--subtext); font-size: 9px; }
.eternal-item p { margin: 4px 0 0; color: #6f6f74; font-size: 10px; line-height: 1.3; }
.return-book { padding: 2px; border: 0; background: transparent; color: var(--subtext); font-size: 13px; cursor: pointer; }
.eternal-empty { height: 100%; display: grid; place-items: center; color: var(--subtext); font-size: 11px; }

.modal-backdrop {
  position: absolute;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(246,246,246,.62);
  backdrop-filter: blur(8px);
}

.completion-modal {
  width: min(100%, 310px);
  padding: 20px;
  border: 1px solid rgba(0,0,0,.055);
  border-radius: 16px;
  background: rgba(255,255,255,.97);
  box-shadow: 0 18px 40px rgba(0,0,0,.13);
  text-align: center;
  animation: modalIn .3s cubic-bezier(.2,.8,.3,1.1);
}

.modal-mark { color: var(--subtext); font-size: 12px; letter-spacing: 2px; }
.completion-modal h2 { margin: 10px 0 0; font-size: 16px; font-weight: 650; }
.completion-modal p { margin: 8px auto 0; max-width: 245px; color: var(--subtext); font-size: 11px; line-height: 1.45; }
.completion-modal textarea {
  width: 100%;
  height: 60px;
  margin-top: 12px;
  padding: 9px;
  resize: none;
  border: 1px solid var(--line);
  border-radius: 9px;
  outline: none;
  color: var(--text);
  font-size: 10px;
  line-height: 1.4;
}
.completion-modal textarea:focus { border-color: #a9aaad; }
.modal-actions { margin-top: 14px; display: flex; justify-content: center; gap: 7px; }
.modal-actions button { min-width: 88px; padding: 7px 11px; border-radius: 8px; font-size: 10px; cursor: pointer; }
.secondary-action { border: 1px solid var(--line); background: #fff; color: var(--subtext); }
.primary-action { border: 1px solid var(--text); background: var(--text); color: #fff; }

@keyframes modalIn {
  from { opacity: 0; transform: translateY(6px) scale(.97); }
  to { opacity: 1; transform: none; }
}

@media (max-width: 360px) {
  .header { grid-template-columns: auto 1fr auto; }
  .shelf-tabs { justify-self: center; gap: 8px; }
  .book-editor-main { grid-template-columns: minmax(90px,1fr) 55px 18px; }
  .book-editor-main .edit-author { display: none; }
}
