/*
 * Marginalia / JournalKit web port.
 * Visual system adapted from replica882/mneme-atrium/marginalia (MIT).
 * Rosenhaus integration changes are limited to responsive layout and runtime states.
 */
:root {
  --desk: #f6f0e7;
  --paper: #fffdf9;
  --paper-under: #f8f3ea;
  --ink: #46413a;
  --pencil: #8a8378;
  --faint: #b3ac9f;
  --mint: #8ebd9f;
  --rose: #c98a8a;
  --amber: #e89b47;
  --clay: #c97b6e;
  --shadow: 74, 69, 61;
  --rule: 30px;
  --serif: "Iowan Old Style", "Palatino", Georgia, "Times New Roman", serif;
  --ui: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", sans-serif;
  --hand: "Bradley Hand", "Snell Roundhand", "Segoe Script", cursive;
  --mono: "SF Mono", ui-monospace, Menlo, monospace;
  --lace-sparse: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQQAAAEECAYAAADOCEoKAAAEsklEQVR42u3dzY6bShAG0MLiqbLLJg/tjXd+rckmSAyyncGm6Z86R8riZqS5obspGrDriwAAAAAAAAAevDn96+v1v+NF9MEKAiAgvBqO7f8MRqUvkVoda3Npg3KuN7u03LSX2/3aV0klv8uWYje+X8oCFC4KJxVCI4wmTKO2BK3vtBrj9F6t2CHAEmLwfakbH3HoCBA4duFvT876uHlOzsSBYEiCx6ABj6p+MkrTZ9DADsqBQEAAAAAAAAAAAAAAAAAACJtu//w9WeTZdxyHsdPWpwpCBD58hleNWCN3pqsartN7VbmoxSFM47lnXGb9f2H8/sotrq2Z5OlEBk33ioIJhnej3KrcdsQotxy3qvWXGhHj9tPnr6XOMZS879+gLiNdjsjsGXPuHnLAJXar3f/lgFqnEAjvGU4owiMPG7gA2MVxs0tAwAAAAAAAAAAAAAAAAAARIs9IjPy9WfQ10FBcOUDBQFeFsrs3Zn0VCQyR6s96oaceWwmrcXHuvKtx+lZ+28jdU4j0lrt5O0QcOX7oBCsbxOyj5OCMNhORCHYv5MqNW4ttEXfu7bnrD3sXfnkPlhzdgiufAoDuBXCOGGhW+iEDyYBAAAAAAAAAAAAAAAAAAAAMWYbPS3UgNCGXWQcKAgo1I7LLQNghxAi4wBguTUR2APJC8G2CDz6OyD55w4UBQAAAAAAAAAAAAAAAIDwLTRomhZqgIIAKAiwq9OQggAoCAAKwklb0evtPnnTQOvkEZzwqnGd+/Do72j3VXC2eRLUUnhX8GyBPfs5AN4yeIYAKAgAAAAAAAAAAAAAAAAAAAAAAAAAITkZDmu0mnXNacMuL6H5i4A5OW9NXwyYHQnYIfyrnNvAFAEquWWf+9kC+J65qBg4MUO2Y5+xaHL94Ng1fZGcDHSZs1fiddDy+7K/bkJWZbdbn6MOcv171oOnKKAgGDyDhzUNAAAAAAAAAAAAAAAAQPhmGNR0MQTgwtB8QXDFFm6jHb+CAFG783bmdvyzq0JIDEI7frkMUO/C0GrxmbNOzPZ3yXYEzxBwqzAtF4HtxWD9M5K9ZRjprYZ28trxKwicFm5j3WFihNsAAAAAAAAAAAAAAAAAAAAAEHpvhJ6KOImcrAoCTiZJStXn/yKOjJCkhB0CkpTs2uKooBaxV5q4llgHIvYkNyGvEgWB3rbwZ0TfLb9veWagmHVSEExO3pP2jJ3Oo1i1Hh8s9rZru7S+KLxpUNhKnzgyHMWReQ/N8HPS/fyLI0NBABQEAAAAAAAAAAAAAAAAAjfpHNcaMMOLg4KAkJ0xjuuIxKvFARbXkLilYLgpEXiVchl4LDW6L23exfSoyBwwJVnHaaiEISgFnJGqikEfczNJ7cNniGw+znLevGN9Nyl93CgV4lXVm9DDxVHOHEePb0e5fhGDAfykFxB8L5eOFD4pCIUyJHMGmrsoWIDiw4AAAAAAAAAAAAAAAAACL0QvhwT6IcAKAhAaJBSd+uuUQoKwocnkpNIoTN2bhkABWG8XvzX231a/sgXgEZbl2fpxa8/P3tMPb03P+oq+7+I7L0R2q2HsfZ6TCgI2pkDoqggPFQEFAQAAAAAAABgIH8BcvzqnbGmd4kAAAAASUVORK5CYII=");
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { min-height: 100%; }
html { background: var(--desk); }
body {
  margin: 0;
  color: var(--ink);
  font-family: var(--ui);
  background-color: #fafaf8;
  background-image: var(--lace-sparse);
  background-repeat: repeat;
  background-size: 130px 130px;
  -webkit-tap-highlight-color: transparent;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
.serif { font-family: var(--serif); }
.hand { font-family: var(--hand); }

.journal-app, .locked-screen {
  min-height: 100dvh;
  padding: max(12px, env(safe-area-inset-top)) 10px max(18px, env(safe-area-inset-bottom));
}
.journal-screen {
  width: min(100%, 430px);
  min-height: calc(100dvh - max(24px, env(safe-area-inset-top)) - max(30px, env(safe-area-inset-bottom)));
  margin: 0 auto;
  position: relative;
  padding-top: 30px;
}
.journal-topbar {
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}
.screen-label {
  margin: 0;
  font-family: var(--serif);
  font-style: italic;
  font-size: 12px;
  letter-spacing: 2px;
  color: var(--faint);
}
.tiny-action {
  position: absolute;
  right: 8px;
  border: 0;
  background: transparent;
  font-family: var(--serif);
  font-style: italic;
  font-size: 10px;
  color: var(--faint);
  padding: 8px;
}

.tabs {
  display: flex;
  gap: 5px;
  padding: 0 12px;
  position: relative;
  z-index: 3;
}
.tab {
  flex: 1;
  border: 0;
  text-align: center;
  padding: 11px 0 17px;
  font-family: var(--serif);
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 1.2px;
  color: var(--faint);
  background: #efe8dc;
  border-radius: 11px 11px 0 0;
  box-shadow: inset 0 -3px 4px rgba(var(--shadow), .05);
  transform: translateY(7px);
  transition: transform .18s ease, color .18s ease, background .18s ease;
}
.tab.active {
  background: var(--paper);
  color: var(--mint);
  transform: translateY(0);
  box-shadow: 0 -2px 8px rgba(var(--shadow), .08);
}
.tab[data-tab="review"].active { color: var(--rose); }

.page-wrap { position: relative; z-index: 2; margin: 0 2px; }
.page-under {
  position: absolute;
  left: 7px;
  right: -3px;
  top: 8px;
  bottom: -6px;
  background: var(--paper-under);
  border-radius: 14px;
  box-shadow: 0 3px 10px rgba(var(--shadow), .10);
  transform: rotate(.5deg);
}
.loose-leaf {
  position: relative;
  z-index: 1;
  min-height: 646px;
  padding: 12px 18px 28px 64px;
  overflow: hidden;
  border-radius: 14px 14px 12px 12px;
  background:
    repeating-linear-gradient(to bottom,
      transparent 0,
      transparent calc(var(--rule) - 1px),
      rgba(142, 189, 159, .24) calc(var(--rule) - 1px),
      rgba(142, 189, 159, .24) var(--rule)),
    var(--paper);
  background-position: 0 12px, 0 0;
  box-shadow: 0 4px 14px rgba(var(--shadow), .13);
}
.loose-leaf::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50px;
  width: 4px;
  border-left: 1px solid rgba(201, 138, 138, .5);
  border-right: 1px solid rgba(201, 138, 138, .28);
}
.hole {
  position: absolute;
  left: 18px;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: #fafaf8;
  box-shadow: inset 0 1.5px 2.5px rgba(var(--shadow), .28), 0 1px 0 rgba(255,255,255,.9);
}
.hole-a { top: 88px; }
.hole-b { top: 50%; }
.hole-c { bottom: 88px; }

.panel { display: none; min-height: 590px; position: relative; }
.panel.active { display: block; animation: page-lift .18s ease; }
@keyframes page-lift { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.progress-top {
  text-align: center;
  font-family: var(--serif);
  font-style: italic;
  font-size: 12px;
  color: var(--pencil);
  letter-spacing: 1px;
  margin: 5px 0 2px;
}
.progress-top b { color: var(--ink); font-size: 14px; font-style: normal; }

.card-zone { position: relative; z-index: 2; margin: 24px 4px 0 8px; }
.index-card {
  position: relative;
  background: var(--paper);
  border-radius: 14px;
  box-shadow: 0 5px 16px rgba(var(--shadow), .14);
  padding: 44px 22px 30px;
  transform: rotate(-.7deg);
  min-height: 335px;
}
.index-card::before {
  content: "";
  position: absolute;
  left: 14px;
  top: 14px;
  bottom: 14px;
  width: 1.5px;
  background: rgba(201, 138, 138, .45);
  border-radius: 2px;
}
.big-word {
  margin: 12px 0 0;
  font-family: var(--serif);
  font-size: clamp(36px, 11vw, 48px);
  line-height: 1.05;
  font-weight: 700;
  text-align: center;
  letter-spacing: .5px;
  overflow-wrap: anywhere;
}
.phon-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  margin-top: 10px;
  min-height: 28px;
  font-family: var(--mono);
  font-size: 13px;
  color: var(--pencil);
}
.speak {
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 50%;
  background: rgba(142, 189, 159, .15);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--mint);
}
.meta-line {
  margin: 0;
  text-align: center;
  font-family: var(--serif);
  font-style: italic;
  font-size: 11px;
  letter-spacing: 1px;
  color: var(--faint);
}
.definition {
  margin: 26px auto 0;
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  line-height: 1.6;
  color: var(--ink);
}
.concealed { visibility: hidden; }
.cover-tape {
  width: 86%;
  height: 58px;
  margin: -58px auto 0;
  border: 0;
  background:
    radial-gradient(circle at 7px 7px, rgba(255,255,255,.60) 2.4px, transparent 2.9px) 0 0 / 24px 24px,
    radial-gradient(circle at 19px 19px, rgba(255,255,255,.42) 1.9px, transparent 2.4px) 0 0 / 24px 24px,
    rgba(158,152,142,.40);
  clip-path: polygon(1% 7%, 99% 0, 100% 92%, 0 100%);
  box-shadow: 0 1.5px 4px rgba(var(--shadow), .14);
  transform: rotate(-.9deg);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity .18s ease, transform .18s ease;
}
.cover-tape span {
  font-family: var(--hand);
  font-size: 15px;
  letter-spacing: 1px;
  color: rgba(255,255,255,.92);
  text-shadow: 0 1px 1px rgba(var(--shadow), .18);
}
.cover-tape.peeled { pointer-events: none; opacity: 0; transform: translateY(-8px) rotate(-2deg); }
.entry-link {
  position: absolute;
  right: 18px;
  bottom: 12px;
  font-family: var(--serif);
  font-style: italic;
  font-size: 11px;
  letter-spacing: .5px;
  color: var(--faint);
}

