/* ------------------------------
   Base
-------------------------------- */

:root {
  --dark: #242526;
  --light: #eaf0fa;
  --white: #eef3fb;
  --text: #272a31;
  --muted-light: rgba(238, 243, 251, 0.62);
  --muted-dark: rgba(39, 42, 49, 0.62);
  --ghost: rgba(238, 243, 251, 0.18);
  --accent: #c6ff3f;
  --orange: #ff6c37;

  --page-x: clamp(28px, 6.85vw, 88px);
  --page-y: clamp(22px, 2.5vw, 34px);
}

* {
  box-sizing: border-box;
}

::selection {
  background: var(--accent);
  color: var(--text);
}

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

body {
  margin: 0;
  background: var(--dark);
  color: var(--white);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  cursor: none;
  overflow: hidden;
}

button,
input,
textarea {
  font: inherit;
}

button,
input,
textarea {
  cursor: none;
}

button {
  border: 0;
  background: transparent;
  color: inherit;
  padding: 0;
}

.app {
  position: relative;
  width: 100vw;
  height: 100svh;
  overflow: hidden;
}

.screen {
  position: absolute;
  inset: 0;
  display: none;
  min-height: 100svh;
  padding: var(--page-y) var(--page-x);
}

.screen.is-active {
  display: block;
}

/* ------------------------------
   Cursor
-------------------------------- */

.cursor-dot {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 300;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: currentColor;
  pointer-events: none;
  transform: translate(-50%, -50%);
  mix-blend-mode: difference;
  transition: width 220ms ease, height 220ms ease, background 220ms ease;
}

.cursor-label {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 301;
  pointer-events: none;
  transform: translate(-50%, -50%);
  color: var(--dark);
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  opacity: 0;
  transition: opacity 160ms ease;
}

body.cursor-active .cursor-dot {
  width: 72px;
  height: 72px;
  background: var(--white);
  mix-blend-mode: normal;
}

body.cursor-active .cursor-label {
  opacity: 1;
}

/* ------------------------------
   Shared topbar
-------------------------------- */

.topbar {
  position: relative;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.topbar h1 {
  margin: 0;
  font-size: clamp(15px, 1.2vw, 18px);
  line-height: 1;
  font-weight: 800;
  letter-spacing: -0.035em;
}

/* ------------------------------
   Login
-------------------------------- */

.login-screen {
  background: var(--dark);
  color: var(--white);
}

.login-form {
  width: min(620px, 100%);
  margin-top: clamp(56px, 6vw, 82px);
}

.field {
  display: block;
  margin-bottom: 26px;
}

.field span {
  display: block;
  margin-bottom: 10px;
  color: var(--white);
  font-size: clamp(15px, 1.2vw, 18px);
  line-height: 1;
  font-weight: 400;
  letter-spacing: -0.03em;
}

.field input {
  width: 100%;
  display: block;
  border: 0;
  outline: 0;
  padding: 0;
  background: transparent;
  color: var(--white);
  font-family: Inter, sans-serif;
  font-size: clamp(52px, 6.3vw, 76px);
  line-height: 0.95;
  font-weight: 900;
  letter-spacing: -0.08em;
}

.field input::placeholder {
  color: var(--ghost);
  opacity: 1;
}

.field input:-webkit-autofill,
.field input:-webkit-autofill:hover,
.field input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--white);
  box-shadow: 0 0 0 1000px var(--dark) inset;
  transition: background-color 9999s ease-in-out 0s;
}

.login-submit {
  position: relative;
  width: 60px;
  height: 48px;
  margin-top: 3px;
  transition: transform 180ms ease, opacity 180ms ease;
}

.login-submit:hover {
  transform: translateX(4px);
}

.login-submit span,
.login-submit span::before,
.login-submit span::after {
  position: absolute;
  display: block;
}

.login-submit span {
  left: 2px;
  top: 50%;
  width: 54px;
  height: 3px;
  background: var(--white);
  transform: translateY(-50%);
}

.login-submit span::before,
.login-submit span::after {
  content: "";
  right: -1px;
  width: 28px;
  height: 3px;
  background: var(--white);
  transform-origin: right center;
}

.login-submit span::before {
  top: 0;
  transform: rotate(45deg);
}

.login-submit span::after {
  bottom: 0;
  transform: rotate(-45deg);
}

.login-error {
  margin: 22px 0 0;
  color: var(--orange);
  font-size: 14px;
  line-height: 1.2;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 180ms ease, transform 180ms ease;
}

.login-error.is-visible {
  opacity: 1;
  transform: translateY(0);
}

/* ------------------------------
   Notes
-------------------------------- */

.notes-screen {
  background: var(--light);
  color: var(--text);
}

.notes-actions {
  display: flex;
  align-items: center;
  gap: 18px;
}

