:root {
  --bg: #fafaf8;
  --text: #1a1a1a;
  --muted: #777;
  --accent: #c0392b;
  --line: #e6e6e3;
  --max-width: 640px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

* {
  box-sizing: border-box;
}

html {
  font-size: 18px;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
  padding-left: var(--safe-left);
  padding-right: var(--safe-right);
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}

.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 3rem 1.5rem 4rem;
}

/* ===== 顶部导航 ===== */
.top-nav {
  display: flex;
  gap: 1.25rem;
  margin-bottom: 2.5rem;
  font-size: 0.95rem;
}

.top-nav a {
  color: var(--muted);
  text-decoration: none;
  padding: 0.35rem 0.15rem;
  border-bottom: 2px solid transparent;
  transition: color 0.15s;
}

.top-nav a:hover {
  color: var(--text);
}

.top-nav a.active {
  color: var(--text);
  border-bottom-color: var(--accent);
}

/* ===== 头部 ===== */
.site-header h1 {
  font-size: 3rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 0.5rem;
}

.tagline {
  color: var(--muted);
  font-size: 1.05rem;
  margin: 0 0 2.5rem;
}

.intro {
  white-space: pre-line;
  margin-bottom: 3rem;
  color: #333;
}

/* ===== Now 板块 ===== */
.section {
  margin-bottom: 2.5rem;
}

.section h2 {
  font-size: 1.15rem;
  font-weight: 600;
  margin: 0 0 0.75rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--line);
}

.section ul {
  margin: 0;
  padding-left: 1.2rem;
}

.section li {
  margin-bottom: 0.5rem;
}

/* ===== 时间轴 / 人生地图 ===== */
.timeline-wrap {
  margin-top: 3.5rem;
}

.timeline-title {
  font-size: 1.4rem;
  font-weight: 700;
  margin: 0 0 0.3rem;
}

.timeline-subtitle {
  color: var(--muted);
  margin: 0 0 2rem;
  font-size: 0.95rem;
}

.timeline {
  position: relative;
  padding-left: 1.75rem;
}

.timeline::before {
  content: "";
  position: absolute;
  left: 6px;
  top: 4px;
  bottom: 4px;
  width: 2px;
  background: var(--line);
}

.tl-item {
  position: relative;
  padding-bottom: 1.75rem;
}

.tl-item:last-child {
  padding-bottom: 0;
}

.tl-dot {
  position: absolute;
  left: -1.75rem;
  top: 5px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--muted);
}

.tl-highlight .tl-dot {
  border-color: var(--accent);
  background: var(--accent);
}

.tl-date {
  font-size: 0.8rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}

.tl-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0.1rem 0;
  flex-wrap: wrap;
}

.tl-name {
  font-weight: 600;
}

.tl-highlight .tl-name {
  color: var(--accent);
}

.tl-tag {
  font-size: 0.7rem;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 1px 8px;
}

.tl-desc {
  margin: 0.2rem 0 0;
  font-size: 0.92rem;
  color: #444;
}

/* 描述折叠（仅移动端生效，桌面始终全文） */
.tl-desc-wrap {
  position: relative;
}

.tl-expand-btn {
  display: none;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 0.75rem;
  cursor: pointer;
  padding: 0.2rem 0 0;
  font-family: inherit;
  touch-action: manipulation;
}

.tl-expand-btn:hover {
  color: var(--accent);
}

/* ===== 页脚 ===== */
.site-footer {
  margin-top: 4rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--line);
  font-size: 0.9rem;
  color: var(--muted);
}

.site-footer a {
  color: var(--accent);
  text-decoration: none;
}

.site-footer a:hover {
  text-decoration: underline;
}

.now-link {
  margin-top: 0.4rem;
}

.loading {
  text-align: center;
  color: var(--muted);
  margin-top: 6rem;
}

/* ===== 登录遮罩 ===== */
.login-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1.5rem;
}

.login-box {
  width: 100%;
  max-width: 360px;
  text-align: center;
}

