﻿/* 像素日记：柔和渐变 + 像素风按钮 */
:root {
  --font: "PingFang SC", "HarmonyOS Sans SC", "MiSans", "Microsoft YaHei UI", system-ui, -apple-system, "Segoe UI", sans-serif;
  --px: 4px;
  --ease: cubic-bezier(.2, .8, .2, 1);
  color-scheme: light dark;
}
[data-theme="light"] {
  --bg1: #ffe3ef; --bg2: #e7e4ff; --bg3: #dff4ff;
  --text: #2a2140; --muted: #7b7092; --card: rgba(255, 255, 255, .72); --card-solid: #fff;
  --line: #2a2140; --soft: rgba(42, 33, 64, .08); --chip: #fff; --accent: #ff6fa5; --accent2: #7c6cff;
  --shadow: 0 14px 34px -18px rgba(90, 60, 140, .45);
  color-scheme: light;
}
[data-theme="dark"] {
  --bg1: #1a1033; --bg2: #0f1630; --bg3: #08202b;
  --text: #f1ecff; --muted: #a39cc0; --card: rgba(30, 24, 58, .7); --card-solid: #1e183a;
  --line: #0a0718; --soft: rgba(255, 255, 255, .07); --chip: #2a2350; --accent: #ff7fb0; --accent2: #9b8cff;
  --shadow: 0 16px 40px -18px rgba(0, 0, 0, .8);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100dvh; font-family: var(--font); color: var(--text); line-height: 1.55; font-size: 15px;
  background:
    radial-gradient(900px 500px at 0% 0%, color-mix(in srgb, var(--accent) 22%, transparent), transparent 60%),
    radial-gradient(800px 500px at 100% 10%, color-mix(in srgb, var(--accent2) 22%, transparent), transparent 60%),
    linear-gradient(160deg, var(--bg1), var(--bg2) 55%, var(--bg3));
  background-attachment: fixed;
  padding-bottom: calc(84px + env(safe-area-inset-bottom));
  -webkit-tap-highlight-color: transparent;
}
button, input { font: inherit; color: inherit; }
a { color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--accent2); outline-offset: 2px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }

/* 像素描边：用阶梯状 box-shadow 模拟像素圆角 */
.pbtn {
  --c: var(--chip);
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 0 14px; border: 0; cursor: pointer; font-weight: 700; font-size: 14px;
  background: var(--c); color: var(--text);
  box-shadow: 0 -3px 0 0 var(--line), 0 3px 0 0 var(--line), -3px 0 0 0 var(--line), 3px 0 0 0 var(--line), inset 0 -4px 0 rgba(0,0,0,.12);
  margin: 3px; transition: transform .08s, filter .15s; user-select: none; white-space: nowrap;
}
.pbtn:hover { filter: brightness(1.05); }
.pbtn:active { transform: translateY(2px); box-shadow: 0 -3px 0 0 var(--line), 0 3px 0 0 var(--line), -3px 0 0 0 var(--line), 3px 0 0 0 var(--line), inset 0 2px 0 rgba(0,0,0,.12); }
.pbtn.icon { width: 40px; padding: 0; font-size: 20px; }
.pbtn.primary { --c: var(--accent); color: #fff; }
.pbtn.danger { color: #e5484d; }
.pbtn[aria-pressed="true"], .pbtn.on { --c: var(--accent2); color: #fff; }
.pbtn:disabled { opacity: .45; cursor: not-allowed; }

/* 顶栏 */
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 8px;
  padding: calc(8px + env(safe-area-inset-top)) clamp(12px, 4vw, 28px) 8px;
  background: color-mix(in srgb, var(--bg1) 65%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--soft);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; margin-right: auto; font-size: 18px; letter-spacing: .04em; }
.brand img { image-rendering: pixelated; }
.tabs { display: flex; gap: 4px; margin-right: 8px; }
.tabs a { text-decoration: none; padding: 6px 14px; font-weight: 700; color: var(--muted); border-radius: 0; }
.tabs a.on { color: var(--text); background: var(--soft); box-shadow: inset 0 -3px 0 var(--accent); }
.bottom-tabs { display: none; }
@media (max-width: 760px) {
  .tabs { display: none; }
  .bottom-tabs {
    display: flex; position: fixed; z-index: 30; left: 12px; right: 12px; bottom: calc(10px + env(safe-area-inset-bottom));
    background: var(--card-solid); box-shadow: 0 -3px 0 var(--line), 0 3px 0 var(--line), -3px 0 0 var(--line), 3px 0 0 var(--line), var(--shadow);
  }
  .bottom-tabs a { flex: 1; display: flex; flex-direction: column; align-items: center; padding: 6px 0 5px; text-decoration: none; font-size: 12px; font-weight: 700; color: var(--muted); }
  .bottom-tabs a span { font-size: 20px; line-height: 1.2; filter: grayscale(1); opacity: .7; }
  .bottom-tabs a.on { color: var(--text); background: var(--soft); }
  .bottom-tabs a.on span { filter: none; opacity: 1; }
}

/* 布局 */
main { max-width: 1120px; margin: 0 auto; padding: 18px clamp(12px, 4vw, 28px) 30px; }
.view { animation: up .35s var(--ease); }
@keyframes up { from { opacity: 0; transform: translateY(8px); } }
#view-today { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(300px, 1fr); gap: 22px; align-items: start; }
@media (max-width: 900px) { #view-today { grid-template-columns: 1fr; } }
.paint-col { position: sticky; top: 76px; }
@media (max-width: 900px) { .paint-col { position: static; } }
.side-col { display: grid; gap: 16px; }
.card { background: var(--card); border: 1px solid var(--soft); border-radius: 18px; padding: 16px; box-shadow: var(--shadow); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.card h2 { font-size: 14px; margin: 0 0 8px; color: var(--muted); display: flex; gap: 8px; align-items: baseline; }
.card h2 + .chips + h2 { margin-top: 14px; }
.need { color: var(--accent); font-weight: 700; font-size: 12.5px; animation: blink 1.2s steps(2) infinite; }
@keyframes blink { 50% { opacity: .35; } }
.count { margin-left: auto; font-weight: 500; font-size: 12px; }

/* 日期 */
.day-head { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.day-title { flex: 1; text-align: center; display: flex; flex-direction: column; line-height: 1.25; }
.day-title b { font-size: 20px; letter-spacing: .03em; }
.day-title .sub { color: var(--muted); font-size: 13px; }

/* 画框 */
.frame {
  position: relative; padding: 12px; background: var(--card-solid);
  box-shadow: 0 -4px 0 var(--line), 0 4px 0 var(--line), -4px 0 0 var(--line), 4px 0 0 var(--line), 0 0 0 10px color-mix(in srgb, var(--accent) 18%, transparent), var(--shadow);
  margin: 4px 4px 18px;
}
#art { display: block; width: 100%; aspect-ratio: 16 / 10; image-rendering: pixelated; image-rendering: crisp-edges; cursor: crosshair; touch-action: manipulation; }
#art.erase { cursor: not-allowed; }
.hint {
  position: absolute; left: 50%; bottom: 20px; transform: translateX(-50%); pointer-events: none;
  background: rgba(20, 14, 40, .72); color: #fff; font-size: 12.5px; padding: 4px 10px; white-space: nowrap; transition: opacity .4s;
}
.hint:empty { opacity: 0; }

/* 贴纸 */
.tools { padding: 12px; }
.stickers { display: grid; grid-template-columns: repeat(auto-fill, minmax(58px, 1fr)); gap: 6px; }
.stk {
  display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 2px; height: 66px; padding: 6px 2px 4px;
  border: 0; background: var(--soft); cursor: pointer; font-size: 11.5px; color: var(--muted); font-weight: 700; transition: transform .1s;
}
.stk canvas { image-rendering: pixelated; flex: 1; max-height: 40px; width: auto; }
[data-theme="dark"] .stk canvas { filter: drop-shadow(1px 0 0 rgba(255,255,255,.55)) drop-shadow(-1px 0 0 rgba(255,255,255,.55)) drop-shadow(0 1px 0 rgba(255,255,255,.55)) drop-shadow(0 -1px 0 rgba(255,255,255,.55)); }
.stk:hover { transform: translateY(-2px); }
.stk[aria-pressed="true"] { background: color-mix(in srgb, var(--accent2) 22%, transparent); color: var(--text); box-shadow: inset 0 0 0 3px var(--accent2); }
.tool-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }

/* 选择 chips */
.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chips .pbtn { min-height: 36px; padding: 0 10px; font-size: 13.5px; }
.chips .pbtn[aria-checked="true"] { --c: var(--accent2); color: #fff; }
#moods .pbtn[aria-checked="true"] { --c: var(--mc); color: #2a2140; }
.input { width: 100%; height: 44px; padding: 0 12px; border: 0; background: var(--chip); font-size: 16px;
  box-shadow: 0 -3px 0 var(--line), 0 3px 0 var(--line), -3px 0 0 var(--line), 3px 0 0 var(--line); margin: 3px 0; }
.input:focus { outline: none; box-shadow: 0 -3px 0 var(--accent2), 0 3px 0 var(--accent2), -3px 0 0 var(--accent2), 3px 0 0 var(--accent2); }
.export { display: flex; gap: 8px; flex-wrap: wrap; }
.export .pbtn { flex: 1; min-height: 46px; }

/* 日历 */
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.cal-head h2 { margin: 0; font-size: 18px; color: var(--text); }
.week, .cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.week span { text-align: center; font-size: 12px; color: var(--muted); font-weight: 700; }
.cal { margin-top: 6px; }
.day {
  position: relative; aspect-ratio: 16 / 12; border: 0; padding: 0; background: var(--soft); cursor: pointer; overflow: hidden;
  display: flex; align-items: flex-start; justify-content: flex-start; color: var(--muted); font-weight: 700; font-size: 12px;
}
.day img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; image-rendering: pixelated; }
.day i { position: relative; z-index: 1; font-style: normal; padding: 1px 5px; }
.day.has i { color: #fff; background: rgba(0, 0, 0, .35); }
.day.today { box-shadow: inset 0 0 0 3px var(--accent); }
.day.future { opacity: .35; cursor: default; }
.day.blank { visibility: hidden; }
.day .m { position: absolute; right: 3px; bottom: 2px; z-index: 1; font-size: 13px; }
@media (max-width: 520px) { .week, .cal { gap: 3px; } .day .m { display: none; } }

/* 我的 */
#view-me, #view-cal { display: grid; gap: 16px; max-width: 760px; margin: 0 auto; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }
.stat { background: var(--card); border: 1px solid var(--soft); border-radius: 18px; padding: 14px; box-shadow: var(--shadow); }
.stat b { display: block; font-size: 28px; line-height: 1.1; }
.stat span { color: var(--muted); font-size: 13px; }
.bar { display: grid; grid-template-columns: 70px 1fr 34px; align-items: center; gap: 8px; margin: 6px 0; font-size: 13.5px; }
.bar div { height: 14px; background: var(--soft); }
.bar div i { display: block; height: 100%; background: var(--c); transition: width .6s var(--ease); }
.bar small { text-align: right; color: var(--muted); }
.year { display: grid; grid-template-columns: 22px repeat(31, 1fr); gap: 2px; font-size: 10px; color: var(--muted); margin-bottom: 10px; }
.year span { aspect-ratio: 1; background: var(--soft); }
.year span.x { background: none; }
.year em { font-style: normal; display: flex; align-items: center; }
.year span[data-d] { cursor: pointer; }
.legend { display: flex; flex-wrap: wrap; gap: 10px; font-size: 12.5px; color: var(--muted); margin-bottom: 10px; }
.legend i { display: inline-block; width: 10px; height: 10px; margin-right: 4px; vertical-align: -1px; }
.set { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 0; flex-wrap: wrap; }
.seg { display: flex; gap: 2px; background: var(--soft); padding: 3px; }
.seg button { border: 0; background: none; padding: 6px 10px; font-size: 13px; font-weight: 700; color: var(--muted); cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--card-solid); color: var(--text); box-shadow: 0 2px 0 var(--accent2); }
.sw { appearance: none; width: 46px; height: 26px; background: var(--soft); position: relative; cursor: pointer; margin: 0; box-shadow: inset 0 0 0 2px var(--line); }
.sw::after { content: ""; position: absolute; left: 4px; top: 4px; width: 18px; height: 18px; background: var(--muted); transition: transform .2s var(--ease); }
.sw:checked { background: var(--accent2); }
.sw:checked::after { transform: translateX(20px); background: #fff; }

/* 弹窗 */
.dlg { border: 0; padding: 14px; background: var(--card-solid); color: var(--text); max-width: min(520px, 94vw);
  box-shadow: 0 -4px 0 var(--line), 0 4px 0 var(--line), -4px 0 0 var(--line), 4px 0 0 var(--line), 0 30px 80px -20px rgba(0,0,0,.6); }
.dlg::backdrop { background: rgba(10, 6, 30, .55); backdrop-filter: blur(4px); }
.dlg[open] { animation: up .3s var(--ease); }
.dlg img { display: block; width: 100%; max-height: 72dvh; object-fit: contain; }
.dlg .tool-row { justify-content: flex-end; }

.toast {
  position: fixed; left: 50%; bottom: calc(100px + env(safe-area-inset-bottom)); transform: translate(-50%, 16px); opacity: 0; z-index: 60;
  background: var(--text); color: var(--card-solid); padding: 9px 16px; font-weight: 700; font-size: 14px; pointer-events: none; transition: .25s var(--ease);
  box-shadow: 0 -3px 0 var(--line), 0 3px 0 var(--line), -3px 0 0 var(--line), 3px 0 0 var(--line); white-space: nowrap; max-width: 92vw;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
@media (min-width: 761px) { body { padding-bottom: 0; } .toast { bottom: 30px; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
