:root {
  --bg: #0f1117;
  --editor-bg: #1e1e1e;
  --editor-line: #252526;
  --text: #d4d4d4;
  --muted: #858585;
  --heading: #4fc1ff;
  --strong: #ffffff;
  --inline-code: #4ec9b0;
  --list: #d7ba7d;
  --table: #c586c0;
  --codeblock: #ce9178;
  --border: #2d2d30;
  --notice-bg: #151922;
  --notice-border: #2f3b52;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: Consolas, "JetBrains Mono", "SFMono-Regular", "Microsoft YaHei UI", "Microsoft YaHei", monospace;
  font-size: 15px;
  line-height: 1.65;
  overflow-x: hidden;
}

.no-select,
.no-select * {
  -webkit-user-select: none !important;
  -moz-user-select: none !important;
  -ms-user-select: none !important;
  user-select: none !important;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 44px;
  padding: 0 18px;
  background: #181818;
  border-bottom: 1px solid var(--border);
  box-shadow: 0 6px 18px rgba(0, 0, 0, .25);
}

.topbar-left,
.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.topbar-right {
  color: #9da5b4;
  font-size: 13px;
}

.dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  display: inline-block;
}

.dot-red { background: #ff5f57; }
.dot-yellow { background: #ffbd2e; }
.dot-green { background: #28c840; }

.file-title {
  margin-left: 8px;
  color: #d7d7d7;
  font-weight: 600;
}

.notice {
  margin: 16px auto 0;
  width: min(1680px, calc(100vw - 32px));
  padding: 12px 16px;
  color: #c9d1d9;
  background: var(--notice-bg);
  border: 1px solid var(--notice-border);
  border-radius: 8px;
  font-size: 14px;
}

.editor-shell {
  width: min(1680px, calc(100vw - 32px));
  margin: 16px auto 40px;
  border: 1px solid var(--border);
  background: var(--editor-bg);
  box-shadow: 0 16px 50px rgba(0, 0, 0, .38);
  overflow: auto;
}

.editor {
  min-width: 980px;
  padding: 10px 0 18px;
  counter-reset: line;
}

.code-row {
  display: flex;
  align-items: stretch;
  min-height: 25px;
  padding-right: 24px;
}

.code-row:hover {
  background: var(--editor-line);
}

.line-no {
  flex: 0 0 62px;
  padding: 0 13px 0 10px;
  color: var(--muted);
  text-align: right;
  white-space: pre;
  opacity: .95;
}

.line-code {
  flex: 1 1 auto;
  min-width: 0;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text);
}

.md-heading {
  color: var(--heading);
  font-weight: 700;
}

.md-strong {
  color: var(--strong);
  font-weight: 700;
}

.md-inline-code {
  color: var(--inline-code);
}

.md-list {
  color: var(--list);
  font-weight: 700;
}

.md-table {
  color: var(--table);
}

.md-codeblock {
  color: var(--codeblock);
}

.md-hr {
  color: #6796e6;
}

.md-empty {
  display: inline-block;
  min-height: 1em;
}

.line-fence {
  background: rgba(206, 145, 120, .035);
}

.watermark {
  position: fixed;
  inset: 0;
  z-index: 1000;
  pointer-events: none;
  color: rgba(255, 255, 255, .055);
  font-size: 18px;
  font-weight: 700;
  transform: rotate(-22deg);
  display: grid;
  grid-template-columns: repeat(3, 520px);
  grid-auto-rows: 220px;
  align-content: center;
  justify-content: center;
  gap: 60px;
  overflow: hidden;
}


.watermark {
  text-shadow: 0 0 1px rgba(255, 255, 255, .08);
}

.copy-toast {
  position: fixed;
  left: 50%;
  bottom: 34px;
  z-index: 2000;
  transform: translateX(-50%) translateY(20px);
  opacity: 0;
  padding: 11px 18px;
  background: rgba(20, 20, 20, .95);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, .15);
  border-radius: 999px;
  transition: all .18s ease;
  pointer-events: none;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .38);
}

.copy-toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

