/* 拾水 SHISHUI · 样式
   原则：暖白底、青绿点缀、圆角、轻阴影、单列、触控友好 */

:root {
  --bg: #faf7f2;
  --bg-soft: #f3eee7;
  --card: #ffffff;
  --ink: #253030;
  --ink-2: #4d5a58;
  --muted: #8a9694;
  --line: #ebe5dc;
  --brand: #2f8f7e;
  --brand-deep: #24705f;
  --brand-soft: #e4f2ee;
  --danger: #c4554d;
  --danger-soft: #fbeceb;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(40, 50, 48, .04), 0 6px 18px rgba(40, 50, 48, .05);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

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

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Noto Sans SC",
    "Source Han Sans SC", "Microsoft YaHei", sans-serif;
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: contain;
}

body { min-height: 100vh; }
.hidden { display: none !important; }

button, input, textarea, select {
  font: inherit;
  color: inherit;
}

button { cursor: pointer; }
a { color: var(--brand); text-decoration: none; }

/* ---------------- 登录 ---------------- */

.auth {
  min-height: 100vh;
  min-height: 100dvh;
  padding: calc(40px + var(--safe-t)) 24px calc(32px + var(--safe-b));
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 28px;
  max-width: 460px;
  margin: 0 auto;
}

.auth-brand { text-align: center; }

.auth-brand .logo {
  width: 64px;
  height: 64px;
  margin: 0 auto 14px;
  border-radius: 22px;
  background: linear-gradient(145deg, #3aa591, #24705f);
  color: #fff;
  font-size: 30px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 22px rgba(47, 143, 126, .28);
}

.auth-brand h1 {
  margin: 0;
  font-size: 26px;
  letter-spacing: 4px;
  font-weight: 600;
}

.auth-brand p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 14px;
  letter-spacing: .5px;
}

.auth-card {
  background: var(--card);
  border-radius: 22px;
  padding: 24px 20px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.auth-card h2 {
  margin: 0 0 4px;
  font-size: 18px;
  font-weight: 600;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field > span {
  font-size: 12.5px;
  color: var(--muted);
  padding-left: 2px;
}

.field input,
.field textarea {
  width: 100%;
  padding: 12px 14px;
  font-size: 16px;                 /* 防 iOS 聚焦缩放 */
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fcfaf7;
  outline: none;
  transition: border-color .15s, background .15s;
}

.field input:focus,
.field textarea:focus {
  border-color: var(--brand);
  background: #fff;
}

.form-error {
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 13px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
}

/* ---------------- 按钮 ---------------- */

.btn-primary {
  width: 100%;
  min-height: 46px;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--brand);
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 1px;
  transition: opacity .15s, transform .08s;
}
.btn-primary:active { transform: scale(.985); }
.btn-primary:disabled { opacity: .55; }

.link-btn {
  background: none;
  border: 0;
  color: var(--brand);
  font-size: 14px;
  padding: 6px;
}

.btn-ghost {
  min-height: 40px;
  padding: 0 16px;
  border: 1.5px solid var(--line);
  background: var(--card);
  border-radius: 999px;
  font-size: 14px;
  color: var(--ink-2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.btn-ghost:active { background: var(--bg-soft); }

.btn-soft {
  min-height: 40px;
  padding: 0 16px;
  border: 0;
  background: var(--brand-soft);
  color: var(--brand-deep);
  border-radius: 999px;
  font-size: 14px;
  font-weight: 500;
}

.icon-btn {
  width: 36px;
  height: 36px;
  min-width: 36px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
}
.icon-btn:active { background: var(--bg-soft); }
.icon-btn.wide {
  width: auto;
  min-width: 44px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 12.5px;
}

/* ---------------- 骨架 ---------------- */

.shell {
  min-height: 100vh;
  min-height: 100dvh;
  padding-bottom: calc(64px + var(--safe-b));
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(10px + var(--safe-t)) 18px 10px;
  background: rgba(250, 247, 242, .92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid transparent;
}

.topbar h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
  letter-spacing: .5px;
}

.topbar-action { display: flex; align-items: center; gap: 8px; }

.main {
  max-width: 560px;
  margin: 0 auto;
  padding: 6px 16px 24px;
}

/* ---------------- 底部 Tab ---------------- */

.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  display: flex;
  padding-bottom: var(--safe-b);
  background: rgba(255, 255, 255, .94);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
}

.tab {
  flex: 1;
  position: relative;
  min-height: 56px;
  border: 0;
  background: none;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 11px;
  padding: 6px 0;
  transition: color .15s;
}

.tab svg {
  width: 23px;
  height: 23px;
  display: block;
}

.tab.active { color: var(--brand); }

.badge {
  position: absolute;
  top: 6px;
  left: 50%;
  margin-left: 6px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 8px;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  font-style: normal;
  line-height: 16px;
  text-align: center;
  font-weight: 600;
}

.fab {
  position: fixed;
  right: 18px;
  bottom: calc(74px + var(--safe-b));
  z-index: 25;
  width: 54px;
  height: 54px;
  border: 0;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 20px rgba(47, 143, 126, .34);
  transition: transform .1s;
}
.fab:active { transform: scale(.94); }

/* ---------------- 卡片 / 列表 ---------------- */

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 12px;
}

.post-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.avatar {
  width: 38px;
  height: 38px;
  min-width: 38px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--brand-soft);
  color: var(--brand-deep);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: 600;
  overflow: hidden;
}

