:root {
  --bg: #171e22;
  --panel: #192126;
  --panel-2: #151b1f;
  --panel-3: #1d252b;
  --menu: #1d1d1d;
  --line: #2b353b;
  --line-soft: #243036;
  --text: #f1f5f7;
  --muted: #aab5bb;
  --dim: #7e8a92;
  --accent: #2a4b83;
  --accent-strong: #4f7ed6;
  --focus: #6fa5ff;
  --danger: #dc6f6f;
  --font: "Segoe UI", "Yu Gothic UI", "Meiryo", system-ui, sans-serif;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  overflow: hidden;
}

button,
input,
textarea {
  font: inherit;
}

.app-shell {
  height: 100vh;
  min-height: 520px;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

.login-screen {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: var(--bg);
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(360px, 100%);
  border: 1px solid var(--line);
  background: var(--panel);
  padding: 28px;
  display: grid;
  gap: 18px;
  box-shadow: 0 18px 40px rgb(0 0 0 / 0.26);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 4px;
}

.login-brand h1 {
  margin: 0;
  font-size: 20px;
}

.login-card label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
}

.login-card input {
  height: 40px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  padding: 0 12px;
  outline: 0;
}

.login-card input:focus {
  border-color: var(--focus);
}

.login-help {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.login-error {
  margin: 0;
  color: #ff6f83;
  font-size: 13px;
  font-weight: 700;
}

.titlebar {
  height: 56px;
  flex: 0 0 auto;
  background: var(--menu);
  border-bottom: 1px solid #202020;
  display: flex;
  flex-direction: column;
}

.brand {
  height: 28px;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 0 8px;
  color: #f7f7f7;
  font-size: 12px;
  user-select: none;
}

.brand-mark {
  width: 15px;
  height: 15px;
  display: inline-grid;
  place-items: center;
  border-radius: 50%;
  background: linear-gradient(135deg, #6fa5ff, #e9f1ff);
  color: #18222c;
  font-size: 10px;
  font-weight: 800;
}

.menubar {
  height: 28px;
  display: flex;
  align-items: stretch;
}

.menu-button {
  border: 0;
  background: transparent;
  color: #f5f5f5;
  padding: 0 7px;
  min-width: 0;
  cursor: default;
  font-size: 12px;
}

.menu-button:hover,
.menu-button.active {
  background: #3b3b3b;
}

.workspace {
  min-height: 0;
  flex: 1;
  display: grid;
  grid-template-columns: 378px minmax(0, 1fr);
}

.sidebar {
  position: relative;
  min-width: 0;
  background: var(--panel);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
}

.nav-drawer {
  position: absolute;
  inset: 0 auto 0 0;
  width: 262px;
  z-index: 7;
  background: var(--panel);
  border-right: 1px solid #31414a;
  box-shadow: 14px 0 30px rgb(0 0 0 / 0.22);
  display: flex;
  flex-direction: column;
}

.nav-main {
  min-height: 0;
  flex: 1;
  overflow-y: auto;
  padding: 42px 0 0;
}

.nav-item {
  width: calc(100% - 10px);
  min-height: 44px;
  margin: 0 0 0 4px;
  border: 0;
  border-bottom: 1px solid var(--line-soft);
  background: transparent;
  color: var(--text);
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  align-items: center;
  text-align: left;
  font: inherit;
  font-size: 16px;
  font-weight: 650;
  cursor: default;
}

.nav-item.active {
  background: var(--accent);
  outline: 2px solid #d6e4ff;
  outline-offset: -2px;
  border-radius: 3px;
}

.nav-icon {
  color: var(--muted);
  font-size: 20px;
  text-align: center;
}

.nav-section {
  padding-top: 12px;
}

.nav-section-title {
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px 0 18px;
  font-size: 16px;
}

.nav-section-title button,
.nav-footer button {
  border: 0;
  background: transparent;
  color: #9fbfff;
  font: inherit;
  cursor: default;
}

.nav-tags button {
  width: calc(100% - 18px);
  min-height: 44px;
  margin-left: 18px;
  padding: 0 12px;
  border: 0;
  border-bottom: 1px solid var(--line-soft);
  background: transparent;
  color: var(--text);
  text-align: left;
  font: inherit;
  font-size: 16px;
  font-weight: 650;
}

.nav-untagged {
  margin-top: 12px;
}

.nav-footer {
  flex: 0 0 auto;
  border-top: 1px solid var(--line);
  padding: 18px 20px 22px;
  color: var(--muted);
  display: grid;
  gap: 18px;
}

.connection,
.nav-footer-links {
  display: flex;
  gap: 12px;
  align-items: center;
}

.nav-footer button {
  color: var(--muted);
  padding: 0;
  text-align: left;
}

.sidebar-top {
  height: 44px;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 44px;
  align-items: center;
  border-bottom: 1px solid var(--line);
}

.sidebar-top h1 {
  margin: 0;
  text-align: center;
  font-size: 16px;
  line-height: 1;
  font-weight: 700;
}

.icon-button {
  width: 36px;
  height: 36px;
  margin: 4px;
  display: inline-grid;
  place-items: center;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
}

.icon-button:hover {
  background: var(--panel-3);
  color: var(--text);
}

.icon-button.active {
  color: var(--focus);
}

.search-row {
  height: 45px;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 18px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
}

.search-row input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-size: 16px;
}

.search-row input::placeholder {
  color: #c2cbd0;
  opacity: 0.9;
}

.notes-list {
  min-height: 0;
  flex: 1;
  overflow-y: auto;
  padding-bottom: 12px;
  scrollbar-color: #87919a transparent;
  scrollbar-width: thin;
}

.empty-trash {
  height: 58px;
  flex: 0 0 auto;
  border: 0;
  border-top: 1px solid var(--line);
  background: transparent;
  color: #ff6f83;
  font: inherit;
  font-weight: 750;
  cursor: default;
}

.note-row {
  position: relative;
  width: 100%;
  min-height: 43px;
  border: 0;
  border-bottom: 1px solid var(--line-soft);
  background: transparent;
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  align-items: center;
  padding: 0 17px 0 4px;
  color: var(--text);
  cursor: default;
  font: inherit;
  text-align: left;
  user-select: none;
}

.note-row:hover {
  background: #1f2a31;
}

.note-row.selected {
  background: var(--accent);
}

.pin-cell {
  width: 26px;
  height: 100%;
  position: relative;
  display: block;
  opacity: 0;
  cursor: pointer;
}

.note-row:hover .pin-cell,
.pin-cell.pinned {
  opacity: 1;
}

.note-row:hover .pin-cell:not(.pinned) {
  opacity: 0.48;
}

.pin-cell:hover {
  opacity: 1 !important;
}

.pin-cell::before,
.pin-cell::after {
  content: "";
  position: absolute;
  left: 10px;
  top: 50%;
  background: #8db4ff;
  transform: translateY(-50%) rotate(-35deg);
  transform-origin: center;
}

.pin-cell::before {
  width: 10px;
  height: 7px;
  border-radius: 1px;
  box-shadow: 0 -3px 0 -1px #8db4ff;
}

.pin-cell::after {
  width: 2px;
  height: 15px;
  margin-top: 5px;
  border-radius: 2px;
}

.pin-cell.pinned::before,
.pin-cell.pinned::after,
.pin-cell:hover::before,
.pin-cell:hover::after {
  background: #a7c4ff;
}

.note-title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 16px;
  font-weight: 700;
}

