/* Dogear — Reading-Circle Placemat theme */

:root {
  --paper: #f3e9d7;
  --paper-deep: #efe2cc;
  --card: #fbf5e7;
  --card-line: #e3d5b8;
  --stitch: #c9b892;
  --ink: #2f2a22;
  --ink-soft: #6b6252;
  --ink-faint: #a3937a;
  --rust: #b85c38;
  --teal: #3f7c73;
  --graphite: #57534a;
  --accent: #d9a441;
  --cream: #f8efdd;
  --fold: #e6d9bf;
  --danger: #a33b1e;
  --serif: Georgia, "Times New Roman", serif;
  --sans: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
}

button {
  font-family: inherit;
  cursor: pointer;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- layout shell ---------- */

.view {
  max-width: 560px;
  margin: 0 auto;
  padding: 0 16px calc(92px + env(safe-area-inset-bottom));
}

.noscript {
  padding: 24px 16px calc(120px + env(safe-area-inset-bottom));
  color: var(--danger);
}

/* ---------- bottom tab bar: folded page corners ---------- */

.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  display: flex;
  background: var(--paper-deep);
  border-top: 1px solid var(--card-line);
  padding: 4px 6px calc(4px + env(safe-area-inset-bottom));
}

.tab {
  position: relative;
  flex: 1;
  border: 0;
  background: transparent;
  color: var(--ink-soft);
  font-size: 15px;
  font-weight: 600;
  padding: 14px 0 18px;
  border-radius: 10px 10px 0 0;
}

/* flat folded page corner on every tab */
.tab::after {
  content: "";
  position: absolute;
  right: 6px;
  bottom: 8px;
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 0 0 11px 11px;
  border-color: transparent transparent var(--fold) transparent;
}

.tab.active {
  color: var(--rust);
  background: #fff9ec;
  transform: translateY(-3px);
  box-shadow: 0 -5px 10px rgba(47, 42, 34, 0.1);
}

/* active corner folds upward, in the accent gold */
.tab.active::after {
  border-width: 0 0 15px 15px;
  border-color: transparent transparent var(--accent) transparent;
}

/* ---------- shared bits ---------- */

.kicker {
  margin: 0;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  opacity: 0.85;
}

h1 {
  font-family: var(--serif);
  font-weight: 700;
  margin: 2px 0 0;
}

.page-head {
  padding: 20px 0 6px;
}

.page-head h1 {
  font-size: 26px;
}

.page-sub {
  margin: 2px 0 0;
  font-size: 13px;
  color: var(--ink-soft);
}

.section-title {
  font-family: var(--serif);
  font-size: 17px;
  margin: 0 0 10px;
}

.group-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--serif);
  font-size: 15px;
  margin: 18px 0 8px;
}

.dot {
  display: inline-block;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  border: 2px solid var(--stage-c, var(--ink-faint));
  background: transparent;
  flex: none;
}

.dot.filled { background: var(--stage-c, var(--ink-faint)); }

.stage-suggested .dot, .dot-suggested { --stage-c: var(--rust); }
.stage-reading .dot, .dot-reading     { --stage-c: var(--teal); }
.stage-finished .dot, .dot-finished   { --stage-c: var(--graphite); }

.stage-suggested .group-band, .dot-suggested { color: var(--rust); }

/* ---------- Circle tab ---------- */

.table-edge {
  background: var(--rust);
  color: var(--cream);
  margin: 0 -16px 18px;
  padding: 24px 20px 32px;
  border-radius: 0 0 50% 50% / 0 0 30px 30px;
}

.table-edge h1 {
  font-size: 30px;
}

.counters {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
}

.stitch {
  flex: 1;
  background: var(--card);
  border: 2px dashed var(--stitch);
  border-radius: 14px;
  padding: 10px 8px;
  text-align: center;
}

.stitch-n {
  display: block;
  font-family: var(--serif);
  font-size: 26px;
  line-height: 1.1;
  color: var(--rust);
}

.stitch-l {
  display: block;
  font-size: 12px;
  color: var(--ink-soft);
  margin-top: 2px;
}

.add-strip {
  display: block;
  width: 100%;
  background: var(--rust);
  color: var(--cream);
  border: 0;
  border-radius: 14px;
  padding: 16px;
  font-size: 18px;
  font-weight: 600;
  margin: 0 0 22px;
}

