@font-face {
  font-family: Inter;
  src: url("inter.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

:root {
  color-scheme: light;
  --paper: #faf9f5;
  --ink: #252525;
  --muted: #62665c;
  --rule: #e9e8e3;
  --line: 22px;
  font-family: Inter, system-ui, sans-serif;
  background: var(--paper);
  color: var(--ink);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  overflow: hidden;
}

.notebook {
  display: none;
}

.desktop {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 24px;
}

.desktop h1 {
  margin: 0;
  font-size: clamp(22px, 4vw, 32px);
  font-weight: 500;
}

@media (pointer: coarse) and (max-width: 1024px) {
  .desktop {
    display: none;
  }

  .notebook {
    position: absolute;
    inset-inline: 0;
    top: var(--viewport-top, 0px);
    height: var(--viewport-height, 100dvh);
    display: flex;
    flex-direction: column;
    padding: env(safe-area-inset-top) max(14px, env(safe-area-inset-right))
      max(6px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
  }

  header {
    display: grid;
    grid-template-columns: auto 44px 1fr 44px;
    align-items: center;
    min-height: 45px;
    border-bottom: 1px solid var(--rule);
  }

  header h1 {
    margin: 0;
  }

  header img {
    display: block;
  }

  header button {
    display: grid;
    place-items: center;
    min-width: 44px;
    min-height: 44px;
    padding: 0;
    border: 0;
    border-radius: 4px;
    background: transparent;
    color: var(--muted);
    font: inherit;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }

  button:active {
    background: var(--rule);
  }

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

  .privacy {
    position: relative;
    z-index: 1;
  }

  .info-icon {
    color: var(--ink);
  }

  #discard {
    grid-column: 4;
  }

  #instruction {
    --tooltip-background: #edf2f7;
    --tooltip-border: #cbd7e3;
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    width: 192px;
    margin: 0;
    padding: 8px 10px;
    border: 1px solid var(--tooltip-border);
    border-radius: 6px;
    background: var(--tooltip-background);
    color: var(--ink);
    font-size: 13px;
    line-height: 18px;
  }

  #instruction::before {
    content: "";
    position: absolute;
    top: -6px;
    left: 15px;
    width: 10px;
    height: 10px;
    border-top: 1px solid var(--tooltip-border);
    border-left: 1px solid var(--tooltip-border);
    background: var(--tooltip-background);
    transform: rotate(45deg);
  }

  .writing-area {
    position: relative;
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
  }

  .blank-line {
    flex: 0 0 var(--line);
    border-bottom: 1px solid var(--rule);
    pointer-events: none;
  }

  #note,
  .caret-measure {
    padding: 0;
    border: 0;
    font: 400 16px / var(--line) Inter, system-ui, sans-serif;
    letter-spacing: normal;
    white-space: pre-wrap;
    overflow-wrap: break-word;
  }

  #note {
    display: block;
    width: 100%;
    flex: 1;
    min-height: 0;
    border-radius: 0;
    outline: none;
    resize: none;
    overflow-y: auto;
    color: var(--ink);
    background: repeating-linear-gradient(
      to bottom,
      transparent 0 calc(var(--line) - 1px),
      var(--rule) calc(var(--line) - 1px) var(--line)
    ) local;
  }

  #note::placeholder {
    color: var(--muted);
    opacity: 1;
  }

  .caret-measure {
    position: absolute;
    top: var(--line);
    left: 0;
    visibility: hidden;
    pointer-events: none;
  }
}

@media (pointer: coarse) and (max-width: 1024px) and (orientation: landscape) {
  .notebook {
    padding-bottom: 0;
  }
}