.editor-pane {
  min-width: 0;
  background: var(--bg);
  display: flex;
  flex-direction: column;
}

.editor-toolbar {
  height: 44px;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid var(--line);
  padding: 0 12px;
}

.toolbar-spacer {
  flex: 1;
}

.trash-actions {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-right: 8px;
}

.danger-outline,
.blue-button {
  height: 28px;
  min-width: 112px;
  padding: 0 18px;
  font: inherit;
  font-size: 12px;
  font-weight: 700;
}

.danger-outline {
  border: 2px solid #ff6f83;
  background: transparent;
  color: #ff6f83;
}

.blue-button {
  border: 1px solid #416dcc;
  background: #315fc9;
  color: #fff;
}

.editor-wrap {
  min-height: 0;
  flex: 1;
  display: flex;
}

#noteBody {
  width: 100%;
  height: 100%;
  resize: none;
  border: 0;
  outline: 0;
  background: var(--bg);
  color: var(--text);
  padding: 42px 12vw 40px 12vw;
  font-size: calc(16px * var(--editor-zoom, 1));
  line-height: 1.48;
  font-weight: 650;
  caret-color: var(--text);
}

body[data-line-length="full"] #noteBody {
  padding-left: 36px;
  padding-right: 36px;
}

body[data-note-display="comfy"] .note-row {
  min-height: 52px;
}