.avatar.sm { width: 30px; height: 30px; min-width: 30px; font-size: 13px; }
.avatar.lg { width: 72px; height: 72px; min-width: 72px; font-size: 26px; }

.post-meta { flex: 1; min-width: 0; }
.post-meta b { display: block; font-size: 14.5px; font-weight: 600; }
.post-meta time { font-size: 12px; color: var(--muted); }

.vis-tag {
  font-size: 11px;
  color: var(--muted);
  background: var(--bg-soft);
  border-radius: 999px;
  padding: 2px 8px;
  white-space: nowrap;
}

.post-text {
  margin: 0 0 10px;
  font-size: 15.5px;
  line-height: 1.72;
  white-space: pre-wrap;
  word-break: break-word;
}

.imgs { display: grid; gap: 4px; border-radius: 12px; overflow: hidden; }
.imgs-1 { grid-template-columns: 1fr; }
.imgs-2 { grid-template-columns: 1fr 1fr; }
.imgs-3, .imgs-4, .imgs-n { grid-template-columns: repeat(3, 1fr); }

.imgs img {
  width: 100%;
  display: block;
  object-fit: cover;
  background: var(--bg-soft);
  border-radius: 4px;
  aspect-ratio: 1 / 1;
}

.imgs-1 img, .imgs-2 img { aspect-ratio: auto; max-height: 420px; }

/* 照片池：按天分组 */
.day-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 16px 2px 8px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink-2);
}
.day-head .day-count {
  font-size: 11.5px;
  font-weight: 400;
  color: var(--muted);
}
.day-head:first-child { padding-top: 8px; }

/* 照片池网格 */
.photo-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
}

.photo-grid .cell {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: 6px;
  overflow: hidden;
  background: var(--bg-soft);
}

.photo-grid img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.photo-grid .cell .del {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 26px;
  height: 26px;
  border: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, .45);
  color: #fff;
  font-size: 13px;
  line-height: 1;
}

/* 状态块 */
.state {
  text-align: center;
  padding: 48px 20px;
  color: var(--muted);
  font-size: 14px;
}
.state .big { font-size: 34px; margin-bottom: 6px; opacity: .5; }
.state .retry { margin-top: 14px; }

.loading-dots { display: flex; gap: 6px; justify-content: center; padding: 28px 0; }
.loading-dots i {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--brand); opacity: .35;
  animation: blink 1.1s infinite;
}
.loading-dots i:nth-child(2) { animation-delay: .18s; }
.loading-dots i:nth-child(3) { animation-delay: .36s; }
@keyframes blink { 0%, 100% { opacity: .2; transform: scale(.8); } 50% { opacity: 1; transform: scale(1); } }

.list-sentinel { height: 1px; }
.list-end { text-align: center; color: var(--muted); font-size: 12.5px; padding: 16px 0 8px; }

/* ---------------- 碎碎念 ---------------- */

.topic-card { display: block; width: 100%; text-align: left; border: 0; font: inherit; color: inherit; }

.topic-title {
  font-size: 16.5px;
  font-weight: 600;
  margin: 0 0 4px;
  word-break: break-word;
}

.topic-desc {
  margin: 0 0 10px;
  color: var(--ink-2);
  font-size: 13.5px;
  line-height: 1.6;
}

