/* Ridgeline (demo) — components */

/* ---------- Icons ---------- */
.icon { flex: none; }

/* ---------- Buttons (tactile "key" press) ---------- */
.btn {
  --btn-bg: var(--accent); --btn-fg: var(--on-accent); --btn-edge: var(--accent-press);
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 52px; padding: 0 22px; border-radius: var(--r-m);
  background: var(--btn-bg); color: var(--btn-fg);
  font-weight: 600; font-size: 16px; letter-spacing: .005em; text-align: center;
  box-shadow: 0 3px 0 var(--btn-edge);
  transition: transform .12s var(--ease), box-shadow .12s var(--ease), background-color .15s;
  -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent;
}
.btn:hover { filter: brightness(1.04); }
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--btn-edge); }
.btn--block { display: flex; width: 100%; }
.btn--ink { --btn-bg: var(--ink); --btn-fg: var(--bg); --btn-edge: var(--key-shadow); }
.btn--pine { --btn-bg: var(--pine); --btn-fg: var(--on-pine); --btn-edge: var(--key-shadow); }
.btn--ghost {
  --btn-bg: transparent; --btn-fg: var(--ink); --btn-edge: transparent;
  box-shadow: inset 0 0 0 1px var(--line-2);
}
.btn--ghost:active { box-shadow: inset 0 0 0 1px var(--ink); transform: translateY(1px); }
.btn--quiet { --btn-bg: transparent; --btn-fg: var(--accent-text); --btn-edge: transparent; box-shadow: none; padding: 0 12px; min-height: 44px; }
.btn--quiet:active { transform: none; background: var(--accent-soft); }
.btn--danger { --btn-bg: var(--bad); --btn-fg: var(--bg); --btn-edge: var(--key-shadow); }
.btn--sm { min-height: 40px; padding: 0 16px; font-size: 14px; border-radius: 12px; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .45; pointer-events: none; }

.iconbtn {
  display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: 50%;
  color: var(--ink); background: var(--surface); box-shadow: inset 0 0 0 1px var(--line);
  transition: background-color .15s, transform .12s var(--ease);
}
.iconbtn:hover { background: var(--surface-2); }
.iconbtn:active { transform: scale(.94); }
.iconbtn--bare { background: transparent; box-shadow: none; }
.theme-btn .i-sun { display: none; }
:root[data-theme="dark"] .theme-btn .i-sun { display: block; }
:root[data-theme="dark"] .theme-btn .i-moon { display: none; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface); border-radius: var(--r-l); padding: var(--s5);
  box-shadow: inset 0 0 0 1px var(--line), var(--shadow-1);
}
.card--flat { box-shadow: inset 0 0 0 1px var(--line); }
.card--inv { background: var(--inv-bg); color: var(--inv-ink); box-shadow: inset 0 0 0 1px var(--inv-line); }
.card--inv .eyebrow, .card--inv .muted { color: var(--inv-ink-2); }
.card--pine { background: var(--pine-soft); box-shadow: inset 0 0 0 1px var(--line); }
.card--accent { background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--line); }
.stack { display: grid; gap: var(--s4); }
.stack--s { gap: var(--s2); }
.stack--l { gap: var(--s6); }
.cluster { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); }
.split { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s3); }
.divider { height: 1px; background: var(--line); border: 0; margin: 0; }

/* ---------- Topbar ---------- */
.topbar { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s4); padding: var(--s5) 0 var(--s4); }
.topbar .eyebrow { margin-bottom: 6px; }
.topbar__actions { display: flex; gap: var(--s2); }

