:root {
  --teal-d: #007979;
  --teal: #24b1b1;
  --cream: #fff0e4;
  --peach: #ffe0c5;

  --ink: #143a3a;
  --muted: #6f8a8a;
  --line: #f0d9c4;
  --card: #fffaf4;
  --shadow: 0 6px 20px rgba(0, 121, 121, 0.08);

  --sans: "EB Garamond", Georgia, "Times New Roman", serif;
  --serif: "EB Garamond", Georgia, serif;
}

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

body {
  margin: 0;
  font-family: var(--sans);
  background: var(--cream);
  color: var(--ink);
  font-size: 17px;
  line-height: 1.55;
}

/* header */
.topbar {
  background: var(--teal-d);
  padding: 14px 22px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.userbox { display: flex; align-items: center; gap: 12px; }
.uname { color: var(--cream); font-size: 14px; opacity: 0.9; }
.logout {
  background: rgba(255, 255, 255, 0.16); color: #fff;
  padding: 6px 13px; font-size: 13px; border-radius: 8px;
}
.logout:hover { background: rgba(255, 255, 255, 0.3); }
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 46px; }
.pw-toggle {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  background: transparent; border: none; padding: 4px 8px;
  font-size: 16px; cursor: pointer;
}
.pw-toggle:hover { background: transparent; }

.auth { max-width: 380px; margin: 36px auto 0; text-align: center; }
.auth .form { text-align: left; }
.auth .tagline { font-style: italic; margin-top: -8px; }
.auth-sub { margin: 6px 0 0; font-size: 16px; color: var(--muted); }
.brand {
  text-decoration: none;
  color: var(--cream);
  font-family: var(--serif);
  font-size: 21px;
  font-weight: 700;
  letter-spacing: 0.2px;
  display: inline-flex;
  align-items: center;
  gap: 9px;
}
.brand-logo { width: 26px; height: 26px; display: block; }
.brand-logo.lg { width: 36px; height: 36px; }
.auth h1 { display: flex; align-items: center; justify-content: center; gap: 10px; }

main { max-width: 720px; margin: 0 auto; padding: 28px 18px 40px; }
.footer {
  text-align: center; color: var(--muted); font-size: 13px;
  padding: 16px 18px 40px;
}

@media (max-width: 520px) {
  main { padding: 20px 14px 36px; }
  h1 { font-size: 24px; }
  .topbar { padding: 12px 16px; }
  .brand { font-size: 19px; }
  .brand-logo { width: 24px; height: 24px; }
  .uname { display: none; }
  .card { padding: 16px; }
  .cover-lg { width: 78px; height: 106px; }
  .quote-card blockquote { font-size: 19px; }
  .hl-controls { gap: 12px; }
}

h1 { margin: 0; font-family: var(--serif); font-size: 28px; letter-spacing: 0.2px; }
h2 { margin: 0 0 6px; font-size: 17px; }
.stack { display: flex; flex-direction: column; gap: 18px; }
.muted { color: var(--muted); margin: 0; }
.back { text-decoration: none; font-size: 14px; width: fit-content; }
.back:hover { color: var(--teal-d); }

/* forms & inputs */
input, select, button, textarea { font: inherit; }
input, select, textarea {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(36, 177, 177, 0.18);
}

button {
  background: var(--teal-d);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 11px 18px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.05s;
}
button:hover { background: var(--teal); }
button:active { transform: translateY(1px); }
button:disabled { opacity: 0.55; cursor: default; }
button.ghost {
  background: transparent;
  color: var(--teal-d);
  border: 1px solid var(--teal-d);
}
button.ghost:hover { background: rgba(36, 177, 177, 0.1); }
.add-btn { align-self: flex-start; }
.shelf-share { align-self: flex-start; }

/* cards */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 20px;
  box-shadow: var(--shadow);
}
.form { display: flex; flex-direction: column; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--muted); font-weight: 500; }