.tape {
  position: absolute;
  width: 104px;
  height: 30px;
  z-index: 5;
  clip-path: polygon(1.5% 4%, 98% 0, 100% 94%, 0 100%);
  box-shadow: 0 1px 3px rgba(var(--shadow), .12);
}
.tape::after {
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(115deg, rgba(255,255,255,.14) 0 5px, transparent 5px 11px);
}
.tape-rose { background: rgba(201,138,138,.42); }
.tape-mint { background: rgba(142,189,159,.42); }
.card-tape { top: -13px; left: 50%; margin-left: -52px; transform: rotate(1.8deg); }
.tape-review { transform: rotate(-2.1deg); }
.notebook-tape { top: -25px; left: 50%; margin-left: -52px; transform: rotate(-2.5deg); }

.rate-row {
  display: flex;
  justify-content: center;
  align-items: baseline;
  gap: clamp(22px, 8vw, 38px);
  margin-top: 30px;
  font-family: var(--serif);
  font-size: 16px;
  letter-spacing: 1px;
}
.rate {
  position: relative;
  border: 0;
  background: transparent;
  padding: 3px 1px 5px;
  font-weight: 600;
}
.rate.again { color: var(--clay); }
.rate.hard { color: var(--amber); }
.rate.good { color: var(--mint); }
.rate::after {
  content: "";
  position: absolute;
  left: 2px;
  right: 2px;
  bottom: 0;
  height: 2px;
  background: currentColor;
  opacity: .35;
  border-radius: 2px;
  transform: rotate(-.8deg);
}
.rate:disabled { opacity: .35; cursor: default; }
.review-rate-row { margin-top: 28px; }
.note-line {
  text-align: center;
  color: var(--pencil);
  font-family: var(--serif);
  font-style: italic;
  font-size: 12.5px;
  letter-spacing: .4px;
  margin-top: 25px;
}
.note-line b { color: var(--mint); font-size: 15px; font-style: normal; padding: 0 2px; }
.review-prompt { min-height: 46px; margin: 20px 10px 0; text-align: center; color: var(--pencil); line-height: 1.55; }