.login-box h2 {
  font-size: 1.4rem;
  font-weight: 700;
  margin: 0 0 0.3rem;
}

.login-hint {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0 0 1.5rem;
}

.login-box input[type="password"] {
  width: 100%;
  padding: 0.65rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 1rem;
  font-family: inherit;
  text-align: center;
  margin-bottom: 0.6rem;
  outline: none;
  transition: border-color 0.15s;
}

.login-box input[type="password"]:focus {
  border-color: var(--accent);
}

.login-error {
  color: var(--accent);
  font-size: 0.85rem;
  min-height: 1.4rem;
  margin-bottom: 0.5rem;
}

.login-box .btn-primary {
  width: 100%;
}

/* ===== 后台编辑 ===== */
.admin {
  max-width: 720px;
}

.tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 2rem;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.tabs::-webkit-scrollbar {
  display: none;
}

.tab-btn {
  background: none;
  border: none;
  padding: 0.6rem 1rem;
  font-size: 1rem;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  font-family: inherit;
  white-space: nowrap;
  flex-shrink: 0;
  transition: color 0.15s;
}

.tab-btn.active {
  color: var(--text);
  border-bottom-color: var(--accent);
  font-weight: 600;
}

.tab-panel.hidden {
  display: none;
}

.field {
  margin-bottom: 1.4rem;
}

.field > label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: #555;
  margin-bottom: 0.4rem;
}

.field-row {
  display: flex;
  gap: 1rem;
}

.field-row > div {
  flex: 1;
}

input[type="text"],
textarea {
  width: 100%;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 0.95rem;
  font-family: inherit;
  background: #fff;
  color: var(--text);
}

input[type="text"]:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
}

textarea {
  resize: vertical;
}

/* 动态卡片 */
.dyn-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 1rem;
  background: #fff;
}

.card-head {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 0.75rem;
}

.card .field-row {
  margin-bottom: 0.6rem;
}

.card textarea {
  margin-bottom: 0.5rem;
}

.items-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 0.6rem;
}

.item-row {
  display: flex;
  gap: 0.5rem;
}

.chk {
  font-size: 0.85rem;
  color: #555;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

/* 按钮 */
.btn-primary {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 0.6rem 1.4rem;
  border-radius: 6px;
  font-size: 0.95rem;
  cursor: pointer;
  font-family: inherit;
  touch-action: manipulation;
  transition: opacity 0.15s;
}

.btn-primary:hover {
  opacity: 0.9;
}

.btn-primary:active {
  opacity: 0.8;
}

.btn-ghost {
  background: none;
  border: 1px dashed var(--muted);
  color: var(--muted);
  padding: 0.45rem 0.9rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
  font-family: inherit;
  touch-action: manipulation;
}

.btn-ghost:hover {
  color: var(--text);
  border-color: var(--text);
}

.btn-ghost.sm {
  padding: 0.25rem 0.7rem;
  font-size: 0.82rem;
}

.btn-del {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.25rem 0.4rem;
  border-radius: 4px;
  touch-action: manipulation;
}

.btn-del:hover {
  color: var(--accent);
}

.btn-del.sm {
  font-size: 1.1rem;
  padding: 0.3rem 0.4rem;
}

.actions {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: 1.5rem;
}

.save-msg {
  font-size: 0.9rem;
}

/* ===== 数码装备（分类卡片 + 时长条） ===== */
.gadgets-wrap {
  margin-top: 3.5rem;
}

.gadgets-title {
  font-size: 1.4rem;
  font-weight: 700;
  margin: 0 0 0.3rem;
}

.gadgets-subtitle {
  color: var(--muted);
  margin: 0 0 1.5rem;
  font-size: 0.95rem;
}

.gantt {
  font-size: 0.9rem;
}

/* 分类分组 */
.g-group {
  margin-bottom: 1.6rem;
}

.g-group-head {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.6rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--line);
}

.g-group-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* 每项产品卡片 */
.g-card {
  padding: 0.55rem 0;
  border-bottom: 1px dashed #f0f0ed;
}

.g-card:last-child {
  border-bottom: none;
}