/* ---------- Chips ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 0 10px; min-height: 26px;
  border-radius: 999px; font-size: 12.5px; font-weight: 600; letter-spacing: .01em;
  background: var(--surface-2); color: var(--ink-2); box-shadow: inset 0 0 0 1px var(--line); white-space: nowrap;
}
.chip--good { background: var(--good-soft); color: var(--good); box-shadow: none; }
.chip--warn { background: var(--warn-soft); color: var(--warn); box-shadow: none; }
.chip--bad { background: var(--bad-soft); color: var(--bad); box-shadow: none; }
.chip--info { background: var(--info-soft); color: var(--info); box-shadow: none; }
.chip--pine { background: var(--pine-soft); color: var(--pine-text); box-shadow: none; }
.chip--accent { background: var(--accent-soft); color: var(--accent-text); box-shadow: none; }
.chip--demo { background: transparent; color: var(--ink-3); box-shadow: inset 0 0 0 1px var(--line-2); border-style: dashed; }
.chip .icon { width: 14px; height: 14px; }

/* ---------- Segmented ---------- */
.seg {
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; padding: 4px;
  background: var(--bg-2); border-radius: 14px; box-shadow: inset 0 0 0 1px var(--line);
}
.seg [role="radio"] {
  min-height: 40px; padding: 0 12px; border-radius: 10px; font-weight: 600; font-size: 14px; color: var(--ink-2);
  transition: background-color .15s, color .15s;
}
.seg [role="radio"][aria-checked="true"] { background: var(--ink); color: var(--bg); }

/* ---------- Fields ---------- */
.field { display: grid; gap: 6px; }
.field > label, .label { font-weight: 600; font-size: 14px; color: var(--ink); }
.field .hint { font-size: 13px; color: var(--ink-3); }
.input {
  width: 100%; min-height: 54px; padding: 0 16px; border-radius: var(--r-m);
  background: var(--surface); border: 0; box-shadow: inset 0 0 0 1px var(--line-2);
  font-size: 17px; color: var(--ink);
  transition: box-shadow .15s;
}
.input::placeholder { color: var(--ink-3); }
.input:focus { outline: none; box-shadow: inset 0 0 0 2px var(--ink); }
.input[aria-invalid="true"] { box-shadow: inset 0 0 0 2px var(--bad); }
.field .error { display: none; color: var(--bad); font-size: 13px; font-weight: 520; }
.field.has-error .error { display: block; }
.field.has-error .input { box-shadow: inset 0 0 0 2px var(--bad); }
.prefix { display: grid; grid-template-columns: auto 1fr; gap: 8px; }
.prefix__tag {
  display: inline-grid; place-items: center; padding: 0 14px; border-radius: var(--r-m);
  background: var(--surface-2); font-weight: 600; box-shadow: inset 0 0 0 1px var(--line);
}

/* ---------- Switch ---------- */
.switch { position: relative; display: inline-block; width: 52px; height: 32px; flex: none; }
.switch input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; z-index: 1; }
.switch__track {
  position: absolute; inset: 0; border-radius: 999px; background: var(--line-2); transition: background-color .2s;
}
.switch__track::after {
  content: ""; position: absolute; left: 3px; top: 3px; width: 26px; height: 26px; border-radius: 50%;
  background: var(--raise); box-shadow: 0 1px 3px rgba(0,0,0,.35); transition: transform .22s var(--ease);
}
.switch input:checked + .switch__track { background: var(--pine); }
:root[data-theme="dark"] .switch input:checked + .switch__track { background: var(--pine); }
.switch input:checked + .switch__track::after { transform: translateX(20px); }
.switch input:focus-visible + .switch__track { outline: 2.5px solid var(--focus); outline-offset: 2px; }

/* ---------- Lists / rows ---------- */
.list { background: var(--surface); border-radius: var(--r-l); box-shadow: inset 0 0 0 1px var(--line); overflow: hidden; }
.row {
  display: flex; align-items: center; gap: var(--s3); min-height: 60px; padding: 10px var(--s4);
  width: 100%; text-align: left;
}
.list > .row + .row { box-shadow: inset 0 1px 0 var(--line); }
a.row:hover, button.row:hover { background: var(--surface-2); }
.row__ico {
  flex: none; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px;
  background: var(--bg-2); color: var(--ink);
}
.row__ico--accent { background: var(--accent-soft); color: var(--accent-text); }
.row__ico--pine { background: var(--pine-soft); color: var(--pine-text); }
.row__body { flex: 1; min-width: 0; }
.row__title { font-weight: 600; line-height: 1.25; }
.row__sub { font-size: 13.5px; color: var(--ink-3); line-height: 1.35; }
.row__end { flex: none; color: var(--ink-3); display: flex; align-items: center; gap: 6px; }