.sticky {
  position: relative;
  background: #fffef6;
  border-radius: 4px 4px 10px 4px;
  box-shadow: 0 4px 12px rgba(var(--shadow), .13);
  padding: 15px 18px 14px;
  transform: rotate(.9deg);
}
.sticky .fold, .stat-note .fold {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 0 0 16px 16px;
  border-color: transparent transparent rgba(var(--shadow), .10) transparent;
  border-radius: 0 0 8px 0;
}
.sticky-label {
  font-family: var(--serif);
  font-style: italic;
  font-size: 11.5px;
  color: var(--faint);
  letter-spacing: 1.5px;
  margin-bottom: 6px;
}
.sticky-body { font-size: 13.5px; line-height: 1.55; }
.review-sticky { margin: 28px 18px 0 28px; }

.completion-page { text-align: center; padding-top: 100px; }
.completion-page h1 { margin: 17px 0 7px; font-family: var(--serif); font-size: 28px; }
.completion-page p { margin: 0; color: var(--pencil); }
.completion-note { margin-top: 24px !important; font-size: 17px; transform: rotate(-2deg); }
.sticker-star { filter: drop-shadow(0 1.5px 2px rgba(var(--shadow), .22)); }
.sticker-star path { stroke: white; stroke-width: 1.4; stroke-linejoin: round; }
.star-large { width: 72px; }
.star-large path { fill: var(--amber); }