@media (max-width: 768px) {
  body {
    font-size: 14px;
    line-height: 1.55;
  }

  .topbar {
    padding: 0 10px;
    height: 40px;
  }

  .topbar-right {
    display: none;
  }

  .file-title {
    font-size: 12px;
    max-width: 60vw;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .notice,
  .editor-shell {
    width: calc(100vw - 12px);
    margin-left: 6px;
    margin-right: 6px;
    margin-top: 8px;
    margin-bottom: 20px;
  }

  .editor {
    min-width: 0;
    width: 100%;
    padding: 6px 0 12px;
  }

  .code-row {
    min-height: 22px;
    padding-right: 10px;
    flex-wrap: nowrap;
  }

  .line-no {
    flex: 0 0 36px;
    padding: 0 6px 0 6px;
    font-size: 11px;
  }

  .line-code {
    font-size: 13px;
    word-break: break-all;
    overflow-wrap: break-word;
  }

  .watermark {
    font-size: 13px;
    grid-template-columns: repeat(2, 300px);
    grid-auto-rows: 160px;
    gap: 30px;
  }

  /* Token input page */
  .auth-body {
    padding: 0;
  }

  .auth-shell {
    padding: 16px;
  }

  .auth-card {
    padding: 24px 18px 22px;
  }

  .auth-card h1 {
    font-size: 20px;
  }

  .auth-form input {
    font-size: 16px;
    height: 44px;
  }

  .auth-form button {
    font-size: 16px;
    height: 44px;
  }

  .auth-icon {
    width: 52px;
    height: 52px;
    font-size: 28px;
    margin-bottom: 14px;
  }

  .logout-link {
    margin-right: 0;
  }
}

@media (max-width: 480px) {
  .topbar {
    padding: 0 8px;
  }

  .dot {
    width: 8px;
    height: 8px;
  }

  .file-title {
    max-width: 45vw;
    font-size: 11px;
  }

  .editor-shell {
    width: 100vw;
    margin: 4px 0 16px;
    border-left: 0;
    border-right: 0;
    border-radius: 0;
  }

  .code-row {
    padding-right: 6px;
  }

  .line-no {
    flex: 0 0 28px;
    padding: 0 4px 0 4px;
    font-size: 10px;
  }

  .line-code {
    font-size: 12px;
  }

  .auth-card {
    padding: 20px 14px 18px;
    border-radius: 14px;
  }

  .auth-card h1 {
    font-size: 18px;
  }

  .auth-desc,
  .auth-tip {
    font-size: 13px;
  }
}

@media print {
  html,
  body,
  body * {
    display: none !important;
    visibility: hidden !important;
  }
}

/* Secret key verification page */
.auth-body {
  min-height: 100vh;
  background: radial-gradient(circle at top, #1b2838 0, #0f1117 42%, #080a0f 100%);
  color: #d4d4d4;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
}

.auth-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px;
}

.auth-card {
  width: min(460px, calc(100vw - 36px));
  background: rgba(30, 30, 30, .96);
  border: 1px solid #2d2d30;
  border-radius: 18px;
  padding: 34px 30px 30px;
  box-shadow: 0 28px 90px rgba(0, 0, 0, .45);
  text-align: center;
}

.auth-icon {
  width: 66px;
  height: 66px;
  margin: 0 auto 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: #151922;
  border: 1px solid #2f3b52;
  font-size: 34px;
}

.auth-card h1 {
  margin: 0 0 10px;
  color: #4fc1ff;
  font-size: 24px;
  font-weight: 700;
}

.auth-desc,
.auth-tip,
.auth-file {
  margin: 0;
  color: #c9d1d9;
  line-height: 1.75;
}

.auth-file {
  margin-top: 10px;
  font-size: 14px;
}

.auth-file span {
  color: #4ec9b0;
  font-family: Consolas, "JetBrains Mono", monospace;
}

.auth-error {
  margin-top: 18px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(248, 81, 73, .12);
  border: 1px solid rgba(248, 81, 73, .38);
  color: #ffb4ad;
  font-size: 14px;
}

.auth-form {
  margin-top: 22px;
  display: grid;
  gap: 12px;
}

.auth-form input {
  width: 100%;
  height: 46px;
  padding: 0 14px;
  border-radius: 10px;
  border: 1px solid #3c3c3c;
  background: #111827;
  color: #f8fafc;
  outline: none;
  font-size: 16px;
}

.auth-form input:focus {
  border-color: #4fc1ff;
  box-shadow: 0 0 0 3px rgba(79, 193, 255, .16);
}

.auth-form button {
  height: 46px;
  border: 0;
  border-radius: 10px;
  background: #007acc;
  color: #ffffff;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
}

.auth-form button:hover {
  background: #0e8fe3;
}

.auth-tip {
  margin-top: 18px;
  font-size: 13px;
  color: #858585;
}

.logout-link {
  color: #4fc1ff;
  text-decoration: none;
  margin-right: 10px;
}

.logout-link:hover {
  text-decoration: underline;
}

.auth-expire {
  margin: 10px 0 0;
  padding: 9px 12px;
  border-radius: 10px;
  background: rgba(79, 193, 255, .08);
  border: 1px solid rgba(79, 193, 255, .24);
  color: #bde9ff;
  font-size: 14px;
  line-height: 1.6;
}