.add-strip:active { background: #a04f2f; }

.next-up { display: block; }

/* large book-cover card */
.cover {
  display: block;
  width: 100%;
  text-align: left;
  background: var(--teal);
  color: var(--cream);
  border: 0;
  border-radius: 6px 20px 20px 6px;
  padding: 18px 16px 20px 24px;
  position: relative;
  min-height: 148px;
}

.cover::before {
  content: "";
  position: absolute;
  left: 11px;
  top: 8px;
  bottom: 8px;
  width: 3px;
  border-radius: 2px;
  background: rgba(0, 0, 0, 0.22);
}

.cover-stage {
  display: block;
  font-size: 12px;
  letter-spacing: 0.06em;
  opacity: 0.9;
  margin-bottom: 8px;
}

.cover-title {
  display: block;
  font-family: var(--serif);
  font-size: 24px;
  line-height: 1.2;
  margin-bottom: 8px;
}

.cover-pitch {
  display: block;
  font-size: 14px;
  font-style: italic;
  opacity: 0.92;
}

/* ---------- slim page-corner pick rows ---------- */

.pick-row {
  position: relative;
  display: flex;
  align-items: stretch;
  background: var(--card);
  border: 1px solid var(--card-line);
  border-left: 0;
  margin: 0 0 10px;
  clip-path: polygon(0 0, 100% 0, 100% calc(100% - 12px), calc(100% - 12px) 100%, 0 100%);
}

/* narrow left stage band */
.pick-row::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 7px;
  background: var(--stage-c, var(--ink-faint));
}

.stage-suggested { --stage-c: var(--rust); }
.stage-reading   { --stage-c: var(--teal); }
.stage-finished  { --stage-c: var(--graphite); }

/* folded bottom-right page corner */
.pick-row::after {
  content: "";
  position: absolute;
  right: 0;
  bottom: 0;
  width: 12px;
  height: 12px;
  background: var(--fold);
  clip-path: polygon(0 0, 100% 0, 0 100%);
}

.stage-cell {
  flex: none;
  width: 88px;
  border: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 10px 4px 14px;
  font-size: 12px;
  font-weight: 600;
  color: var(--stage-c, var(--ink-soft));
}

.stage-suggested .stage-cell { background: #f2e2d6; }
.stage-reading   .stage-cell { background: #e0ebe6; }
.stage-finished  .stage-cell { background: #eae7de; }

.row-main {
  flex: 1;
  min-width: 0;
  text-align: left;
  border: 0;
  background: transparent;
  padding: 10px 10px 14px;
  color: var(--ink);
}

.row-title {
  display: block;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.3;
}

.row-pitch {
  display: block;
  font-size: 13px;
  color: var(--ink-soft);
  margin-top: 2px;
}

.row-by {
  display: block;
  font-size: 12px;
  color: var(--ink-faint);
  margin-top: 4px;
}

.row-del {
  flex: none;
  width: 42px;
  border: 0;
  background: transparent;
  color: var(--ink-faint);
  font-size: 17px;
  padding-top: 10px;
}

.row-del:active { color: var(--danger); }

/* ---------- Add / Edit form: library-card panel ---------- */

.card-form {
  background: var(--card);
  border: 1px solid var(--card-line);
  border-top: 6px solid var(--accent);
  border-radius: 4px 4px 14px 14px;
  padding: 16px 14px 18px;
  margin-top: 8px;
}

.field {
  display: block;
  margin-bottom: 14px;
}

.field-label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
}

.field-label em {
  font-style: normal;
  font-weight: 400;
  font-size: 11px;
  color: var(--ink-faint);
}

.field input,
.field select,
.field textarea,
.find-input {
  width: 100%;
  font-family: var(--sans);
  font-size: 16px; /* avoids mobile zoom-on-focus */
  color: var(--ink);
  background: #fffdf6;
  border: 1px solid #d8c8a8;
  border-radius: 10px;
  padding: 12px;
}

.field textarea { resize: vertical; }

.err {
  display: block;
  min-height: 15px;
  margin-top: 4px;
  font-size: 12px;
  color: var(--danger);
}

.form-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 18px;
}

.btn-primary {
  background: var(--rust);
  color: var(--cream);
  border: 0;
  border-radius: 12px;
  padding: 14px;
  font-size: 17px;
  font-weight: 600;
}

.btn-primary:active { background: #a04f2f; }

.btn-ghost {
  background: transparent;
  color: var(--ink-soft);
  border: 1px solid var(--card-line);
  border-radius: 12px;
  padding: 12px;
  font-size: 15px;
}

.btn-danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid #dcb9a8;
  border-radius: 12px;
  padding: 12px;
  font-size: 15px;
}

/* ---------- Find tab ---------- */

.find-input { margin-bottom: 14px; }

.about {
  margin-top: 30px;
  border-top: 2px dashed var(--stitch);
  padding-top: 14px;
  font-size: 14px;
  color: var(--ink-soft);
}

.about h2 {
  font-family: var(--serif);
  font-size: 16px;
  color: var(--ink);
  margin: 0 0 6px;
}

.about p { margin: 0 0 12px; }

/* ---------- empty states ---------- */

.empty {
  text-align: center;
  color: var(--ink-faint);
  padding: 34px 14px;
}

.empty p {
  margin: 10px auto 0;
  max-width: 300px;
  font-size: 14px;
}

.book-outline {
  width: 64px;
  height: auto;
  display: block;
  margin: 0 auto;
  color: #cdbb98;
}

/* ---------- toast ---------- */

#toast {
  position: fixed;
  left: 50%;
  bottom: calc(78px + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(10px);
  z-index: 60;
  background: var(--ink);
  color: var(--cream);
  font-size: 14px;
  padding: 9px 16px;
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  max-width: 86vw;
}

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