body[data-note-display="expanded"] .note-row {
  min-height: 62px;
}

body[data-theme="light"] {
  --bg: #f5f7f8;
  --panel: #eef2f4;
  --panel-2: #ffffff;
  --panel-3: #e6ebef;
  --menu: #f7f8f9;
  --line: #d6dde1;
  --line-soft: #dfe5e8;
  --text: #182026;
  --muted: #5f6d76;
  --dim: #77848c;
  --accent: #2f5796;
  color-scheme: light;
}

body[data-theme="light"] .titlebar {
  background: #f7f8f9;
  border-bottom-color: #d6dde1;
}

body[data-theme="light"] .brand,
body[data-theme="light"] .menu-button {
  color: #182026;
}

body[data-theme="light"] .titlebar,
body[data-theme="light"] .titlebar *,
body[data-theme="light"] .titlebar button,
body[data-theme="light"] .titlebar span {
  color: #182026;
}

body[data-theme="light"] .brand {
  color: #182026 !important;
}

body[data-theme="light"] .brand-mark {
  background: #6fa5ff;
  color: #102033 !important;
}

body[data-theme="light"] .menubar {
  background: #f7f8f9;
}

body[data-theme="light"] .menu-button {
  color: #182026 !important;
}

body[data-theme="light"] .menu-button:hover,
body[data-theme="light"] .menu-button.active {
  background: #e5eaee;
}

body[data-theme="light"] .dropdown-layer,
body[data-theme="light"] .submenu-layer,
body[data-theme="light"] .note-actions-menu {
  background: #ffffff;
  border-color: #ccd5da;
  box-shadow: 0 12px 28px rgb(16 31 43 / 0.18);
}

body[data-theme="light"] .dropdown-item,
body[data-theme="light"] .note-actions-menu button {
  color: #182026;
}

body[data-theme="light"] .dropdown-item:hover,
body[data-theme="light"] .note-actions-menu button:hover {
  background: #e8edf1;
}

body[data-theme="light"] .dropdown-shortcut {
  color: #315f9d;
}

body[data-theme="light"] .dropdown-separator,
body[data-theme="light"] .note-actions-separator {
  background: #d6dde1;
}

body[data-theme="light"] .note-row.selected {
  color: #ffffff;
}

body[data-theme="light"] .pin-cell::before,
body[data-theme="light"] .pin-cell::after {
  background: #79a7f5;
}

body[data-theme="light"] .pin-cell.pinned::before,
body[data-theme="light"] .pin-cell.pinned::after,
body[data-theme="light"] .pin-cell:hover::before,
body[data-theme="light"] .pin-cell:hover::after {
  background: #b9d2ff;
}

body[data-theme="light"] .search-row input::placeholder {
  color: #95a2aa;
}

#noteBody::selection {
  background: #365f9d;
}

.tagbar {
  min-height: 34px;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  color: var(--muted);
}

#tagInput {
  width: 120px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
}

#tagInput::placeholder {
  color: #9eb8df;
}