.search-row {
  height: var(--rule);
  display: flex;
  align-items: flex-end;
  padding-bottom: 6px;
  gap: 7px;
  color: var(--faint);
  font-family: var(--serif);
  font-style: italic;
}
.search-row input {
  min-width: 0;
  flex: 1;
  border: 0;
  outline: 0;
  background: transparent;
  font-family: var(--serif);
  font-style: italic;
  font-size: 13.5px;
  color: var(--ink);
}
.search-row input::placeholder { color: var(--faint); }
.notebook-list { margin-top: 0; max-height: 485px; overflow: auto; overscroll-behavior: contain; scrollbar-width: none; }
.notebook-list::-webkit-scrollbar { display: none; }
.note-row {
  min-height: var(--rule);
  display: grid;
  grid-template-columns: 9px minmax(0, 1fr) auto;
  gap: 8px;
  align-items: start;
  padding: 6px 0 7px;
}
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-top: 7px;
  box-shadow: inset 0 0 0 4px currentColor, 0 0 0 1px rgba(var(--shadow), .08);
}
.status-dot.known { color: var(--mint); }
.status-dot.slow { color: var(--amber); }
.status-dot.unknown { color: var(--clay); }
.note-main { min-width: 0; }
.note-heading { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.note-word { margin: 0; font-family: var(--serif); font-size: 16px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.note-source { margin-left: auto; font-family: var(--serif); font-style: italic; font-size: 10.5px; color: var(--rose); }
.note-input {
  width: 100%;
  min-height: 34px;
  margin-top: 3px;
  padding: 4px 5px;
  resize: vertical;
  border: 0;
  border-bottom: 1px solid rgba(142,189,159,.25);
  outline: none;
  background: rgba(255,254,246,.48);
  color: var(--pencil);
  font-size: 12px;
  line-height: 1.4;
}
.note-status { padding-top: 5px; font-family: var(--serif); font-style: italic; font-size: 10.5px; color: var(--faint); }
.notebook-empty { margin: 85px 16px 0; text-align: center; color: var(--pencil); font-family: var(--serif); font-style: italic; }
.notebook-footer { position: absolute; left: 0; right: 0; bottom: 9px; min-height: 55px; }
.notebook-footer .hand { position: absolute; right: 8px; bottom: 8px; color: var(--pencil); font-size: 17px; transform: rotate(-3deg); opacity: .75; }
.star-rose { position: absolute; left: -4px; bottom: 17px; width: 34px; }
.star-rose path { fill: var(--rose); }
.star-mint { position: absolute; left: 21px; bottom: 0; width: 22px; transform: rotate(18deg); }
.star-mint path { fill: var(--mint); }

.stats-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; margin: 22px 6px 0 8px; }
.stat-note { min-height: 105px; margin: 0; display: grid; place-content: center; text-align: center; }
.stat-note:nth-child(odd) { transform: rotate(-.7deg); }
.stat-note:nth-child(even) { transform: rotate(.8deg); }
.stat-note span { font-family: var(--serif); font-size: 34px; color: var(--mint); }
.stat-note p { margin: 2px 0 0; color: var(--pencil); font-family: var(--serif); font-style: italic; }
.heat-strip { margin: 28px 5px 0 8px; }
.heat-cells { display: grid; grid-template-columns: repeat(7, 1fr); gap: 7px; margin-top: 10px; }
.heat-cell { aspect-ratio: 1; border-radius: 3px; background: rgba(142,189,159, calc(.10 + var(--level) * .17)); box-shadow: inset 0 0 0 1px rgba(86,134,106,.08); }
.settings-note { margin: 28px 12px 0 18px; }
.daily-limit-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; color: var(--pencil); font-size: 13px; }
.daily-limit-row select { border: 0; border-bottom: 1px solid rgba(142,189,159,.55); background: transparent; padding: 3px 18px 3px 5px; font-family: var(--serif); color: var(--ink); }

