/* ===================================================================
   大事年表 — 布局：无顶栏无底栏，整屏即画布
   =================================================================== */

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;                 /* 画布占满视口，不产生页面滚动条 */
  overscroll-behavior: none;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

#stage {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;               /* 手势全部由脚本接管 */
  cursor: grab;
}
#stage.is-panning { cursor: grabbing; }
#stage.is-over-node { cursor: pointer; }
#stage.is-move-time { cursor: ew-resize; }

/* ------------------------------ 悬浮按钮组 ------------------------------ */

.toolbar {
  position: fixed;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.375rem;
  border-radius: var(--radius-xl);
  background: var(--glass);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow);
  -webkit-backdrop-filter: blur(16px) saturate(150%);
  backdrop-filter: blur(16px) saturate(150%);
}

.toolbar--top {
  top: calc(0.75rem + var(--safe-top));
  left: calc(0.75rem + var(--safe-left));
  max-width: calc(100vw - 1.5rem - var(--safe-left) - var(--safe-right));
  flex-wrap: wrap;
}

.toolbar--bottom {
  bottom: calc(0.75rem + var(--safe-bottom));
  right: calc(0.75rem + var(--safe-right));
  max-width: calc(100vw - 1.5rem - var(--safe-left) - var(--safe-right));
  flex-wrap: wrap;
  justify-content: flex-end;
}

.toolbar__sep {
  width: 1px;
  align-self: stretch;
  margin: 0.25rem 0.125rem;
  background: var(--line);
}

/* ------------------------------ 按钮 ------------------------------ */

.tbtn {
  -webkit-appearance: none;
  appearance: none;
  border: 0;
  margin: 0;
  min-height: var(--tap);
  min-width: var(--tap);
  padding: 0 0.7rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 0.8125rem;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease),
              transform var(--dur-fast) var(--ease);
  user-select: none;
}
.tbtn:hover { background: var(--glass-hi); }
.tbtn:active { transform: scale(0.96); }
.tbtn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.tbtn[aria-pressed="true"],
.tbtn.is-active {
  background: var(--accent-soft);
  color: var(--accent);
}
.tbtn--danger:hover { background: var(--danger-soft); color: var(--danger); }
.tbtn--solid {
  background: var(--accent);
  color: var(--accent-text);
}
.tbtn--solid:hover { background: var(--accent); filter: brightness(1.08); }
.tbtn[disabled] { opacity: 0.4; cursor: not-allowed; }
.tbtn svg { width: 1.15em; height: 1.15em; flex: 0 0 auto; }
.tbtn__label { display: inline; }

/* ------------------------------ 状态区 + 版权 ------------------------------ */

.status-wrap {
  position: fixed;
  z-index: 35;
  left: calc(0.9rem + var(--safe-left));
  bottom: calc(0.9rem + var(--safe-bottom));
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.4rem;
  max-width: calc(100vw - 1.8rem - var(--safe-left) - var(--safe-right));
  pointer-events: none;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.18rem 0.6rem;
  border-radius: 999px;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  -webkit-backdrop-filter: blur(14px) saturate(150%);
  backdrop-filter: blur(14px) saturate(150%);
  color: var(--text-faint);
  font-size: 0.6875rem;
  line-height: 1.6;
  pointer-events: auto;
  user-select: none;
}
.brand__copy { letter-spacing: 0.02em; }
.brand__link {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
  padding: 0 0.1rem;
  border-radius: 4px;
  white-space: nowrap;
}
.brand__link::after { content: ' ↗'; font-weight: 400; opacity: 0.8; }
.brand__link:hover { text-decoration: underline; }
.brand__link:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.status {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  align-items: center;
  pointer-events: none;
  max-width: 100%;
}

.chip {
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  height: 28px;
  padding: 0 0.6rem;
  border-radius: 999px;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  -webkit-backdrop-filter: blur(14px) saturate(150%);
  backdrop-filter: blur(14px) saturate(150%);
  color: var(--text-dim);
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.chip--warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 40%, transparent); }
.chip--edit { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 45%, transparent); }
.chip--dirty { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, transparent); }
.chip__dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: currentColor;
  flex: 0 0 auto;
}

/* ------------------------------ 首次提示 ------------------------------ */

.hint {
  position: fixed;
  z-index: 38;
  left: 50%;
  transform: translateX(-50%);
  top: calc(4.75rem + var(--safe-top));
  max-width: min(92vw, 640px);
  padding: 0.55rem 0.9rem;
  border-radius: 999px;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  color: var(--text-dim);
  font-size: 0.8125rem;
  text-align: center;
  opacity: 0;
  transition: opacity var(--dur-slow) var(--ease);
  pointer-events: none;
}
.hint.is-on { opacity: 1; }
.hint b { color: var(--text); font-weight: 600; }

/* ------------------------------ 拖拽导入 ------------------------------ */

[hidden] { display: none !important; }

.dropzone {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  background: var(--mask);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}
.dropzone__box {
  display: grid;
  justify-items: center;
  gap: 0.4rem;
  padding: 2rem 2.75rem;
  border-radius: var(--radius-xl);
  border: 2px dashed color-mix(in srgb, var(--accent) 55%, transparent);
  background: var(--glass-strong);
  color: var(--accent);
  text-align: center;
}
.dropzone__box p { margin: 0; font-size: 1rem; font-weight: 600; }
.dropzone__box small { color: var(--text-dim); }

.noscript {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 2rem;
  background: var(--bg);
  color: var(--text);
  text-align: center;
}

/* ------------------------------ 响应式 ------------------------------ */

@media (max-width: 900px) {
  .toolbar { padding: 0.3rem; gap: 0.25rem; border-radius: var(--radius-lg); }
  .tbtn { padding: 0 0.5rem; }
}

/* 窄屏：按钮只留图标，标签隐藏；次要按钮由「更多」面板收纳 */
@media (max-width: 640px) {
  .tbtn__label { display: none; }
  .tbtn { padding: 0; }
  .toolbar--top { left: calc(0.5rem + var(--safe-left)); right: calc(0.5rem + var(--safe-right)); max-width: none; }
  .toolbar--bottom { left: calc(0.5rem + var(--safe-left)); right: calc(0.5rem + var(--safe-right)); max-width: none; }
  .status-wrap { left: calc(0.6rem + var(--safe-left)); bottom: calc(5rem + var(--safe-bottom)); max-width: calc(100vw - 1.2rem); }
  .brand { font-size: 0.625rem; padding: 0.14rem 0.5rem; }
  .chip { height: 26px; font-size: 0.6875rem; }
  .hint { font-size: 0.75rem; top: calc(8.6rem + var(--safe-top)); }

  .fold-panel { width: min(94vw, 340px); padding: 0.7rem; }
}

/* 横屏矮屏 */
@media (max-height: 460px) {
  .hint { display: none; }
  .status-wrap { bottom: calc(0.6rem + var(--safe-bottom)); }
}