/* ---------- Task check ---------- */
.task { display: flex; align-items: center; gap: var(--s3); padding: 14px 0; cursor: pointer; position: relative; }
.task + .task { box-shadow: inset 0 1px 0 var(--inv-line); }
.task input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.task__box {
  flex: none; display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%;
  box-shadow: inset 0 0 0 2px var(--inv-ink-2); color: transparent; transition: background-color .18s, box-shadow .18s, transform .18s var(--ease);
}
.task input:checked + .task__box { background: var(--accent); box-shadow: none; color: var(--on-accent); transform: scale(1.04); }
.task input:focus-visible + .task__box { outline: 2.5px solid var(--inv-ink); outline-offset: 3px; }
.task__text { flex: 1; font-weight: 520; line-height: 1.3; }
.task__meta { font-size: 13px; color: var(--inv-ink-2); font-weight: 500; }
.task input:checked ~ .task__text { text-decoration: line-through; text-decoration-thickness: 1.5px; opacity: .65; }

/* ---------- Progress ---------- */
.bar { height: 10px; border-radius: 999px; background: var(--bg-2); box-shadow: inset 0 0 0 1px var(--line); overflow: hidden; }
.bar > span { display: block; height: 100%; border-radius: 999px; background: var(--accent); transition: width .6s var(--ease); }
.bar--pine > span { background: var(--pine); }
.card--inv .bar { background: rgba(244, 238, 227, .14); box-shadow: none; }

/* ---------- Banners ---------- */
.notice {
  display: flex; gap: var(--s3); padding: 12px 14px; border-radius: var(--r-m);
  background: var(--info-soft); color: var(--ink); font-size: 14px; line-height: 1.45;
}
.notice .icon { margin-top: 2px; color: var(--info); }
.notice--care { background: var(--pine-soft); }
.notice--care .icon { color: var(--pine-text); }
.notice--warn { background: var(--warn-soft); } .notice--warn .icon { color: var(--warn); }
.notice--bad { background: var(--bad-soft); } .notice--bad .icon { color: var(--bad); }
.notice--good { background: var(--good-soft); } .notice--good .icon { color: var(--good); }

/* ---------- Skeleton / empty / error ---------- */
.skel { position: relative; overflow: hidden; background: var(--bg-2); border-radius: 10px; min-height: 14px; }
.skel::after {
  content: ""; position: absolute; inset: 0; transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, var(--surface-2), transparent);
  animation: shimmer 1.4s infinite;
}
@keyframes shimmer { to { transform: translateX(100%); } }
.state { display: grid; justify-items: center; text-align: center; gap: var(--s2); padding: var(--s7) var(--s5); }
.state__ico { display: grid; place-items: center; width: 56px; height: 56px; border-radius: 18px; background: var(--bg-2); color: var(--ink-2); margin-bottom: 4px; }
.state--bad .state__ico { background: var(--bad-soft); color: var(--bad); }

/* ---------- Tab bar ---------- */
.tabbar {
  flex: none; display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--surface); box-shadow: inset 0 1px 0 var(--line);
  padding: 0 6px calc(6px + env(safe-area-inset-bottom));
}
.tab {
  position: relative; display: grid; justify-items: center; gap: 3px; padding: 10px 0 6px;
  font-size: 11.5px; font-weight: 600; letter-spacing: .01em; color: var(--ink-3);
  min-height: 58px;
}
.tab::before {
  content: ""; position: absolute; top: 0; left: 28%; right: 28%; height: 3px; border-radius: 0 0 3px 3px;
  background: var(--accent); transform: scaleX(0); transition: transform .25s var(--ease);
}
.tab[aria-current="page"] { color: var(--ink); }
.tab[aria-current="page"]::before { transform: scaleX(1); }
.tab:hover { color: var(--ink); }

