* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0;
  padding: 0;
  background: #ffffff;
  color: #000000;
  font-family: -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
  font-size: 18px;
  line-height: 1.35;
}
#app { max-width: 960px; margin: 0 auto; padding: 16px 16px 64px; }

button {
  font: inherit;
  color: #000;
  background: #fff;
  border: 2px solid #000;
  border-radius: 0;
  padding: 10px 16px;
  cursor: pointer;
}
button:active { background: #000; color: #fff; }
button.primary { background: #000; color: #fff; }
button.primary:active { background: #fff; color: #000; }
button.ghost { border-color: #666; color: #333; }
input, textarea, select {
  font: inherit;
  border: 2px solid #000;
  padding: 8px 10px;
  background: #fff;
  color: #000;
}

/* ---------- header / nav ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 3px solid #000;
  padding-bottom: 10px;
  margin-bottom: 16px;
}
.topbar h1 { font-size: 24px; margin: 0; letter-spacing: 0.02em; }
.topbar .sub { font-size: 14px; color: #444; }

/* ---------- list view ---------- */
.entry-list { list-style: none; margin: 0; padding: 0; }
.entry-card {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  border: 2px solid #000;
  padding: 10px;
  margin-bottom: 12px;
}
.entry-card .thumb {
  width: 84px;
  height: 84px;
  border: 1px solid #999;
  flex-shrink: 0;
  background: #fff;
  object-fit: cover;
}
.entry-card .meta { flex: 1; min-width: 0; }
.entry-card .date { font-weight: 700; font-size: 16px; }
.entry-card .time { color: #555; font-size: 13px; }
.entry-card .chips { margin-top: 6px; }
.chip {
  display: inline-block;
  border: 1px solid #000;
  padding: 2px 8px;
  margin: 2px 4px 0 0;
  font-size: 13px;
}
.chip.distortion { border-style: dashed; }
.empty-state { text-align: center; color: #555; padding: 48px 16px; }

.fab-row { position: sticky; bottom: 0; background: #fff; padding: 12px 0; border-top: 3px solid #000; margin-top: 16px; }
.fab-row button { width: 100%; font-size: 20px; padding: 14px; }

/* ---------- section blocks ---------- */
.section {
  border: 2px solid #000;
  padding: 14px;
  margin-bottom: 18px;
}
.section h2 { font-size: 18px; margin: 0 0 4px; }
.section .hint { font-size: 13px; color: #444; margin: 0 0 10px; }
.field-row { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.field-row label { font-weight: 600; }

/* ---------- ink pad ---------- */
.inkpad-wrap { position: relative; border: 2px solid #000; background: #fff; touch-action: none; }
.inkpad-wrap canvas { display: block; width: 100%; touch-action: none; }
.inkpad-toolbar { display: flex; gap: 8px; margin-top: 8px; }
.inkpad-toolbar button { padding: 6px 12px; font-size: 14px; }

.inkpad-resize-handle {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 32px;
  height: 32px;
  cursor: ns-resize;
  touch-action: none;
  background:
    linear-gradient(135deg, transparent 0 46%, #000 46% 54%, transparent 54% 100%),
    linear-gradient(135deg, transparent 0 66%, #000 66% 74%, transparent 74% 100%);
}

/* ---------- emotion chips ---------- */
.emotion-grid { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.emotion-btn {
  border: 2px solid #000;
  padding: 8px 14px;
  background: #fff;
}
.emotion-btn.selected { background: #000; color: #fff; }
.emotion-selected-list { display: flex; flex-direction: column; gap: 10px; }
.emotion-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border: 1px solid #000;
  padding: 8px 10px;
}
.emotion-row .name { font-weight: 700; }
.stepper { display: flex; align-items: center; gap: 8px; }
.stepper button { width: 40px; height: 40px; padding: 0; font-size: 20px; line-height: 1; }
.stepper .val { min-width: 34px; text-align: center; font-weight: 700; font-size: 18px; }
.custom-emotion-add { display: flex; gap: 8px; margin-top: 6px; }
.custom-emotion-add input { flex: 1; }

/* ---------- distortions (legend + compact chips) ---------- */
.legend-toggle { font-size: 13px; padding: 6px 10px; margin-bottom: 10px; }
.distortion-legend { border: 1px solid #000; padding: 10px; margin-bottom: 14px; }
.legend-item { font-size: 13px; margin-bottom: 6px; }
.legend-item:last-child { margin-bottom: 0; }
.legend-name { font-weight: 700; }

.distortion-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.distortion-chip {
  border: 2px solid #000;
  background: #fff;
  padding: 6px 10px;
  font-size: 13px;
}
.distortion-chip.selected { background: #000; color: #fff; }

/* ---------- triple column technique ---------- */
.triple-rows { display: flex; flex-direction: column; gap: 16px; }
.triple-row-block { border: 2px solid #000; padding: 10px; }
.triple-row-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 700;
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid #000;
}
.triple-row-header .row-remove { font-size: 12px; padding: 4px 8px; font-weight: normal; }
.triple-row { display: grid; grid-template-columns: 1fr; gap: 12px; }
.triple-cell { min-width: 0; }
.cell-label { font-weight: 700; font-size: 13px; margin-bottom: 4px; text-transform: uppercase; letter-spacing: 0.03em; }
.add-thought { width: 100%; margin-top: 4px; }

/* Stay single-column (full-width cells) on tablets like the Boox Go 7 so
   there's actually room to write — only go side-by-side on much wider
   desktop screens, where the book's 3-column look still fits comfortably. */
@media (min-width: 1100px) {
  .triple-row { grid-template-columns: 1fr 1fr 1fr; }
}

/* ---------- save bar ---------- */
.save-bar {
  position: sticky;
  bottom: 0;
  background: #fff;
  border-top: 3px solid #000;
  padding: 12px 0;
  display: flex;
  gap: 10px;
}
.save-bar button { flex: 1; font-size: 18px; padding: 14px; }

.icon-btn { border: none; background: none; padding: 6px; font-size: 20px; }

@media (max-width: 420px) {
  html, body { font-size: 16px; }
}