.notice { min-height: 18px; margin: 13px 7px 0; text-align: center; color: var(--pencil); font-family: var(--serif); font-style: italic; font-size: 11.5px; }
.license-note { margin-top: 6px; text-align: center; color: rgba(138,131,120,.62); font-size: 9px; letter-spacing: .3px; }

.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 20px;
  background-color: #fafaf8;
  background-image: var(--lace-sparse);
  background-size: 130px 130px;
}
.loading-paper {
  position: relative;
  width: min(260px, 78vw);
  min-height: 110px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--paper);
  box-shadow: 0 5px 16px rgba(var(--shadow), .14);
  transform: rotate(-.8deg);
}
.loading-paper p { margin: 0; color: var(--pencil); font-style: italic; letter-spacing: 1px; }
.loading-tape { top: -13px; left: 50%; margin-left: -52px; transform: rotate(1.8deg); }
.status-banner {
  position: fixed;
  left: max(10px, env(safe-area-inset-left));
  right: max(10px, env(safe-area-inset-right));
  bottom: max(10px, env(safe-area-inset-bottom));
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 8px;
  background: #fffef6;
  color: var(--clay);
  box-shadow: 0 5px 16px rgba(var(--shadow), .16);
  font-size: 13px;
}
.status-banner button { flex: none; border: 0; border-bottom: 1px solid currentColor; background: transparent; color: var(--clay); font-family: var(--serif); }
.locked-screen { display: grid; place-items: center; }
.locked-page { width: min(100%, 410px); }
.locked-leaf { min-height: 520px; display: grid; align-items: center; }
.locked-note { margin: 0 18px 0 8px; min-height: 130px; display: grid; align-content: center; }
.locked-note p { margin: 8px 0 0; line-height: 1.6; color: var(--pencil); }

@media (max-width: 370px) {
  .journal-app, .locked-screen { padding-left: 5px; padding-right: 5px; }
  .loose-leaf { padding-left: 59px; padding-right: 13px; }
  .loose-leaf::before { left: 46px; }
  .hole { left: 15px; }
  .tabs { padding-left: 8px; padding-right: 8px; }
  .tab { font-size: 11.5px; letter-spacing: .7px; }
  .index-card { padding-left: 18px; padding-right: 18px; }
  .rate-row { gap: 18px; }
}
@media (min-width: 700px) {
  .journal-screen { padding-top: 42px; }
  .journal-app { padding-top: 20px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
