/* =========================================================
   临时文本 · 主样式
   ========================================================= */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: #f6f7fb;
  color: #14151a;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  display: flex;
  flex-direction: column;
  position: relative;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(58rem 38rem at 8% -12%, rgba(99, 102, 241, 0.12), transparent 62%),
    radial-gradient(48rem 34rem at 96% -6%, rgba(168, 85, 247, 0.1), transparent 58%),
    radial-gradient(40rem 30rem at 50% 112%, rgba(56, 189, 248, 0.09), transparent 62%);
}

:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --ink: #14151a;
  --ink-2: #3b3e49;
  --muted: #777b89;
  --muted-2: #9a9dab;
  --line: #e9eaf1;
  --line-2: #dcdee9;
  --accent: #5b5bd6;
  --accent-2: #8b5cf6;
  --accent-soft: #f1f1ff;
  --ok: #0d9d63;
  --warn: #a95d07;
  --warn-bg: #fff9ec;
  --warn-line: #f7e3bd;
  --danger: #d63a2c;
  --radius: 16px;
  --shadow-card: 0 1px 2px rgba(20, 21, 26, 0.04), 0 18px 44px -20px rgba(20, 21, 26, 0.22);
  --shadow-pop: 0 24px 64px -20px rgba(20, 21, 26, 0.36);
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

::selection {
  background: rgba(99, 102, 241, 0.18);
}

a {
  color: inherit;
}

button {
  font-family: inherit;
}

/* ---------------- 顶栏 ---------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: rgba(255, 255, 255, 0.88);
  -webkit-backdrop-filter: saturate(1.8) blur(16px);
  backdrop-filter: saturate(1.8) blur(16px);
  border-bottom: 1px solid rgba(233, 234, 241, 0.9);
}

.topbar-inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 11px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  text-decoration: none;
  flex-shrink: 0;
}

.brand-mark {
  width: 27px;
  height: 27px;
  border-radius: 9px;
  background: linear-gradient(140deg, #6366f1, #a855f7);
  box-shadow: 0 4px 12px -4px rgba(99, 102, 241, 0.8);
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -0.02em;
  overflow: hidden;
}

.brand-mark.has-logo {
  background: #fff;
  box-shadow: none;
  border: 1px solid var(--line);
}

.brand-mark img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: inherit;
  display: block;
}

.brand-name {
  font-size: 14.5px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--ink);
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 28px;
  padding: 0 10px;
  border-radius: 8px;
  background: #f4f5fa;
  border: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
  cursor: pointer;
  transition: 0.16s ease;
  user-select: none;
}

.chip:hover {
  background: #eef0f9;
  color: var(--ink-2);
  border-color: var(--line-2);
}

.chip .dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.14);
}

.topbar .spacer {
  flex: 1;
}

.actions {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-shrink: 0;
}

/* ---------------- 按钮 ---------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 34px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid var(--line-2);
  background: #fff;
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 500;
  line-height: 1;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease,
    transform 0.1s ease, box-shadow 0.15s ease;
}

.btn svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}

.btn:hover {
  background: #fafaff;
  border-color: #cbcede;
  color: var(--ink);
}

.btn:active {
  transform: translateY(0.5px);
}

.btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.22);
}

.btn-primary {
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 8px 20px -10px rgba(99, 102, 241, 0.95);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #5b5bf0, #8250f5);
  color: #fff;
  border-color: transparent;
}

.btn-ghost {
  border-color: transparent;
  background: transparent;
}

.btn-ghost:hover {
  background: #f1f2f9;
  border-color: transparent;
}

.btn-danger {
  color: var(--danger);
  border-color: #f4cfca;
}

.btn-danger:hover {
  background: #fff5f4;
  border-color: #eab5ae;
  color: #b92b1e;
}

.btn-sm {
  height: 28px;
  padding: 0 9px;
  font-size: 12px;
  border-radius: 8px;
}

.btn[disabled] {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

/* ---------------- 复制链接菜单 ---------------- */

.copy-wrap {
  position: relative;
}

.copy-menu {
  position: absolute;
  top: calc(100% + 9px);
  right: 0;
  z-index: 50;
  width: 246px;
  max-width: calc(100vw - 28px);
  padding: 6px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #fff;
  box-shadow: var(--shadow-pop);
  animation: pop 0.16s ease;
}

