:root {
  --bg: #f7f5f0;
  --bg-soft: #efece4;
  --card: #ffffff;
  --ink: #1e1c18;
  --ink-2: #55504a;
  --ink-3: #8a837a;
  --line: #e2ddd2;
  --accent: #2f6b4f;
  --accent-soft: #e6efe9;
  --warn: #b26a1f;
  --warn-soft: #fbf0e2;
  --danger: #a83a32;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(30, 28, 24, .06), 0 8px 24px rgba(30, 28, 24, .05);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Source Han Sans SC", sans-serif;
  font-size: 16px;
  line-height: 1.55;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: none;
}

body { height: 100dvh; overflow: hidden; }
@supports not (height: 100dvh) {
  body { height: 100vh; }
}

.app {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  max-width: 720px;
  margin: 0 auto;
  background: var(--bg);
}
@supports not (height: 100dvh) {
  .app { height: 100vh; }
}

/* ---------------- 顶栏 ---------------- */
.topbar {
  flex: 0 0 auto;
  padding: calc(10px + env(safe-area-inset-top, 0px)) 14px 8px;
  background: rgba(247, 245, 240, .94);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  position: relative;
  z-index: 5;
}
.topbar-main { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-width: 0; }
.day-chip {
  display: flex; flex-direction: column; align-items: flex-start; gap: 1px;
  background: none; border: 0; padding: 4px 2px; cursor: pointer; color: var(--ink);
  font-family: inherit; min-width: 0; flex: 1 1 auto; overflow: hidden;
}
.day-chip #dayChipText {
  font-size: 17px; font-weight: 650; letter-spacing: .2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%;
}
.day-chip-sub {
  font-size: 11px; color: var(--ink-3);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%;
}
.topbar-actions { display: flex; gap: 5px; flex: 0 0 auto; }
.icon-btn {
  font: inherit; font-size: 12.5px;
  padding: 7px 8px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--card); color: var(--ink-2);
  cursor: pointer; white-space: nowrap;
}
.icon-btn:active { background: var(--bg-soft); }

.banner {
  margin-top: 8px; padding: 8px 10px; border-radius: 10px;
  background: var(--warn-soft); color: var(--warn);
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  font-size: 13px; font-weight: 600;
}
.banner-btn {
  font: inherit; font-size: 12px; font-weight: 600;
  border: 0; border-radius: 8px; padding: 5px 9px;
  background: var(--warn); color: #fff; cursor: pointer;
}

