/* History side panel (Look 3, "Soft cards"): approved prototype in docs/prototypes/history/index.html */
#view { transition: padding-inline-end .25s ease; }
body.hist-open #view { padding-inline-end: 448px; }
/* The fixed Back / History row makes room too, so the History button stays in sight (dark = open) and closes the panel */
body.hist-open .ctxbar { padding-inline-end: calc(448px + var(--sp-5)); }

.hist-btn[aria-pressed="true"] { border-color: var(--c-ink); background: var(--c-select); color: var(--c-text); }
.hist-ic { flex: none; }

.hist-panel { position: fixed; top: 0; right: 0; bottom: 0; width: 420px; max-width: 100vw; background: var(--c-card); border-inline-start: 1px solid var(--c-line); box-shadow: -10px 0 30px rgba(28,27,37,.07); z-index: 60; display: flex; flex-direction: column; animation: hist-in .25s ease; }
.hist-panel.over { z-index: 2; }
@keyframes hist-in { from { transform: translateX(104%); } to { transform: none; } }

.hist-head { display: flex; align-items: center; gap: 8px; padding: 14px 18px 14px 22px; border-bottom: 1px solid var(--c-line); }
.hist-head h2 { font-size: var(--fs-section); flex: 1; margin: 0; color: var(--c-ink); }
.hist-head .btn { display: inline-flex; align-items: center; gap: 6px; }
.hist-head .btn[hidden] { display: none; }
.hist-x { padding: 6px 8px; }
.hist-back { display: none; align-items: center; gap: 5px; margin-inline-start: -8px; padding: 4px 8px 4px 4px; border: 0; border-radius: var(--r-md); background: none; color: var(--c-ink); font: inherit; font-weight: var(--fw-semibold); font-size: var(--fs-body); cursor: pointer; min-width: 0; }
.hist-back span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hist-back:hover { background: var(--c-select); }
.hist-back .hist-ic { color: var(--c-muted); }
.hist-body { flex: 1; overflow: auto; padding: 0 22px 40px; }
.hist-btn:disabled, .hist-panel .btn:disabled { opacity: .45; cursor: default; }

.hist-compose { margin: 16px 0 4px; border: 1px solid var(--c-ink); border-radius: var(--r-lg); box-shadow: 0 0 0 3px rgba(16, 24, 40,.12); background: var(--c-card); }
.hist-compose[hidden] { display: none; }
.hist-compose textarea { display: block; width: 100%; border: 0; outline: 0; resize: none; min-height: 84px; padding: 12px 14px 4px; border-radius: var(--r-lg); background: transparent; line-height: 1.5; font: inherit; color: var(--c-text); }
.hist-compose .bar { display: flex; align-items: center; gap: 8px; padding: 6px 10px 10px 14px; }
.hist-compose .hint { color: var(--c-faint); font-size: var(--fs-hint); flex: 1; }

.hist-panel .day { display: flex; align-items: center; gap: 12px; margin: 26px 0 18px; }
.hist-panel .day::before, .hist-panel .day::after { content: ""; flex: 1; height: 1px; background: var(--c-line); }
.hist-panel .day span { white-space: nowrap; background: var(--c-card); border: 1px solid var(--c-line-strong); color: var(--c-ink); font-size: var(--fs-hint); font-weight: var(--fw-semibold); border-radius: var(--r-pill); padding: 3px 13px; }
.hist-panel .it { background: var(--c-tile); border-radius: var(--r-lg); padding: 13px 15px 11px; margin-bottom: 10px; }
.hist-panel .chgs { display: grid; gap: 10px; }
.hist-panel .lbl { display: flex; align-items: center; gap: 7px; font-size: var(--fs-hint); font-weight: var(--fw-semibold); color: var(--c-ink); margin-bottom: 3px; }
.hist-panel .lbl::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--tc, var(--c-faint)); }
.hist-panel .t-money { --tc: #d9921c; }
.hist-panel .t-stage { --tc: #3a78d8; }
.hist-panel .t-person { --tc: #14a58f; }
.hist-panel .t-list { --tc: var(--c-text); }
.hist-panel .t-text { --tc: var(--c-faint); }
.hist-panel .vals { display: flex; align-items: baseline; flex-wrap: wrap; gap: 3px 8px; font-size: var(--fs-table); line-height: 1.45; overflow-wrap: anywhere; }
.hist-panel .old { color: var(--c-faint); text-decoration: line-through; text-decoration-color: var(--c-line-strong); }
.hist-panel .arr { color: var(--c-line-strong); font-size: var(--fs-table); font-weight: 400; margin-inline-end: 3px; }
.hist-panel .new { color: var(--c-text); font-weight: var(--fw-semibold); }
.hist-panel .none { color: var(--c-faint); font-style: italic; }
.hist-panel .plain { font-size: var(--fs-table); color: var(--c-ink); line-height: 1.45; overflow-wrap: anywhere; }
.hist-panel .what { font-size: var(--fs-hint); color: var(--c-muted); line-height: 1.4; margin-bottom: 6px; overflow-wrap: anywhere; }
.hist-panel .note { background: var(--c-card); border-radius: 4px 12px 12px 12px; padding: 10px 14px; color: var(--c-text); font-size: var(--fs-table); line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; }
.hist-panel .why { display: flex; align-items: baseline; gap: 8px; margin-top: 8px; font-size: var(--fs-hint); color: var(--c-muted); line-height: 1.4; }
.hist-panel .chgs + .note, .hist-panel .plain + .note { margin-top: 8px; }
.hist-panel .why b { flex: none; font-size: 10px; font-weight: var(--fw-semibold); letter-spacing: .06em; text-transform: uppercase; color: #6b5a1e; background: var(--c-warning-soft); border-radius: 4px; padding: 1px 6px; }
.hist-panel .meta { display: flex; align-items: center; gap: 8px; margin-top: 7px; font-size: var(--fs-hint); }
.hist-panel .meta .nm { color: var(--c-faint); }
.hist-panel .meta .sp { flex: 1; }
.hist-panel .meta time { color: var(--c-faint); font-variant-numeric: tabular-nums; }
.hist-panel .empty { text-align: center; color: var(--c-faint); padding: 40px 0; }
.hist-more { text-align: center; color: var(--c-faint); font-size: var(--fs-hint); padding: 10px 0; }

/* Phone: the panel is a full-screen sheet; "Back to <page>" replaces the X */
@media (max-width: 720px) {
  body.hist-open #view { padding-inline-end: 0; }
  body.hist-open .ctxbar { padding-inline-end: var(--sp-3); }
  .hist-panel { width: 100vw; border-inline-start: 0; box-shadow: none; }
  .hist-back { display: inline-flex; }
  .hist-x { display: none; }
  .hist-head h2 { display: none; }
  .hist-head .hist-back { flex: 1; }
  .hist-body { padding: 0 16px 40px; }
}
@media (prefers-reduced-motion: reduce) { .hist-panel { animation: none; } #view { transition: none; } }

/* In a pop-up header (role, user): the button sits just left of the close X */
.modal-head .hist-btn { margin-inline-start: auto; margin-inline-end: 8px; align-self: center; }