.copy-menu[hidden] {
  display: none;
}

.copy-menu-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 9px 9px;
  font-size: 11.5px;
  color: var(--muted-2);
}

.copy-menu-pw {
  padding: 1px 6px;
  border-radius: 6px;
  background: #eefaf3;
  border: 1px solid #cdeedc;
  color: #0b7a4d;
  font-size: 10.5px;
  white-space: nowrap;
}

.copy-row {
  display: flex;
  align-items: center;
  border-radius: 10px;
}

.copy-row:hover {
  background: #f6f7fc;
}

.copy-item {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px;
  border: 0;
  background: transparent;
  color: var(--ink-2);
  text-align: left;
  cursor: pointer;
  font-family: inherit;
}

.copy-item:focus-visible,
.copy-open:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.22);
  border-radius: 9px;
}

.copy-ico {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: var(--accent-soft);
  color: #5b5bd6;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.copy-ico svg {
  width: 16px;
  height: 16px;
}

.copy-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.35;
}

.copy-text b {
  font-size: 13px;
  font-weight: 600;
}

.copy-text small {
  font-size: 11px;
  color: var(--muted-2);
}

.copy-open {
  width: 28px;
  height: 28px;
  margin-right: 5px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted-2);
  cursor: pointer;
}

.copy-open:hover {
  background: #eef0f9;
  color: var(--accent);
}

.copy-open svg {
  width: 14px;
  height: 14px;
}

/* ---------------- 主体 ---------------- */

.main {
  position: relative;
  z-index: 1;
  flex: 1;
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  padding: 24px 20px 24px;
  display: flex;
  flex-direction: column;
}

/* ---------------- 密码条（加密者可见） ---------------- */

.secretbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 10px 14px;
  margin-bottom: 14px;
  border-radius: 12px;
  background: linear-gradient(100deg, #f4f2ff, #fbf5ff 60%, #f4f2ff);
  border: 1px solid #e5e0ff;
  color: #4a3fa8;
  font-size: 13px;
}

.secretbar .label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  color: #4c3fa8;
}

.secretbar code {
  font-family: var(--mono);
  font-size: 13.5px;
  letter-spacing: 0.06em;
  padding: 3px 9px;
  border-radius: 7px;
  background: #fff;
  border: 1px solid #e2dcff;
  color: #372f86;
}

.secretbar .grow {
  flex: 1;
}

.secretbar .hint {
  color: #6f66b8;
  font-size: 12px;
}

/* 访问密码条用青色区分，避免与编辑密码条混淆 */
.secretbar-private {
  background: linear-gradient(100deg, #eefaf7, #f4fdfb 60%, #eefaf7);
  border-color: #cfeee6;
  color: #1c7565;
}

.secretbar-private .label {
  color: #1c7565;
}

.secretbar-private code {
  border-color: #cbe9e1;
  color: #145c50;
}

/* ---------------- 只读提示条 ---------------- */

.lockbar {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  padding: 14px 16px;
  margin-bottom: 16px;
  border-radius: 14px;
  background: var(--warn-bg);
  border: 1px solid var(--warn-line);
}

.lockbar .lock-ico {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: #fdecc8;
  color: #a9670b;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.lockbar .lock-ico svg {
  width: 17px;
  height: 17px;
}

.lockbar .lock-text {
  flex: 1;
  min-width: 200px;
}

.lockbar .lock-text b {
  display: block;
  font-size: 13.5px;
  color: #8a5406;
  font-weight: 600;
}

.lockbar .lock-text span {
  font-size: 12.5px;
  color: #a1793c;
}

.unlock-form {
  display: flex;
  gap: 7px;
  align-items: center;
}

.unlock-form .input {
  width: 168px;
  height: 34px;
}

/* ---------------- 纸张 ---------------- */

.sheet {
  flex: 1;
  min-height: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.sheet:focus-within {
  border-color: #c9c9f5;
  box-shadow: var(--shadow-card), 0 0 0 4px rgba(99, 102, 241, 0.09);
}

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 20px;
  border-bottom: 1px solid var(--line);
  font-size: 12.5px;
  color: var(--muted);
  background: linear-gradient(180deg, #fdfdfe, #fafafd);
}

.sheet-head .meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.sheet-head .sep {
  color: #d6d8e3;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--ok);
  font-variant-numeric: tabular-nums;
}

.status::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.85;
}

.status[data-kind="saving"] {
  color: var(--muted);
}

.status[data-kind="saving"]::before {
  animation: pulse 1s ease-in-out infinite;
}

.status[data-kind="error"] {
  color: var(--danger);
  cursor: pointer;
}

.status[data-kind="read"] {
  color: var(--muted);
}

.status[data-kind="read"]::before {
  opacity: 0.45;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 0.25;
    transform: scale(0.85);
  }
  50% {
    opacity: 1;
    transform: scale(1.15);
  }
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 20px;
  padding: 0 8px;
  border-radius: 6px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.01em;
  background: #fff4e2;
  color: #9a5c06;
  border: 1px solid #f6e2c0;
}

