/* Commonplace — Dog-Ear Page-Marker Focus Stack */

:root {
  --ivory: #f8f1e4;
  --paper: #fdf8ec;
  --secondary: #f2e7d8;
  --fold: #e8d9c0;
  --ink: #3a2c35;
  --ink-soft: #7a6a70;
  --primary: #5b3a55;
  --accent: #d98c5f;
  --plum: #5b3a55;
  --ochre: #d9a441;
  --sage: #8aa07c;
  --coral: #e0705f;
  --line: #e2d5c2;
  --shadow: 0 2px 8px rgba(91, 58, 85, 0.10);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--ivory);
  color: var(--ink);
  font-family: "Avenir Next", "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  padding-bottom: calc(96px + env(safe-area-inset-bottom, 0px));
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
}

/* ---------- header: slim page-marker ---------- */

.desk-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: calc(14px + env(safe-area-inset-top, 0px)) 18px 12px;
  background: var(--primary);
  color: var(--secondary);
  border-bottom: 3px solid var(--accent);
}

.page-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  flex: none;
}

.desk-header-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.app-name {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.25rem;
  letter-spacing: 0.03em;
}

.app-sub {
  font-size: 0.72rem;
  opacity: 0.75;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

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

main {
  padding: 18px 16px 8px;
  max-width: 480px;
  margin: 0 auto;
}

.view-title {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.5rem;
  margin: 0 0 4px;
  color: var(--primary);
}

.view-note {
  margin: 0 0 16px;
  font-size: 0.82rem;
  color: var(--ink-soft);
}

.section-label {
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin: 26px 0 10px;
}

/* ---------- desk widgets (varied shapes) ---------- */

.tally {
  display: flex;
  align-items: baseline;
  gap: 14px;
  background: var(--secondary);
  border-left: 6px solid var(--accent);
  border-radius: 4px 12px 12px 4px;
  padding: 14px 18px;
  margin-bottom: 12px;
}

.tally-num {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 2.6rem;
  line-height: 1;
  color: var(--paper);
  background: var(--primary);
  padding: 4px 12px;
  border-radius: 3px;
  box-shadow: inset 0 0 0 1px rgba(253, 248, 236, 0.25);
}

.tally-label {
  font-size: 0.85rem;
  color: var(--ink-soft);
  max-width: 9rem;
}

.current-book {
  margin-bottom: 16px;
  padding: 2px 2px 10px;
  border-bottom: 1px dashed var(--line);
}

.current-book-label {
  display: block;
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin-bottom: 2px;
}

.current-book-title {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.15rem;
  color: var(--ink);
}

.capture-strip {
  display: block;
  width: 100%;
  text-align: left;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 16px 18px;
  box-shadow: var(--shadow);
}

.capture-strip:active { transform: translateY(1px); }

.capture-strip-main {
  display: block;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.15rem;
}

.capture-strip-sub {
  display: block;
  font-size: 0.78rem;
  opacity: 0.85;
  margin-top: 2px;
}

/* ---------- dog-eared index slips ---------- */

.stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.slip {
  position: relative;
  background: var(--paper);
  border-radius: 4px 10px 10px 4px;
  padding: 14px 20px 14px 18px;
  box-shadow: var(--shadow);
  clip-path: polygon(0 0, calc(100% - 24px) 0, 100% 24px, 100% 100%, 0 100%);
}

.slip::before { /* left book-spine color band */
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 8px;
  border-radius: 4px 0 0 4px;
}

.slip::after { /* folded top-right flap */
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  width: 24px;
  height: 24px;
  background: linear-gradient(225deg, var(--ivory) 0%, var(--fold) 60%);
  clip-path: polygon(0 0, 100% 100%, 0 100%);
  filter: drop-shadow(-1px 1px 1px rgba(58, 44, 53, 0.18));
}

.slip-pinned {
  margin-top: 4px;
  border: 1px solid var(--line);
}

.color-plum::before { background: var(--plum); }
.color-ochre::before { background: var(--ochre); }
.color-sage::before { background: var(--sage); }
.color-coral::before { background: var(--coral); }

.slip-book {
  margin: 0 0 1px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.05rem;
  color: var(--primary);
  padding-right: 26px;
  overflow-wrap: anywhere;
}

.slip-page {
  margin: 0 0 8px;
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.slip-excerpt {
  margin: 0 0 6px;
  font-family: Georgia, "Times New Roman", serif;
  font-style: italic;
  font-size: 0.95rem;
  color: var(--ink);
}

.slip-cue {
  margin: 0;
  font-size: 0.85rem;
  color: var(--ink-soft);
}

.slip-cue-label {
  display: inline-block;
  font-size: 0.66rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  margin-right: 6px;
}

.slip-actions {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}

.slip-btn {
  min-height: 40px;
  padding: 0 16px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--secondary);
  font-size: 0.85rem;
}

.slip-btn.slip-delete {
  color: #a4422f;
  border-color: #e5c0b6;
  background: #f7e8e2;
}

.slip-btn:active { transform: translateY(1px); }

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

.empty {
  text-align: center;
  padding: 34px 20px;
  border: 1px dashed var(--line);
  border-radius: 10px;
  background: rgba(253, 248, 236, 0.6);
}

.empty-title {
  margin: 0 0 4px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.05rem;
  color: var(--primary);
}

.empty-note {
  margin: 0;
  font-size: 0.85rem;
  color: var(--ink-soft);
}

/* ---------- capture notecard ---------- */

.notecard {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 18px 16px;
  box-shadow: var(--shadow);
  clip-path: polygon(0 0, calc(100% - 24px) 0, 100% 24px, 100% 100%, 0 100%);
  position: relative;
}

.notecard::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  width: 24px;
  height: 24px;
  background: linear-gradient(225deg, var(--ivory) 0%, var(--fold) 60%);
  clip-path: polygon(0 0, 100% 100%, 0 100%);
}

