:root {
  color-scheme: light;
  font-family: Inter, "SF Pro Text", "Segoe UI", "Microsoft YaHei", system-ui, sans-serif;
  --bg: #f5f7fb;
  --surface: #ffffff;
  --ink: #172033;
  --muted: #667085;
  --line: #e3e8ef;
  --accent: #1b7f6d;
  --accent-soft: #e9f6f2;
  --danger: #b42318;
  --shadow: 0 16px 48px rgba(31, 42, 68, 0.11);
  background: var(--bg);
  color: var(--ink);
}

* { box-sizing: border-box; }

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

body { background: var(--bg); }

button,
input,
textarea { font: inherit; }

button { border: 0; cursor: pointer; }

button:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(27, 127, 109, 0.22);
  outline-offset: 2px;
}

svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.app-shell {
  position: relative;
  width: 100%;
  min-height: 100vh;
  background: var(--bg);
}

.page {
  display: none;
  min-height: 100vh;
  padding: calc(env(safe-area-inset-top) + 18px) 20px calc(88px + env(safe-area-inset-bottom));
}

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

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 76px;
  margin-bottom: 14px;
}

.simple-top-bar { min-height: 64px; }

.brand {
  margin: 0 0 2px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 750;
  letter-spacing: 0.08em;
}

.top-bar h1 {
  margin: 0;
  font-size: 28px;
  font-weight: 760;
  letter-spacing: -0.035em;
}

.primary-icon-button {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  box-shadow: 0 8px 18px rgba(23, 32, 51, 0.18);
}

.primary-icon-button:active { transform: translateY(1px); }

.search-wrap {
  position: relative;
  display: flex;
  align-items: center;
  margin: 0 0 18px;
}

.search-wrap > svg {
  position: absolute;
  left: 14px;
  width: 19px;
  height: 19px;
  color: #8791a3;
}

.search-wrap input {
  width: 100%;
  height: 46px;
  padding: 0 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font-size: 15px;
  font-weight: 450;
}