.logout-button,
.sync-state {
  color: var(--muted-dark);
  font-size: 13px;
  line-height: 1;
}

.logout-button {
  transition: color 160ms ease;
}

.logout-button:hover {
  color: var(--text);
}

.sync-state.is-saving {
  color: var(--orange);
}

.sync-state.is-saved {
  color: var(--muted-dark);
}

.sync-state.is-error {
  color: var(--orange);
}

.note-area {
  margin-top: clamp(58px, 6vw, 78px);
  width: min(780px, 100%);
}

.note-editor-wrap {
  position: relative;
  width: 100%;
  min-height: 360px;
}

.bullet-layer {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 1;
  width: 24px;
  color: var(--text);
  font-size: clamp(15px, 1.2vw, 18px);
  line-height: 1.2;
  pointer-events: none;
  white-space: pre;
}

.note-input {
  position: relative;
  z-index: 2;
  display: block;
  width: 100%;
  min-height: 360px;
  max-height: calc(100svh - 180px);
  overflow: auto;
  resize: none;
  border: 0;
  outline: 0;
  padding: 0 0 160px 23px;
  background: transparent;
  color: var(--text);
  font-family: Inter, sans-serif;
  font-size: clamp(15px, 1.2vw, 18px);
  line-height: 1.2;
  letter-spacing: -0.025em;
  caret-color: var(--text);
}

.note-input::placeholder {
  color: var(--muted-dark);
}

/* ------------------------------
   Mobile
-------------------------------- */

@media (max-width: 700px) {
  body {
    cursor: auto;
    overflow: hidden;
  }

  button,
  input,
  textarea {
    cursor: auto;
  }

  .cursor-dot,
  .cursor-label {
    display: none;
  }

  :root {
    --page-x: 22px;
    --page-y: 22px;
  }

  .screen {
    padding: var(--page-y) var(--page-x);
  }

  .login-form {
    margin-top: 58px;
  }

  .field {
    margin-bottom: 24px;
  }

  .field input {
    font-size: clamp(46px, 15vw, 72px);
    line-height: 0.96;
  }

  .notes-actions {
    gap: 12px;
  }

  .sync-state {
    display: none;
  }

  .notes-screen {
    overflow: hidden;
  }

  .note-area {
    margin-top: 58px;
    width: 100%;
  }

  .note-editor-wrap {
    min-height: calc(100svh - 130px);
  }

  .note-input {
    min-height: calc(100svh - 130px);
    max-height: calc(100svh - 130px);
    padding-bottom: 180px;
    font-size: 16px;
    line-height: 1.35;
    -webkit-text-size-adjust: 100%;
  }

  .bullet-layer {
    font-size: 16px;
    line-height: 1.35;
  }
}

@media (max-width: 420px) {
  .field input {
    font-size: clamp(42px, 14vw, 58px);
  }
}


/* ------------------------------
   v2 — Full-page notes layout
-------------------------------- */

body.is-loading {
  overflow: hidden;
}

body.login-active {
  background: var(--dark);
  color: var(--white);
  overflow: hidden;
}

body.notes-active {
  background: var(--light);
  color: var(--text);
  overflow-x: hidden;
  overflow-y: auto;
}

body.notes-active .app {
  height: auto;
  min-height: 100svh;
  overflow: visible;
}

body.notes-active .screen {
  position: relative;
  inset: auto;
  min-height: 100svh;
  width: 100%;
  overflow: visible;
}

body.login-active .app {
  height: 100svh;
  overflow: hidden;
}

body.login-active .screen {
  position: absolute;
  inset: 0;
}

.notes-screen {
  overflow: visible;
}

.note-area {
  width: 100%;
  max-width: none;
  padding-bottom: 35svh;
}

.note-editor-wrap {
  width: 100%;
  min-height: calc(100svh - 150px);
}

.note-input {
  width: 100%;
  min-height: calc(100svh - 150px);
  max-height: none;
  overflow: hidden;
  padding-bottom: 32px;
}

.bullet-layer {
  overflow: hidden;
}

/* ------------------------------
   Coming-soon square-grid intro
-------------------------------- */

.intro-loader.pixel-loader {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: block;
  overflow: hidden;
  background: transparent;
  opacity: 1;
  visibility: visible;
  pointer-events: none;
  transition: visibility 0s linear 1250ms;
}

body.is-ready .intro-loader.pixel-loader {
  opacity: 1;
  visibility: hidden;
}

.pixel-reveal-grid {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: repeat(16, 1fr);
  grid-template-rows: repeat(16, 1fr);
  gap: 0;
  background: transparent;
}

.pixel-reveal-grid span {
  display: block;
  background: var(--dark);
  transform: scale(1.01);
  opacity: 1;
  will-change: transform, opacity;
  transition:
    transform 620ms cubic-bezier(.77, 0, .175, 1),
    opacity 620ms cubic-bezier(.77, 0, .175, 1);
  transition-delay: var(--delay, 0ms);
}