.g-card-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.75rem;
  margin-bottom: 0.35rem;
}

.g-card-name {
  font-weight: 600;
  font-size: 0.95rem;
}

.g-card-date {
  font-size: 0.78rem;
  color: var(--muted);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* 底部：时长文字 + 比例条 */
.g-card-bar-wrap {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.g-card-dur {
  font-size: 0.73rem;
  color: var(--muted);
  white-space: nowrap;
  min-width: 4.5rem;
  text-align: right;
}

.g-card-track {
  flex: 1;
  height: 5px;
  background: #eaeae5;
  border-radius: 999px;
  overflow: hidden;
}

.g-card-bar {
  height: 100%;
  border-radius: 999px;
  opacity: 0.82;
  transition: width 0.5s ease;
  min-width: 3px;
}

.g-dur-high { opacity: 0.9; }
.g-dur-mid  { opacity: 0.7; }
.g-dur-low  { opacity: 0.5; }

/* ===== 后台日期选择器 ===== */
.g-date-row {
  align-items: flex-end;
}

.g-date-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.g-date-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: #777;
}

.g-date-hint {
  font-weight: 400;
  color: #aaa;
  font-size: 0.72rem;
}

.g-date-input {
  display: flex;
  gap: 0.35rem;
  align-items: center;
}

.g-date-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  color: #999;
  pointer-events: none;
}

.g-date-input input[type="month"] {
  flex: 1;
  width: auto;
  min-width: 0;
}

.g-clear-end {
  background: #f5f5f3;
  border: 1px solid #ddd;
  border-radius: 50%;
  color: #999;
  font-size: 0.75rem;
  cursor: pointer;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  line-height: 1;
  padding: 0;
  transition: all 0.15s;
  touch-action: manipulation;
}

.g-clear-end:hover {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
}

input[type="month"],
input[type="date"] {
  width: 100%;
  padding: 0.48rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 0.92rem;
  font-family: inherit;
  background: #fff;
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
  -webkit-appearance: none;
}

input[type="month"]::-webkit-calendar-picker-indicator,
input[type="date"]::-webkit-calendar-picker-indicator {
  opacity: 0.45;
  cursor: pointer;
  padding: 2px;
  transition: opacity 0.15s;
}

input[type="month"]:hover::-webkit-calendar-picker-indicator,
input[type="date"]:hover::-webkit-calendar-picker-indicator {
  opacity: 0.8;
}

input[type="month"]:focus,
input[type="date"]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(192, 57, 43, 0.1);
}

input[type="month"]:hover,
input[type="date"]:hover {
  border-color: #bbb;
}

.g-date-input input[type="month"] {
  flex: 1;
  width: auto;
}

.m-date-wrap,
.m-category-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.m-date-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: #777;
}

.m-date-input {
  display: flex;
  gap: 0.35rem;
  align-items: center;
}

.m-date-input input[type="date"] {
  flex: 1;
  min-width: 0;
}

/* =====================================================
   移动端优化 (≤ 640px)
   ===================================================== */