.search-wrap input::placeholder { color: #98a2b3; }

.clear-search {
  position: absolute;
  right: 8px;
  display: none;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 22px;
}

.clear-search.is-visible { display: block; }

.sync-banner {
  margin: 0 0 12px;
  padding: 10px 12px;
  border: 1px solid #fedf89;
  border-radius: 8px;
  background: #fffaeb;
  color: #7a2e0e;
  font-size: 13px;
  line-height: 1.45;
}

.note-list {
  min-height: 300px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  overflow: hidden;
}

.note-row {
  display: block;
  width: 100%;
  padding: 17px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  text-align: left;
}

.note-row:last-child { border-bottom: 0; }
.note-row:hover { background: #f9fafb; }
.note-row:active { background: var(--accent-soft); }

.note-row-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

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

.note-row-head time {
  flex: 0 0 auto;
  color: #98a2b3;
  font-size: 12px;
  font-weight: 550;
}

.pin {
  margin-right: 7px;
  color: var(--accent);
  font-size: 10px;
}

.note-preview {
  display: -webkit-box;
  margin-top: 7px;
  overflow: hidden;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.empty-state {
  display: grid;
  place-items: center;
  align-content: center;
  min-height: 340px;
  padding: 36px 24px;
  text-align: center;
}

.empty-icon {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  margin-bottom: 18px;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 25px;
  font-weight: 650;
}

.empty-state h2 {
  margin: 0 0 7px;
  font-size: 18px;
  letter-spacing: -0.015em;
}

.empty-state p {
  max-width: 270px;
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.65;
}

.profile-panel {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.profile-panel h2 { margin: 0 0 6px; font-size: 18px; }
.profile-panel p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.5; }

.avatar {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 52px;
  height: 52px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-size: 20px;
  font-weight: 750;
}

.info-list {
  margin: 18px 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  overflow: hidden;
}

.info-list > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 52px;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
}

.info-list > div:last-child { border-bottom: 0; }
.info-list dt { color: var(--muted); font-size: 14px; }
.info-list dd { margin: 0; overflow-wrap: anywhere; color: var(--ink); font-size: 14px; font-weight: 650; text-align: right; }
.status-offline { color: #b54708 !important; }

.secondary-button,
.primary-button {
  width: 100%;
  min-height: 48px;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 700;
}

.secondary-button { border: 1px solid var(--line); background: var(--surface); }
.primary-button { background: var(--ink); color: #fff; }
.primary-button:disabled { cursor: wait; opacity: 0.62; }
.danger-text { color: var(--danger) !important; }

.tab-bar {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  height: calc(68px + env(safe-area-inset-bottom));
  padding: 6px 14px calc(6px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(18px);
}

.tab-item {
  display: grid;
  grid-template-rows: 26px 18px;
  place-items: center;
  gap: 2px;
  border-radius: 8px;
  background: transparent;
  color: #7c8799;
  font-size: 12px;
  font-weight: 600;
}

.tab-item svg { width: 22px; height: 22px; stroke-width: 1.7; }
.tab-item.is-active { color: var(--accent); background: var(--accent-soft); }

dialog {
  margin: auto;
  border: 0;
  padding: 0;
  color: var(--ink);
}

dialog::backdrop { background: rgba(16, 24, 40, 0.42); backdrop-filter: blur(3px); }

.editor-dialog {
  width: min(100%, 620px);
  height: min(92vh, 760px);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.editor-dialog form {
  display: grid;
  grid-template-rows: 64px auto 1fr 58px;
  height: 100%;
}

.editor-head,
.editor-footer {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 18px;
  border-bottom: 1px solid var(--line);
}

.editor-head { justify-content: space-between; }
.editor-head strong { font-size: 15px; }
.editor-footer { border-top: 1px solid var(--line); border-bottom: 0; color: var(--muted); font-size: 13px; }
.editor-footer > span { margin-left: auto; }

.text-button {
  min-height: 36px;
  padding: 0 6px;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  font-weight: 650;
}

.accent-text { color: var(--accent); }

.note-title-input,
.note-content-input {
  width: 100%;
  border: 0;
  border-radius: 0;
  background: var(--surface);
  color: var(--ink);
}

.note-title-input {
  height: 62px;
  padding: 8px 22px 0;
  font-size: 24px;
  font-weight: 750;
  letter-spacing: -0.025em;
}

.note-content-input {
  padding: 16px 22px;
  resize: none;
  font-size: 16px;
  line-height: 1.75;
}

.note-title-input:focus,
.note-content-input:focus { outline: 0; }

.note-title-input::placeholder,
.note-content-input::placeholder { color: #b0b8c5; }

.toggle-label { display: flex; align-items: center; gap: 6px; color: var(--ink); font-weight: 600; }
.toggle-label input { width: 16px; height: 16px; accent-color: var(--accent); }

.login-dialog {
  width: min(calc(100% - 36px), 390px);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.login-dialog form { padding: 32px; }

.login-mark {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  margin-bottom: 24px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-size: 22px;
  font-weight: 800;
}

.login-dialog h1 { margin: 0 0 8px; font-size: 26px; letter-spacing: -0.03em; }
.login-dialog > form > p { margin: 0 0 24px; color: var(--muted); font-size: 14px; line-height: 1.6; }
.login-dialog label { display: block; margin-bottom: 8px; color: var(--ink); font-size: 13px; font-weight: 700; }
.login-dialog input { width: 100%; height: 48px; margin-bottom: 6px; padding: 0 13px; border: 1px solid var(--line); border-radius: 8px; color: var(--ink); font-size: 16px; }
.login-dialog .form-error { min-height: 22px; margin: 0 0 8px; color: var(--danger); font-size: 13px; }

.toast {
  position: fixed;
  bottom: calc(84px + env(safe-area-inset-bottom));
  left: 50%;
  z-index: 40;
  max-width: calc(100% - 40px);
  padding: 10px 16px;
  border-radius: 8px;
  background: rgba(23, 32, 51, 0.94);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 8px);
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 640px) {
  .editor-dialog {
    width: 100%;
    height: calc(100% - env(safe-area-inset-top));
    max-height: none;
    margin: env(safe-area-inset-top) 0 0;
    border-radius: 10px 10px 0 0;
  }

  .editor-footer { padding-bottom: env(safe-area-inset-bottom); min-height: calc(58px + env(safe-area-inset-bottom)); }
  .editor-footer > span { display: none; }
}

@media (min-width: 760px) {
  .app-shell { max-width: 680px; margin: 0 auto; border-right: 1px solid var(--line); border-left: 1px solid var(--line); }
  .page { padding-right: 42px; padding-left: 42px; }
  .tab-bar { left: 50%; width: 680px; transform: translateX(-50%); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: 0.01ms !important; }
}