.topic-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
}
.topic-foot .dot { opacity: .5; }

.topic-header { padding: 4px 2px 14px; border-bottom: 1px solid var(--line); margin-bottom: 14px; }
.topic-header h2 { margin: 6px 0 8px; font-size: 21px; line-height: 1.4; }
.topic-header .topic-desc { font-size: 14px; }

.discussion {
  display: flex;
  gap: 10px;
  padding: 12px 2px;
  border-bottom: 1px solid var(--line);
}
.discussion:last-child { border-bottom: 0; }
.discussion .body { flex: 1; min-width: 0; }
.discussion .who { font-size: 13px; color: var(--muted); margin-bottom: 2px; display: flex; gap: 8px; align-items: center; }
.discussion .who b { color: var(--ink-2); font-weight: 600; }
.discussion p { margin: 0; font-size: 15px; white-space: pre-wrap; word-break: break-word; }

.reply-bar {
  position: sticky;
  bottom: calc(64px + var(--safe-b));
  margin-top: 12px;
  background: var(--bg);
  padding: 10px 0;
  display: flex;
  gap: 8px;
}
.reply-bar textarea {
  flex: 1;
  resize: none;
  height: 44px;
  padding: 11px 14px;
  font-size: 16px;
  border: 1.5px solid var(--line);
  border-radius: 22px;
  background: var(--card);
  outline: none;
  line-height: 1.4;
}
.reply-bar textarea:focus { border-color: var(--brand); }
.reply-bar button {
  min-width: 62px;
  height: 44px;
  border: 0;
  border-radius: 22px;
  background: var(--brand);
  color: #fff;
  font-size: 14.5px;
  font-weight: 500;
}
.reply-bar button:disabled { opacity: .5; }

/* ---------------- 通知 ---------------- */

.notice {
  display: flex;
  gap: 12px;
  padding: 14px 4px;
  border-bottom: 1px solid var(--line);
  position: relative;
  width: 100%;
  text-align: left;
  background: none;
  border-left: 0;
  border-right: 0;
  border-top: 0;
  font: inherit;
  color: inherit;
}
.notice.unread { background: linear-gradient(90deg, var(--brand-soft), transparent 60%); }
.notice.unread::before {
  content: "";
  position: absolute;
  left: -16px;
  top: 14px;
  bottom: 14px;
  width: 3px;
  border-radius: 2px;
  background: var(--brand);
}
.notice .body { flex: 1; min-width: 0; }
.notice .t { font-size: 14.5px; font-weight: 500; margin: 0 0 2px; }
.notice .c { font-size: 13.5px; color: var(--muted); margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.notice time { font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.notice .cnt {
  font-size: 11px;
  color: var(--brand-deep);
  background: var(--brand-soft);
  border-radius: 999px;
  padding: 1px 7px;
  margin-left: 6px;
}

.settings-title {
  font-size: 13px;
  color: var(--muted);
  padding: 18px 4px 6px;
  letter-spacing: .5px;
}

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 4px;
  border-bottom: 1px solid var(--line);
}
.switch-row .label { font-size: 14.5px; }
.switch-row .hint { font-size: 12px; color: var(--muted); }

.switch {
  position: relative;
  width: 46px;
  height: 28px;
  min-width: 46px;
  border-radius: 14px;
  border: 0;
  background: #dcd7cf;
  transition: background .18s;
}
.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .2);
  transition: transform .18s;
}
.switch.on { background: var(--brand); }
.switch.on::after { transform: translateX(18px); }

/* ---------------- 我的 ---------------- */

.me-head {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 8px 4px 18px;
}
.me-head .name { font-size: 20px; font-weight: 600; }
.me-head .mail { font-size: 12.5px; color: var(--muted); margin-top: 2px; }

.stats {
  display: flex;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 0;
  margin-bottom: 14px;
}
.stats > div { flex: 1; text-align: center; }
.stats .n { font-size: 20px; font-weight: 600; }
.stats .k { font-size: 12px; color: var(--muted); }

.menu {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  margin-bottom: 14px;
}
.menu button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: 50px;
  padding: 0 16px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: none;
  font-size: 15px;
  text-align: left;
}
.menu button:last-child { border-bottom: 0; }
.menu button .arrow { color: var(--muted); font-size: 18px; }
.menu button.danger { color: var(--danger); justify-content: center; }

.about {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  padding: 20px 0 8px;
  line-height: 1.8;
}