body.notes-active .pixel-reveal-grid span {
  background: var(--light);
}

body.is-ready .pixel-reveal-grid span {
  transform: scale(0);
  opacity: 0;
}

@media (max-width: 700px) {
  body.notes-active {
    background: var(--light);
  }

  body.notes-active .screen {
    min-height: 100svh;
  }

  .note-area {
    width: 100%;
    max-width: none;
    padding-bottom: 30svh;
  }

  .note-editor-wrap {
    min-height: calc(100svh - 130px);
  }

  .note-input {
    width: 100%;
    min-height: calc(100svh - 130px);
    max-height: none;
    overflow: hidden;
    padding-bottom: 36px;
  }

  .intro-loader.pixel-loader {
    transition: visibility 0s linear 1050ms;
  }

  .pixel-reveal-grid span {
    transition-duration: 520ms;
  }
}

@media (prefers-reduced-motion: reduce) {
  .intro-loader.pixel-loader {
    display: none;
  }

  body.is-loading {
    overflow: auto;
  }
}


/* ------------------------------
   v3 — True full-page editor fix
-------------------------------- */

html {
  min-height: 100%;
  background: var(--light);
}

body.notes-active {
  min-height: 100%;
  height: auto;
  overflow-x: hidden !important;
  overflow-y: auto !important;
  background: var(--light) !important;
}

body.notes-active .app {
  width: 100%;
  height: auto !important;
  min-height: 100svh;
  overflow: visible !important;
}

body.notes-active .notes-screen {
  position: relative !important;
  display: block !important;
  width: 100%;
  min-height: 100svh;
  height: auto !important;
  overflow: visible !important;
}

body.notes-active .note-area {
  width: calc(100vw - (var(--page-x) * 2)) !important;
  max-width: none !important;
  margin-right: 0 !important;
  padding-bottom: 40svh;
}

body.notes-active .note-editor-wrap {
  width: 100% !important;
  max-width: none !important;
  min-height: calc(100svh - 150px);
  height: auto !important;
  overflow: visible !important;
}

body.notes-active .note-input {
  display: block;
  width: 100% !important;
  max-width: none !important;
  min-width: 0;
  height: auto;
  min-height: calc(100svh - 150px);
  max-height: none !important;
  overflow: hidden !important;
  overflow-y: hidden !important;
  scrollbar-width: none;
  -ms-overflow-style: none;
  resize: none !important;
}

body.notes-active .note-input::-webkit-scrollbar {
  width: 0 !important;
  height: 0 !important;
  display: none !important;
}

body.notes-active .bullet-layer {
  overflow: visible !important;
  width: 24px;
}

@media (max-width: 700px) {
  body.notes-active .note-area {
    width: calc(100vw - (var(--page-x) * 2)) !important;
    max-width: none !important;
    padding-bottom: 34svh;
  }

  body.notes-active .note-editor-wrap {
    min-height: calc(100svh - 130px);
  }

  body.notes-active .note-input {
    min-height: calc(100svh - 130px);
    max-height: none !important;
    overflow: hidden !important;
    overflow-y: hidden !important;
  }
}


/* ------------------------------
   v4 — favicon/mobile editor polish
-------------------------------- */

.refresh-button {
  color: var(--muted-dark);
  font-size: 13px;
  line-height: 1;
  transition: color 160ms ease;
}

.refresh-button:hover {
  color: var(--text);
}

.notes-actions {
  flex-shrink: 0;
}

body.notes-active .note-input {
  line-height: 1.2 !important;
  overflow: hidden !important;
  overflow-y: hidden !important;
  touch-action: manipulation;
}

body.notes-active .bullet-layer {
  line-height: 1.2 !important;
  transform: translateY(0);
}

.bullet-layer div.is-empty {
  opacity: 0;
}

@media (max-width: 700px) {
  .notes-topbar {
    align-items: flex-start;
    gap: 18px;
  }

  .notes-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 14px;
    flex-wrap: nowrap;
    min-width: 0;
  }

  .sync-state {
    display: inline-block !important;
    font-size: 12px;
    color: var(--muted-dark);
  }

  .refresh-button,
  .logout-button {
    display: inline-block;
    font-size: 12px;
    color: var(--muted-dark);
  }

  body.notes-active .note-input {
    line-height: 1.35 !important;
    overflow: hidden !important;
    overflow-y: hidden !important;
    -webkit-overflow-scrolling: auto;
  }

  body.notes-active .bullet-layer {
    line-height: 1.35 !important;
    transform: translateY(1px);
  }

  body.notes-active .bullet-layer div {
    display: block;
  }
}


/* ------------------------------
   v5 — Row-based editor
   Fixes mobile bullet alignment + internal scrolling
-------------------------------- */

