/* ============================================================
   Scratch — 临时记事本 设计系统
   主题：代码编辑器质感，服务"调试时随手记一笔"的场景
   ============================================================ */

:root {
  --bg-primary:   #14161b;
  --bg-surface:   #1b1e25;
  --bg-elevated:  #22252e;
  --bg-input:     #191b21;
  --border:       #2b2f39;
  --border-soft:  #23262f;

  --text-primary: #e7e9ee;
  --text-muted:   #8a90a2;
  --text-faint:   #565c6c;

  --accent:       #7c9cff;
  --accent-dim:   #4f63a8;
  --accent-amber: #e3b341;
  --accent-green: #4fd1a5;
  --danger:       #ef6461;

  --font-ui:   -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-mono: "JetBrains Mono", "Fira Code", ui-monospace, SFMono-Regular, Menlo, Consolas, "Courier New", monospace;

  --radius: 6px;
  --status-bar-h: 34px;
  --topbar-h: 52px;
}

* { box-sizing: border-box; }

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

body {
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-ui);
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

button {
  font-family: inherit;
  cursor: pointer;
}

::selection {
  background: var(--accent-dim);
  color: #fff;
}

/* ---------- 顶部栏 ---------- */
.topbar {
  height: var(--topbar-h);
  min-height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-surface);
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 15px;
  letter-spacing: 0.2px;
}

.brand .dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn {
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-primary);
  padding: 6px 12px;
  border-radius: var(--radius);
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: border-color .15s, background .15s;
}
.btn:hover { border-color: var(--accent-dim); background: #262a34; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #10131c;
  font-weight: 600;
}
.btn-primary:hover { background: #93aeff; border-color: #93aeff; }

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-muted);
}
.btn-ghost:hover { color: var(--text-primary); background: var(--bg-elevated); }

.user-chip {
  font-size: 13px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 8px;
}
.user-chip strong { color: var(--text-primary); font-weight: 600; }

/* ---------- 主编辑区 ---------- */
.editor-wrap {
  flex: 1;
  display: flex;
  min-height: 0;
  position: relative;
}

#editor {
  flex: 1;
  width: 100%;
  height: 100%;
  resize: none;
  border: none;
  outline: none;
  padding: 20px 24px;
  background: var(--bg-input);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 15px;
  line-height: 1.7;
  tab-size: 2;
}

#editor::placeholder { color: var(--text-faint); }

#editor[readonly] {
  cursor: default;
  background: var(--bg-primary);
  color: var(--text-muted);
}

/* ---------- 底部状态栏 ---------- */
.statusbar {
  height: var(--status-bar-h);
  min-height: var(--status-bar-h);
  background: var(--accent-dim);
  color: #eef1ff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  font-size: 12px;
  font-family: var(--font-mono);
}

