/* ============================================================
   Tempo 日律 · PWA 增强样式
   桌面保留双设备展示；手机 / 安装态切换为全屏 App + 手表浮层。
   ============================================================ */

:root {
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

[hidden] { display: none !important; }

/* ---------------- header actions ---------------- */

.head-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.install-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border: 1px solid var(--line-2);
  border-radius: 999px;
  background: var(--surface);
  color: var(--forest);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background .18s, transform .18s;
}
.install-btn:hover { background: var(--forest-soft); transform: translateY(-1px); }
.install-btn .ic { width: 14px; height: 14px; }

.offline-banner {
  position: sticky;
  top: 0;
  z-index: 45;
  padding: 7px 16px;
  background: var(--amber-soft);
  border-bottom: 1px solid rgba(201, 151, 63, .35);
  color: #7C5715;
  font-size: 12px;
  text-align: center;
  letter-spacing: .01em;
}

button:focus-visible,
a:focus-visible,
input:focus-visible {
  outline: 2px solid var(--forest);
  outline-offset: 2px;
}

/* 移动端手表入口：桌面隐藏 */
.watch-fab { display: none; }
.watch-overlay { display: none; }

/* ---------------- 手机 / 安装态：全屏 App ---------------- */

@media (max-width: 640px) {
  html, body {
    height: 100dvh;
    overflow: hidden;
    background: var(--paper);
  }
  body::before { opacity: .28; }

  .showcase-head,
  .showcase-foot,
  .device-label,
  .stage > .watch-col {
    display: none !important;
  }

  .stage {
    display: block;
    height: 100dvh;
    padding: 0;
  }

  .phone-col {
    height: 100dvh;
    display: block;
  }

  .phone {
    width: 100%;
    height: 100dvh;
    padding: 0;
    border-radius: 0;
    background: var(--paper);
    box-shadow: none;
    overflow: hidden;
  }

  .phone-screen {
    width: 100%;
    height: 100dvh;
    border-radius: 0;
  }

  .island,
  .status-bar,
  .home-indicator {
    display: none;
  }

  .app-body { inset: 0; }

  .screen {
    padding: calc(10px + var(--safe-top)) 20px calc(116px + var(--safe-bottom));
  }

  .tabbar {
    height: calc(66px + var(--safe-bottom));
    padding: 8px 10px var(--safe-bottom);
  }

  .phone .sheet { max-height: 82dvh; }
  .phone .toast { bottom: calc(100px + var(--safe-bottom)); }

  .offline-banner {
    position: fixed;
    top: var(--safe-top);
    left: 0;
    right: 0;
    z-index: 80;
  }

  /* 手表入口 */
  .watch-fab {
    position: fixed;
    left: 14px;
    bottom: calc(84px + var(--safe-bottom));
    z-index: 33;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 14px 9px 11px;
    border: 1px solid rgba(46, 75, 58, .18);
    border-radius: 999px;
    background: rgba(251, 249, 244, .92);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    color: var(--forest);
    font: inherit;
    font-size: 11px;
    font-weight: 600;
    box-shadow: 0 10px 24px -14px rgba(27, 26, 22, .5);
    cursor: pointer;
  }
  .watch-fab .ic { width: 15px; height: 15px; }

  /* 手表浮层 */
  .watch-overlay {
    position: fixed;
    inset: 0;
    z-index: 70;
    display: none;
    align-items: center;
    justify-content: center;
    padding: calc(16px + var(--safe-top)) 16px calc(16px + var(--safe-bottom));
    background: rgba(24, 22, 18, .46);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
  }
  .watch-overlay.is-open { display: flex; }

  .watch-overlay-panel {
    width: min(330px, 100%);
    max-height: 100%;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    padding: 16px 20px 22px;
    border-radius: 30px;
    background: var(--surface);
    box-shadow: 0 40px 80px -30px rgba(20, 18, 14, .6);
    animation: watchIn .32s cubic-bezier(.2, .8, .3, 1) both;
  }

  @keyframes watchIn {
    from { opacity: 0; transform: translateY(18px) scale(.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
  }

  .watch-overlay-head {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: var(--ink-3);
  }
  .watch-overlay-head button {
    width: 28px;
    height: 28px;
    display: grid;
    place-items: center;
    border: 0;
    border-radius: 50%;
    background: rgba(27, 26, 22, .06);
    color: var(--ink-2);
    cursor: pointer;
  }

  .watch-overlay .watch-case {
    transform: scale(.94);
    transform-origin: center;
    margin: -4px 0;
  }

  .watch-overlay-note {
    max-width: 250px;
    margin: 0;
    font-size: 10.5px;
    line-height: 1.65;
    text-align: center;
    color: var(--ink-3);
  }
}

/* 很矮的屏幕（横屏手机）也保证手表完整可见 */
@media (max-width: 640px) and (max-height: 720px) {
  .watch-overlay .watch-case { transform: scale(.82); margin: -14px 0; }
  .watch-overlay-panel { gap: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  .watch-overlay-panel { animation: none; }
}

/* ---------------- AI 整理 ---------------- */

.ai-console {
  margin-top: 14px;
  padding: 13px 14px 12px;
  border: 1px solid rgba(46, 75, 58, .16);
  border-radius: var(--radius-m);
  background:
    linear-gradient(180deg, rgba(222, 230, 220, .55), rgba(251, 249, 244, .9));
}

.ai-console-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.ai-title { display: flex; align-items: center; gap: 9px; min-width: 0; }
.ai-title b {
  display: block;
  font-size: 12px;
  font-weight: 650;
  letter-spacing: .02em;
}
.ai-title span:not(.ai-mark) {
  display: block;
  margin-top: 2px;
  font-size: 9.5px;
  color: var(--ink-3);
}
.ai-mark {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  flex: none;
  border-radius: 9px;
  background: var(--forest);
  color: #F7F3E8;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: .04em;
}

.ai-note {
  margin: 9px 0 0;
  font-size: 9.5px;
  line-height: 1.6;
  color: var(--ink-3);
}

.ai-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}
.ai-actions .btn { flex: 1; }

.ai-result {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed rgba(46, 75, 58, .18);
}
.ai-result-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 10px;
  font-weight: 600;
  color: var(--forest);
}
.ai-result-head .ic { width: 13px; height: 13px; margin-right: 2px; }
.ai-result-head b {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: .04em;
  color: var(--ink-3);
}
.ai-result p {
  margin: 5px 0 0;
  font-size: 9.5px;
  line-height: 1.6;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}

.ai-loading,
.ai-error {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  font-size: 10px;
  line-height: 1.6;
}
.ai-loading { color: var(--ink-2); }
.ai-loading .ic,
.ai-error .ic { width: 13px; height: 13px; }
.ai-loading .ic { color: var(--forest); animation: spin .9s linear infinite; }
.ai-error { color: var(--clay); }

/* 排程理由（AI 候选时出现） */
.plan-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.plan-reason {
  font-size: 9.5px;
  line-height: 1.5;
  color: var(--ink-3);
}

/* 周报趋势 */
.trend-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 12px;
}
.trend-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface);
  font-size: 11.5px;
}
.trend-val {
  font-size: 10.5px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  color: var(--forest);
}
.trend-val.down { color: var(--clay); }
.trend-val.flat { color: var(--ink-3); }
.ai-exp-title {
  margin: 0 0 4px;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.45;
}

/* 模型选择 */
.model-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin: 12px 0 10px;
}
.model-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  text-align: left;
  font: inherit;
  color: var(--ink);
  cursor: pointer;
  transition: border-color .2s, background .2s;
}
.model-row.is-active {
  border-color: rgba(46, 75, 58, .45);
  background: var(--forest-soft);
}
.model-row:disabled {
  opacity: .45;
  cursor: not-allowed;
}
.model-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.model-main b { font-size: 12px; font-weight: 650; }
.model-main small { font-size: 9.5px; color: var(--ink-3); }
.model-check {
  flex: none;
  width: 18px;
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--forest);
}