.tag-list {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  min-width: 0;
}

.tag-chip {
  border: 1px solid #3a4850;
  border-radius: 4px;
  color: #d5dee4;
  background: #1d272d;
  padding: 2px 7px;
  font-size: 12px;
}

.save-state {
  margin-left: auto;
  color: var(--dim);
  font-size: 12px;
}

.dropdown-layer,
.submenu-layer {
  position: fixed;
  min-width: 244px;
  background: var(--menu);
  border: 1px solid #252525;
  box-shadow: 0 12px 28px rgb(0 0 0 / 0.35);
  z-index: 10;
  padding: 5px 0;
  border-radius: 0 0 6px 6px;
}

.submenu-layer {
  min-width: 152px;
  z-index: 11;
  border-radius: 0 8px 8px 8px;
}

.document-panel {
  position: fixed;
  top: 56px;
  right: 0;
  width: 355px;
  z-index: 9;
  background: var(--panel);
  border-left: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  color: var(--text);
}

.document-head {
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 10px 0 13px;
  border-bottom: 1px solid var(--line);
}

.document-head h2 {
  margin: 0;
  color: var(--muted);
  font-size: 16px;
  font-weight: 700;
}

.document-stats {
  margin: 0;
  padding: 12px 13px 18px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px 28px;
}

.document-stats dt {
  margin: 0;
  font-size: 13px;
  font-weight: 750;
  color: #ffffff;
}

.document-stats dd {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  text-align: right;
}

.note-actions-menu {
  position: fixed;
  top: 48px;
  right: 10px;
  width: 184px;
  z-index: 11;
  background: var(--panel);
  border: 1px solid #2d3a42;
  border-radius: 5px;
  box-shadow: 0 12px 28px rgb(0 0 0 / 0.36);
  overflow: hidden;
  padding: 8px 0;
}

.note-actions-menu button {
  width: 100%;
  min-height: 31px;
  padding: 0 10px;
  border: 0;
  background: transparent;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  text-align: left;
  font: inherit;
  font-size: 14px;
  cursor: default;
}

.note-actions-menu button:hover {
  background: #263138;
}

.note-actions-menu .disabled {
  color: #68737a;
}

.note-actions-menu .danger {
  color: #ff7777;
}

.fake-check {
  width: 16px;
  height: 16px;
  border: 2px solid #97a3ad;
  border-radius: 3px;
  display: inline-block;
}

.fake-check.checked {
  background: #97a3ad;
  box-shadow: inset 0 0 0 3px var(--panel);
}

.note-actions-separator {
  height: 1px;
  margin: 6px 0;
  background: var(--line);
}

.settings-modal {
  position: fixed;
  inset: 0;
  z-index: 12;
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
}

.settings-head {
  height: 55px;
  flex: 0 0 auto;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
}

.settings-head h2 {
  margin: 0;
  font-size: 16px;
}

.settings-tabs {
  height: 46px;
  flex: 0 0 auto;
  display: flex;
  justify-content: center;
  gap: 12px;
  border-bottom: 1px solid var(--line);
}

.settings-tabs button {
  min-width: 70px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: #7fa8ff;
  font: inherit;
  font-weight: 700;
  cursor: default;
}

.settings-tabs button.active {
  border-bottom-color: #8badff;
}

.settings-body {
  min-height: 0;
  flex: 1;
  overflow-y: auto;
  padding: 38px 0 70px;
}

.settings-page {
  width: min(354px, calc(100vw - 40px));
  margin: 0 auto;
  display: none;
}

.settings-page.active {
  display: block;
}