.badge-free {
  background: #eefaf3;
  color: #0b7a4d;
  border-color: #cdeedc;
}

.badge-live {
  background: var(--accent-soft);
  color: #4b46b5;
  border-color: #ded9ff;
}

#editor {
  flex: 1;
  min-height: 0;
  width: 100%;
  border: 0;
  outline: 0;
  resize: none;
  padding: 24px 30px 8px;
  font-family: inherit;
  font-size: 16.5px;
  line-height: 1.8;
  color: var(--ink);
  background: transparent;
  display: block;
  tab-size: 4;
}

#editor::placeholder {
  color: #b9bcc8;
}

.reader {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 26px 30px 30px;
  font-size: 16.5px;
  line-height: 1.8;
  color: var(--ink);
}

.reader pre {
  margin: 0;
  font-family: inherit;
  font-size: inherit;
  line-height: inherit;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.reader .empty {
  color: #b9bcc8;
}

.sheet-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 20px 11px;
  border-top: 1px solid var(--line);
  font-size: 12px;
  color: var(--muted-2);
  font-variant-numeric: tabular-nums;
  background: #fcfcfe;
}

.sheet-foot .tip {
  font-size: 11.5px;
  color: #adb0bd;
}

kbd {
  font-family: var(--mono);
  font-size: 10.5px;
  padding: 1px 5px;
  border-radius: 4px;
  border: 1px solid var(--line-2);
  border-bottom-width: 2px;
  background: #fff;
  color: var(--muted);
}

/* ---------------- 访问密码门 ---------------- */

.gate-body {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.gate-main {
  position: relative;
  z-index: 1;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 20px 60px;
}

.gate-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 34px 30px 30px;
  text-align: center;
}

.gate-ico {
  width: 52px;
  height: 52px;
  margin: 0 auto 18px;
  border-radius: 15px;
  background: linear-gradient(140deg, #eef2ff, #f6f0ff);
  color: #6366f1;
  display: grid;
  place-items: center;
}

.gate-ico svg {
  width: 25px;
  height: 25px;
}

.gate-card h1 {
  font-size: 19px;
  margin: 0 0 8px;
  letter-spacing: -0.01em;
  color: var(--ink);
}

.gate-card p {
  font-size: 13px;
  line-height: 1.6;
  color: var(--muted);
  margin: 0 0 22px;
}

.gate-form {
  display: flex;
  gap: 8px;
}

.gate-form .input {
  flex: 1;
  min-width: 0;
}

.gate-error {
  margin: 14px 0 0 !important;
  color: var(--danger) !important;
  font-size: 12.5px !important;
}

/* ---------------- 页脚 ---------------- */

.footer {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: 0 20px 28px;
  font-size: 12px;
  color: #a6a9b6;
}

.footer a {
  color: #83879a;
  text-decoration: none;
  border-bottom: 1px dashed #d3d6e2;
}

.footer a:hover {
  color: var(--accent);
  border-color: #c3c0f5;
}

.footer-note,
.footer-links {
  display: inline;
}

/* ---------------- 表单 ---------------- */

.input {
  height: 38px;
  width: 100%;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid var(--line-2);
  background: #fff;
  color: var(--ink);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.input::placeholder {
  color: #b3b6c3;
}

.input:focus {
  border-color: #a5a3f0;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.13);
}

.input-mono {
  font-family: var(--mono);
  letter-spacing: 0.05em;
}

.field {
  margin-bottom: 14px;
}

.field-label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-2);
  margin-bottom: 6px;
}

.field-hint {
  font-size: 12px;
  color: var(--muted-2);
  margin-top: 6px;
}

