/**
 * 手机 App 风格布局层（在 styles.css 之后加载，负责整体骨架）
 * 顶部：标题栏 + 搜索   底部：品牌标签栏   右下：悬浮「＋」
 */

/* ---------------- 应用骨架 ---------------- */

.app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
  background: var(--bg);
}

.appbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  padding-top: calc(10px + env(safe-area-inset-top));
  background: rgba(255, 255, 255, .94);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
  position: relative;
  z-index: 20;
  flex: none;
}

.appbar-user {
  border: 0;
  background: transparent;
  padding: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
}

.appbar-title { flex: 1; min-width: 0; display: grid; gap: 1px; }
.appbar-title h1 {
  font-size: 16px;
  font-weight: 650;
  margin: 0;
  letter-spacing: .2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.appbar-title span { font-size: 11.5px; color: var(--ink-3); }

.appbar-actions { display: flex; align-items: center; gap: 8px; flex: none; }

.searchbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  flex: none;
}

.searchbar input {
  flex: 1;
  min-width: 0;
  padding: 10px 12px;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: #f5f7fa;
  font-size: 14px;
  font-family: inherit;
  color: var(--ink);
}

.searchbar input:focus {
  outline: none;
  border-color: var(--primary);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(47, 111, 237, .13);
}

/* 主区域：这里滚动，底部给标签栏和悬浮按钮留位置 */
.main {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 12px 14px calc(104px + env(safe-area-inset-bottom));
}

/* ---------------- 顶部工具行 ---------------- */

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 2px 0 10px;
  position: sticky;
  top: 0;
  z-index: 10;
  background: linear-gradient(var(--bg) 72%, rgba(244, 246, 249, 0));
}

.toolbar-left { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; }
.toolbar-right { display: flex; align-items: center; gap: 8px; }
.toolbar .page-title { font-size: 15.5px; font-weight: 650; }

.status-filters {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  overflow-x: auto;
  padding: 2px 0 4px;
  scrollbar-width: none;
}

.status-filters::-webkit-scrollbar { display: none; }

.status-chip {
  flex: 0 0 auto;
  padding: 7px 12px;
  font-size: 12.5px;
}

.status-chip b {
  font-weight: 700;
  margin-left: 5px;
  font-variant-numeric: tabular-nums;
}