.settings-page h3 {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

.settings-page h3:not(:first-child) {
  margin-top: 34px;
}

.settings-page p {
  margin: 14px 0 0;
  line-height: 1.45;
}

.settings-box,
.settings-list {
  border: 1px solid var(--line);
  background: var(--panel);
}

.settings-box {
  min-height: 44px;
  padding: 0 18px;
  display: flex;
  align-items: center;
}

.settings-box.centered {
  justify-content: center;
  font-size: 16px;
}

.settings-box.row {
  justify-content: space-between;
  gap: 12px;
  font-size: 16px;
}

.settings-box.spaced {
  margin-top: 50px;
}

.settings-list {
  display: grid;
}

.settings-list button {
  min-height: 43px;
  padding: 0 18px;
  border: 0;
  border-bottom: 1px solid var(--line-soft);
  background: transparent;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font: inherit;
  font-size: 16px;
  text-align: left;
  cursor: default;
}

.settings-list button:last-child {
  border-bottom: 0;
}

.link-button {
  display: block;
  margin: 24px auto 0;
  border: 0;
  background: transparent;
  color: #7fa8ff;
  font: inherit;
  font-weight: 700;
}

.primary-button {
  width: 100%;
  height: 40px;
  margin-top: 36px;
  border: 1px solid #527cd7;
  background: #3a68cf;
  color: #fff;
  font: inherit;
  font-weight: 700;
}

.switch {
  width: 24px;
  height: 16px;
  border-radius: 999px;
  background: #8f969b;
  position: relative;
}

.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #fff;
}

.switch.on {
  background: #24d66b;
}

.switch.on::after {
  left: 11px;
}

.radio {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 1px solid #3e4b54;
}

.radio.on {
  border-color: #20d36a;
  background: #20d36a;
}

.dropdown-item {
  width: 100%;
  height: 28px;
  border: 0;
  background: transparent;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 18px;
  padding: 0 18px;
  color: var(--text);
  font: inherit;
  font-size: 12px;
  line-height: 1;
  text-align: left;
  white-space: nowrap;
  cursor: default;
  appearance: none;
}

.dropdown-item:hover {
  background: #373737;
}

.submenu-layer .dropdown-item {
  height: 28px;
  grid-template-columns: 18px minmax(0, 1fr);
  padding: 0 20px;
  gap: 10px;
}

.menu-dot {
  width: 14px;
  height: 14px;
  border: 2px solid #8ca3c8;
  border-radius: 50%;
  display: inline-block;
}

.menu-dot.on {
  border-color: #8fb3ff;
  box-shadow: inset 0 0 0 3px var(--menu);
  background: #8fb3ff;
}

.dropdown-shortcut {
  color: #dce8ff;
}

.dropdown-separator {
  height: 1px;
  background: #505050;
  margin: 6px 0;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  background: #26313a;
  border: 1px solid #3f4f5a;
  color: var(--text);
  border-radius: 4px;
  padding: 8px 12px;
  box-shadow: 0 8px 20px rgb(0 0 0 / 0.3);
  font-size: 13px;
}

body.list-collapsed .workspace {
  grid-template-columns: 0 minmax(0, 1fr);
}

body.list-collapsed .sidebar {
  overflow: hidden;
  border-right: 0;
}

body.focus-mode .titlebar,
body.focus-mode .sidebar,
body.focus-mode .editor-toolbar {
  display: none;
}

body.focus-mode .workspace {
  grid-template-columns: minmax(0, 1fr);
}

body.focus-mode .app-shell {
  min-height: 100vh;
}

body.focus-mode #noteBody {
  padding-top: 10vh;
}

@media (max-width: 760px) {
  .titlebar {
    height: 46px;
  }

  .brand {
    display: none;
  }

  .menubar {
    height: 46px;
  }

  .menu-button {
    flex: 1;
    font-size: 12px;
  }

  .workspace {
    grid-template-columns: 1fr;
  }

  .sidebar {
    display: none;
  }

  body.mobile-list .sidebar {
    display: flex;
    position: fixed;
    inset: 46px 0 0 0;
    z-index: 8;
  }

  .nav-drawer {
    width: min(100vw, 300px);
  }

  .document-panel {
    top: 46px;
    width: 100%;
  }

  #noteBody {
    padding: 28px 22px 36px;
    font-size: 16px;
  }
}
