:root {
  color-scheme: light;
  --ink: #1d1d1f;
  --muted: #86868b;
  --line: rgba(60, 60, 67, 0.14);
  --surface: rgba(255, 255, 255, 0.9);
  --accent: #ffcc33;
  --shadow: 0 22px 80px rgba(0, 0, 0, 0.14);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

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

body {
  display: grid;
  place-items: center;
  margin: 0;
  padding: 14px;
  min-width: 320px;
  color: var(--ink);
  background:
    radial-gradient(circle at 18% 12%, rgba(255, 255, 255, 0.96), transparent 34%),
    radial-gradient(circle at 84% 10%, rgba(255, 255, 255, 0.92), transparent 30%),
    radial-gradient(circle at 82% 88%, rgba(255, 214, 168, 0.14), transparent 30%),
    linear-gradient(to bottom, #fffdf9 0%, #fffaf3 34%, #fde8d2 100%);
  overflow: hidden;
}

.simple-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  width: min(1120px, 100%);
}

button,
input,
textarea {
  font: inherit;
}

button {
  border: 0;
}

.simple-shell {
  width: min(1120px, 100%);
  height: min(900px, calc(100vh - 88px));
}

.simple-cross-links {
  display: flex;
  flex-wrap: nowrap;
  justify-content: flex-start;
  gap: 8px;
  width: 100%;
  max-width: 100%;
  padding: 0 6px;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.simple-cross-links::-webkit-scrollbar {
  display: none;
}

.simple-cross-links a {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  min-height: 34px;
  padding: 0 14px;
  white-space: nowrap;
  color: rgba(29, 29, 31, 0.68);
  background: rgba(255, 255, 255, 0.62);
  border: 1px solid rgba(60, 60, 67, 0.12);
  border-radius: 999px;
  box-shadow: 0 6px 20px rgba(56, 44, 28, 0.04);
  backdrop-filter: blur(18px) saturate(1.08);
  -webkit-backdrop-filter: blur(18px) saturate(1.08);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  transition: background-color 150ms ease, color 150ms ease, border-color 150ms ease;
}

.simple-cross-links a:hover {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.82);
  border-color: rgba(60, 60, 67, 0.16);
}

.simple-editor {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid rgba(255, 255, 255, 0.74);
  border-radius: 22px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(26px) saturate(1.35);
}

.simple-topbar {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr) 88px;
  align-items: center;
  gap: 16px;
  min-height: 62px;
  padding: 14px 18px;
  border-bottom: 1px solid rgba(60, 60, 67, 0.08);
}

.simple-topbar-spacer {
  width: 88px;
}

.simple-toolbar {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  width: 88px;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  color: #3a3a3c;
  background: rgba(118, 118, 128, 0.09);
  border-radius: 999px;
  cursor: pointer;
  transition: background-color 150ms ease, color 150ms ease, transform 150ms ease;
}

.icon-button:hover {
  background: rgba(118, 118, 128, 0.16);
}

.icon-button:active,
.format-button:active {
  transform: scale(0.96);
}

.icon-mask {
  display: block;
  width: 18px;
  height: 18px;
  background-position: center;
  background-repeat: no-repeat;
  background-size: contain;
  opacity: 0.9;
}

.icon-download {
  background-image: url("/icons/png/download.png");
}

.format-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 46px;
  padding: 6px 28px 8px;
  border-bottom: 1px solid rgba(60, 60, 67, 0.08);
}

.format-bar-header {
  justify-content: center;
  min-height: 36px;
  padding: 0 18px;
  overflow-x: auto;
  border-bottom: 0;
  scrollbar-width: none;
}

.format-bar-header::-webkit-scrollbar,
.format-bar-mobile::-webkit-scrollbar {
  display: none;
}

.format-bar-mobile {
  display: none;
}

.format-button {
  display: inline-grid;
  place-items: center;
  min-width: 32px;
  height: 32px;
  padding: 0 9px;
  color: #3a3a3c;
  background: rgba(118, 118, 128, 0.08);
  border-radius: 8px;
  cursor: pointer;
  line-height: 1;
  transition: background-color 150ms ease, color 150ms ease, transform 150ms ease;
}

.format-button:hover {
  background: rgba(118, 118, 128, 0.15);
}

.format-button.active {
  color: #8a6700;
  background: rgba(255, 204, 51, 0.34);
}

.text-mode-button {
  min-width: 52px;
  font-size: 12px;
  font-weight: 700;
}

.heading-button {
  min-width: 38px;
  font-size: 12px;
  font-weight: 800;
}