.status-chip.st-making.is-on b { color: #a35f00; }
.status-chip.st-ready.is-on b { color: var(--primary-dark); }
.status-chip.st-done.is-on b { color: #0a7a54; }
.status-chip.st-canceled.is-on b { color: #5b6b83; }

.scope-total {
  flex: 0 0 auto;
  font-size: 12px;
  color: var(--ink-3);
  padding-left: 4px;
  white-space: nowrap;
}

/* ---------------- 底部品牌标签栏（App 底部导航） ---------------- */

.bottombar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px calc(9px + env(safe-area-inset-bottom));
  background: rgba(255, 255, 255, .97);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
  overflow-x: auto;
  scrollbar-width: none;
  justify-content: safe center;
}

.bottombar::-webkit-scrollbar { display: none; }

.btab {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 15px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: #f2f4f8;
  color: var(--ink-2);
  font-family: inherit;
  font-size: 13.5px;
  white-space: nowrap;
  cursor: pointer;
  transition: background .16s, color .16s, box-shadow .16s;
}

.btab:active { transform: scale(.97); }

.btab-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--brand, #94a3b8);
  flex: none;
}

.btab-dot-all { background: linear-gradient(140deg, #6ea8ff, #a78bfa); }

.btab-name { font-weight: 500; }

.btab-count {
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
  padding: 1px 7px;
  border-radius: 999px;
  background: #fff;
  color: var(--ink-3);
}

.btab.is-active {
  background: #16233c;
  color: #fff;
  box-shadow: 0 10px 22px -14px rgba(19, 26, 36, .9);
}

.btab.is-active .btab-count { background: rgba(255, 255, 255, .18); color: #fff; }

.btab-add { border-style: dashed; border-color: var(--line); background: #fff; color: var(--ink-3); }
.btab-plus { font-size: 15px; line-height: 1; }

/* ---------------- 悬浮新建按钮 ---------------- */

.fab {
  position: fixed;
  right: 16px;
  bottom: calc(84px + env(safe-area-inset-bottom));
  z-index: 31;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  border: 0;
  background: var(--primary);
  color: #fff;
  font-size: 26px;
  line-height: 1;
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: 0 16px 30px -12px rgba(47, 111, 237, .95);
  transition: background .16s, transform .16s;
}

.fab:hover { background: var(--primary-dark); }
.fab:active { transform: scale(.95); }

/* ---------------- 手机版：日历改成按天排的日程 ---------------- */

.agenda { display: grid; gap: 10px; }

.agenda-day {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.agenda-day.is-today {
  box-shadow: 0 0 0 2px rgba(47, 111, 237, .3), var(--shadow-sm);
}

.agenda-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: #fafbfd;
  border-bottom: 1px solid var(--line-2);
  cursor: pointer;
}

.agenda-day.is-today .agenda-head { background: #f4f8ff; }

.agenda-date { display: inline-flex; align-items: baseline; gap: 7px; }
.agenda-date b { font-size: 14.5px; }
.agenda-week { font-size: 11.5px; color: var(--ink-3); }
.agenda-count { margin-left: auto; font-size: 11.5px; color: var(--ink-3); }

.agenda-add {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #eef3ff;
  color: var(--primary-dark);
  display: grid;
  place-items: center;
  font-size: 16px;
  flex: none;
}

.agenda-items {
  display: grid;
  gap: 8px;
  padding: 10px;
  background: #fff;
}

.agenda-items:empty { display: none; }
.agenda-items .chip { padding: 8px 10px; }

/* ---------------- 手机版总表：卡片列表 ---------------- */

.rowcards { display: grid; gap: 10px; }

.rowcard {
  --st: #8494ab;
  --st-bg: #f1f4f8;
  --st-line: #dde4ee;
  display: grid;
  gap: 5px;
  padding: 12px 14px;
  border-radius: 14px;
  background: var(--st-bg);
  border: 1px solid var(--st-line);
  border-left: 4px solid var(--st);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
}

.rowcard.st-making { --st: #e0820a; --st-bg: #fef4e6; --st-line: #f6ddb5; }
.rowcard.st-ready { --st: #2f6fed; --st-bg: #e9f0ff; --st-line: #c6d8ff; }
.rowcard.st-done { --st: #0e9f6e; --st-bg: #e5f7ef; --st-line: #b0e5d0; }
.rowcard.st-canceled { --st: #8494ab; --st-bg: #eff2f7; --st-line: #dde4ee; }

.rowcard-top { display: flex; align-items: center; gap: 8px; }
.rowcard-date { font-size: 13.5px; font-weight: 650; }
.rowcard-week { font-size: 11.5px; color: var(--ink-3); margin-left: 6px; font-weight: 400; }

.rowcard-status {
  margin-left: auto;
  font-size: 11.5px;
  font-weight: 600;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--st);
  color: #fff;
}

.rowcard-title { font-size: 15px; font-weight: 650; line-height: 1.35; }
.rowcard.is-canceled .rowcard-title { text-decoration: line-through; color: var(--ink-3); }
.rowcard-note { font-size: 12px; color: var(--ink-2); line-height: 1.5; }

.rowcard-brand {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--ink-2);
  margin-top: 1px;
}

.rowcard-brand i { width: 8px; height: 8px; border-radius: 50%; }

.rowcard-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px 9px;
  font-size: 12px;
  white-space: normal;
  overflow: visible;
  color: var(--ink-2);
}

.rowcard-line .dist-progress { margin-left: auto; }

/* ---------------- 紧凑模式：小屏适配 ---------------- */

@media (max-width: 820px) {
  .appbar { padding: 9px 12px; padding-top: calc(9px + env(safe-area-inset-top)); }
  .appbar-title h1 { font-size: 15px; }
  .segmented button { padding: 6px 10px; font-size: 12.5px; }

  .main { padding: 10px 10px calc(100px + env(safe-area-inset-bottom)); }

  .toolbar { padding: 0 0 8px; }
  .toolbar-left .month-label { font-size: 15px; min-width: 96px; }
  .toolbar .btn-mini { padding: 5px 9px; font-size: 12px; }

  .status-chip { padding: 6px 10px; font-size: 12px; }
  .scope-total { display: none; }

  .fab { width: 50px; height: 50px; font-size: 24px; right: 14px; bottom: calc(80px + env(safe-area-inset-bottom)); }

  /* 弹窗改成从底部升起的卡片 */
  .modal-backdrop { align-items: flex-end; padding: 0; }
  .modal, .modal-wide {
    width: 100%;
    max-width: 100%;
    max-height: 92dvh;
    border-radius: 18px 18px 0 0;
    animation: sheetUp .22s ease-out;
  }
  .modal-head { padding: 16px 18px 12px; }
  .modal-body { padding: 14px 18px; }
  .modal-foot {
    position: sticky;
    bottom: 0;
    z-index: 2;
    background: #fff;
    padding: 12px 18px;
    padding-bottom: calc(12px + env(safe-area-inset-bottom));
    border-radius: 0;
    box-shadow: 0 -8px 20px -16px rgba(16, 24, 40, .6);
  }
  .grid-2 { grid-template-columns: 1fr; }
  .plat-row { flex: 1 1 46%; }
  .dist-legend { gap: 10px; }
  .dist-legend .dist-all-btn { margin-left: 0; }

  .settings-panel { padding: 14px; }
  .setting-head { gap: 10px; }
  .add-inline { width: 100%; }
  .add-inline .input { width: 100%; flex: 1; }
  .history-row { grid-template-columns: 1fr; gap: 8px; }
  .main-picker { flex-wrap: wrap; }
  .table-wrap { max-height: none; }

  /* 设置页：一行放不下就换行，别把输入框挤窄 */
  .setting-row { flex-wrap: wrap; gap: 8px 10px; padding: 10px 12px; }
  .setting-row .input-inline { flex: 1 1 auto; max-width: none; min-width: 0; }
  .setting-row .setting-count { flex: 0 0 auto; }
  .setting-row .row-actions { width: 100%; margin-left: 0; justify-content: flex-end; }
  .memberName, .member-name { width: 100%; }
}

@keyframes sheetUp { from { transform: translateY(24px); opacity: .6; } }