/* ---------------- 消息流 ---------------- */
.stream {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 14px 14px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.day-divider {
  align-self: center;
  font-size: 11.5px; color: var(--ink-3);
  background: var(--bg-soft);
  padding: 3px 10px; border-radius: 999px;
  margin: 2px 0 4px;
}

.msg { display: flex; flex-direction: column; gap: 4px; max-width: 100%; }
.msg.me { align-items: flex-end; }

.bubble {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  border-bottom-right-radius: 6px;
  padding: 10px 13px;
  box-shadow: var(--shadow);
  max-width: 86%;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 15.5px;
}
.msg.sys .bubble {
  background: var(--accent-soft);
  border-color: #cfe0d6;
  border-radius: var(--radius);
  border-bottom-left-radius: 6px;
  max-width: 100%;
  color: #1f4a37;
  font-size: 14px;
}
.msg.sys.warn .bubble { background: var(--warn-soft); border-color: #ecd9bd; color: #7a4a12; }

.meta { font-size: 11px; color: var(--ink-3); padding: 0 4px; display: flex; gap: 6px; align-items: center; }
.tag {
  font-size: 10.5px; padding: 1px 6px; border-radius: 6px;
  background: var(--bg-soft); color: var(--ink-2);
}
.tag.backfill { background: var(--warn-soft); color: var(--warn); }
.tag.linked { background: var(--accent-soft); color: var(--accent); }

/* 评价卡 */
.review-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 15px 12px;
  width: 100%;
}
.review-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.review-grade { font-size: 15px; font-weight: 700; }
.review-grade.g优秀 { color: var(--accent); }
.review-grade.g正常 { color: #2b6cb0; }
.review-grade.g偏松 { color: var(--warn); }
.review-grade.g需要调整 { color: var(--danger); }
.review-total { font-size: 12px; color: var(--ink-3); }
.review-warn {
  font-size: 12px; color: var(--warn); background: var(--warn-soft);
  border-radius: 8px; padding: 6px 9px; margin: 4px 0 10px;
}
.review-one { font-size: 15px; font-weight: 600; margin: 2px 0 10px; }
.dim-row { display: flex; gap: 8px; padding: 7px 0; border-top: 1px dashed var(--line); }
.dim-key { flex: 0 0 52px; font-size: 13px; font-weight: 650; color: var(--ink-2); padding-top: 1px; }
.dim-body { flex: 1 1 auto; min-width: 0; font-size: 13px; color: var(--ink-2); }
.dim-score { font-weight: 700; color: var(--ink); margin-right: 6px; }
.dim-score.na { color: var(--ink-3); font-weight: 500; }
.dim-evidence { color: var(--ink-2); }
.dim-advice { color: var(--accent); margin-top: 2px; }
.review-sec { margin-top: 12px; }
.review-sec h4 { margin: 0 0 4px; font-size: 12.5px; color: var(--ink-3); font-weight: 600; letter-spacing: .3px; }
.review-sec ul { margin: 0; padding-left: 16px; font-size: 13px; color: var(--ink-2); }
.review-sec li { margin: 2px 0; }
.review-tomorrow {
  margin-top: 12px; padding: 10px 12px; border-radius: 10px;
  background: var(--accent); color: #fff; font-size: 14px; font-weight: 600;
}
.review-actions { display: flex; gap: 8px; margin-top: 10px; }

/* ---------------- 输入区 ---------------- */
.composer {
  flex: 0 0 auto;
  padding: 8px 12px calc(8px + var(--safe-b));
  background: rgba(247, 245, 240, .97);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
}
.composer-row { display: flex; align-items: flex-end; gap: 8px; }
.composer-tool {
  flex: 0 0 auto;
  width: 38px; height: 38px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--card); color: var(--ink-2);
  font-size: 20px; line-height: 1; cursor: pointer; padding: 0;
}
#input {
  flex: 1 1 auto; resize: none;
  min-height: 38px; max-height: 132px;
  padding: 9px 12px;
  border-radius: 19px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  font: inherit; font-size: 16px; line-height: 1.4;
  outline: none;
}
#input:focus { border-color: #bcd0c4; box-shadow: 0 0 0 3px var(--accent-soft); }
.send-btn {
  flex: 0 0 auto;
  height: 38px; padding: 0 16px; border-radius: 19px;
  border: 0; background: var(--accent); color: #fff;
  font: inherit; font-size: 15px; font-weight: 600; cursor: pointer;
}
.send-btn:disabled { opacity: .45; }
.composer-hint {
  font-size: 11px; color: var(--ink-3); text-align: center;
  margin-top: 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ---------------- 面板 ---------------- */
.sheet-mask {
  position: fixed; inset: 0; background: rgba(20, 18, 15, .38);
  z-index: 20; animation: fade .16s ease;
}
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0;
  max-width: 720px; margin: 0 auto;
  height: min(88dvh, 900px);
  background: var(--bg);
  border-radius: 20px 20px 0 0;
  z-index: 21;
  display: flex; flex-direction: column;
  box-shadow: 0 -8px 40px rgba(20, 18, 15, .18);
  animation: slideUp .22s cubic-bezier(.2, .8, .2, 1);
  padding-bottom: var(--safe-b);
}
@keyframes slideUp { from { transform: translateY(16px); opacity: .6; } to { transform: none; opacity: 1; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.sheet-head {
  flex: 0 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px 10px; border-bottom: 1px solid var(--line);
}
.sheet-head h2 { margin: 0; font-size: 17px; }
.sheet-body { flex: 1 1 auto; overflow-y: auto; padding: 14px 16px 28px; -webkit-overflow-scrolling: touch; }

/* ---------------- 通用控件 ---------------- */
.btn {
  font: inherit; font-size: 14px; font-weight: 600;
  padding: 9px 14px; border-radius: 11px;
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  cursor: pointer;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); border-color: #e8cfcb; }
.btn.sm { font-size: 12.5px; padding: 6px 10px; border-radius: 9px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

.field { margin: 10px 0; }
.field label { display: block; font-size: 12.5px; color: var(--ink-3); margin-bottom: 4px; }
input[type="text"], input[type="date"], input[type="time"], input[type="number"], textarea, select {
  width: 100%; font: inherit; font-size: 16px;
  padding: 9px 11px; border-radius: 11px;
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  outline: none;
}
input:focus, textarea:focus, select:focus { border-color: #bcd0c4; box-shadow: 0 0 0 3px var(--accent-soft); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.hint { font-size: 11.5px; color: var(--ink-3); margin-top: 4px; line-height: 1.5; }
.hint input[type="date"] { width: auto; display: inline-block; padding: 3px 7px; font-size: 12.5px; border-radius: 8px; }
.hint .mini { margin-left: 2px; }
.item-title .pill { font-size: 10px; vertical-align: 1px; margin-left: 4px; }

.list { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.item {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 10px 12px; display: flex; gap: 10px; align-items: flex-start;
}
.item-main { flex: 1 1 auto; min-width: 0; }
.item-title { font-size: 14.5px; font-weight: 600; word-break: break-word; }
.item-sub { font-size: 12px; color: var(--ink-3); margin-top: 2px; word-break: break-word; }
.item-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.empty { text-align: center; color: var(--ink-3); font-size: 13px; padding: 28px 10px; }

.daygroup { margin-top: 12px; }
.daygroup h3 { font-size: 13px; color: var(--ink-2); margin: 0 0 6px; font-weight: 650; }
.pill {
  display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 999px;
  background: var(--bg-soft); color: var(--ink-2); margin-right: 4px;
}
.pill.course { background: #e7eef8; color: #2b5f9e; }
.pill.study { background: var(--accent-soft); color: var(--accent); }
.pill.fixed { background: #f3ece2; color: #8a6a3b; }
.pill.free { background: #eef0f2; color: #5d6470; }

.step {
  display: flex; align-items: flex-start; gap: 8px;
  padding: 8px 0; border-top: 1px dashed var(--line);
}
.step:first-child { border-top: 0; }
.step-check { width: 22px; height: 22px; flex: 0 0 auto; margin-top: 1px; accent-color: var(--accent); }
.step-body { flex: 1 1 auto; min-width: 0; }
.step-text { font-size: 14px; }
.step-text.done { text-decoration: line-through; color: var(--ink-3); }
.step-meta { font-size: 11.5px; color: var(--ink-3); margin-top: 1px; }
.step-tools { display: flex; gap: 2px; flex: 0 0 auto; }
.mini {
  border: 0; background: transparent; color: var(--ink-3);
  font-size: 13px; padding: 3px 5px; border-radius: 6px; cursor: pointer;
}
.mini:active { background: var(--bg-soft); }

.dropzone {
  border: 1.5px dashed var(--line); border-radius: 12px;
  padding: 14px; text-align: center; color: var(--ink-3); font-size: 13px;
  background: var(--card);
}
.dropzone.over { border-color: var(--accent); background: var(--accent-soft); }
.thumbs { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.thumb { position: relative; width: 92px; height: 92px; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); background: #000; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb button {
  position: absolute; top: 2px; right: 2px; width: 20px; height: 20px;
  border-radius: 50%; border: 0; background: rgba(0,0,0,.6); color: #fff;
  font-size: 12px; line-height: 1; cursor: pointer;
}
.progress { height: 4px; border-radius: 2px; background: var(--bg-soft); overflow: hidden; margin-top: 8px; }
.progress > i { display: block; height: 100%; background: var(--accent); width: 0; transition: width .2s; }

.toast {
  position: fixed; left: 50%; bottom: calc(84px + var(--safe-b));
  transform: translateX(-50%);
  background: rgba(30, 28, 24, .92); color: #fff;
  font-size: 13px; padding: 8px 14px; border-radius: 10px;
  z-index: 40; max-width: 88vw; text-align: center;
}

.hidden { display: none !important; }
.mt8 { margin-top: 8px; } .mt12 { margin-top: 12px; } .mt16 { margin-top: 16px; }
.small { font-size: 12px; color: var(--ink-3); }

@media (min-width: 720px) {
  body { background: #e9e6de; }
  .app { box-shadow: 0 0 60px rgba(0, 0, 0, .08); }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