/* book list */
.book-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; }
.book-list a {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 16px; background: var(--card); border: 1px solid var(--line);
  border-left: 4px solid var(--peach);
  border-radius: 12px; text-decoration: none; color: var(--ink);
  box-shadow: var(--shadow);
  transition: border-left-color 0.15s, transform 0.1s;
}
.book-list a:hover { border-left-color: var(--teal); transform: translateX(2px); }
.book-list strong { font-family: var(--serif); font-size: 18px; }
.book-list span { color: var(--muted); font-size: 14px; }
.del-book-link {
  align-self: center; margin-top: 32px; padding: 6px 10px;
  background: transparent; color: var(--muted); border: none;
  font-size: 14px; text-decoration: underline; cursor: pointer;
}
.del-book-link:hover { color: #c0552f; background: transparent; }
.book-meta { display: flex; flex-direction: column; gap: 2px; }
.cover-sm {
  width: 46px; height: 62px; flex: none; object-fit: cover; border-radius: 6px;
  border: 1px solid var(--line);
}
.cover-sm.placeholder {
  display: flex; align-items: center; justify-content: center;
  background: var(--peach); font-size: 22px;
}
.book-head { display: flex; align-items: center; gap: 18px; }
.cover-lg {
  width: 96px; height: 132px; flex: none; object-fit: cover;
  border-radius: 10px; border: 1px solid var(--line); box-shadow: var(--shadow);
}

/* capture (highlighter) */
.cam-wrap { display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
#cam { width: 100%; max-height: 320px; border-radius: 10px; background: #000; }
#cover-cam { width: 100%; max-height: 280px; border-radius: 10px; background: #000; }
.cover-preview {
  width: 96px; height: 132px; object-fit: cover;
  border-radius: 8px; border: 1px solid var(--line); margin-top: 4px;
}

.capture { display: flex; flex-direction: column; gap: 12px; }
.canvas-wrap { width: 100%; }
.hl-overlay {
  position: fixed; inset: 0; z-index: 1000;
  background: #16302f; display: flex; flex-direction: column;
}
.hl-bar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 10px 12px; background: var(--teal-d);
}
.hl-bar .brush { display: flex; align-items: center; gap: 6px; color: #fff; font-size: 15px; }
.hl-bar .brush input { width: 120px; }
.hl-bar input[type="range"] { accent-color: #fff; }
.hl-bar .seg.active { background: var(--teal); }
.hl-bar .ghost { color: #fff; border-color: rgba(255, 255, 255, 0.45); }
.hl-bar .ghost:hover { background: rgba(255, 255, 255, 0.15); }
.hl-canvas-area {
  flex: 1; min-height: 0; overflow: hidden; padding: 8px;
  display: flex; align-items: center; justify-content: center;
}
#hl-canvas {
  max-width: 100%; max-height: 100%;
  background: #fff; border-radius: 6px;
  cursor: crosshair; touch-action: none;
}
.hl-foot {
  display: flex; gap: 10px; align-items: center;
  padding: 10px 12px; background: var(--card); border-top: 1px solid var(--line);
}
.hl-foot input { flex: 1; }
.hl-controls { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.mode-toggle { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg { background: #fff; color: var(--teal-d); border: none; border-radius: 0; padding: 8px 13px; font-size: 13px; font-weight: 600; }
.seg:hover { background: rgba(36, 177, 177, 0.12); }
.seg.active { background: var(--teal-d); color: #fff; }
.seg + .seg { border-left: 1px solid var(--line); }
.hl-controls .brush { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.hl-controls .brush input { width: 130px; padding: 0; }
input[type="range"] { accent-color: var(--teal-d); }

/* gallery */
.gallery { display: flex; flex-direction: column; gap: 16px; margin-top: 6px; }

.quote-card {
  border-left: 4px solid var(--teal-d);
  background: linear-gradient(180deg, #fffaf4, var(--card));
}
.quote-card { position: relative; }
.quote-card .del {
  position: absolute; top: 10px; right: 10px;
  width: 28px; height: 28px; padding: 0; line-height: 1;
  background: transparent; color: var(--muted);
  border: 1px solid var(--line); border-radius: 50%;
  font-size: 14px; opacity: 0; transition: opacity 0.15s, color 0.15s, border-color 0.15s;
}
.quote-card:hover .del { opacity: 1; }
.quote-card .del:hover { color: #c0552f; border-color: #c0552f; background: #fff; }
@media (hover: none) { .quote-card .del { opacity: 1; } }

.quote-card blockquote {
  margin: 0 0 12px;
  font-family: var(--serif);
  font-size: 21px;
  line-height: 1.55;
  color: var(--ink);
}
.quote-card figcaption { color: var(--muted); font-size: 14px; }
.quote-card cite { font-style: italic; color: var(--teal-d); font-weight: 600; }
.card-actions { display: flex; gap: 8px; margin-top: 16px; }
.ghost.sm { padding: 6px 13px; font-size: 14px; }

/* states */
.card.pending { display: flex; align-items: center; gap: 14px; }
.card.pending figcaption { color: var(--muted); }

.card.review .thumb {
  display: block; width: 100%; max-height: 240px; object-fit: contain;
  background: #fff; border: 1px solid var(--line); border-radius: 10px; margin-bottom: 14px;
}
.card.review textarea { font-family: var(--serif); font-size: 18px; resize: vertical; }
.card.review .hint { color: #c0552f; font-size: 13px; margin: -4px 0 0; }
.actions { display: flex; gap: 10px; align-items: center; }

.spinner {
  width: 20px; height: 20px; border-radius: 50%;
  border: 3px solid var(--peach); border-top-color: var(--teal-d);
  animation: spin 0.8s linear infinite; flex: none;
}
@keyframes spin { to { transform: rotate(360deg); } }
