:root {
      --ink: #2d241f;
      --muted-ink: #77675d;
      --paper: #fffaf0;
      --paper-deep: #f4ead8;
      --paper-highlight: #fffdf7;
      --paper-line: rgba(89, 73, 56, 0.085);
      --page-ink: #2d241f;
      --page-muted: #77675d;
      --leather: #5c2743;
      --leather-light: #854469;
      --leather-dark: #2e1424;
      --book-binding: #5e3b2c;
      --book-binding-light: #6f4a35;
      --gold: #d7b26d;
      --gold-light: #f7df9c;
      --accent: #7a3d60;
      --accent-soft: #f2e4ed;
      --danger: #a83f4b;
      --shadow: 0 28px 70px rgba(22, 13, 18, 0.35);
      --radius: 20px;
      --viewport-height: 100vh;
      --safe-top: env(safe-area-inset-top, 0px);
      --safe-right: env(safe-area-inset-right, 0px);
      --safe-bottom: env(safe-area-inset-bottom, 0px);
      --safe-left: env(safe-area-inset-left, 0px);
    }

    * { box-sizing: border-box; }

    html, body { width: 100%; min-height: 100%; overscroll-behavior: none; }

    body {
      margin: 0;
      min-height: var(--viewport-height);
      overflow: hidden;
      font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
      color: var(--ink);
      background:
        radial-gradient(circle at 20% 10%, rgba(255, 255, 255, 0.16), transparent 32%),
        radial-gradient(circle at 85% 78%, rgba(215, 178, 109, 0.16), transparent 28%),
        linear-gradient(145deg, #201724 0%, #3a2333 44%, #1b1720 100%);
    }

    button, input, select, textarea { font: inherit; }
    button, [role="button"], select, input[type="color"] { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
    button { color: inherit; }
    button:focus-visible, input:focus-visible, [contenteditable="true"]:focus-visible {
      outline: 3px solid rgba(122, 61, 96, 0.28);
      outline-offset: 2px;
    }

    .hidden { display: none !important; }

    .app-shell {
      position: relative;
      width: 100vw;
      height: var(--viewport-height);
      overflow: hidden;
      isolation: isolate;
    }

    .ambient-orb {
      position: absolute;
      border-radius: 50%;
      filter: blur(1px);
      opacity: 0.5;
      pointer-events: none;
      animation: drift 8s ease-in-out infinite alternate;
    }

    .orb-one {
      width: 330px;
      height: 330px;
      left: -130px;
      top: -90px;
      background: radial-gradient(circle, rgba(235, 193, 139, 0.2), transparent 68%);
    }

    .orb-two {
      width: 380px;
      height: 380px;
      right: -150px;
      bottom: -140px;
      background: radial-gradient(circle, rgba(161, 84, 125, 0.22), transparent 70%);
      animation-delay: -3s;
    }

    @keyframes drift {
      to { transform: translate3d(18px, 12px, 0) scale(1.05); }
    }

    /* Closed diary */
    .cover-scene {
      position: absolute;
      inset: 0;
      display: grid;
      place-items: center;
      padding: 24px;
      perspective: 1600px;
      transition: opacity 350ms ease, transform 700ms cubic-bezier(.2,.8,.2,1);
      z-index: 10;
    }

    .cover-scene.opening {
      opacity: 0;
      transform: scale(1.08);
      pointer-events: none;
    }

    .cover-wrap {
      position: relative;
      width: min(420px, 82vw);
      aspect-ratio: 0.73;
      transform-style: preserve-3d;
      filter: drop-shadow(0 38px 35px rgba(0, 0, 0, 0.45));
      animation: coverFloat 5s ease-in-out infinite;
    }

    @keyframes coverFloat {
      50% { transform: translateY(-8px) rotateX(1.2deg) rotateY(-1deg); }
    }

    .cover-scene.opening .cover-wrap {
      animation: coverOpen 720ms cubic-bezier(.23,.78,.22,1) forwards;
    }

    @keyframes coverOpen {
      0% { transform: rotateY(0) scale(1); }
      45% { transform: rotateY(-18deg) translateX(-5%) scale(1.03); }
      100% { transform: rotateY(-82deg) translateX(-22%) scale(1.1); }
    }

    .diary-cover {
      position: absolute;
      inset: 0;
      overflow: hidden;
      border: 1px solid rgba(255,255,255,0.15);
      border-radius: 18px 28px 28px 18px;
      cursor: pointer;
      background:
        linear-gradient(90deg, rgba(255,255,255,0.06), transparent 8%, transparent 92%, rgba(0,0,0,0.2)),
        repeating-linear-gradient(15deg, rgba(255,255,255,0.025) 0 1px, transparent 1px 5px),
        radial-gradient(circle at 45% 30%, var(--leather-light) 0%, var(--leather) 43%, var(--leather-dark) 100%);
      box-shadow:
        inset 9px 0 16px rgba(0,0,0,0.28),
        inset -5px 0 12px rgba(255,255,255,0.06),
        10px 13px 0 #d6c9af,
        13px 16px 0 #806b5a;
    }

    .diary-cover::before,
    .diary-cover::after {
      content: "";
      position: absolute;
      pointer-events: none;
    }

    .diary-cover::before {
      inset: 18px;
      border: 1px solid rgba(247, 223, 156, 0.52);
      border-radius: 10px 18px 18px 10px;
      box-shadow: inset 0 0 0 4px rgba(59, 23, 43, 0.28);
    }

    .diary-cover::after {
      left: 27px;
      top: 0;
      bottom: 0;
      width: 10px;
      background: linear-gradient(90deg, rgba(0,0,0,0.2), rgba(255,255,255,0.07), rgba(0,0,0,0.1));
      box-shadow: 9px 0 18px rgba(0,0,0,0.18);
    }

    .cover-content {
      position: relative;
      height: 100%;
      z-index: 2;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      gap: 14px;
      padding: 54px;
      text-align: center;
      color: #fff8ea;
    }

    .cover-emblem {
      width: 72px;
      height: 72px;
      display: grid;
      place-items: center;
      border-radius: 50%;
      color: var(--gold-light);
      border: 1px solid rgba(247, 223, 156, 0.7);
      background: rgba(42, 14, 31, 0.32);
      box-shadow: inset 0 0 0 5px rgba(215, 178, 109, 0.08);
      font-size: 32px;
    }

    .cover-title {
      margin: 8px 0 0;
      max-width: 100%;
      overflow-wrap: anywhere;
      font-family: Georgia, "Times New Roman", serif;
      font-size: clamp(34px, 7vw, 50px);
      line-height: 1.02;
      font-weight: 600;
      letter-spacing: -0.025em;
      text-shadow: 0 2px 0 rgba(0,0,0,0.25);
    }

    .cover-rule {
      width: 116px;
      height: 1px;
      margin: 4px 0;
      background: linear-gradient(90deg, transparent, var(--gold-light), transparent);
    }

    .cover-pages {
      margin: 0;
      color: rgba(255, 248, 234, 0.72);
      font-size: 14px;
      letter-spacing: 0.12em;
      text-transform: uppercase;
    }

    .cover-lock-status {
      min-height: 28px;
      display: inline-flex;
      align-items: center;
      gap: 7px;
      margin-top: 12px;
      padding: 6px 10px;
      border: 1px solid rgba(255,255,255,0.15);
      border-radius: 999px;
      background: rgba(25, 10, 20, 0.2);
      color: rgba(255, 248, 234, 0.86);
      font-size: 12px;
    }

    .cover-hint {
      position: absolute;
      left: 50%;
      bottom: -70px;
      transform: translateX(-50%);
      width: max-content;
      max-width: 90vw;
      color: rgba(255,255,255,0.72);
      font-size: 13px;
      letter-spacing: 0.04em;
      text-align: center;
    }

    .cover-actions {
      position: absolute;
      top: 22px;
      right: 24px;
      z-index: 12;
      display: flex;
      gap: 9px;
    }

    .glass-button {
      border: 1px solid rgba(255,255,255,0.16);
      border-radius: 12px;
      min-width: 42px;
      height: 42px;
      padding: 0 13px;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      gap: 8px;
      color: rgba(255,255,255,0.88);
      background: rgba(255,255,255,0.08);
      backdrop-filter: blur(12px);
      cursor: pointer;
      transition: transform 160ms ease, background 160ms ease;
    }

    .glass-button:hover { transform: translateY(-2px); background: rgba(255,255,255,0.14); }

    /* Open book */
    .book-view {
      position: absolute;
      inset: 0;
      z-index: 5;
      display: flex;
      flex-direction: column;
      gap: 10px;
      padding: 12px;
      opacity: 0;
      transform: scale(0.96);
      pointer-events: none;
      transition: opacity 380ms ease, transform 600ms cubic-bezier(.2,.8,.2,1);
    }

    .book-view.visible {
      opacity: 1;
      transform: scale(1);
      pointer-events: auto;
    }

    .topbar {
      min-height: 56px;
      display: grid;
      grid-template-columns: auto minmax(0, 1fr) auto;
      align-items: center;
      gap: 12px;
      padding: 7px 10px;
      border: 1px solid rgba(255,255,255,0.12);
      border-radius: 16px;
      background: rgba(31, 22, 29, 0.72);
      backdrop-filter: blur(18px);
      box-shadow: 0 10px 30px rgba(0,0,0,0.15);
    }

    .topbar-group { display: flex; align-items: center; gap: 8px; }
    .topbar-group.right { justify-content: flex-end; }

    .topbar-title {
      min-width: 0;
      text-align: center;
      color: rgba(255,255,255,0.95);
      font-family: Georgia, "Times New Roman", serif;
      font-size: clamp(18px, 2vw, 25px);
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }

    .topbar-button {
      height: 40px;
      border: 1px solid rgba(255,255,255,0.12);
      border-radius: 11px;
      padding: 0 13px;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      gap: 7px;
      color: rgba(255,255,255,0.88);
      background: rgba(255,255,255,0.07);
      cursor: pointer;
      transition: background 150ms ease, transform 150ms ease;
    }

    .topbar-button:hover { background: rgba(255,255,255,0.13); transform: translateY(-1px); }
    .topbar-button.primary { background: rgba(215,178,109,0.2); border-color: rgba(215,178,109,0.28); }
    .button-label { display: inline; }

    .save-indicator {
      position: absolute;
      top: 76px;
      left: 50%;
      z-index: 50;
      transform: translateX(-50%) translateY(-8px);
      opacity: 0;
      pointer-events: none;
      padding: 7px 11px;
      border-radius: 999px;
      color: rgba(255,255,255,0.86);
      background: rgba(26,20,24,0.82);
      box-shadow: 0 8px 20px rgba(0,0,0,0.18);
      font-size: 12px;
      transition: opacity 180ms ease, transform 180ms ease;
    }

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

    .book-stage {
      position: relative;
      flex: 1;
      min-height: 0;
      perspective: 2200px;
    }

    .book-shadow {
      position: absolute;
      left: 5%;
      right: 5%;
      bottom: -2px;
      height: 16%;
      border-radius: 50%;
      background: rgba(0,0,0,0.4);
      filter: blur(28px);
      pointer-events: none;
    }

    .open-book {
      position: absolute;
      inset: 0;
      display: grid;
      grid-template-columns: 1fr 1fr;
      overflow: hidden;
      border-radius: 16px 16px 22px 22px;
      box-shadow: var(--shadow);
      transform-style: preserve-3d;
      background: var(--book-binding);
    }

    .open-book::before {
      content: "";
      position: absolute;
      inset: 0;
      z-index: 0;
      border: 7px solid var(--book-binding-light);
      border-radius: inherit;
      pointer-events: none;
      box-shadow: inset 0 0 0 2px rgba(255,255,255,0.08);
    }

    .page {
      position: relative;
      z-index: 2;
      min-width: 0;
      min-height: 0;
      overflow: hidden;
      display: flex;
      flex-direction: column;
      padding: clamp(18px, 2.6vw, 36px) clamp(18px, 3vw, 42px) 18px;
      color: var(--page-ink);
      background:
        radial-gradient(circle at 15% 10%, rgba(255,255,255,0.42), transparent 28%),
        linear-gradient(100deg, var(--paper-deep) 0%, var(--paper) 10%, var(--paper-highlight) 100%);
      box-shadow: inset 0 0 42px rgba(91, 67, 40, 0.11);
    }

    .page.template-ruled {
      background:
        linear-gradient(var(--paper-line) 1px, transparent 1px) 0 104px / 100% 30px,
        radial-gradient(circle at 15% 10%, rgba(255,255,255,0.42), transparent 28%),
        linear-gradient(100deg, var(--paper-deep) 0%, var(--paper) 10%, var(--paper-highlight) 100%);
    }

    .page.template-unruled {
      background:
        radial-gradient(circle at 15% 10%, rgba(255,255,255,0.42), transparent 28%),
        linear-gradient(100deg, var(--paper-deep) 0%, var(--paper) 10%, var(--paper-highlight) 100%);
    }

    .page.left {
      border-radius: 13px 0 0 17px;
      box-shadow: inset -26px 0 34px -28px rgba(45, 30, 21, 0.9), inset 0 0 42px rgba(91,67,40,0.1);
    }

    .page.right {
      border-radius: 0 13px 17px 0;
      box-shadow: inset 26px 0 34px -28px rgba(45, 30, 21, 0.9), inset 0 0 42px rgba(91,67,40,0.1);
    }

    .page.left::after,
    .page.right::before {
      content: "";
      position: absolute;
      top: 0;
      bottom: 0;
      width: 36px;
      z-index: 3;
      pointer-events: none;
    }

    .page.left::after {
      right: 0;
      background: linear-gradient(90deg, transparent, rgba(70, 48, 30, 0.12));
    }

    .page.right::before {
      left: 0;
      background: linear-gradient(90deg, rgba(70, 48, 30, 0.12), transparent);
    }

    .centre-crease {
      position: absolute;
      z-index: 12;
      top: 0;
      bottom: 0;
      left: 50%;
      width: 22px;
      transform: translateX(-50%);
      pointer-events: none;
      background: linear-gradient(90deg, transparent, rgba(45,28,17,0.14), rgba(255,255,255,0.34), rgba(45,28,17,0.14), transparent);
      filter: blur(0.2px);
      mix-blend-mode: multiply;
    }

    .page-header {
      position: relative;
      z-index: 4;
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 12px;
      min-height: 34px;
      padding-bottom: 12px;
      border-bottom: 1px solid rgba(82, 63, 46, 0.15);
    }

    .timestamp-input {
      min-width: 0;
      width: min(260px, 52%);
      height: 36px;
      border: 1px solid transparent;
      border-radius: 9px;
      padding: 0 8px;
      font-family: Georgia, "Times New Roman", serif;
      color: var(--page-muted);
      background: transparent;
      font-size: clamp(13px, 1.15vw, 17px);
      letter-spacing: 0.015em;
      cursor: pointer;
      transition: border-color 150ms ease, background 150ms ease;
    }

    .timestamp-input:hover,
    .timestamp-input:focus {
      border-color: rgba(122,61,96,0.2);
      background: rgba(255,255,255,0.28);
    }

    .timestamp-input::-webkit-calendar-picker-indicator { cursor: pointer; opacity: 0.68; }

    .page-header-actions {
      min-width: 0;
      display: flex;
      align-items: center;
      justify-content: flex-end;
      gap: 7px;
    }

    .template-select {
      width: 92px;
      height: 34px;
      border: 1px solid rgba(95,70,51,0.16);
      border-radius: 9px;
      padding: 0 27px 0 9px;
      color: var(--page-muted);
      background: rgba(255,255,255,0.3);
      cursor: pointer;
      font-size: 12px;
    }

    .page-action {
      flex: 0 0 auto;
      width: 38px;
      height: 38px;
      display: grid;
      place-items: center;
      border: 1px solid rgba(168,63,75,0.22);
      border-radius: 11px;
      color: var(--danger);
      background: rgba(168,63,75,0.1);
      box-shadow: 0 4px 12px rgba(117,37,47,0.08);
      cursor: pointer;
      transition: background 150ms ease, color 150ms ease, transform 150ms ease, box-shadow 150ms ease;
    }

    .page-action svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
    .page-action:hover { color: white; background: var(--danger); transform: translateY(-1px) scale(1.04); box-shadow: 0 7px 17px rgba(117,37,47,0.2); }

    .editor-toolbar {
      position: relative;
      z-index: 4;
      display: flex;
      align-items: center;
      gap: 5px;
      padding: 9px 0 7px;
      overflow-x: auto;
      scrollbar-width: none;
    }

    .editor-toolbar::-webkit-scrollbar { display: none; }

    .tool-button,
    .tool-colour-label,
    .tool-select {
      flex: 0 0 auto;
      min-width: 30px;
      height: 30px;
      border: 1px solid rgba(95, 70, 51, 0.12);
      border-radius: 8px;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      padding: 0 8px;
      color: var(--page-muted);
      background: rgba(255,255,255,0.38);
      cursor: pointer;
      transition: background 130ms ease, transform 130ms ease;
      font-size: 13px;
      font-weight: 650;
    }

    .tool-button:hover,
    .tool-colour-label:hover,
    .tool-select:hover { background: rgba(122,61,96,0.1); transform: translateY(-1px); }

    .tool-select {
      min-width: 74px;
      max-width: 112px;
      padding: 0 24px 0 8px;
      font-weight: 600;
    }

    .tool-select.size-select { width: 80px; min-width: 80px; max-width: 80px; }
    .tool-separator { width: 1px; height: 20px; background: rgba(89,68,51,0.14); flex: 0 0 auto; }

    .tool-colour-label input {
      position: absolute;
      opacity: 0;
      pointer-events: none;
    }

    .colour-dot {
      width: 15px;
      height: 15px;
      border-radius: 50%;
      border: 1px solid rgba(0,0,0,0.18);
      background: var(--picker-colour, #7a3d60);
    }

    .editor {
      position: relative;
      z-index: 4;
      flex: 1;
      min-height: 0;
      overflow-y: auto;
      padding: 6px 5px 58px;
      line-height: 1.78;
      font-family: Georgia, "Times New Roman", serif;
      font-size: clamp(15px, 1.25vw, 18px);
      color: var(--page-ink);
      caret-color: var(--accent);
      scrollbar-width: thin;
      scrollbar-color: rgba(122,61,96,0.28) transparent;
    }

    .editor:empty::before {
      content: attr(data-placeholder);
      color: var(--page-muted);
      opacity: 0.55;
      font-style: italic;
      pointer-events: none;
    }

    .editor h1, .editor h2, .editor h3 { line-height: 1.25; }
    .editor blockquote {
      margin: 12px 0;
      padding: 2px 0 2px 14px;
      border-left: 3px solid rgba(122,61,96,0.35);
      color: var(--page-muted);
    }

    .editor .sticker {
      display: inline-block;
      margin: 2px 5px;
      font-size: 2.1em;
      line-height: 1;
      vertical-align: middle;
      filter: drop-shadow(0 3px 3px rgba(0,0,0,0.12));
      transform: rotate(-2deg);
      user-select: all;
    }

    .page-footer {
      position: absolute;
      z-index: 6;
      left: 20px;
      right: 20px;
      bottom: 12px;
      display: flex;
      align-items: center;
      justify-content: space-between;
      pointer-events: none;
    }

    .page-number {
      position: absolute;
      left: 50%;
      transform: translateX(-50%);
      color: var(--page-muted);
      font-family: Georgia, "Times New Roman", serif;
      font-size: 13px;
    }

    .flip-button {
      pointer-events: auto;
      width: 42px;
      height: 42px;
      border: 1px solid rgba(100,76,57,0.18);
      border-radius: 50%;
      display: grid;
      place-items: center;
      color: #644e40;
      background: rgba(255,255,255,0.52);
      box-shadow: 0 5px 16px rgba(70,48,30,0.09);
      cursor: pointer;
      transition: transform 150ms ease, background 150ms ease;
    }

    .flip-button:hover:not(:disabled) { transform: scale(1.07); background: #fff; }
    .flip-button:disabled { opacity: 0.25; cursor: not-allowed; }
    .page-footer.right-footer { justify-content: flex-end; }

    .blank-page {
      align-items: center;
      justify-content: center;
      text-align: center;
    }

    .blank-page-card {
      position: relative;
      z-index: 4;
      max-width: 310px;
      padding: 26px;
      border: 1px dashed rgba(97,73,54,0.22);
      border-radius: 18px;
      color: #756153;
      background: rgba(255,255,255,0.26);
    }

    .blank-page-card .blank-icon { font-size: 38px; }
    .blank-page-card h3 { margin: 10px 0 5px; font-family: Georgia, "Times New Roman", serif; }
    .blank-page-card p { margin: 0 0 16px; font-size: 13px; line-height: 1.5; }

    .paper-button {
      border: 1px solid rgba(122,61,96,0.2);
      border-radius: 11px;
      padding: 10px 14px;
      color: #61324d;
      background: var(--accent-soft);
      cursor: pointer;
      font-weight: 700;
    }

    .flip-sheet {
      position: absolute;
      top: 0;
      bottom: 0;
      width: 50%;
      z-index: 30;
      pointer-events: none;
      backface-visibility: hidden;
      transform-style: preserve-3d;
      overflow: hidden;
    }

    .flip-sheet.next {
      left: 50%;
      transform-origin: left center;
      animation: flipNext 1400ms cubic-bezier(.16,.72,.22,1) forwards;
    }

    .flip-sheet.prev {
      left: 0;
      transform-origin: right center;
      animation: flipPrev 1400ms cubic-bezier(.16,.72,.22,1) forwards;
    }

    @keyframes flipNext {
      0% { transform: rotateY(0deg); filter: brightness(1); box-shadow: 0 0 0 rgba(35,22,14,0); }
      18% { transform: rotateY(-24deg); filter: brightness(0.96); box-shadow: -8px 5px 18px rgba(35,22,14,0.12); }
      48% { transform: rotateY(-88deg); filter: brightness(0.68); box-shadow: -28px 8px 45px rgba(35,22,14,0.26); }
      72% { transform: rotateY(-138deg); filter: brightness(0.82); box-shadow: -14px 6px 28px rgba(35,22,14,0.17); }
      100% { transform: rotateY(-180deg); filter: brightness(0.98); box-shadow: 0 0 0 rgba(35,22,14,0); }
    }

    @keyframes flipPrev {
      0% { transform: rotateY(0deg); filter: brightness(1); box-shadow: 0 0 0 rgba(35,22,14,0); }
      18% { transform: rotateY(24deg); filter: brightness(0.96); box-shadow: 8px 5px 18px rgba(35,22,14,0.12); }
      48% { transform: rotateY(88deg); filter: brightness(0.68); box-shadow: 28px 8px 45px rgba(35,22,14,0.26); }
      72% { transform: rotateY(138deg); filter: brightness(0.82); box-shadow: 14px 6px 28px rgba(35,22,14,0.17); }
      100% { transform: rotateY(180deg); filter: brightness(0.98); box-shadow: 0 0 0 rgba(35,22,14,0); }
    }

    /* Pickers and dialogs */
    .picker-popover {
      position: fixed;
      z-index: 120;
      width: min(360px, calc(100vw - 24px));
      max-height: 330px;
      overflow: auto;
      padding: 12px;
      border: 1px solid rgba(255,255,255,0.18);
      border-radius: 17px;
      background: rgba(44, 32, 40, 0.96);
      box-shadow: 0 20px 52px rgba(0,0,0,0.32);
      backdrop-filter: blur(18px);
      color: white;
    }

    .picker-section-title {
      margin: 2px 4px 8px;
      color: rgba(255,255,255,0.64);
      font-size: 11px;
      letter-spacing: 0.09em;
      text-transform: uppercase;
    }

    .picker-grid {
      display: grid;
      grid-template-columns: repeat(8, 1fr);
      gap: 4px;
    }

    .picker-grid.stickers { grid-template-columns: repeat(6, 1fr); }

    .picker-item {
      aspect-ratio: 1;
      border: 0;
      border-radius: 10px;
      display: grid;
      place-items: center;
      background: transparent;
      cursor: pointer;
      font-size: 22px;
    }

    .picker-grid.stickers .picker-item { font-size: 30px; }
    .picker-item:hover { background: rgba(255,255,255,0.1); transform: scale(1.08); }

    .modal-backdrop {
      position: fixed;
      inset: 0;
      z-index: 200;
      display: grid;
      place-items: center;
      padding: 20px;
      background: rgba(15, 10, 14, 0.62);
      backdrop-filter: blur(12px);
    }

    .modal {
      width: min(480px, 100%);
      max-height: min(720px, calc(100vh - 40px));
      overflow: auto;
      border: 1px solid rgba(255,255,255,0.5);
      border-radius: 22px;
      padding: 22px;
      background: linear-gradient(160deg, rgba(255,255,255,0.98), rgba(248,241,232,0.98));
      box-shadow: 0 30px 80px rgba(0,0,0,0.38);
    }

    .modal-header {
      display: flex;
      align-items: flex-start;
      justify-content: space-between;
      gap: 15px;
      margin-bottom: 18px;
    }

    .modal-title { margin: 0; font-family: Georgia, "Times New Roman", serif; font-size: 28px; }
    .modal-subtitle { margin: 5px 0 0; color: var(--muted-ink); font-size: 13px; line-height: 1.5; }

    .modal-close {
      flex: 0 0 auto;
      width: 36px;
      height: 36px;
      border: 0;
      border-radius: 10px;
      background: rgba(122,61,96,0.08);
      cursor: pointer;
    }

    .field { margin-bottom: 14px; }
    .field label { display: block; margin: 0 0 7px; color: #5e4c40; font-size: 13px; font-weight: 700; }

    .field input[type="text"],
    .field input[type="password"],
    .field input[type="datetime-local"] {
      width: 100%;
      height: 46px;
      border: 1px solid rgba(80,60,45,0.18);
      border-radius: 11px;
      padding: 0 13px;
      color: var(--ink);
      background: rgba(255,255,255,0.72);
    }

    .field-note { margin: 6px 0 0; color: var(--muted-ink); font-size: 12px; line-height: 1.45; }


    .appearance-grid {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 10px;
      margin-bottom: 14px;
    }

    .colour-setting {
      padding: 12px;
      border: 1px solid rgba(80,60,45,0.13);
      border-radius: 14px;
      background: rgba(255,255,255,0.42);
    }

    .colour-setting label {
      display: block;
      margin-bottom: 8px;
      color: #5e4c40;
      font-size: 13px;
      font-weight: 700;
    }

    .colour-setting-control {
      display: flex;
      align-items: center;
      gap: 10px;
    }

    .colour-setting input[type="color"] {
      flex: 0 0 auto;
      width: 48px;
      height: 40px;
      border: 1px solid rgba(80,60,45,0.18);
      border-radius: 10px;
      padding: 3px;
      background: white;
      cursor: pointer;
    }

    .colour-value {
      min-width: 0;
      color: var(--muted-ink);
      font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
      font-size: 12px;
      text-transform: uppercase;
    }

    .switch-row {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 16px;
      padding: 14px;
      border: 1px solid rgba(80,60,45,0.13);
      border-radius: 14px;
      background: rgba(255,255,255,0.42);
    }

    .switch-copy strong { display: block; font-size: 14px; }
    .switch-copy span { color: var(--muted-ink); font-size: 12px; }

    .switch {
      position: relative;
      width: 48px;
      height: 28px;
      flex: 0 0 auto;
    }

    .switch input { position: absolute; opacity: 0; }
    .switch-track {
      position: absolute;
      inset: 0;
      border-radius: 999px;
      background: #c9c0b8;
      transition: background 160ms ease;
      cursor: pointer;
    }

    .switch-track::after {
      content: "";
      position: absolute;
      width: 22px;
      height: 22px;
      left: 3px;
      top: 3px;
      border-radius: 50%;
      background: white;
      box-shadow: 0 2px 6px rgba(0,0,0,0.2);
      transition: transform 160ms ease;
    }

    .switch input:checked + .switch-track { background: var(--accent); }
    .switch input:checked + .switch-track::after { transform: translateX(20px); }

    .security-fields {
      margin-top: 14px;
      padding: 14px;
      border-radius: 14px;
      background: rgba(122,61,96,0.055);
    }

    .modal-actions {
      display: flex;
      justify-content: flex-end;
      gap: 9px;
      margin-top: 20px;
    }

    .dialog-button {
      min-height: 42px;
      border: 1px solid rgba(80,60,45,0.16);
      border-radius: 11px;
      padding: 0 16px;
      background: white;
      cursor: pointer;
      font-weight: 700;
    }

    .dialog-button.primary { color: white; background: var(--accent); border-color: var(--accent); }
    .dialog-button.danger { color: white; background: var(--danger); border-color: var(--danger); }

    .dialog-message {
      margin: 0 0 14px;
      padding: 11px 13px;
      border-radius: 11px;
      background: rgba(122,61,96,0.07);
      color: #614e42;
      font-size: 13px;
      line-height: 1.5;
    }

    .dialog-message.error { background: rgba(168,63,75,0.1); color: #8e2f3a; }

    .data-grid {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 10px;
      margin-top: 12px;
    }

    .data-card {
      border: 1px solid rgba(80,60,45,0.13);
      border-radius: 14px;
      padding: 15px;
      background: rgba(255,255,255,0.46);
    }

    .data-card strong { display: block; margin-bottom: 5px; }
    .data-card p { margin: 0 0 12px; color: var(--muted-ink); font-size: 12px; line-height: 1.45; }
    .data-card button { width: 100%; }

    .toast-stack {
      position: fixed;
      z-index: 500;
      right: 18px;
      bottom: 18px;
      display: flex;
      flex-direction: column;
      gap: 8px;
      pointer-events: none;
    }

    .toast {
      max-width: min(360px, calc(100vw - 36px));
      padding: 11px 14px;
      border: 1px solid rgba(255,255,255,0.16);
      border-radius: 12px;
      color: white;
      background: rgba(35,27,32,0.93);
      box-shadow: 0 12px 28px rgba(0,0,0,0.28);
      animation: toastIn 180ms ease both;
      font-size: 13px;
    }

    .toast.error { background: rgba(128, 42, 52, 0.97); }
    @keyframes toastIn { from { opacity: 0; transform: translateY(8px); } }

    .file-input { display: none; }

    @media (max-width: 950px) {
      .button-label { display: none; }
      .topbar-button { width: 40px; padding: 0; }
      .page { padding-left: 20px; padding-right: 20px; }
      .tool-select { min-width: 72px; max-width: 96px; }
      .tool-select.size-select { width: 80px; min-width: 80px; max-width: 80px; }
    }

    @media (max-width: 760px), (max-height: 520px) and (pointer: coarse) {
      body {
        width: 100%;
        min-height: var(--viewport-height);
        overflow: hidden;
        -webkit-text-size-adjust: 100%;
      }

      .app-shell {
        width: 100%;
        height: var(--viewport-height);
        min-width: 0;
        overflow: hidden;
      }

      .ambient-orb { opacity: 0.34; }
      .orb-one { width: 230px; height: 230px; }
      .orb-two { width: 250px; height: 250px; }

      .cover-scene {
        position: absolute;
        min-width: 0;
        padding:
          calc(68px + var(--safe-top))
          calc(18px + var(--safe-right))
          calc(72px + var(--safe-bottom))
          calc(18px + var(--safe-left));
      }

      .cover-actions {
        top: calc(12px + var(--safe-top));
        right: calc(12px + var(--safe-right));
      }

      .glass-button {
        min-width: 44px;
        height: 44px;
        border-radius: 13px;
      }

      .cover-wrap {
        width: min(84vw, 350px, calc((var(--viewport-height) - 180px) * 0.73));
        max-height: calc(var(--viewport-height) - 180px);
      }

      .cover-content {
        gap: 11px;
        padding: 38px 34px;
      }

      .cover-emblem { width: 62px; height: 62px; font-size: 27px; }
      .cover-title { font-size: clamp(30px, 9.5vw, 43px); }
      .cover-pages { font-size: 12px; }
      .cover-lock-status { margin-top: 7px; }
      .cover-hint { bottom: -48px; width: min(330px, 88vw); font-size: 12px; }

      .book-view {
        min-width: 0;
        min-height: 0;
        width: 100%;
        height: var(--viewport-height);
        gap: 8px;
        padding:
          calc(7px + var(--safe-top))
          calc(7px + var(--safe-right))
          calc(7px + var(--safe-bottom))
          calc(7px + var(--safe-left));
      }

      .topbar {
        min-height: 52px;
        grid-template-columns: 44px minmax(0, 1fr) auto;
        gap: 6px;
        padding: 4px;
        border-radius: 14px;
      }

      .topbar-group { gap: 5px; }
      .topbar-title { font-size: clamp(16px, 5vw, 21px); }
      .topbar-button {
        width: 44px;
        min-width: 44px;
        height: 44px;
        padding: 0;
        border-radius: 11px;
        font-size: 18px;
      }
      .button-label { display: none; }

      .save-indicator {
        top: calc(67px + var(--safe-top));
        max-width: calc(100vw - 28px);
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
      }

      .book-stage {
        min-height: 0;
        perspective: 1500px;
      }

      .book-shadow { left: 3%; right: 3%; height: 10%; filter: blur(18px); }

      .open-book,
      .open-book.mobile-book {
        display: grid;
        grid-template-columns: minmax(0, 1fr);
        overflow: hidden;
        border-radius: 13px 13px 18px 18px;
        touch-action: pan-y;
      }

      .open-book::before { border-width: 4px; }
      .centre-crease { display: none; }
      .mobile-hidden { display: none !important; }

      .page,
      .page.single {
        width: 100%;
        height: 100%;
        min-width: 0;
        min-height: 0;
        padding: 13px 12px 8px;
        border-radius: 10px 10px 15px 15px;
        box-shadow: inset 0 0 34px rgba(91, 67, 40, 0.1);
      }

      .page.single::before,
      .page.single::after { display: none; }

      .page.template-ruled {
        background:
          linear-gradient(var(--paper-line) 1px, transparent 1px) 0 112px / 100% 29px,
          radial-gradient(circle at 15% 10%, rgba(255,255,255,0.42), transparent 28%),
          linear-gradient(100deg, var(--paper-deep) 0%, var(--paper) 10%, var(--paper-highlight) 100%);
      }

      .page-header {
        min-height: 44px;
        gap: 8px;
        padding-bottom: 8px;
      }

      .timestamp-input {
        flex: 1 1 auto;
        width: auto;
        min-width: 0;
        height: 42px;
        padding: 0 7px;
        font-size: 16px;
        background: rgba(255,255,255,0.22);
      }

      .page-header-actions { flex: 0 0 auto; gap: 5px; }
      .template-select {
        width: 92px;
        height: 42px;
        padding: 0 23px 0 8px;
        font-size: 16px;
      }

      .page-action {
        width: 42px;
        height: 42px;
        border-radius: 10px;
      }

      .editor-toolbar {
        gap: 6px;
        padding: 8px 0;
        scroll-snap-type: x proximity;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior-inline: contain;
      }

      .tool-button,
      .tool-colour-label,
      .tool-select {
        min-width: 38px;
        height: 38px;
        border-radius: 9px;
        scroll-snap-align: start;
        font-size: 15px;
      }

      .tool-select {
        min-width: 94px;
        max-width: 112px;
        padding: 0 26px 0 9px;
        font-size: 16px;
      }

      .tool-select.size-select { width: 90px; min-width: 90px; max-width: 90px; }
      .tool-separator { height: 25px; }

      .editor {
        min-height: 0;
        padding: 7px 5px 64px;
        font-size: 16px;
        line-height: 1.7;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
        touch-action: pan-y;
      }

      .page-footer {
        left: 12px;
        right: 12px;
        bottom: 8px;
      }

      .mobile-page-footer { justify-content: space-between; }
      .mobile-page-footer .page-number {
        max-width: calc(100% - 112px);
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        font-size: 12px;
      }

      .flip-button { width: 46px; height: 46px; font-size: 20px; }

      .flip-sheet.mobile-flip {
        left: 0;
        width: 100%;
        border-radius: 10px 10px 15px 15px;
      }

      .flip-sheet.next.mobile-flip { left: 0; transform-origin: left center; }
      .flip-sheet.prev.mobile-flip { left: 0; transform-origin: right center; }

      .picker-popover {
        left: calc(8px + var(--safe-left)) !important;
        right: calc(8px + var(--safe-right));
        top: auto !important;
        bottom: calc(8px + var(--safe-bottom));
        width: auto;
        max-height: min(46vh, 360px);
        border-radius: 18px;
        -webkit-overflow-scrolling: touch;
      }

      .picker-item { min-height: 48px; }

      .modal-overlay {
        align-items: end;
        padding:
          calc(10px + var(--safe-top))
          calc(8px + var(--safe-right))
          calc(8px + var(--safe-bottom))
          calc(8px + var(--safe-left));
      }

      .modal {
        width: 100%;
        max-height: min(88vh, calc(var(--viewport-height) - var(--safe-top) - 18px));
        padding: 19px 16px;
        border-radius: 22px 22px 15px 15px;
        -webkit-overflow-scrolling: touch;
      }

      .modal-title { font-size: 25px; }
      .field input[type="text"],
      .field input[type="password"],
      .field input[type="datetime-local"] { font-size: 16px; }

      .appearance-grid,
      .data-grid { grid-template-columns: 1fr; }

      .modal-actions {
        position: sticky;
        bottom: -19px;
        padding: 11px 0 4px;
        background: linear-gradient(transparent, rgba(248,241,232,0.98) 25%);
      }

      .dialog-button { min-height: 46px; flex: 1 1 auto; }

      .toast-stack {
        right: calc(10px + var(--safe-right));
        bottom: calc(10px + var(--safe-bottom));
        left: calc(10px + var(--safe-left));
        align-items: stretch;
      }

      .toast { max-width: none; text-align: center; }
    }

    @media (max-width: 420px) {
      .cover-actions .glass-button span { display: none; }
      .cover-content { padding: 30px 26px; }
      .cover-lock-status { max-width: 92%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
      .topbar-title { font-size: 16px; }
      .page { padding-inline: 9px; }
      .timestamp-input { font-size: 14px; }
      .template-select { width: 84px; font-size: 14px; }
      .page-action { width: 40px; }
    }

    @media (max-height: 520px) and (pointer: coarse) {
      .cover-scene { padding-top: calc(54px + var(--safe-top)); padding-bottom: calc(42px + var(--safe-bottom)); }
      .cover-wrap { width: min(60vw, 245px, calc((var(--viewport-height) - 100px) * 0.73)); max-height: calc(var(--viewport-height) - 100px); }
      .cover-content { padding: 23px; }
      .cover-emblem { width: 45px; height: 45px; font-size: 21px; }
      .cover-title { font-size: 27px; }
      .cover-lock-status { margin-top: 2px; }
      .cover-hint { display: none; }
      .book-view { gap: 5px; }
      .topbar { min-height: 48px; }
      .topbar-button { width: 40px; min-width: 40px; height: 40px; }
      .page-header { min-height: 39px; }
      .timestamp-input, .template-select, .page-action { height: 38px; }
      .editor-toolbar { padding: 5px 0; }
      .tool-button, .tool-colour-label, .tool-select { height: 34px; }
      .flip-button { width: 40px; height: 40px; }
    }

    @media (prefers-reduced-motion: reduce) {
      *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; }
    }

/* Appointments, notifications and dinklets rewards */
.cover-dinklets {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  padding: 6px 12px;
  border: 1px solid rgba(247, 223, 156, 0.28);
  border-radius: 999px;
  color: var(--gold-light);
  background: rgba(30, 12, 24, 0.24);
  font-size: 13px;
  font-weight: 750;
  letter-spacing: 0.035em;
}

.topbar-heading {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
}

.topbar-heading .topbar-title { flex: 0 1 auto; }

.topbar-dinklets {
  flex: 0 0 auto;
  padding: 4px 8px;
  border: 1px solid rgba(247, 223, 156, 0.2);
  border-radius: 999px;
  color: var(--gold-light);
  background: rgba(215, 178, 109, 0.12);
  font-size: 11px;
  font-weight: 800;
}

.icon-badge-button { position: relative; }

.notification-badge,
.action-count {
  position: absolute;
  display: grid;
  place-items: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border: 2px solid #33232d;
  border-radius: 999px;
  color: #fff;
  background: #cf4655;
  box-shadow: 0 3px 8px rgba(80, 18, 31, 0.3);
  font-size: 9px;
  font-weight: 850;
  line-height: 1;
}

.notification-badge { top: -6px; right: -6px; }
.action-count { top: -7px; right: -7px; border-color: var(--paper); }

.page-action.utility-action {
  position: relative;
  border-color: rgba(90, 70, 52, 0.18);
  color: var(--accent);
  background: rgba(122, 61, 96, 0.075);
  box-shadow: 0 4px 12px rgba(70, 45, 62, 0.07);
}

.page-action.utility-action:hover {
  color: #fff;
  background: var(--accent);
  box-shadow: 0 7px 17px rgba(80, 42, 65, 0.2);
}

.share-network-icon circle {
  fill: currentColor;
  stroke: none;
}

.share-network-icon path {
  fill: none;
  stroke: currentColor;
}

.page-footer-centre {
  position: absolute;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  max-width: calc(100% - 104px);
  color: var(--page-muted);
  text-align: center;
  pointer-events: none;
}

.page-footer-centre .page-number {
  position: static;
  transform: none;
  line-height: 1.1;
}

.page-stats {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  white-space: nowrap;
  font-size: 10px;
  opacity: 0.82;
}

.page-dinklets {
  color: var(--accent);
  font-weight: 850;
}

.footer-spacer { width: 42px; height: 42px; }

.decorated-page {
  box-shadow: inset 0 0 0 5px var(--washi-primary), inset 0 0 42px rgba(91, 67, 40, 0.11);
}

.page.decorated-page.left {
  box-shadow: inset 0 0 0 5px var(--washi-primary), inset -26px 0 34px -28px rgba(45, 30, 21, 0.9), inset 0 0 42px rgba(91,67,40,0.1);
}

.page.decorated-page.right {
  box-shadow: inset 0 0 0 5px var(--washi-primary), inset 26px 0 34px -28px rgba(45, 30, 21, 0.9), inset 0 0 42px rgba(91,67,40,0.1);
}

.washi-strip {
  position: absolute;
  z-index: 7;
  top: 0;
  left: 0;
  right: 0;
  height: 14px;
  border-bottom: 1px solid rgba(42, 31, 23, 0.12);
  pointer-events: none;
}

.washi-divider {
  position: absolute;
  z-index: 3;
  top: 105px;
  left: 7%;
  right: 7%;
  height: 4px;
  border-radius: 999px;
  background: linear-gradient(90deg, transparent, var(--washi-primary), var(--washi-secondary), var(--washi-primary), transparent);
  opacity: 0.7;
  pointer-events: none;
}

.pattern-stripes {
  background: repeating-linear-gradient(45deg, var(--washi-primary) 0 9px, var(--washi-secondary) 9px 18px);
}
.pattern-dots {
  background-color: var(--washi-secondary);
  background-image: radial-gradient(circle, var(--washi-primary) 0 2px, transparent 2.5px);
  background-size: 13px 13px;
}
.pattern-leaves {
  background: radial-gradient(ellipse at 20% 50%, var(--washi-secondary) 0 5px, transparent 6px) 0 0 / 24px 14px, var(--washi-primary);
}
.pattern-clouds {
  background: radial-gradient(circle at 30% 65%, var(--washi-secondary) 0 5px, transparent 6px) 0 0 / 30px 14px, var(--washi-primary);
}
.pattern-checks {
  background-color: var(--washi-secondary);
  background-image: linear-gradient(45deg, var(--washi-primary) 25%, transparent 25%, transparent 75%, var(--washi-primary) 75%), linear-gradient(45deg, var(--washi-primary) 25%, transparent 25%, transparent 75%, var(--washi-primary) 75%);
  background-position: 0 0, 7px 7px;
  background-size: 14px 14px;
}
.pattern-waves {
  background: repeating-radial-gradient(ellipse at 50% 115%, var(--washi-secondary) 0 5px, var(--washi-primary) 6px 10px);
}
.pattern-floral {
  background-color: var(--washi-secondary);
  background-image: radial-gradient(circle, var(--washi-primary) 0 3px, transparent 3.5px), radial-gradient(circle, #fff 0 2px, transparent 2.5px);
  background-position: 0 0, 9px 6px;
  background-size: 18px 12px;
}
.pattern-stars {
  background: linear-gradient(90deg, var(--washi-primary), #414a85, var(--washi-primary));
  box-shadow: inset 0 0 0 1px var(--washi-secondary);
}
.pattern-aurora {
  background: linear-gradient(90deg, var(--washi-primary), var(--washi-secondary), #66b6a8, var(--washi-primary));
}
.pattern-diamonds {
  background-color: var(--washi-primary);
  background-image: linear-gradient(45deg, transparent 42%, var(--washi-secondary) 43% 57%, transparent 58%);
  background-size: 20px 20px;
}

.page-marker {
  position: absolute;
  z-index: 14;
  top: 118px;
  width: 36px;
  height: 54px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255,255,255,0.42);
  color: #fff;
  background: var(--marker-colour);
  box-shadow: 0 7px 15px rgba(40, 25, 31, 0.2);
  font-size: 17px;
  font-weight: 900;
  pointer-events: none;
}
.page-marker.marker-right { right: 0; border-radius: 11px 0 0 11px; }
.page-marker.marker-left { left: 0; border-radius: 0 11px 11px 0; }

.picker-shop-button {
  width: 100%;
  min-height: 40px;
  margin-top: 10px;
  border: 1px solid rgba(247, 223, 156, 0.22);
  border-radius: 11px;
  color: var(--gold-light);
  background: rgba(215, 178, 109, 0.1);
  cursor: pointer;
  font-weight: 750;
}

.dialog-select {
  width: 100%;
  height: 46px;
  border: 1px solid rgba(80,60,45,0.18);
  border-radius: 11px;
  padding: 0 35px 0 13px;
  color: var(--ink);
  background: rgba(255,255,255,0.72);
}

.field-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
  gap: 10px;
}

.form-panel,
.reminder-note {
  margin-top: 14px;
  padding: 14px;
  border: 1px solid rgba(80,60,45,0.13);
  border-radius: 15px;
  background: rgba(255,255,255,0.45);
}
.form-panel h3 { margin: 0 0 13px; font-family: Georgia, "Times New Roman", serif; }
.full-width { width: 100%; }

.appointment-list,
.notification-list {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.appointment-item,
.notification-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: start;
  gap: 11px;
  padding: 12px;
  border: 1px solid rgba(80,60,45,0.12);
  border-radius: 14px;
  background: rgba(255,255,255,0.52);
}
.appointment-item.past { opacity: 0.7; }
.appointment-icon,
.notification-symbol {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 11px;
  background: rgba(122,61,96,0.09);
  font-size: 19px;
}
.appointment-copy,
.notification-copy { min-width: 0; }
.appointment-copy strong,
.appointment-copy span,
.appointment-copy small { display: block; }
.appointment-copy span { margin-top: 3px; color: #5d4b40; font-size: 13px; }
.appointment-copy small { margin-top: 4px; color: var(--muted-ink); }

.mini-icon-button {
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 10px;
  background: rgba(122,61,96,0.07);
  cursor: pointer;
}
.mini-icon-button.danger { background: rgba(168,63,75,0.09); }

.reminder-note strong { font-size: 13px; }
.reminder-note p { margin: 5px 0 10px; color: var(--muted-ink); font-size: 12px; line-height: 1.5; }
.text-button {
  border: 0;
  padding: 4px 0;
  color: var(--accent);
  background: transparent;
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
}
.text-button:disabled { opacity: 0.45; cursor: default; }
.danger-link { color: var(--danger) !important; }

.empty-state-card {
  padding: 24px;
  border: 1px dashed rgba(80,60,45,0.2);
  border-radius: 15px;
  text-align: center;
  background: rgba(255,255,255,0.34);
}
.empty-state-card > span { display: block; margin-bottom: 7px; font-size: 31px; }
.empty-state-card strong { display: block; }
.empty-state-card p { margin: 6px auto 0; max-width: 350px; color: var(--muted-ink); font-size: 12px; line-height: 1.5; }

.notification-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.notification-toolbar > div { display: flex; gap: 12px; }
.notification-item { grid-template-columns: auto minmax(0, 1fr); }
.notification-item.unread { border-color: rgba(122,61,96,0.28); background: rgba(122,61,96,0.065); }
.notification-heading { display: flex; align-items: center; gap: 7px; }
.notification-copy p { margin: 5px 0; color: #5f4d42; font-size: 13px; line-height: 1.45; }
.notification-copy small { color: var(--muted-ink); }
.unread-dot { width: 8px; height: 8px; border-radius: 50%; background: #c34c68; }
.notification-actions { display: flex; flex-wrap: wrap; gap: 11px; margin-top: 8px; }
.notification-actions button { border: 0; padding: 0; color: var(--accent); background: transparent; cursor: pointer; font-size: 11px; font-weight: 800; }

#modalRoot .modal:has(.shop-section) { width: min(980px, 100%); }
#modalRoot .modal:has(.decoration-section) { width: min(720px, 100%); }
#modalRoot .modal:has(.notification-list) { width: min(680px, 100%); }
#modalRoot .modal:has(.appointment-list) { width: min(620px, 100%); }

.wallet-card {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 9px;
  margin-bottom: 14px;
}
.wallet-card > div {
  padding: 13px;
  border: 1px solid rgba(122,61,96,0.13);
  border-radius: 14px;
  background: linear-gradient(145deg, rgba(122,61,96,0.08), rgba(215,178,109,0.08));
}
.wallet-card span { display: block; color: var(--muted-ink); font-size: 10px; text-transform: uppercase; letter-spacing: 0.06em; }
.wallet-card strong { display: block; margin-top: 4px; color: var(--accent); font-size: 21px; }

.shop-section { margin-top: 22px; }
.shop-section-heading { display: flex; align-items: end; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.shop-section-heading h3 { margin: 0; font-family: Georgia, "Times New Roman", serif; font-size: 20px; }
.shop-section-heading p { margin: 3px 0 0; color: var(--muted-ink); font-size: 12px; }
.shop-section-heading > span { color: var(--muted-ink); font-size: 11px; }
.shop-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 9px;
}
.shop-card {
  min-width: 0;
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  padding: 10px;
  border: 1px solid rgba(80,60,45,0.13);
  border-radius: 14px;
  background: rgba(255,255,255,0.48);
}
.shop-card.owned { background: rgba(103,143,111,0.08); }
.shop-preview {
  width: 52px;
  height: 44px;
  border: 1px solid rgba(80,60,45,0.12);
  border-radius: 11px;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: #fff;
}
.sticker-preview { font-size: 29px; }
.washi-preview { background-color: var(--preview-secondary); }
.washi-preview.pattern-stripes { background: repeating-linear-gradient(45deg, var(--preview-primary) 0 9px, var(--preview-secondary) 9px 18px); }
.washi-preview.pattern-dots { background-color: var(--preview-secondary); background-image: radial-gradient(circle, var(--preview-primary) 0 2px, transparent 2.5px); background-size: 13px 13px; }
.washi-preview.pattern-leaves,
.washi-preview.pattern-clouds,
.washi-preview.pattern-waves,
.washi-preview.pattern-floral,
.washi-preview.pattern-stars,
.washi-preview.pattern-aurora,
.washi-preview.pattern-checks,
.washi-preview.pattern-diamonds { background: linear-gradient(135deg, var(--preview-primary), var(--preview-secondary), var(--preview-primary)); }
.marker-preview { color: #fff; background: var(--preview-primary); font-size: 20px; font-weight: 900; }
.none-preview { color: var(--muted-ink); font-size: 10px; }
.shop-card-copy { min-width: 0; }
.shop-card-copy strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.tier-tag { display: inline-block; margin-top: 4px; padding: 2px 6px; border-radius: 999px; color: #635145; background: rgba(90,70,52,0.08); font-size: 9px; font-weight: 800; text-transform: uppercase; }
.tier-tag.exotic { color: #71426d; background: rgba(125,71,120,0.13); }
.tier-tag.starter { color: #527059; background: rgba(89,130,99,0.13); }
.shop-card > button {
  min-width: 53px;
  height: 34px;
  border: 1px solid rgba(122,61,96,0.17);
  border-radius: 9px;
  color: #fff;
  background: var(--accent);
  cursor: pointer;
  font-size: 11px;
  font-weight: 850;
}
.shop-card > button:disabled { color: var(--muted-ink); background: rgba(90,70,52,0.07); cursor: default; }

.decoration-section { margin-top: 16px; }
.decoration-section h3 { margin: 0 0 9px; font-family: Georgia, "Times New Roman", serif; }
.decoration-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 9px; }
.decoration-option {
  min-width: 0;
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  align-items: center;
  gap: 9px;
  padding: 9px;
  border: 2px solid transparent;
  border-radius: 13px;
  background: rgba(255,255,255,0.45);
  cursor: pointer;
}
.decoration-option.selected { border-color: var(--accent); background: rgba(122,61,96,0.08); }
.decoration-option input { position: absolute; opacity: 0; }
.decoration-option span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; font-weight: 750; }
.shop-link-button { width: 100%; margin-top: 15px; padding: 11px; border: 1px solid rgba(122,61,96,0.14); border-radius: 11px; background: rgba(122,61,96,0.06); }

@media (max-width: 950px) {
  .shop-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .topbar-heading { gap: 5px; }
  .topbar-dinklets { padding-inline: 6px; }
}

@media (max-width: 760px), (max-height: 520px) and (pointer: coarse) {
  .cover-dinklets { min-height: 27px; padding: 4px 9px; font-size: 11px; }
  .topbar-heading { flex-direction: column; gap: 0; line-height: 1; }
  .topbar-dinklets { border: 0; padding: 2px 4px; background: transparent; font-size: 9px; }
  .page-header { align-items: flex-start; }
  .page-header-actions { max-width: 56%; overflow-x: auto; padding: 1px 1px 4px; scrollbar-width: none; }
  .page-header-actions::-webkit-scrollbar { display: none; }
  .washi-divider { top: 116px; }
  .page-marker { top: 124px; width: 31px; height: 48px; }
  .page-footer-centre { max-width: calc(100% - 104px); }
  .page-stats { gap: 5px; font-size: 9px; }
  .field-grid,
  .wallet-card { grid-template-columns: 1fr; }
  .shop-grid { grid-template-columns: 1fr; }
  .decoration-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .notification-toolbar { align-items: flex-start; flex-direction: column; }
  .notification-toolbar > div { width: 100%; justify-content: space-between; }
  .appointment-item { grid-template-columns: auto minmax(0, 1fr) auto; }
  .shop-card { grid-template-columns: 48px minmax(0, 1fr) auto; }
  .shop-preview { width: 48px; }
}

@media (max-width: 420px) {
  .topbar-group.right { gap: 3px; }
  .topbar-button { width: 40px; min-width: 40px; }
  .topbar-heading .topbar-title { max-width: 55px; }
  .page-header-actions { max-width: 60%; }
  .decoration-grid { grid-template-columns: 1fr; }
  .appointment-item { grid-template-columns: 34px minmax(0, 1fr) 36px; gap: 7px; padding: 9px; }
  .appointment-icon, .notification-symbol { width: 34px; height: 34px; }
  .page-footer-centre { max-width: calc(100% - 94px); }
}

/* Dinklets shop tiers, purchasable templates/fonts, and movable decorations */
.page.template-dotted {
  background:
    radial-gradient(circle, color-mix(in srgb, var(--page-ink) 23%, transparent) 0 1.1px, transparent 1.4px) 0 105px / 22px 22px,
    radial-gradient(circle at 15% 10%, rgba(255,255,255,0.42), transparent 28%),
    linear-gradient(100deg, var(--paper-deep) 0%, var(--paper) 10%, var(--paper-highlight) 100%);
}

.page.template-grid {
  background:
    linear-gradient(color-mix(in srgb, var(--page-ink) 15%, transparent) 1px, transparent 1px) 0 105px / 24px 24px,
    linear-gradient(90deg, color-mix(in srgb, var(--page-ink) 15%, transparent) 1px, transparent 1px) 0 105px / 24px 24px,
    radial-gradient(circle at 15% 10%, rgba(255,255,255,0.42), transparent 28%),
    linear-gradient(100deg, var(--paper-deep) 0%, var(--paper) 10%, var(--paper-highlight) 100%);
}

.page.template-parchment {
  background:
    radial-gradient(circle at 18% 22%, rgba(129, 87, 42, 0.08) 0 2px, transparent 3px) 0 0 / 36px 39px,
    radial-gradient(circle at 80% 70%, rgba(116, 73, 32, 0.07) 0 1px, transparent 2px) 0 0 / 29px 31px,
    linear-gradient(90deg, rgba(128, 83, 38, 0.08), transparent 12%, transparent 88%, rgba(128, 83, 38, 0.08)),
    linear-gradient(100deg, color-mix(in srgb, var(--paper-deep) 82%, #d7b77c) 0%, color-mix(in srgb, var(--paper) 88%, #f4dfb6) 10%, color-mix(in srgb, var(--paper-highlight) 88%, #fff1cf) 100%);
}

.page.template-cornell {
  background:
    linear-gradient(90deg, transparent 0 25%, rgba(174, 77, 77, 0.34) 25% calc(25% + 1px), transparent calc(25% + 1px)),
    linear-gradient(var(--paper-line) 1px, transparent 1px) 0 105px / 100% 30px,
    linear-gradient(0deg, rgba(174, 77, 77, 0.27) 0 1px, transparent 1px) 0 calc(100% - 112px) / 100% 100%,
    radial-gradient(circle at 15% 10%, rgba(255,255,255,0.42), transparent 28%),
    linear-gradient(100deg, var(--paper-deep) 0%, var(--paper) 10%, var(--paper-highlight) 100%);
}

.page.template-starlight {
  background:
    radial-gradient(circle at 12% 18%, rgba(255,255,255,0.85) 0 1px, transparent 1.5px) 0 0 / 34px 31px,
    radial-gradient(circle at 78% 42%, rgba(224, 195, 112, 0.75) 0 1.2px, transparent 1.8px) 0 0 / 47px 43px,
    linear-gradient(145deg, #202846, #37335d 52%, #222b4d);
  color: #f5f0df;
  --page-ink: #f5f0df;
  --page-muted: #d4caac;
  --paper-line: rgba(255,255,255,0.1);
}

.page.template-botanical {
  background:
    radial-gradient(ellipse at 7% 14%, rgba(92, 137, 91, 0.16) 0 11px, transparent 12px) 0 0 / 58px 72px,
    radial-gradient(ellipse at 94% 80%, rgba(117, 155, 105, 0.14) 0 13px, transparent 14px) 0 0 / 66px 78px,
    linear-gradient(var(--paper-line) 1px, transparent 1px) 0 105px / 100% 30px,
    linear-gradient(100deg, color-mix(in srgb, var(--paper-deep) 88%, #d9ead5) 0%, color-mix(in srgb, var(--paper) 92%, #edf7e9) 10%, color-mix(in srgb, var(--paper-highlight) 94%, #f7fff3) 100%);
}

.sticker-layer {
  position: absolute;
  z-index: 9;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.draggable-sticker {
  position: absolute;
  display: grid;
  place-items: center;
  min-width: 46px;
  min-height: 46px;
  padding: 4px;
  border: 1px solid transparent;
  border-radius: 14px;
  transform: translate(-50%, -50%) rotate(-2deg);
  font-size: clamp(30px, 3.2vw, 46px);
  line-height: 1;
  filter: drop-shadow(0 5px 5px rgba(0,0,0,0.18));
  cursor: grab;
  user-select: none;
  touch-action: none;
  pointer-events: auto;
  transition: border-color 130ms ease, background 130ms ease, transform 130ms ease, filter 130ms ease;
}

.draggable-sticker:nth-child(even) { transform: translate(-50%, -50%) rotate(3deg); }
.draggable-sticker:hover,
.draggable-sticker:focus,
.draggable-sticker:focus-within {
  outline: none;
  border-color: rgba(122,61,96,0.3);
  background: rgba(255,255,255,0.62);
  filter: drop-shadow(0 8px 8px rgba(0,0,0,0.2));
}
.draggable-sticker.dragging {
  z-index: 20;
  cursor: grabbing;
  transform: translate(-50%, -50%) rotate(0deg) scale(1.1);
}

.sticker-remove {
  position: absolute;
  top: -9px;
  right: -9px;
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 2px solid rgba(255,255,255,0.9);
  border-radius: 50%;
  color: #fff;
  background: #9e3e50;
  box-shadow: 0 4px 10px rgba(69,25,34,0.25);
  cursor: pointer;
  font-size: 16px;
  font-weight: 900;
  line-height: 1;
  opacity: 0;
  transform: scale(0.75);
  pointer-events: none;
  transition: opacity 120ms ease, transform 120ms ease;
}
.draggable-sticker:hover .sticker-remove,
.draggable-sticker:focus .sticker-remove,
.draggable-sticker:focus-within .sticker-remove {
  opacity: 1;
  transform: scale(1);
  pointer-events: auto;
}

.page-header,
.editor-toolbar,
.page-footer { z-index: 12; }

.page-marker {
  pointer-events: auto;
  touch-action: none;
  cursor: ns-resize;
  user-select: none;
  transform: translateY(-50%);
  transition: filter 130ms ease, box-shadow 130ms ease;
}
.page-marker:hover,
.page-marker:focus,
.page-marker.dragging {
  outline: 2px solid rgba(255,255,255,0.8);
  outline-offset: -4px;
  filter: brightness(1.08);
  box-shadow: 0 10px 22px rgba(40,25,31,0.3);
}

.shop-tier-tabs {
  position: sticky;
  z-index: 3;
  top: -1px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin: 16px 0 10px;
  padding: 8px;
  border: 1px solid rgba(94,69,51,0.12);
  border-radius: 16px;
  background: rgba(252,248,240,0.94);
  backdrop-filter: blur(12px);
}

.shop-tier-tab {
  min-width: 0;
  min-height: 58px;
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  grid-template-rows: auto auto;
  align-items: center;
  column-gap: 7px;
  padding: 8px 9px;
  border: 1px solid transparent;
  border-radius: 12px;
  color: var(--muted-ink);
  background: transparent;
  cursor: pointer;
  font-size: 12px;
  font-weight: 850;
  text-align: left;
}
.shop-tier-tab > span {
  grid-row: 1 / 3;
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: rgba(122,61,96,0.55);
  font-size: 11px;
}
.shop-tier-tab small {
  overflow: hidden;
  color: var(--muted-ink);
  font-size: 9px;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.shop-tier-tab:hover { background: rgba(122,61,96,0.06); }
.shop-tier-tab.active {
  border-color: rgba(122,61,96,0.22);
  color: var(--accent);
  background: rgba(122,61,96,0.1);
  box-shadow: 0 5px 14px rgba(83,49,65,0.08);
}
.shop-tier-tab.active > span { background: var(--accent); }

.shop-tier-summary {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 11px 13px;
  border-radius: 13px;
  background: linear-gradient(135deg, rgba(122,61,96,0.08), rgba(215,178,109,0.1));
}
.shop-tier-summary strong { color: var(--accent); font-family: Georgia, "Times New Roman", serif; }
.shop-tier-summary span { color: var(--muted-ink); font-size: 11px; }
.shop-tier-summary b { color: var(--muted-ink); font-size: 10px; white-space: nowrap; }

.tier-tag.standard { color: #75621e; background: rgba(190,154,48,0.14); }
.tier-tag.premium { color: #3f6390; background: rgba(67,112,164,0.14); }
.tier-tag.exotic { color: #71426d; background: rgba(125,71,120,0.13); }
.tier-tag.starter { color: #527059; background: rgba(89,130,99,0.13); }
.negative-balance { color: var(--danger) !important; }

.template-preview {
  color: #6f5b4b;
  background:
    linear-gradient(rgba(100,80,60,0.12) 1px, transparent 1px) 0 8px / 100% 8px,
    #fffaf0;
  font-size: 24px;
}
.template-preview-unruled { background: #fffaf0; }
.template-preview-dotted { background: radial-gradient(circle, #9b8d7c 0 1px, transparent 1.4px) 0 0 / 8px 8px, #fffaf0; }
.template-preview-grid { background: linear-gradient(#c9bca9 1px, transparent 1px) 0 0 / 9px 9px, linear-gradient(90deg, #c9bca9 1px, transparent 1px) 0 0 / 9px 9px, #fffaf0; }
.template-preview-parchment { background: linear-gradient(135deg, #d7b77c, #fff0c7); }
.template-preview-cornell { background: linear-gradient(90deg, transparent 27%, #d98d8d 28% 30%, transparent 31%), repeating-linear-gradient(#fffaf0 0 7px, #c7bdae 8px); }
.template-preview-starlight { color: #f8db80; background: radial-gradient(circle, #fff 0 1px, transparent 1.5px) 0 0 / 10px 9px, #283054; }
.template-preview-botanical { color: #467452; background: radial-gradient(ellipse, #bad3b7 0 6px, transparent 7px) 0 0 / 20px 18px, #f3faef; }
.font-preview { color: var(--accent); background: linear-gradient(145deg, #fff, #f7f0e6); font-size: 25px; }

.purchase-confirm-card {
  display: grid;
  grid-template-columns: 84px minmax(0, 1fr);
  align-items: center;
  gap: 16px;
  padding: 18px;
  border: 1px solid rgba(122,61,96,0.14);
  border-radius: 18px;
  background: linear-gradient(145deg, rgba(255,255,255,0.7), rgba(215,178,109,0.08));
}
.purchase-confirm-card .shop-preview { width: 84px; height: 74px; }
.purchase-confirm-card strong { display: block; font-family: Georgia, "Times New Roman", serif; font-size: 22px; }
.purchase-confirm-card span { display: block; margin-top: 5px; color: var(--accent); font-weight: 900; }
.purchase-confirm-card p { margin: 8px 0 0; color: var(--muted-ink); font-size: 12px; line-height: 1.5; }

@media (max-width: 760px), (max-height: 520px) and (pointer: coarse) {
  .draggable-sticker { min-width: 44px; min-height: 44px; font-size: 34px; }
  .sticker-remove { width: 26px; height: 26px; opacity: 1; transform: scale(1); pointer-events: auto; }
  .shop-tier-tabs { grid-template-columns: repeat(2, minmax(0, 1fr)); position: static; }
  .shop-tier-summary { grid-template-columns: auto minmax(0, 1fr); }
  .shop-tier-summary b { grid-column: 1 / -1; }
  .purchase-confirm-card { grid-template-columns: 64px minmax(0, 1fr); padding: 13px; gap: 12px; }
  .purchase-confirm-card .shop-preview { width: 64px; height: 60px; }
}

@media (max-width: 420px) {
  .shop-tier-tabs { gap: 5px; padding: 6px; }
  .shop-tier-tab { min-height: 52px; padding: 6px; }
  .shop-tier-summary { grid-template-columns: 1fr; }
  .purchase-confirm-card { grid-template-columns: 1fr; text-align: center; }
  .purchase-confirm-card .shop-preview { margin-inline: auto; }
}

/* Store trials and page sharing */
.editor {
  font-family: var(--page-font, Georgia, "Times New Roman", serif);
}

.trial-watermark {
  position: absolute;
  z-index: 8;
  left: 50%;
  top: 52%;
  transform: translate(-50%, -50%) rotate(-24deg);
  pointer-events: none;
  user-select: none;
  color: rgba(154, 64, 79, 0.13);
  font: 800 clamp(54px, 9vw, 108px)/1 ui-sans-serif, system-ui, sans-serif;
  letter-spacing: 0.14em;
  border: 7px double rgba(154, 64, 79, 0.11);
  border-radius: 16px;
  padding: 8px 16px;
}

.trial-banner {
  position: relative;
  z-index: 15;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 7px 0 1px;
  padding: 8px 10px;
  border: 1px dashed rgba(150, 72, 91, 0.42);
  border-radius: 11px;
  color: #713b4d;
  background: rgba(255, 242, 247, 0.88);
  box-shadow: 0 5px 14px rgba(92, 39, 67, 0.08);
}

.trial-banner > div:first-child {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.trial-banner strong { font-size: 12px; }
.trial-banner span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #8a6571;
  font-size: 10px;
}

.trial-banner-actions {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 6px;
}

.trial-banner button {
  min-height: 30px;
  border: 1px solid rgba(122, 61, 96, 0.2);
  border-radius: 8px;
  padding: 0 9px;
  color: #6a3450;
  background: rgba(255,255,255,0.72);
  cursor: pointer;
  font-size: 10px;
  font-weight: 750;
}

.trial-banner button:first-child {
  color: white;
  background: var(--accent);
  border-color: var(--accent);
}

.trial-sticker {
  outline: 3px dashed rgba(155, 70, 91, 0.48);
  outline-offset: 4px;
}

.page-marker.trial-marker {
  outline: 3px dashed rgba(155, 70, 91, 0.48);
  outline-offset: 3px;
}

.shop-card-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
}

.shop-card-actions > button {
  min-width: 78px;
  height: 30px;
  border: 0;
  border-radius: 8px;
  padding: 0 9px;
  color: white;
  background: var(--accent);
  cursor: pointer;
  font-size: 11px;
  font-weight: 760;
}

.shop-card-actions > button:disabled {
  color: var(--muted-ink);
  background: rgba(90,70,52,0.07);
  cursor: default;
}

.shop-card-actions .shop-try-button {
  color: #6d3652;
  border: 1px solid rgba(122,61,96,0.25);
  background: rgba(255,255,255,0.78);
}

.shop-card-actions .shop-try-button:not(:disabled):hover {
  background: rgba(122,61,96,0.1);
}

.page.capture-mode .page-header-actions,
.page.capture-mode .editor-toolbar,
.page.capture-mode .flip-button,
.page.capture-mode .sticker-remove,
.page.capture-mode .trial-banner {
  display: none !important;
}

.page.capture-mode .page-header {
  justify-content: flex-start;
}

.page.capture-mode .timestamp-input,
.timestamp-capture {
  width: auto;
  max-width: 100%;
  height: auto;
  padding: 2px 0 9px;
  border: 0;
  color: var(--page-muted);
  background: transparent;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(13px, 1.15vw, 17px);
}

.page.capture-mode .editor {
  padding-top: 12px;
  padding-bottom: 45px;
  scrollbar-width: none;
}
.page.capture-mode .editor::-webkit-scrollbar { display: none; }

.page-share-preview {
  display: grid;
  gap: 12px;
}

.page-share-preview img {
  display: block;
  width: min(100%, 520px);
  max-height: min(58vh, 680px);
  margin: 0 auto;
  object-fit: contain;
  border: 1px solid rgba(80, 58, 43, 0.18);
  border-radius: 14px;
  background: #f8efe0;
  box-shadow: 0 14px 30px rgba(35, 22, 28, 0.16);
}

.page-share-preview p {
  margin: 0;
  color: var(--muted-ink);
  text-align: center;
  font-size: 12px;
  line-height: 1.5;
}

#modalRoot .modal:has(.page-share-preview) { width: min(720px, 100%); }

@media (max-width: 760px), (max-height: 520px) and (pointer: coarse) {
  .trial-banner {
    align-items: stretch;
    flex-direction: column;
    gap: 6px;
    padding: 7px 8px;
  }
  .trial-banner span { white-space: normal; }
  .trial-banner-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .trial-banner button { min-height: 36px; }
  .trial-watermark { font-size: clamp(42px, 19vw, 76px); }
  .shop-card-actions { min-width: 92px; }
  .shop-card-actions > button { min-width: 92px; min-height: 34px; height: auto; }
}

@media (max-width: 420px) {
  .page-header-actions { max-width: 68%; }
  .page-action.share-page-button { color: #5f5b9d; background: rgba(95,91,157,0.1); border-color: rgba(95,91,157,0.22); }
}


/* Version details, changelog, cache refresh, and report sharing */
.settings-section {
  margin-top: 14px;
  padding: 15px;
  border: 1px solid rgba(80,60,45,0.13);
  border-radius: 16px;
  background: rgba(255,255,255,0.48);
}

.settings-section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.settings-section-heading h3 {
  margin: 2px 0 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 19px;
}

.settings-section-kicker {
  display: block;
  color: var(--muted-ink);
  font-size: 9px;
  font-weight: 850;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.version-pill,
.settings-section-icon {
  flex: 0 0 auto;
  min-width: 54px;
  min-height: 32px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  padding: 0 10px;
  color: #fff;
  background: linear-gradient(145deg, var(--accent), color-mix(in srgb, var(--accent) 68%, #24131d));
  box-shadow: 0 8px 18px rgba(74,38,59,0.17);
  font-size: 11px;
  font-weight: 850;
}

.settings-section-icon { min-width: 34px; width: 34px; padding: 0; font-size: 16px; }

.version-facts {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 13px;
}

.version-facts > div {
  min-width: 0;
  padding: 10px;
  border: 1px solid rgba(80,60,45,0.1);
  border-radius: 12px;
  background: rgba(122,61,96,0.045);
}

.version-facts span,
.version-facts strong { display: block; }
.version-facts span { color: var(--muted-ink); font-size: 9px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.06em; }
.version-facts strong { margin-top: 4px; overflow-wrap: anywhere; font-size: 12px; }
.version-note { margin-top: 12px; }

.settings-button-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 12px;
}

.settings-action-button {
  min-height: 42px;
  border: 1px solid rgba(122,61,96,0.18);
  border-radius: 11px;
  padding: 8px 12px;
  color: var(--accent);
  background: rgba(122,61,96,0.055);
  cursor: pointer;
  font-size: 12px;
  font-weight: 850;
}

.settings-action-button.primary { color: #fff; border-color: var(--accent); background: var(--accent); }
.settings-action-button:hover { transform: translateY(-1px); }

.changelog-panel {
  max-height: 390px;
  overflow: auto;
  margin-top: 13px;
  padding-right: 4px;
}

.changelog-release {
  padding: 12px 0;
  border-top: 1px solid rgba(80,60,45,0.11);
}

.changelog-release:first-child { border-top: 0; padding-top: 2px; }
.changelog-release-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.changelog-release-heading strong { color: var(--accent); font-size: 13px; }
.changelog-release-heading span { color: var(--muted-ink); font-size: 10px; white-space: nowrap; }
.changelog-release ul { margin: 8px 0 0; padding-left: 18px; }
.changelog-release li { margin: 5px 0; color: #604e42; font-size: 11px; line-height: 1.45; }

.field select,
.field textarea {
  width: 100%;
  border: 1px solid rgba(80,60,45,0.18);
  border-radius: 11px;
  padding: 11px 13px;
  color: var(--ink);
  background: rgba(255,255,255,0.72);
}
.field select { height: 46px; padding-block: 0; }
.field textarea { min-height: 130px; resize: vertical; line-height: 1.5; }

.report-file-input { position: absolute; width: 1px; height: 1px; overflow: hidden; opacity: 0; pointer-events: none; }
.report-file-picker {
  min-height: 78px;
  border: 1px dashed rgba(122,61,96,0.3);
  border-radius: 14px;
  display: grid !important;
  grid-template-columns: 42px minmax(0, 1fr);
  align-content: center;
  column-gap: 10px;
  padding: 12px;
  background: rgba(122,61,96,0.045);
  cursor: pointer;
}
.report-file-picker > span {
  grid-row: 1 / span 2;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  color: #fff;
  background: var(--accent);
  font-size: 21px;
}
.report-file-picker strong { align-self: end; font-size: 12px; }
.report-file-picker small { align-self: start; color: var(--muted-ink); font-size: 10px; }

.report-image-preview {
  display: grid;
  grid-template-columns: 68px minmax(0, 1fr) 36px;
  align-items: center;
  gap: 10px;
  margin: -3px 0 14px;
  padding: 9px;
  border: 1px solid rgba(80,60,45,0.12);
  border-radius: 13px;
  background: rgba(255,255,255,0.5);
}
.report-image-preview img { width: 68px; height: 58px; border-radius: 9px; object-fit: cover; }
.report-image-preview strong,
.report-image-preview span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.report-image-preview strong { font-size: 11px; }
.report-image-preview span { margin-top: 3px; color: var(--muted-ink); font-size: 10px; }
.report-image-preview button { width: 34px; height: 34px; border: 0; border-radius: 9px; background: rgba(168,63,75,0.09); cursor: pointer; }

.report-share-summary {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
  padding: 12px;
  border-radius: 14px;
  background: rgba(122,61,96,0.06);
}
.report-share-icon { width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; color: #fff; background: var(--accent); font-size: 24px; font-weight: 900; }
.report-share-summary strong { display: block; font-size: 13px; }
.report-share-summary p { margin: 4px 0 0; color: var(--muted-ink); font-size: 11px; line-height: 1.4; }

.report-channel-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.report-channel-button {
  min-height: 102px;
  border: 1px solid rgba(80,60,45,0.12);
  border-radius: 15px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 4px;
  padding: 12px;
  background: rgba(255,255,255,0.55);
  cursor: pointer;
}
.report-channel-button > span { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; color: #fff; font-size: 21px; }
.report-channel-button.email > span { background: #5d6fb5; }
.report-channel-button.whatsapp > span { background: #269b55; }
.report-channel-button strong { font-size: 13px; }
.report-channel-button small { color: var(--muted-ink); font-size: 10px; text-align: center; }
.report-channel-button:hover { transform: translateY(-2px); box-shadow: 0 8px 18px rgba(70,45,55,0.1); }

.report-text-preview { margin-top: 12px; border: 1px solid rgba(80,60,45,0.12); border-radius: 12px; overflow: hidden; }
.report-text-preview summary { padding: 11px 12px; cursor: pointer; color: var(--accent); font-size: 11px; font-weight: 850; }
.report-text-preview pre { max-height: 220px; overflow: auto; margin: 0; padding: 12px; border-top: 1px solid rgba(80,60,45,0.1); white-space: pre-wrap; overflow-wrap: anywhere; background: rgba(255,255,255,0.48); font: 10px/1.5 ui-monospace, SFMono-Regular, Consolas, monospace; }

#modalRoot .modal:has(.version-details-card),
#modalRoot .modal:has(.report-form),
#modalRoot .modal:has(.report-channel-grid) { width: min(620px, 100%); }

@media (max-width: 760px), (max-height: 520px) and (pointer: coarse) {
  .version-facts { grid-template-columns: 1fr; }
  .settings-button-row,
  .report-channel-grid { grid-template-columns: 1fr; }
  .changelog-panel { max-height: 310px; }
  .report-channel-button { min-height: 82px; grid-template-columns: 42px minmax(0, 1fr); justify-items: start; text-align: left; }
  .report-channel-button > span { grid-row: 1 / span 2; }
  .report-channel-button small { text-align: left; }
}