.field { margin-bottom: 16px; }

.field label {
  display: block;
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  color: var(--primary);
  margin-bottom: 6px;
  font-weight: 600;
}

.req, .optional {
  font-weight: 400;
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.field input,
.field textarea {
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  font: inherit;
  color: var(--ink);
  background: #fffdf7;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}

.field textarea { resize: vertical; line-height: 1.5; }

.field input:focus,
.field textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(217, 140, 95, 0.18);
}

.field input[aria-invalid="true"],
.field textarea[aria-invalid="true"] {
  border-color: var(--coral);
}

.field-error {
  margin: 6px 0 0;
  font-size: 0.8rem;
  color: #a4422f;
}

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

.btn-save {
  min-height: 52px;
  border: none;
  border-radius: 8px;
  background: var(--primary);
  color: var(--secondary);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.05rem;
  letter-spacing: 0.03em;
  box-shadow: var(--shadow);
}

.btn-save:active { transform: translateY(1px); }

.btn-quiet {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: transparent;
  color: var(--ink-soft);
  font-size: 0.9rem;
}

/* ---------- lookup card-catalog strip ---------- */

.card-catalog {
  background: var(--secondary);
  border-left: 6px solid var(--plum);
  border-radius: 4px 10px 10px 4px;
  padding: 14px 14px 16px;
  margin-bottom: 14px;
}

.catalog-label {
  display: block;
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin-bottom: 8px;
}

.catalog-row { display: flex; gap: 10px; }

.catalog-row input {
  flex: 1;
  min-width: 0;
  min-height: 48px;
  padding: 12px 14px;
  font: inherit;
  background: #fffdf7;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}

.catalog-row input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(217, 140, 95, 0.18);
}

.btn-clear { flex: none; min-width: 72px; }

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

.toast {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: calc(104px + env(safe-area-inset-bottom, 0px));
  margin: 0 auto;
  max-width: 448px;
  background: var(--primary);
  color: var(--secondary);
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 0.88rem;
  text-align: center;
  box-shadow: var(--shadow);
  z-index: 20;
}

/* ---------- bottom tabs: folded-page-corner silhouettes ---------- */

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

.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  background: none;
  border: none;
  padding: 6px 2px 4px;
  min-height: 56px;
  color: var(--ink-soft);
  -webkit-tap-highlight-color: transparent;
}

.tab-label {
  font-size: 0.68rem;
  letter-spacing: 0.04em;
}

.corner {
  width: 26px;
  height: 22px;
  background: #cdc0ab;
  clip-path: polygon(0 0, 62% 0, 100% 38%, 100% 100%, 0 100%);
  position: relative;
  transition: transform 0.15s ease;
}

.corner::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  width: 11px;
  height: 9px;
  background: var(--paper);
  clip-path: polygon(0 0, 100% 100%, 0 100%);
}

.tab[aria-current="page"] {
  color: var(--primary);
}

.tab[aria-current="page"] .corner {
  background: var(--primary);
  transform: translateY(-2px);
  filter: drop-shadow(0 3px 3px rgba(91, 58, 85, 0.28));
}