@media (max-width: 640px) {
  html {
    font-size: 16px;
  }

  .container {
    padding: 1.5rem 1rem 3rem;
  }

  /* 头部缩小 */
  .site-header h1 {
    font-size: 2.2rem;
  }

  .tagline {
    font-size: 0.95rem;
    margin-bottom: 1.8rem;
  }

  .intro {
    margin-bottom: 2rem;
  }

  /* 导航间距加大，方便手指点按 */
  .top-nav {
    gap: 1.5rem;
    margin-bottom: 1.8rem;
  }

  .top-nav a {
    font-size: 1rem;
    padding: 0.4rem 0.15rem;
    min-height: 44px;
    display: flex;
    align-items: center;
  }

  /* 时间轴 */
  .timeline-wrap {
    margin-top: 2.5rem;
  }

  .tl-item {
    padding-bottom: 1.4rem;
  }

  /* 移动端：描述默认折叠 2 行 */
  .tl-desc-wrap.collapsed .tl-desc {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
  }

  .tl-desc-wrap.collapsed .tl-expand-btn {
    display: block;
  }

  .tl-head {
    gap: 0.4rem;
  }

  /* 数码装备 */
  .gadgets-wrap {
    margin-top: 2.5rem;
  }

  .g-card-top {
    /* 保持 row 布局，日期在标题右侧 */
    gap: 0.5rem;
  }

  .g-card-name {
    font-size: 0.88rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .g-card-date {
    font-size: 0.72rem;
    flex-shrink: 0;
  }

  .g-card-dur {
    min-width: 3.6rem;
    font-size: 0.7rem;
  }

  .g-card-bar-wrap {
    gap: 0.5rem;
  }

  .g-card-name {
    font-size: 0.9rem;
  }

  /* 页脚 */
  .site-footer {
    margin-top: 3rem;
  }

  /* ===== 后台编辑移动端 ===== */
  .admin .site-header h1 {
    font-size: 1.6rem;
  }

  .tabs {
    gap: 0.3rem;
    margin-bottom: 1.4rem;
  }

  .tab-btn {
    padding: 0.5rem 0.8rem;
    font-size: 0.9rem;
    min-height: 42px;
  }

  .field-row {
    flex-direction: column;
    gap: 0.6rem;
  }

  .g-date-row {
    flex-direction: column;
    align-items: stretch;
    gap: 0.6rem;
  }

  .g-date-input input[type="month"] {
    width: 100%;
  }

  /* 表单输入框加大触控区域 */
  input[type="text"],
  textarea {
    padding: 0.6rem 0.7rem;
    font-size: 16px; /* 防止 iOS 缩放 */
  }

  input[type="month"],
  input[type="date"] {
    padding: 0.55rem 0.6rem;
    font-size: 16px;
    min-height: 42px;
  }

  select {
    font-size: 16px;
    min-height: 42px;
  }

  /* 按钮加大 */
  .btn-primary {
    padding: 0.7rem 1.5rem;
    min-height: 44px;
    width: 100%;
    text-align: center;
  }

  .btn-ghost {
    padding: 0.55rem 1rem;
    min-height: 44px;
    width: 100%;
    text-align: center;
  }

  .btn-ghost.sm {
    width: auto;
    min-height: 36px;
  }

  .btn-del {
    padding: 0.3rem 0.5rem;
    font-size: 1.3rem;
  }

  .btn-del.sm {
    padding: 0.35rem 0.5rem;
  }

  /* 保存区固定底部 */
  .actions {
    position: sticky;
    bottom: 0;
    background: var(--bg);
    padding: 0.8rem 0 1rem;
    margin-top: 1rem;
    border-top: 1px solid var(--line);
    flex-wrap: wrap;
    z-index: 10;
  }

  .save-msg {
    width: 100%;
    text-align: center;
    order: 1;
  }

  /* 卡片内元素 */
  .card {
    padding: 0.8rem;
    border-radius: 6px;
  }

  .card .field-row {
    flex-direction: column;
    gap: 0.5rem;
  }

  /* 复选框增大触控区 */
  .chk {
    min-height: 40px;
    font-size: 0.9rem;
  }

  .chk input[type="checkbox"] {
    width: 20px;
    height: 20px;
  }

  /* 日期清除按钮增大 */
  .g-clear-end {
    width: 30px;
    height: 30px;
    font-size: 0.85rem;
  }

  /* 日期图标 */
  .g-date-icon {
    width: 20px;
    height: 20px;
  }
}

/* =====================================================
   超小屏 (< 400px)
   ===================================================== */
@media (max-width: 400px) {
  html {
    font-size: 15px;
  }

  .container {
    padding: 1.2rem 0.85rem 2.5rem;
  }

  .site-header h1 {
    font-size: 2rem;
  }

  .top-nav a {
    font-size: 0.95rem;
  }

  .tl-content {
    margin-left: 0;
  }

  .g-card-date {
    font-size: 0.72rem;
  }

  .btn-primary {
    font-size: 0.9rem;
    padding: 0.65rem 1.2rem;
  }
}