.statusbar.mode-local { background: #3a3f4d; }
.statusbar.mode-saving { background: var(--accent-amber); color: #2a1f00; }
.statusbar.mode-error { background: var(--danger); color: #2a0000; }

.status-left, .status-right {
  display: flex;
  align-items: center;
  gap: 14px;
}

.status-item { display: flex; align-items: center; gap: 5px; }

.status-btn {
  background: transparent;
  border: none;
  color: inherit;
  font-family: inherit;
  font-size: 12px;
  padding: 2px 6px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  gap: 5px;
}
.status-btn:hover { background: rgba(255,255,255,.14); }
.status-btn:disabled { opacity: .4; cursor: not-allowed; }
.status-btn:disabled:hover { background: transparent; }
.status-btn.locked-active {
  background: rgba(227, 179, 65, .18);
  color: var(--accent-amber);
}
.status-btn.locked-active:hover { background: rgba(227, 179, 65, .28); }

/* ---------- 历史面板（右侧抽屉） ---------- */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s;
  z-index: 40;
}
.overlay.open { opacity: 1; pointer-events: auto; }

.history-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 360px;
  max-width: 92vw;
  background: var(--bg-surface);
  border-left: 1px solid var(--border);
  transform: translateX(100%);
  transition: transform .22s ease;
  z-index: 50;
  display: flex;
  flex-direction: column;
}
.history-panel.open { transform: translateX(0); }

.history-header {
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.history-header h2 { font-size: 15px; margin: 0; font-weight: 600; }

.history-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.history-item {
  padding: 10px 12px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  margin-bottom: 4px;
  transition: background .12s, border-color .12s;
}
.history-item:hover { background: var(--bg-elevated); border-color: var(--border); }

.history-item .h-time {
  font-size: 12px;
  color: var(--accent);
  font-family: var(--font-mono);
  margin-bottom: 4px;
}
.history-item .h-preview {
  font-size: 13px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.history-empty {
  color: var(--text-faint);
  font-size: 13px;
  text-align: center;
  padding: 40px 20px;
}

/* ---------- 认证页面（登录/注册） ---------- */
.auth-page {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 32px 28px;
}

.auth-card .brand {
  justify-content: center;
  margin-bottom: 22px;
  font-size: 17px;
}

.auth-card h1 {
  font-size: 18px;
  margin: 0 0 6px;
  text-align: center;
}
.auth-card .sub {
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  margin: 0 0 24px;
}

.field { margin-bottom: 16px; }
.field label {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.field input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  color: var(--text-primary);
  font-size: 14px;
  outline: none;
  transition: border-color .15s;
}
.field input:focus { border-color: var(--accent); }

.auth-submit {
  width: 100%;
  padding: 11px;
  margin-top: 6px;
}

.auth-error {
  background: rgba(239, 100, 97, .12);
  border: 1px solid rgba(239, 100, 97, .35);
  color: #ff9c99;
  font-size: 13px;
  padding: 9px 12px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  display: none;
}
.auth-error.show { display: block; }

.auth-foot {
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 20px;
}

/* ---------- 管理后台 ---------- */
.admin-page {
  height: 100%;
  display: flex;
  flex-direction: column;
}

.admin-main {
  flex: 1;
  overflow-y: auto;
  padding: 28px 32px 60px;
}

.admin-main h1 {
  font-size: 20px;
  margin: 0 0 4px;
}
.admin-main .admin-sub {
  color: var(--text-muted);
  font-size: 13px;
  margin: 0 0 26px;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 32px;
}

.stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px 20px;
}

.stat-card .stat-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.stat-card .stat-value {
  font-size: 28px;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--accent);
}

.section-title {
  font-size: 14px;
  font-weight: 600;
  margin: 0 0 12px;
  color: var(--text-primary);
}

.text-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}
.text-table th, .text-table td {
  text-align: left;
  padding: 11px 14px;
  font-size: 13px;
  border-bottom: 1px solid var(--border-soft);
}
.text-table th {
  color: var(--text-muted);
  font-weight: 500;
  background: var(--bg-elevated);
}
.text-table tr:last-child td { border-bottom: none; }
.text-table td.col-preview {
  color: var(--text-muted);
  max-width: 360px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: var(--font-mono);
}
.text-table td.col-user { color: var(--accent); font-weight: 600; }
.text-table td.col-time { color: var(--text-faint); font-family: var(--font-mono); white-space: nowrap; }

.link-view {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 4px 10px;
  border-radius: 5px;
  font-size: 12px;
}
.link-view:hover { color: var(--text-primary); border-color: var(--accent-dim); }

.admin-empty, .admin-loading {
  color: var(--text-faint);
  font-size: 13px;
  padding: 20px 0;
}

/* 只读查看弹窗 */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 60;
  padding: 20px;
}
.modal-overlay.open { display: flex; }

.modal-box {
  width: 100%;
  max-width: 560px;
  max-height: 80vh;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
}
.modal-head {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-head .modal-meta {
  font-size: 12px;
  color: var(--text-muted);
}
.modal-body {
  padding: 16px 18px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.7;
  color: var(--text-primary);
}
.readonly-badge {
  font-size: 11px;
  color: var(--accent-amber);
  border: 1px solid rgba(227,179,65,.4);
  padding: 2px 8px;
  border-radius: 10px;
}

@media (max-width: 640px) {
  .admin-main { padding: 20px 16px 40px; }
  .text-table { display: block; overflow-x: auto; white-space: nowrap; }
}

/* ---------- 响应式 ---------- */
@media (max-width: 640px) {
  .topbar { padding: 0 12px; }
  .brand span.brand-text { display: none; }
  #editor { padding: 14px 16px; font-size: 14px; }
  .statusbar { padding: 0 10px; font-size: 11px; }
  .status-left { gap: 8px; }
  .status-right { gap: 8px; }
  .status-item .label-full { display: none; }
  .history-panel { width: 100%; }
  .auth-card { padding: 26px 20px; }
}

/* ---------- 品牌副标题 / 语言切换器 ---------- */
.brand-tagline {
  font-weight: 400;
  font-size: 11px;
  color: var(--text-muted);
  margin-left: 4px;
  letter-spacing: .3px;
}

.lang-switch {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-primary);
  border-radius: var(--radius);
  padding: 6px 8px;
  font-size: 12px;
  font-family: var(--font-ui);
  cursor: pointer;
}
.lang-switch:hover { border-color: var(--accent-dim); }

