:root {
  --orange: #f26a1b;
  --orange-deep: #d9550c;
  --orange-light: #ff9046;
  --orange-soft: #fff1e6;
  --orange-line: #ffd7b8;
  --bg-image: none;
  --ink: #2f2418;
  --ink-soft: #6b6055;
  --ink-faint: #9b9084;
  --line: #e9e2d9;
  --paper: #ffffff;
  --bg: #faf7f3;
  --green: #2e9b63;
  --shadow: 0 10px 34px rgba(120, 78, 40, .10);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  font-family: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", system-ui, -apple-system, sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  font-size: 14px;
}

button, input { font-family: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

/* ---------- 品牌标记 ---------- */
.brand-mark {
  width: 46px; height: 46px;
  flex: 0 0 46px;
  border-radius: 13px;
  background: linear-gradient(140deg, var(--orange-light), var(--orange-deep));
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 26px; font-weight: 800;
  box-shadow: 0 6px 16px rgba(242, 106, 27, .3);
}
.brand-mark.small { width: 38px; height: 38px; flex-basis: 38px; font-size: 21px; border-radius: 11px; }

/* ---------- 登录页 ---------- */
.auth-view {
  position: relative;
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  overflow: hidden;
  background: linear-gradient(155deg, #fff8f1 0%, #ffeddc 48%, #ffe2c8 100%);
}
.auth-bg-shape {
  position: absolute; border-radius: 50%;
  background: rgba(242, 106, 27, .10);
  filter: blur(2px);
}
.shape-a { width: 420px; height: 420px; top: -150px; right: -90px; }
.shape-b { width: 300px; height: 300px; bottom: -120px; left: -80px; background: rgba(242, 106, 27, .08); }

.auth-card {
  position: relative; z-index: 1;
  width: 100%; max-width: 420px;
  background: var(--paper);
  border-radius: 20px;
  padding: 34px 32px 26px;
  box-shadow: var(--shadow);
  border: 1px solid #f3e8dc;
}
.auth-brand { display: flex; align-items: center; gap: 14px; margin-bottom: 26px; }
.auth-brand h1 { font-size: 22px; margin: 0 0 4px; letter-spacing: .5px; }
.auth-brand p { font-size: 12px; color: var(--ink-soft); margin: 0; }

.auth-tabs {
  display: flex; gap: 6px;
  background: #f7f3ee; padding: 4px;
  border-radius: 11px; margin-bottom: 22px;
}
.auth-tab {
  flex: 1; border: 0; background: transparent;
  padding: 9px; border-radius: 8px;
  color: var(--ink-soft); font-size: 14px; font-weight: 600;
  transition: .18s;
}
.auth-tab.active { background: #fff; color: var(--orange-deep); box-shadow: 0 2px 8px rgba(120,78,40,.10); }

.auth-form { display: flex; flex-direction: column; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 7px; }
.field span { font-size: 13px; color: var(--ink-soft); font-weight: 600; }
.field input {
  height: 44px; padding: 0 14px;
  border: 1px solid var(--line); border-radius: 10px;
  font-size: 14px; color: var(--ink);
  outline: none; transition: .18s;
  background: #fff;
}
.field input:focus { border-color: var(--orange); box-shadow: 0 0 0 3px rgba(242,106,27,.12); }

.auth-error { min-height: 18px; margin: -4px 0 0; color: #c93b2b; font-size: 12px; }

.btn-primary {
  height: 46px; border: 0; border-radius: 10px;
  background: linear-gradient(135deg, var(--orange-light), var(--orange-deep));
  color: #fff; font-size: 15px; font-weight: 700;
  box-shadow: 0 6px 16px rgba(242,106,27,.28);
  transition: .18s;
}
.btn-primary:hover { filter: brightness(1.04); transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }

.auth-note {
  margin-top: 20px; padding-top: 16px;
  border-top: 1px dashed var(--line);
  color: var(--ink-faint); font-size: 11.5px;
  display: flex; align-items: center; gap: 7px;
}
.note-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--orange); flex: 0 0 6px; }

/* ---------- 顶部栏 ---------- */
.topbar {
  background: linear-gradient(100deg, var(--orange), var(--orange-deep));
  color: #fff;
  position: sticky; top: 0; z-index: 20;
  box-shadow: 0 3px 14px rgba(200, 88, 20, .22);
}
.topbar-inner {
  max-width: 1180px; margin: 0 auto;
  padding: 12px 22px;
  display: flex; align-items: center; justify-content: space-between; gap: 18px;
}
.topbar-brand { display: flex; align-items: center; gap: 11px; min-width: 190px; }
.topbar-brand .brand-mark { background: rgba(255,255,255,.2); box-shadow: none; }
.topbar-brand strong { display: block; font-size: 16px; letter-spacing: .5px; }
.topbar-brand span { display: block; font-size: 11px; opacity: .85; margin-top: 2px; }

.date-nav { display: flex; align-items: center; gap: 6px; }
.icon-btn {
  width: 30px; height: 30px;
  border: 0; border-radius: 8px;
  background: rgba(255,255,255,.16); color: #fff;
  font-size: 21px; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  transition: .15s;
}
.icon-btn:hover { background: rgba(255,255,255,.3); }
.date-label {
  border: 0; background: transparent; color: #fff;
  font-size: 15px; font-weight: 700; padding: 6px 8px;
  min-width: 138px; border-radius: 8px;
}
.date-label:hover { background: rgba(255,255,255,.14); }
.hidden-date-input {
  position: absolute; opacity: 0; width: 1px; height: 1px;
  pointer-events: none;
}
.today-btn {
  border: 1px solid rgba(255,255,255,.55); background: transparent;
  color: #fff; padding: 5px 11px; border-radius: 8px;
  font-size: 12px; font-weight: 600;
}
.today-btn:hover { background: rgba(255,255,255,.16); }

.topbar-user { display: flex; align-items: center; gap: 10px; min-width: 190px; justify-content: flex-end; }
.user-name { font-size: 13px; font-weight: 600; max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ghost-btn {
  border: 1px solid rgba(255,255,255,.5); background: transparent; color: #fff;
  padding: 5px 12px; border-radius: 8px; font-size: 12px;
}
.ghost-btn:hover { background: rgba(255,255,255,.16); }

/* ---------- 主体布局 ---------- */
.workspace {
  max-width: 1180px; margin: 0 auto;
  padding: 26px 22px 60px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 22px;
  align-items: start;
}

/* ---------- 主卡片（卡片式界面） ---------- */
.sheet-card {
  position: relative;
  background: var(--paper);
  border: 1px solid #efe6db;
  border-radius: 20px;
  overflow: hidden;
  box-shadow: 0 18px 50px rgba(90, 55, 25, .16);
}

/* 背景层：铺满整张卡片，透明度可调 */
.sheet-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: var(--bg-image);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  opacity: var(--bg-opacity, .55);
  pointer-events: none;
  z-index: 0;
}
.sheet-card > * { position: relative; z-index: 1; }

/* 有背景时，内容区半透明让背景透出来，同时保证文字可读 */
.sheet-card.has-bg .sections { background: rgba(255, 255, 255, .55); border-radius: 14px; margin: 16px 16px 0; padding: 18px 14px 6px; }
.sheet-card.has-bg .section-body { background: rgba(255, 255, 255, .82); }
.sheet-card.has-bg .card-date-row { background: rgba(255, 241, 230, .74); }
.sheet-card.has-bg .sheet-foot { background: rgba(253, 250, 247, .72); }
.sheet-card.has-bg .card-header { background: linear-gradient(120deg, var(--orange-light), var(--orange) 55%, var(--orange-deep)); }

/* 渐变标题头 */
.card-header {
  position: relative;
  overflow: hidden;
  background: linear-gradient(120deg, var(--orange-light), var(--orange) 55%, var(--orange-deep));
  color: #fff;
  padding: 30px 32px 26px;
  text-align: center;
}
.card-header::before, .card-header::after {
  content: ''; position: absolute; border-radius: 50%;
  background: rgba(255,255,255,.14);
}
.card-header::before { width: 180px; height: 180px; right: -40px; top: -70px; }
.card-header::after { width: 120px; height: 120px; left: -30px; bottom: -60px; }
.card-kicker {
  position: relative; display: block;
  font-size: 11px; letter-spacing: 2px; opacity: .85; margin-bottom: 10px;
}
.card-header h2 {
  position: relative; margin: 0;
  font-size: 22px; font-weight: 800; letter-spacing: .5px;
}
.card-header p {
  position: relative; margin: 9px 0 0;
  font-size: 13px; opacity: .92; letter-spacing: 2px;
}

/* 日期 + 起床 */
.card-date-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 16px 32px;
  background: var(--orange-soft);
  border-bottom: 1px solid var(--orange-line);
}
.card-date-row strong { font-size: 17px; color: var(--ink); }
.wake-row { display: flex; align-items: center; gap: 8px; white-space: nowrap; font-size: 13px; color: var(--orange-deep); font-weight: 700; }
.wake-row input {
  width: 96px; height: 32px; padding: 0 9px;
  border: 1px solid var(--orange-line); border-radius: 8px;
  background: #fff; color: var(--orange-deep);
  font-size: 13px; outline: none; text-align: center; font-weight: 700;
}
.wake-row input:focus { border-color: var(--orange); }

/* 板块区 */
.sections { padding: 20px 24px 8px; display: flex; flex-direction: column; gap: 18px; }
.section-head {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--orange-soft);
  color: var(--orange-deep);
  font-size: 15px; font-weight: 800;
  letter-spacing: 1px;
  padding: 10px 12px 10px 16px;
  border-radius: 10px 10px 0 0;
  border-left: 4px solid var(--orange);
}
.section-title-text { flex: 1 1 auto; min-width: 0; }
.section-del {
  flex: 0 0 auto;
  border: 0; background: transparent;
  color: var(--ink-faint);
  font-size: 18px; line-height: 1;
  width: 24px; height: 24px; border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  opacity: .45; transition: .15s;
}
.section-head:hover .section-del { opacity: 1; }
.section-del:hover { background: rgba(224, 90, 74, .14); color: #c93b2b; }

/* 添加栏目 */
.add-section-row { padding: 0 0 4px; }
.add-section-btn {
  width: 100%;
  border: 1px dashed #d9cbbd; background: #fffdfb;
  color: var(--orange-deep); font-size: 13px; font-weight: 700;
  padding: 11px; border-radius: 10px;
  transition: .15s;
}
.add-section-btn:hover { border-color: var(--orange); background: var(--orange-soft); }
.add-section-input { width: 100%; }
.section-body {
  border: 1px solid var(--line); border-top: 0;
  border-radius: 0 0 12px 12px;
  overflow: hidden;
  background: #fff;
}
.item-row {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid #f2ede7;
  transition: background .15s;
}
.item-row:last-child { border-bottom: 0; }
.item-row:hover { background: #fffcf9; }

.checkbox {
  appearance: none; -webkit-appearance: none;
  width: 19px; height: 19px; flex: 0 0 19px;
  border: 1.5px solid #cfc4b8; border-radius: 5px;
  margin: 2px 0 0; cursor: pointer;
  position: relative; transition: .15s;
  background: #fff;
}
.checkbox:checked { background: var(--orange); border-color: var(--orange); }
.checkbox:checked::after {
  content: ''; position: absolute;
  left: 6px; top: 2px;
  width: 4px; height: 9px;
  border: solid #fff; border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.item-main { flex: 1 1 auto; min-width: 0; }
.item-text {
  display: block; width: 100%;
  line-height: 1.65; font-size: 14px;
  border: 1px solid transparent; border-radius: 6px;
  padding: 2px 6px; margin-left: -6px;
  background: transparent; color: var(--ink);
  outline: none; resize: none; overflow: hidden;
}
.item-text:hover { border-color: #f0e3d4; }
.item-text:focus { border-color: var(--orange); background: #fffaf5; }
.item-row.done .item-text { color: var(--ink-faint); text-decoration: line-through; }

.item-progress {
  display: inline-flex; align-items: center; gap: 4px;
  margin-top: 5px; margin-left: -6px;
  font-size: 12px; color: var(--orange-deep); font-weight: 700;
  background: var(--orange-soft); border: 0;
  padding: 2px 9px; border-radius: 12px;
}
.item-progress:hover { background: #ffe1c7; }
.item-progress.empty { color: var(--ink-faint); background: #f5f1ec; font-weight: 500; }
.progress-inputs { display: flex; gap: 5px; margin-top: 6px; align-items: center; }
.progress-inputs input {
  width: 56px; height: 27px; padding: 0 7px;
  border: 1px solid var(--orange-line); border-radius: 6px;
  font-size: 12px; outline: none; color: var(--ink);
}
.progress-inputs span { color: var(--ink-faint); }

.row-actions { display: flex; gap: 4px; opacity: 0; transition: opacity .15s; }
.item-row:hover .row-actions, .item-row:focus-within .row-actions { opacity: 1; }
.mini-btn {
  border: 1px solid var(--line); background: #fff;
  width: 26px; height: 26px; border-radius: 7px;
  color: var(--ink-faint); font-size: 15px; line-height: 1;
  display: flex; align-items: center; justify-content: center;
}
.mini-btn:hover { border-color: var(--orange); color: var(--orange-deep); }
.mini-btn.del:hover { border-color: #e05a4a; color: #c93b2b; }

.add-row { padding: 10px 16px 13px; }
.add-btn {
  border: 1px dashed #e4d3c2; background: #fffdfb;
  color: var(--orange-deep); font-size: 12.5px;
  padding: 7px 14px; border-radius: 8px;
  transition: .15s;
}
.add-btn:hover { border-color: var(--orange); background: var(--orange-soft); }
.add-input {
  width: 100%; height: 34px; padding: 0 12px;
  border: 1px solid var(--orange); border-radius: 8px;
  outline: none; font-size: 13px; color: var(--ink);
}

.section-body.empty-hint { padding: 14px 16px; color: var(--ink-faint); font-size: 13px; }

/* 底部统计条 */
.card-summary {
  margin: 12px 24px 20px;
  background: linear-gradient(120deg, var(--orange), var(--orange-deep));
  color: #fff;
  border-radius: 12px;
  padding: 16px;
  text-align: center;
}
.card-summary strong { font-size: 17px; letter-spacing: 1px; }

.sheet-foot {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 26px;
  background: #fdfaf7; border-top: 1px solid var(--line);
}
.soft-btn {
  border: 1px solid var(--line); background: #fff; color: var(--ink-soft);
  padding: 7px 13px; border-radius: 8px; font-size: 12px;
}
.soft-btn:hover { border-color: var(--orange); color: var(--orange-deep); }
.danger-soft:hover { border-color: #e05a4a; color: #c93b2b; }
.save-status { margin-left: auto; font-size: 11.5px; color: var(--green); }

/* ---------- 侧栏 ---------- */
.side-col { display: flex; flex-direction: column; gap: 18px; }
.panel {
  background: var(--paper); border: 1px solid #efe6db;
  border-radius: 14px; padding: 18px 19px;
  box-shadow: 0 6px 22px rgba(120,78,40,.06);
}
.panel h3 {
  margin: 0 0 16px; font-size: 14px; color: var(--orange-deep);
  padding-left: 9px; border-left: 3px solid var(--orange);
  line-height: 1.1;
}
.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 8px; }
.stat-item { text-align: center; }
.stat-value { display: block; font-size: 23px; font-weight: 800; color: var(--orange-deep); line-height: 1.2; }
.stat-label { display: block; font-size: 11px; color: var(--ink-faint); margin-top: 5px; }
.progress-track {
  height: 7px; border-radius: 6px; background: #f3ede6;
  margin: 20px 0 10px; overflow: hidden;
}
.progress-fill {
  height: 100%; width: 0%;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--orange-light), var(--orange));
  transition: width .3s;
}
.stat-hint { margin: 0; font-size: 11.5px; color: var(--ink-soft); line-height: 1.6; }

.tip-panel ul { margin: 0; padding-left: 18px; }
.tip-panel li { font-size: 12px; color: var(--ink-soft); line-height: 1.9; }
.tip-warn {
  margin: 14px 0 0; padding: 10px 11px;
  background: #fff8f0; border: 1px solid #fbe3ca;
  border-radius: 8px; font-size: 11px; color: #9a6b3e; line-height: 1.6;
}

/* ---------- 出图设置 ---------- */
.style-group { margin-bottom: 18px; }
.style-label {
  display: block; font-size: 12px; color: var(--ink-soft);
  font-weight: 600; margin-bottom: 9px;
}
.swatches { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.swatch {
  width: 26px; height: 26px; border-radius: 50%;
  border: 2px solid #fff; box-shadow: 0 0 0 1px var(--line);
  transition: .15s; padding: 0;
}
.swatch:hover { transform: scale(1.12); }
.swatch.active { box-shadow: 0 0 0 2px var(--ink); }
.custom-color {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 12px; color: var(--ink-soft); cursor: pointer;
}
.custom-color input {
  width: 30px; height: 26px; border: 1px solid var(--line);
  border-radius: 6px; background: none; padding: 2px; cursor: pointer;
}
.bg-swatches { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.bg-swatch {
  width: 40px; height: 28px; border-radius: 7px;
  border: 2px solid #fff; box-shadow: 0 0 0 1px var(--line);
  padding: 0; transition: .15s; background-size: cover; background-position: center;
}
.bg-swatch:hover { transform: translateY(-1px); }
.bg-swatch.active { box-shadow: 0 0 0 2px var(--ink); }
.bg-upload {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px dashed #d9cbbd; background: #fffdfb;
  padding: 6px 11px; border-radius: 8px;
  font-size: 12px; color: var(--ink-soft); cursor: pointer;
}
.bg-upload:hover { border-color: var(--orange); color: var(--orange-deep); }
.bg-upload input { display: none; }

/* 背景预览缩略图（白色蒙层模拟当前透明度，拖滑块即时反馈） */
.bg-preview {
  position: relative;
  margin-top: 10px;
  height: 92px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background-color: #fff;
  background-image: var(--bg-image);
  background-size: cover;
  background-position: center;
  display: flex; align-items: flex-end; justify-content: center;
  overflow: hidden;
}
.bg-preview::after {
  content: '';
  position: absolute; inset: 0;
  background: #fff;
  opacity: calc(1 - var(--bg-opacity, .55));
  pointer-events: none;
  transition: opacity .12s;
}
.bg-preview span {
  position: relative; z-index: 1;
  font-size: 10.5px; color: #fff;
  background: rgba(0, 0, 0, .5);
  padding: 3px 9px; border-radius: 10px;
  margin-bottom: 6px;
}

/* 透明度调节 */
.opacity-box {
  margin-top: 12px;
  border: 1px solid var(--orange-line);
  background: var(--orange-soft);
  border-radius: 10px;
  padding: 10px 12px;
}
.opacity-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 8px;
}
.opacity-head b { font-size: 12px; color: var(--orange-deep); }
.opacity-head .opacity-val { font-size: 15px; font-weight: 800; color: var(--orange-deep); }
.opacity-row {
  display: flex; align-items: center; gap: 8px;
  font-size: 11px; color: var(--ink-soft);
}
.opacity-row .op-min, .opacity-row .op-max { flex: 0 0 auto; font-size: 10px; color: var(--ink-faint); }
.opacity-row input[type=range] {
  flex: 1; height: 20px; accent-color: var(--orange); cursor: pointer;
}
.opacity-tip { margin: 7px 0 0; font-size: 10px; color: var(--ink-faint); line-height: 1.5; }

.text-btn {
  border: 0; background: transparent; color: var(--ink-faint);
  font-size: 11.5px; padding: 4px 0 0 6px; text-decoration: underline;
}
.text-btn:hover { color: var(--orange-deep); }
.export-btn { width: 100%; margin-top: 4px; }
.export-hint {
  margin: 9px 0 0; font-size: 11px; color: var(--ink-faint);
  line-height: 1.6; text-align: center;
}

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 30px; transform: translateX(-50%);
  background: rgba(47,36,24,.92); color: #fff;
  padding: 10px 18px; border-radius: 9px;
  font-size: 13px; z-index: 100;
  box-shadow: 0 8px 24px rgba(0,0,0,.2);
}

/* ---------- 响应式 ---------- */
@media (max-width: 900px) {
  .workspace { grid-template-columns: 1fr; }
  .side-col { flex-direction: row; flex-wrap: wrap; }
  .side-col .panel { flex: 1 1 260px; }
}
@media (max-width: 640px) {
  .topbar-inner { flex-wrap: wrap; gap: 10px; padding: 11px 15px; }
  .topbar-brand, .topbar-user { min-width: 0; flex: 1 1 auto; }
  .date-nav { order: 3; width: 100%; justify-content: center; }
  .workspace { padding: 16px 12px 40px; }
  .sheet-head { padding: 16px 17px; flex-direction: column; align-items: flex-start; }
  .item-row { padding: 12px 17px; }
  .section-head { padding: 9px 17px; }
  .add-row, .sheet-foot { padding-left: 17px; padding-right: 17px; }
  .sheet-foot { flex-wrap: wrap; }
  .save-status { width: 100%; margin-left: 0; }
  .row-actions { opacity: 1; }
}