.note-input-hidden {
  display: none !important;
}

body.notes-active {
  background: var(--light) !important;
  color: var(--text);
  overflow-x: hidden !important;
  overflow-y: auto !important;
  height: auto !important;
  min-height: 100%;
}

body.notes-active .app {
  width: 100%;
  height: auto !important;
  min-height: 100svh;
  overflow: visible !important;
}

body.notes-active .screen,
body.notes-active .notes-screen {
  position: relative !important;
  inset: auto !important;
  display: block !important;
  width: 100%;
  height: auto !important;
  min-height: 100svh;
  overflow: visible !important;
}

body.notes-active .note-area {
  width: calc(100vw - (var(--page-x) * 2)) !important;
  max-width: none !important;
  margin-right: 0 !important;
  padding-bottom: 40svh;
}

body.notes-active .note-editor-wrap {
  position: relative;
  width: 100% !important;
  max-width: none !important;
  min-height: calc(100svh - 150px);
  height: auto !important;
  overflow: visible !important;
}

.lines-editor {
  width: 100%;
  min-height: calc(100svh - 150px);
  padding-bottom: 36px;
  outline: none;
}

.note-line {
  display: grid;
  grid-template-columns: 23px minmax(0, 1fr);
  align-items: start;
  width: 100%;
  min-height: 1.2em;
  color: var(--text);
  font-family: Inter, sans-serif;
  font-size: clamp(15px, 1.2vw, 18px);
  line-height: 1.2;
  letter-spacing: -0.025em;
}

.note-bullet {
  display: block;
  width: 23px;
  color: var(--text);
  line-height: inherit;
  user-select: none;
  pointer-events: none;
}

.note-line.is-empty .note-bullet {
  opacity: 0;
}

.note-text {
  display: block;
  width: 100%;
  min-width: 0;
  min-height: 1.2em;
  line-height: inherit;
  outline: none;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  caret-color: var(--text);
  -webkit-user-select: text;
  user-select: text;
}

.note-text:empty::after {
  content: "\\00a0";
}

.note-text br {
  display: none;
}

.refresh-button {
  color: var(--muted-dark);
  font-size: 13px;
  line-height: 1;
  transition: color 160ms ease;
}

.refresh-button:hover {
  color: var(--text);
}

@media (max-width: 700px) {
  .notes-topbar {
    align-items: flex-start;
    gap: 18px;
  }

  .notes-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 14px;
    flex-wrap: nowrap;
    min-width: 0;
  }

  .sync-state,
  .refresh-button,
  .logout-button {
    display: inline-block !important;
    font-size: 12px;
    color: var(--muted-dark);
    white-space: nowrap;
  }

  body.notes-active .note-area {
    width: calc(100vw - (var(--page-x) * 2)) !important;
    max-width: none !important;
    padding-bottom: 34svh;
  }

  body.notes-active .note-editor-wrap {
    min-height: calc(100svh - 130px);
  }

  .lines-editor {
    min-height: calc(100svh - 130px);
    padding-bottom: 42px;
  }

  .note-line {
    grid-template-columns: 22px minmax(0, 1fr);
    font-size: 16px;
    line-height: 1.35;
    min-height: 1.35em;
  }

  .note-bullet {
    width: 22px;
    line-height: inherit;
  }

  .note-text {
    min-height: 1.35em;
    line-height: inherit;
    -webkit-text-size-adjust: 100%;
  }
}


/* ------------------------------
   v6 — Screen state fix
   Prevents scrolling back to login after unlock
-------------------------------- */

.screen:not(.is-active) {
  display: none !important;
  height: 0 !important;
  min-height: 0 !important;
  overflow: hidden !important;
  padding-top: 0 !important;
  padding-bottom: 0 !important;
  pointer-events: none !important;
}

body.notes-active .login-screen,
body.login-active .notes-screen {
  display: none !important;
  height: 0 !important;
  min-height: 0 !important;
  overflow: hidden !important;
  padding: 0 !important;
  pointer-events: none !important;
}

body.notes-active .notes-screen.is-active {
  display: block !important;
  height: auto !important;
  min-height: 100svh !important;
  overflow: visible !important;
  padding: var(--page-y) var(--page-x) !important;
}

body.login-active .login-screen.is-active {
  display: block !important;
  height: 100svh !important;
  min-height: 100svh !important;
  overflow: hidden !important;
  padding: var(--page-y) var(--page-x) !important;
}

body.notes-active {
  scroll-padding-top: 0;
}


/* ------------------------------
   v7 — Remove visible empty-row spacer text
-------------------------------- */

.note-text:empty::after {
  content: "" !important;
  display: none !important;
}

.note-text {
  min-height: 1.2em !important;
}

@media (max-width: 700px) {
  .note-text {
    min-height: 1.35em !important;
  }
}