.form-alert {
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 12.5px;
  margin-bottom: 14px;
}

.form-alert.error {
  background: #fff2f0;
  border: 1px solid #f7d3cd;
  color: #b32d1f;
}

.form-alert.ok {
  background: #f0fbf5;
  border: 1px solid #cfeedd;
  color: #0a7a4c;
}

/* ---------------- 弹窗 ---------------- */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(18, 19, 26, 0.42);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  animation: fade 0.18s ease;
}

.overlay[hidden] {
  display: none;
}

@keyframes fade {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.dialog {
  width: 100%;
  max-width: 460px;
  background: #fff;
  border-radius: 20px;
  padding: 24px;
  box-shadow: var(--shadow-pop);
  animation: pop 0.2s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}

.dialog-sm {
  max-width: 400px;
}

@keyframes pop {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.dialog h2 {
  margin: 0 0 8px;
  font-size: 17px;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.dialog-desc {
  margin: 0 0 18px;
  font-size: 13px;
  line-height: 1.7;
  color: var(--muted);
}

.dialog .row {
  display: flex;
  gap: 8px;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 22px;
}

/* ---------------- 提示 ---------------- */

.toast-wrap {
  position: fixed;
  left: 50%;
  bottom: 30px;
  transform: translateX(-50%);
  z-index: 120;
  display: flex;
  flex-direction: column-reverse;
  gap: 8px;
  align-items: center;
  pointer-events: none;
}

.toast {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  border-radius: 999px;
  background: #1b1c22;
  color: #fff;
  font-size: 13px;
  box-shadow: 0 16px 36px -14px rgba(0, 0, 0, 0.6);
  animation: toastIn 0.24s cubic-bezier(0.2, 0.9, 0.3, 1.2);
  max-width: 88vw;
}

.toast.out {
  animation: toastOut 0.2s ease forwards;
}

.toast-error {
  background: #3a1614;
  color: #ffd9d3;
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes toastOut {
  to {
    opacity: 0;
    transform: translateY(6px) scale(0.97);
  }
}

/* ---------------- 登录 / 安装卡片 ---------------- */

.auth-wrap {
  position: relative;
  z-index: 1;
  flex: 1;
  display: grid;
  place-items: center;
  padding: 40px 20px 60px;
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 28px;
  box-shadow: var(--shadow-card);
}

.auth-card h1 {
  margin: 14px 0 6px;
  font-size: 19px;
  font-weight: 650;
  letter-spacing: -0.015em;
}

.auth-card .sub {
  margin: 0 0 22px;
  font-size: 13px;
  color: var(--muted);
}

.auth-card .btn {
  width: 100%;
  height: 40px;
  border-radius: 11px;
}

/* ---------------- 响应式 ---------------- */

@media (max-width: 720px) {
  .topbar-inner {
    padding: 10px 14px;
    gap: 8px;
    min-width: 0;
  }

  .brand-name {
    display: none;
  }

  .topbar .btn .label {
    display: none;
  }

  .topbar .btn {
    width: 34px;
    padding: 0;
  }

  .topbar .btn.keep-label {
    width: auto;
    padding: 0 12px;
  }

  .topbar .btn.keep-label .label {
    display: inline;
  }

  .topbar .hide-sm {
    display: none;
  }

  .main {
    padding: 16px 12px 10px;
  }

  #editor,
  .reader {
    padding-left: 18px;
    padding-right: 18px;
    font-size: 16px;
  }

  .sheet-head,
  .sheet-foot {
    padding-left: 16px;
    padding-right: 16px;
  }

  .sheet-head .tip,
  .sheet-foot .tip {
    display: none;
  }

  .unlock-form {
    width: 100%;
  }

  .unlock-form .input {
    flex: 1;
    width: auto;
  }

  .lockbar {
    gap: 8px;
    padding: 10px 12px;
    margin-bottom: 10px;
  }

  .gate-card {
    padding: 28px 20px 24px;
  }

  .gate-form {
    flex-direction: column;
  }

  .footer {
    padding: 0 12px 12px;
    font-size: 11.5px;
    line-height: 1.5;
  }

  .footer-note,
  .footer-links {
    display: block;
  }

  .footer-sep {
    display: none;
  }

  .footer-links {
    margin-top: 2px;
  }

  #editor,
  .reader {
    min-height: 140px;
  }

  .chip .id-text {
    max-width: 88px;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