.format-button svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.format-divider {
  width: 1px;
  height: 22px;
  margin: 0 4px;
  background: var(--line);
}

.title-input {
  width: 100%;
  padding: 26px 34px 10px;
  color: var(--ink);
  background: transparent;
  border: 0;
  outline: 0;
  font-size: clamp(28px, 3vw, 42px);
  font-weight: 700;
  line-height: 1.08;
}

.content-input {
  width: 100%;
  flex: 1;
  padding: 8px 34px 34px;
  color: #2d2d2f;
  background: transparent;
  border: 0;
  outline: 0;
  resize: none;
  overflow: auto;
  font-size: 18px;
  line-height: 1.52;
}

.rich-editor {
  min-height: 0;
  white-space: pre-wrap;
  word-break: break-word;
}

.rich-editor:empty::before {
  content: attr(data-placeholder);
  color: rgba(60, 60, 67, 0.38);
}

.rich-editor p,
.rich-editor h2,
.rich-editor h3,
.rich-editor ul,
.rich-editor ol,
.rich-editor blockquote,
.rich-editor pre {
  margin: 0 0 12px;
}

.rich-editor h2 {
  font-size: 28px;
  font-weight: 700;
  line-height: 1.18;
}

.rich-editor h3 {
  font-size: 22px;
  font-weight: 700;
  line-height: 1.22;
}

.rich-editor ul,
.rich-editor ol {
  padding-left: 28px;
}

.rich-editor li {
  margin: 4px 0;
}

.rich-editor ul[data-list="checkpoints"] {
  padding-left: 0;
  list-style: none;
}

.rich-editor ul[data-list="checkpoints"] li {
  position: relative;
  padding-left: 38px;
  list-style: none;
}

.rich-editor ul[data-list="checkpoints"] li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.18em;
  width: 20px;
  height: 20px;
  background: rgba(255, 255, 255, 0.72);
  border: 1.6px solid rgba(60, 60, 67, 0.38);
  border-radius: 50%;
}

.rich-editor ul[data-list="checkpoints"] li[data-checked="true"] {
  color: rgba(31, 31, 36, 0.58);
  text-decoration: line-through;
}

.rich-editor ul[data-list="checkpoints"] li[data-checked="true"]::before {
  background: rgba(255, 214, 107, 0.88);
  border-color: rgba(138, 103, 0, 0.24);
}

.rich-editor ul[data-list="checkpoints"] li[data-checked="true"]::after {
  content: "";
  position: absolute;
  left: 7px;
  top: calc(0.18em + 3px);
  width: 6px;
  height: 10px;
  border-right: 2px solid #1f1f24;
  border-bottom: 2px solid #1f1f24;
  transform: rotate(45deg);
}

.rich-editor blockquote {
  padding-left: 14px;
  color: #5f5f63;
  border-left: 3px solid rgba(255, 204, 51, 0.7);
}

.html-source {
  display: none;
  min-height: 0;
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 14px;
  line-height: 1.5;
  white-space: pre;
}

.simple-editor.html-mode .rich-editor {
  display: none;
}

.simple-editor.html-mode .html-source {
  display: block;
}

.simple-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 58px;
  padding: 10px 34px 12px;
  background: rgba(250, 250, 252, 0.92);
  border-top: 1px solid rgba(60, 60, 67, 0.12);
}

.note-stats-group {
  display: flex;
  align-items: center;
  gap: 26px;
  min-width: 0;
}

.stat-item {
  display: grid;
  gap: 4px;
  min-width: 86px;
}

.stat-item span {
  color: #3a3a3c;
  font-size: 10px;
  line-height: 1.15;
}

.stat-item strong {
  color: var(--ink);
  font-size: 15px;
  font-weight: 700;
  line-height: 1;
}

.simple-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 5px;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.save-check {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 15px;
  height: 15px;
  margin-right: 2px;
  color: #ffffff;
  background: #28c840;
  border-radius: 50%;
  opacity: 0;
  transform: scale(0.72);
  transition: opacity 180ms ease, transform 180ms ease;
}

.save-check::after {
  content: "";
  width: 6px;
  height: 3px;
  margin-top: -1px;
  border-bottom: 2px solid currentColor;
  border-left: 2px solid currentColor;
  transform: rotate(-45deg);
}

.save-check.visible {
  opacity: 1;
  transform: scale(1);
}