/* ---------------- 弹层 ---------------- */

.modal-root { display: none; }
.modal-root.show { display: block; }

.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(24, 30, 29, .42);
  z-index: 50;
  animation: fade .16s ease-out;
}

.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 51;
  background: var(--bg);
  border-radius: 22px 22px 0 0;
  padding: 8px 18px calc(18px + var(--safe-b));
  max-height: 90vh;
  overflow-y: auto;
  max-width: 560px;
  margin: 0 auto;
  animation: rise .2s ease-out;
}

@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(18px); opacity: .6; } }

.sheet-handle {
  width: 38px;
  height: 4px;
  border-radius: 2px;
  background: var(--line);
  margin: 4px auto 14px;
}

.sheet h3 { margin: 0 0 14px; font-size: 17px; font-weight: 600; }
.sheet .actions { display: flex; gap: 10px; margin-top: 18px; }
.sheet .actions > * { flex: 1; }

.compose-text {
  width: 100%;
  min-height: 110px;
  padding: 12px 14px;
  font-size: 16px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--card);
  outline: none;
  resize: none;
  line-height: 1.6;
}
.compose-text:focus { border-color: var(--brand); }

.thumbs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 10px 0 4px;
  scrollbar-width: none;
}
.thumbs::-webkit-scrollbar { display: none; }
.thumb {
  position: relative;
  width: 76px;
  height: 76px;
  min-width: 76px;
  border-radius: 10px;
  overflow: hidden;
  background: var(--bg-soft);
}
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb .x {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 22px;
  height: 22px;
  border: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, .5);
  color: #fff;
  font-size: 12px;
  line-height: 1;
}
.thumb .prog {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, .7);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: var(--brand-deep);
}

.seg {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}
.seg button {
  flex: 1;
  min-height: 40px;
  border-radius: 999px;
  border: 1.5px solid var(--line);
  background: var(--card);
  color: var(--ink-2);
  font-size: 13.5px;
}
.seg button.on {
  border-color: var(--brand);
  background: var(--brand-soft);
  color: var(--brand-deep);
  font-weight: 500;
}

.progress-line {
  font-size: 13px;
  color: var(--muted);
  padding: 6px 0;
}

/* 图片查看器 */
.viewer {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: #0d1211;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fade .15s;
}
.viewer img { max-width: 100%; max-height: 100%; object-fit: contain; }
.viewer .close {
  position: absolute;
  top: calc(14px + var(--safe-t));
  right: 14px;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, .14);
  color: #fff;
  font-size: 18px;
}
.viewer .nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 44px;
  height: 60px;
  border: 0;
  background: rgba(255, 255, 255, .1);
  color: #fff;
  font-size: 20px;
  border-radius: 10px;
}
.viewer .nav.prev { left: 8px; }
.viewer .nav.next { right: 8px; }
.viewer .viewer-date {
  position: absolute;
  bottom: calc(52px + var(--safe-b));
  left: 0;
  right: 0;
  text-align: center;
  color: rgba(255, 255, 255, .62);
  font-size: 12px;
  letter-spacing: .3px;
}
.viewer .counter {
  position: absolute;
  bottom: calc(20px + var(--safe-b));
  left: 0;
  right: 0;
  text-align: center;
  color: rgba(255, 255, 255, .7);
  font-size: 12.5px;
}

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(96px + var(--safe-b));
  transform: translate(-50%, 10px);
  z-index: 70;
  background: rgba(37, 48, 48, .94);
  color: #fff;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 13.5px;
  max-width: 80vw;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: rgba(196, 85, 77, .96); }

/* 宽屏 */
@media (min-width: 768px) {
  body { background: #f2ece3; }
  .shell { max-width: 560px; margin: 0 auto; background: var(--bg); min-height: 100dvh; box-shadow: 0 0 40px rgba(0, 0, 0, .06); }
  .tabbar { max-width: 560px; margin: 0 auto; }
}

/* 启动闪屏 */
.splash {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
}
.splash .logo {
  width: 64px;
  height: 64px;
  border-radius: 22px;
  background: linear-gradient(145deg, #3aa591, #24705f);
  color: #fff;
  font-size: 30px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 22px rgba(47, 143, 126, .28);
  animation: splashPulse 1.3s ease-in-out infinite;
}
@keyframes splashPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: .65; transform: scale(.94); }
}
