:root {
  --bg: #121212;
  --panel: #1b1b1b;
  --line: #2b2b2b;
  --fg: #f2f2f2;
  --muted: #9a9a9a;
  --grid: #2f2f2f;
  --bad: #e5484d;
  --accent: #3b8be3;
  --radius: 10px;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f6f5f2; --panel: #ffffff; --line: #e4e1da; --fg: #1a1a1a;
    --muted: #6d6a63; --grid: #ebe8e1; color-scheme: light;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--fg); font-family: var(--sans); -webkit-text-size-adjust: 100%; }
body { min-height: 100vh; min-height: 100dvh; padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom); }
[hidden] { display: none !important; }
button, input { font: inherit; }

.title { font-family: var(--serif); font-weight: 400; font-size: 1.9rem; margin: 0; }
.muted { color: var(--muted); }
.small { font-size: .78rem; }
.msg { margin: .6rem 0 0; color: var(--bad); font-size: .9rem; min-height: 1.2em; }

/* ---------- Login ---------- */
.login { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 16px; }
.login-card { width: min(100%, 22rem); background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 1.6rem; display: grid; gap: .9rem; }
.login-card p { margin: 0; }
.login-card input { width: 100%; height: 3rem; border-radius: var(--radius); border: 1px solid var(--line); background: var(--bg); color: var(--fg); padding: 0 .9rem; font-size: 16px; }
.login-card input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.login-card button { height: 3rem; border: 0; border-radius: var(--radius); background: var(--accent); color: #fff; font-weight: 600; cursor: pointer; }
.login-card button:disabled { opacity: .6; cursor: default; }

/* ---------- App ---------- */
.xp { display: grid; gap: 16px; max-width: 72rem; margin: 0 auto; padding: 24px 16px 48px; }
.top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.take { margin: .4rem 0 0; line-height: 1.5; color: var(--muted); }
.take b { color: var(--fg); font-weight: 600; font-variant-numeric: tabular-nums; }
.actions { display: flex; align-items: center; gap: .4rem; flex-shrink: 0; }
.ghost { width: 2.2rem; height: 2.2rem; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); color: var(--muted); cursor: pointer; font-size: 1.05rem; line-height: 1; }
.ghost:hover { color: var(--fg); }
.ghost.spin { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 9.5rem), 1fr)); gap: 12px; }
.tile, .card, .day { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.tile { display: grid; gap: .35rem; align-content: start; min-height: 5.5rem; }
.tile.accent { box-shadow: inset 0 3px 0 var(--accent); }
.lab { color: var(--muted); font-size: .8rem; }
.big { font-family: var(--serif); font-size: 2.1rem; font-variant-numeric: tabular-nums; line-height: 1.1; }
.big b { font-weight: 400; }
.big i { font-style: normal; font-family: var(--sans); font-size: .8rem; color: var(--muted); margin-left: .3rem; }

.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 20rem), 1fr)); gap: 12px; }
.card { position: relative; min-width: 0; }
.card h2, .h2 { margin: 0; font-size: 1.05rem; font-weight: 500; }
.note { margin: .2rem 0 12px; color: var(--muted); font-size: .8rem; }
.note0 { margin-bottom: 12px; }

.days { min-height: 12rem; }
.days svg { display: block; width: 100%; }