@media (max-width: 720px) {
  html,
  body {
    max-width: 100%;
    overflow-x: hidden;
  }

  body {
    display: block;
    padding: 0;
    overflow-x: hidden;
    overflow-y: auto;
  }

  .simple-page,
  .simple-shell {
    max-width: 100%;
    width: 100%;
    height: 100dvh;
    overflow-x: hidden;
  }

  .simple-editor {
    width: 100%;
    max-width: 100%;
    height: 100%;
    border: 0;
    border-radius: 0;
    overflow-x: hidden;
  }

  .simple-topbar {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    padding: 12px 14px;
  }

  .simple-topbar-spacer {
    display: none;
  }

  .format-bar-header {
    display: none;
  }

  .simple-toolbar {
    width: auto;
    gap: 2px;
    padding: 4px 6px;
    background:
      linear-gradient(180deg, rgba(255, 255, 255, 0.34), rgba(247, 248, 251, 0.18)),
      linear-gradient(180deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.02));
    border: 1px solid rgba(255, 255, 255, 0.34);
    border-radius: 999px;
    box-shadow:
      0 12px 26px rgba(56, 44, 28, 0.05),
      0 4px 10px rgba(31, 33, 36, 0.03),
      inset 0 1px 0 rgba(255, 255, 255, 0.42),
      inset 0 -1px 0 rgba(255, 255, 255, 0.06);
    backdrop-filter: blur(28px) saturate(1.12);
    -webkit-backdrop-filter: blur(28px) saturate(1.12);
  }

  .simple-toolbar .icon-button {
    width: 30px;
    height: 30px;
    background: transparent;
  }

  .title-input {
    padding: 20px 20px 8px;
    font-size: 30px;
    text-align: center;
  }

  .content-input {
    padding: 6px 20px 24px;
    font-size: 17px;
  }

  .content-input {
    max-width: 100%;
    padding-bottom: calc(132px + env(safe-area-inset-bottom));
    overflow-x: hidden;
    overflow-wrap: anywhere;
    word-break: break-word;
  }

  .title-input,
  .rich-editor,
  .html-source,
  .simple-cross-links {
    max-width: 100%;
    overflow-wrap: anywhere;
    word-break: break-word;
  }

  .format-bar-mobile {
    display: inline-flex;
    position: fixed;
    z-index: 40;
    left: 50%;
    right: auto;
    bottom: max(22px, calc(env(safe-area-inset-bottom) + 8px));
    width: auto;
    max-width: calc(100vw - 32px - env(safe-area-inset-left) - env(safe-area-inset-right));
    justify-content: center;
    flex-wrap: nowrap;
    gap: 1px;
    min-height: 58px;
    padding: 8px 10px;
    overflow-x: hidden;
    transform: translateX(-50%);
    background:
      linear-gradient(180deg, rgba(255, 255, 255, 0.34), rgba(247, 248, 251, 0.18)),
      linear-gradient(180deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.02));
    border: 1px solid rgba(255, 255, 255, 0.34);
    border-radius: 999px;
    box-shadow:
      0 18px 38px rgba(56, 44, 28, 0.05),
      0 6px 16px rgba(31, 33, 36, 0.03),
      inset 0 1px 0 rgba(255, 255, 255, 0.42),
      inset 0 -1px 0 rgba(255, 255, 255, 0.06);
    backdrop-filter: blur(28px) saturate(1.12);
    -webkit-backdrop-filter: blur(28px) saturate(1.12);
    scrollbar-width: none;
  }

  .format-bar-mobile .format-button {
    flex: 0 0 auto;
    min-width: 36px;
    height: 40px;
    padding: 0 8px;
    color: rgba(20, 20, 22, 0.94);
    background: rgba(255, 255, 255, 0.18);
    border-radius: 999px;
    box-shadow:
      inset 0 1px 0 rgba(255, 255, 255, 0.36),
      inset 0 -1px 0 rgba(255, 255, 255, 0.08);
  }

  .format-bar-mobile .format-button.active {
    color: #8a6700;
    background: rgba(255, 214, 120, 0.32);
  }

  .format-bar-mobile .text-mode-button {
    min-width: 50px;
    font-size: 12px;
  }

  .format-bar-mobile .heading-button {
    min-width: 40px;
    font-size: 12px;
    font-weight: 700;
  }

  .format-bar-mobile .format-divider {
    flex: 0 0 1px;
    height: 22px;
    margin: 0 2px;
    background: rgba(60, 60, 67, 0.1);
  }

  .simple-footer {
    display: none;
  }

  .simple-cross-links {
    padding: 0 14px 12px;
  }
}