/* ---------- 广告位 ---------- */
.ad-slot-wrap {
  border-bottom: 1px solid var(--border);
  background: var(--bg-surface);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 12px;
  min-height: 0;
}
.ad-slot {
  width: 100%;
  max-width: 970px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* 内容页（非全屏工具页）里的广告位，留白更大一些 */
.content-page .ad-slot-wrap {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-surface);
  margin: 28px 0;
  padding: 14px;
}

/* ---------- 底部极简法律链接条（用在工具主页） ---------- */
.site-footer-mini {
  height: 30px;
  min-height: 30px;
  background: var(--bg-primary);
  border-top: 1px solid var(--border-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  font-size: 11px;
  color: var(--text-faint);
}
.site-footer-mini a { color: var(--text-faint); }
.site-footer-mini a:hover { color: var(--text-muted); text-decoration: underline; }
.site-footer-brand { color: var(--text-muted); font-weight: 600; }

/* ---------- Cookie / 广告同意横幅 ---------- */
.consent-bar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 80;
  background: var(--bg-elevated);
  border-top: 1px solid var(--border);
  padding: 14px 18px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  box-shadow: 0 -6px 24px rgba(0,0,0,.35);
}
.consent-text {
  font-size: 12.5px;
  color: var(--text-muted);
  max-width: 640px;
  line-height: 1.6;
}
.consent-text a { color: var(--accent); }
.consent-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

/* ---------- 内容页（About / Contact / Privacy / Terms）通用布局 ---------- */
.content-page {
  height: auto;
  min-height: 100%;
  overflow-y: auto;
  display: block;
}
.content-nav {
  height: var(--topbar-h);
  min-height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-surface);
  position: sticky;
  top: 0;
  z-index: 10;
}
.content-nav .links {
  display: flex;
  align-items: center;
  gap: 18px;
  font-size: 13px;
}
.content-nav .links a { color: var(--text-muted); }
.content-nav .links a:hover { color: var(--text-primary); }
.content-nav .right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.content-main {
  max-width: 720px;
  margin: 0 auto;
  padding: 48px 24px 80px;
}
.content-main h1 {
  font-size: 26px;
  margin: 0 0 6px;
}
.content-main .updated-note {
  color: var(--text-faint);
  font-size: 12px;
  margin: 0 0 32px;
  font-family: var(--font-mono);
}
.legal-body h2 {
  font-size: 16px;
  margin: 30px 0 10px;
  color: var(--text-primary);
}
.legal-body h2:first-child { margin-top: 0; }
.legal-body p {
  color: var(--text-muted);
  line-height: 1.85;
  margin: 0 0 14px;
  font-size: 14px;
}
.legal-body ul {
  color: var(--text-muted);
  line-height: 1.85;
  font-size: 14px;
  padding-left: 20px;
  margin: 0 0 14px;
}
.legal-body a { color: var(--accent); }
.legal-body strong { color: var(--text-primary); }

.content-footer {
  border-top: 1px solid var(--border);
  padding: 24px;
  text-align: center;
  color: var(--text-faint);
  font-size: 12px;
}
.content-footer .links {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.content-footer .links a { color: var(--text-muted); }
.content-footer .links a:hover { color: var(--text-primary); }

/* ---------- 管理后台：广告代码管理 ---------- */
.ad-admin-box {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 32px;
}
.ad-admin-box textarea {
  width: 100%;
  min-height: 140px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 12.5px;
  padding: 12px;
  resize: vertical;
  margin: 12px 0;
}
.ad-admin-box .ad-admin-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}
.ad-admin-msg {
  font-size: 12px;
  color: var(--accent-green);
  margin-left: 4px;
}

@media (max-width: 640px) {
  .content-main { padding: 32px 16px 60px; }
  .consent-bar { flex-direction: column; align-items: stretch; }
  .consent-actions { justify-content: flex-end; }
  .site-footer-mini { flex-wrap: wrap; height: auto; padding: 6px 10px; gap: 10px 14px; }
}