.list { list-style: none; margin: 0; padding: 0; display: grid; gap: .7rem; }
.row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .2rem .75rem; align-items: baseline; }
.row .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .v { font-variant-numeric: tabular-nums; color: var(--muted); font-size: .8rem; }
.row .v b { color: var(--fg); font-weight: 600; }
.track { grid-column: 1 / -1; height: .5rem; border-radius: 99px; background: var(--grid); overflow: hidden; }
.fill { display: block; height: 100%; border-radius: 99px; }
.stack { display: flex; height: 1.1rem; gap: 2px; border-radius: 99px; overflow: hidden; margin-bottom: 12px; }
.seg { height: 100%; }
.dot { display: inline-block; width: .6rem; height: .6rem; border-radius: 50%; margin-right: .5rem; }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 18rem), 1fr)); gap: 12px; align-items: start; }
.day { display: grid; gap: .75rem; }
.day.is-today { background: color-mix(in srgb, var(--accent) 6%, var(--panel)); box-shadow: inset 0 3px 0 var(--accent); }
.dayhead { display: flex; justify-content: space-between; align-items: flex-start; gap: .75rem; }
.dayname { margin: 0; font-size: 1.05rem; font-weight: 500; }
.daysub { display: block; color: var(--muted); font-size: .8rem; margin-top: .1rem; }
.daytot { font-family: var(--serif); font-size: 1.9rem; font-variant-numeric: tabular-nums; white-space: nowrap; line-height: 1.1; }
.daytot b { font-weight: 400; }
.none { margin: 0; color: var(--muted); font-size: .85rem; }
.items { list-style: none; margin: 0; padding: 0; display: grid; }
.item { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: .75rem; align-items: start; padding: .6rem 0; border-top: 1px solid var(--line); }
.item:first-child { border-top: 0; padding-top: 0; }
.inote { display: block; overflow-wrap: anywhere; }
.imeta { display: block; color: var(--muted); font-size: .8rem; margin-top: .15rem; }
.pill { display: inline-block; padding: .05rem .55rem; border-radius: 99px; background: color-mix(in srgb, var(--c) 30%, transparent); color: var(--fg); font-size: .78rem; margin-right: .4rem; }
.iamt { font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--muted); }
.iamt b { color: var(--fg); font-weight: 600; }
.inline { all: unset; cursor: pointer; color: var(--muted); font-size: .8rem; text-decoration: underline; text-underline-offset: 3px; }
.more { margin-top: 12px; width: 100%; height: 2.75rem; border-radius: var(--radius); border: 1px solid var(--line); background: var(--panel); color: var(--muted); cursor: pointer; }

.tip { position: absolute; pointer-events: none; z-index: 5; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 6px 20px rgba(0,0,0,.35); padding: 6px 10px; font-size: .8rem; white-space: nowrap; opacity: 0; transition: opacity .15s; }
.tip small { display: block; color: var(--muted); }

.loading .tile .big b, .loading .take { opacity: .45; }

@media (max-width: 520px) {
  .title { font-size: 1.6rem; }
  .big { font-size: 1.8rem; }
  #updated { display: none; }
}

/* ---------- Modification ---------- */
.edit { all: unset; box-sizing: border-box; width: 2rem; height: 2rem; display: grid; place-items: center; border-radius: 8px; color: var(--muted); cursor: pointer; margin: -.35rem -.35rem -.35rem 0; }
.edit:hover, .edit:focus-visible { color: var(--fg); background: var(--grid); }
.edit svg { width: 1rem; height: 1rem; }

.modal { position: fixed; inset: 0; z-index: 20; background: rgba(0, 0, 0, .55); display: grid; place-items: center; padding: 16px; overflow-y: auto; }
.sheet { width: min(100%, 26rem); background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 1.3rem; display: grid; gap: .8rem; box-shadow: 0 20px 60px rgba(0, 0, 0, .45); }
.sheet h2 { margin: 0 0 .2rem; font-size: 1.15rem; font-weight: 500; }
.sheet label { display: grid; gap: .3rem; color: var(--muted); font-size: .8rem; }
.sheet input, .sheet select, .sheet textarea { width: 100%; border-radius: var(--radius); border: 1px solid var(--line); background: var(--bg); color: var(--fg); padding: .6rem .75rem; font-size: 16px; font-family: inherit; }
.sheet input, .sheet select { height: 2.8rem; }
.sheet textarea { resize: vertical; min-height: 3.4rem; line-height: 1.4; }
.sheet input:focus, .sheet select:focus, .sheet textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.btns { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; margin-top: .2rem; }
.btns button { height: 2.9rem; border-radius: var(--radius); font-weight: 600; cursor: pointer; border: 1px solid var(--line); }
.btns .secondary { background: var(--panel); color: var(--muted); }
.btns .primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btns button:disabled { opacity: .6; cursor: default; }
.sheet .msg { margin: 0; }

/* ---------- Suppression ---------- */
.danger-zone { border-top: 1px solid var(--line); padding-top: .8rem; display: grid; gap: .6rem; }
.danger { height: 2.6rem; border-radius: var(--radius); border: 1px solid color-mix(in srgb, var(--bad) 55%, var(--line)); background: transparent; color: var(--bad); font-weight: 600; cursor: pointer; }
.danger:hover { background: color-mix(in srgb, var(--bad) 10%, transparent); }
.confirm { display: grid; gap: .6rem; }
.confirm p { margin: 0; font-size: .9rem; line-height: 1.4; }
.btns .dangerfill { background: var(--bad); border-color: var(--bad); color: #fff; }
.danger:disabled { opacity: .6; cursor: default; }