/* ---------- Layers: sheet / dialog / toast ---------- */
.layer { position: absolute; inset: 0; z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.layer__scrim { position: absolute; inset: 0; background: var(--scrim); animation: fade .2s both; }
.layer.out .layer__scrim { animation: fade .18s reverse both; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.sheet {
  position: relative; width: 100%; max-height: 88%; display: flex; flex-direction: column;
  background: var(--bg); border-radius: 28px 28px 0 0; box-shadow: var(--shadow-2);
  animation: sheet-in .34s var(--ease) both;
  padding-bottom: env(safe-area-inset-bottom);
}
.layer.out .sheet { animation: sheet-out .2s ease-in both; }
@keyframes sheet-in { from { transform: translateY(100%); } to { transform: none; } }
@keyframes sheet-out { to { transform: translateY(100%); } }
.sheet__grab { width: 40px; height: 4px; border-radius: 4px; background: var(--line-2); margin: 10px auto 0; flex: none; }
.sheet__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px var(--pad) 6px; flex: none; }
.sheet__body { padding: 8px var(--pad) var(--s6); overflow-y: auto; display: grid; gap: var(--s4); }
.sheet__foot { padding: 0 var(--pad) var(--s5); display: grid; gap: var(--s2); }
.layer--dialog { align-items: center; padding: var(--pad); }
.layer--dialog .sheet { border-radius: 24px; max-height: 90%; animation: pop .28s var(--ease) both; }
.layer--dialog.out .sheet { animation: fade .16s reverse both; }
@keyframes pop { from { opacity: 0; transform: scale(.94) translateY(8px); } to { opacity: 1; transform: none; } }
.layer--dialog .sheet__grab { display: none; }

.toasts { position: absolute; left: 0; right: 0; bottom: 84px; z-index: 60; display: grid; justify-items: center; gap: 8px; padding: 0 var(--pad); pointer-events: none; }
.toast {
  display: flex; align-items: center; gap: 10px; max-width: 100%; padding: 12px 16px; border-radius: 14px;
  background: var(--ink); color: var(--bg); font-weight: 520; font-size: 14.5px; box-shadow: var(--shadow-2);
  animation: rise .3s var(--ease) both; pointer-events: auto;
}
.toast.out { animation: fade .2s reverse both; }
.toast--good .icon { color: var(--good-soft); }
.toast--bad { background: var(--bad); color: #fff; }
:root[data-theme="dark"] .toast--bad { color: #1A0806; }

/* ---------- Charts ---------- */
.chart { width: 100%; height: auto; overflow: visible; }
.chart text { font-family: var(--f-ui); font-variant-numeric: tabular-nums; fill: var(--chart-axis); font-size: 11px; font-weight: 520; }
.chart .grid { stroke: var(--chart-grid); stroke-width: 1; }
.chart .line { fill: none; stroke: var(--chart-line); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.chart .area { fill: var(--chart-fill); stroke: none; }
.chart .dot { fill: var(--bg); stroke: var(--chart-line); stroke-width: 3; }
.chart .dot--solid { fill: var(--chart-line); stroke: var(--bg); stroke-width: 3; }
.chart .tag { fill: var(--ink); }
.chart text.tag-t { fill: var(--bg); font-weight: 650; font-size: 12px; }
.chart .target { stroke: var(--ink-3); stroke-width: 1.5; stroke-dasharray: 4 4; }
.chart .c-bar { fill: var(--chart-bar); }
.chart .c-bar--now { fill: var(--chart-line); }
.chart .c-bar--hit { fill: var(--chart-alt); }
.ring-wrap { position: relative; display: grid; place-items: center; }
.ring-wrap__center { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.ring .track { fill: none; stroke: var(--bg-2); }
.ring .prog { fill: none; stroke-linecap: round; transition: stroke-dashoffset .9s var(--ease); }
.legend { display: flex; gap: var(--s4); font-size: 13px; color: var(--ink-2); font-weight: 520; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
