/* ============================================================================
   Porsi — stylesheet

   Everything is set in Bricolage Grotesque, a display grotesque: big and
   characterful at hero sizes, still legible down at input-label size. Panel
   surfaces stay on the two colours the chart palette was validated against
   (#fcfcfb light, #1a1a19 dark) so the slice colours keep their contrast.
   ========================================================================== */

:root {
  color-scheme: dark;

  --page: #0c0c0b;
  --surface: #1a1a19;
  --surface-2: #222221;
  --surface-3: #2b2b29;

  --ink: #ffffff;
  --ink-2: #c3c2b7;
  --muted: #8b8981;

  --line: rgba(255, 255, 255, 0.10);
  --line-strong: rgba(255, 255, 255, 0.20);

  --accent: #3987e5;
  --accent-ink: #07141f;
  --accent-soft: rgba(57, 135, 229, 0.16);
  --good: #0ca30c;
  --warn: #fab219;
  --crit: #e66767;

  --shadow: 0 2px 4px rgba(0, 0, 0, .3), 0 18px 44px rgba(0, 0, 0, .34);
  --shadow-lg: 0 30px 80px rgba(0, 0, 0, .6);

  --r: 26px;
  --r-sm: 16px;
  --display: 'Bricolage Grotesque', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --ease: cubic-bezier(.22, .61, .36, 1);
}

:root[data-theme="light"] {
  color-scheme: light;

  --page: #f6f5f1;
  --surface: #fcfcfb;
  --surface-2: #ffffff;
  --surface-3: #f0efe9;

  --ink: #14140f;
  --ink-2: #55544f;
  --muted: #8b8981;

  --line: rgba(11, 11, 11, 0.10);
  --line-strong: rgba(11, 11, 11, 0.20);

  --accent: #2a78d6;
  --accent-ink: #ffffff;
  --accent-soft: rgba(42, 120, 214, 0.10);
  --crit: #d03b3b;

  --shadow: 0 1px 2px rgba(11, 11, 11, .05), 0 14px 36px rgba(11, 11, 11, .07);
  --shadow-lg: 0 30px 70px rgba(11, 11, 11, .16);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--page);
  color: var(--ink);
  font-family: var(--display);
  font-size: 15px;
  font-weight: 450;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
body.locked { overflow: hidden; }

h1, h2, h3 { margin: 0; font-weight: 700; letter-spacing: -0.02em; line-height: 1.15; }
p { margin: 0; }
button, input { font: inherit; color: inherit; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 8px; }

/* A single soft light behind everything, so the page isn't a flat slab. */
.glow {
  position: fixed;
  inset: -20vmax 0 auto 50%;
  width: 90vmax; height: 70vmax;
  transform: translateX(-50%);
  background:
    radial-gradient(45% 45% at 30% 40%, rgba(57, 135, 229, .30), transparent 70%),
    radial-gradient(40% 40% at 70% 30%, rgba(237, 161, 0, .22), transparent 70%);
  filter: blur(40px);
  pointer-events: none;
  z-index: 0;
}
:root[data-theme="light"] .glow { opacity: .55; }

/* ── Chrome ──────────────────────────────────────────────────────────────── */

.top {
  position: relative; z-index: 1;
  max-width: 1080px;
  margin: 0 auto;
  padding: 26px clamp(18px, 4vw, 30px) 0;
  display: flex; align-items: center; justify-content: space-between;
}
.wordmark {
  font-size: 22px; font-weight: 800; letter-spacing: -0.045em;
}
.gear {
  width: 44px; height: 44px;
  display: grid; place-items: center;
  border: 1px solid var(--line); border-radius: 14px;
  background: var(--surface);
  color: var(--ink-2);
  cursor: pointer;
  transition: transform .25s var(--ease), color .2s var(--ease), border-color .2s var(--ease);
}
.gear svg { width: 20px; height: 20px; }
.gear:hover { color: var(--ink); border-color: var(--line-strong); transform: translateY(-1px); }
.gear--sm { width: 38px; height: 38px; border-radius: 12px; }
.gear--sm:hover { transform: none; }

.wrap {
  position: relative; z-index: 1;
  max-width: 1080px;
  margin: 0 auto;
  padding: 22px clamp(18px, 4vw, 30px) 90px;
  display: flex; flex-direction: column; gap: 18px;
}

/* ── Hero: the amount you have ───────────────────────────────────────────── */

.hero {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: clamp(20px, 4vw, 32px);
  box-shadow: var(--shadow);
}
.hero__label {
  display: block;
  font-size: 12.5px; font-weight: 650;
  text-transform: uppercase; letter-spacing: .12em;
  color: var(--muted);
}
.hero__field {
  display: flex; align-items: center; gap: 12px;
  margin-top: 14px; flex-wrap: wrap;
}
.hero__symbol {
  font-size: clamp(28px, 5vw, 44px); font-weight: 600;
  color: var(--muted); letter-spacing: -0.03em;
}
.hero__field input {
  flex: 1; min-width: 140px;
  border: 0; background: transparent; padding: 0;
  font-size: clamp(38px, 8vw, 68px);
  font-weight: 800; letter-spacing: -0.045em;
  line-height: 1.05;
}
.hero__field input:focus { outline: none; }
.hero__field input::placeholder { color: var(--muted); opacity: .4; }
.hero__note { margin-top: 12px; color: var(--muted); font-size: 13.5px; }

.ccy {
  display: inline-flex; align-items: center; gap: 9px;
  padding: 8px 14px 8px 9px;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--surface-2);
  cursor: pointer;
  transition: border-color .2s var(--ease), transform .2s var(--ease);
}
.ccy:hover { border-color: var(--accent); transform: translateY(-1px); }
.ccy__code { font-weight: 700; font-size: 14px; letter-spacing: -0.01em; }
.ccy__flag { display: block; width: 26px; height: 17px; }
.flag { width: 100%; height: 100%; display: block; border-radius: 3px; }

/* ── Board ───────────────────────────────────────────────────────────────── */

.board {
  display: grid; gap: 18px;
  grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.05fr);
  align-items: start;
}
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: clamp(18px, 3vw, 26px);
  box-shadow: var(--shadow);
  overflow: hidden;
}

/* ── Pie ─────────────────────────────────────────────────────────────────── */

.pie-wrap { display: flex; flex-direction: column; align-items: center; }
svg.pie { width: 100%; max-width: 320px; height: auto; overflow: visible; }
.slice {
  cursor: pointer;
  outline: none;

  stroke: transparent;
  stroke-width: 0;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;

  transition:
    filter .2s var(--ease),
    stroke .16s var(--ease),
    stroke-width .16s var(--ease);
}

.slice:hover {
  filter: brightness(1.06);
}

.slice:focus {
  outline: none;
  stroke: var(--ink);
  stroke-width: 2.5px;
  stroke-opacity: .88;
}

.slice.is-rest {
  opacity: .85;
}
.slice__label {
  font-family: var(--display);
  font-size: 13px; font-weight: 700; letter-spacing: -0.01em;
  pointer-events: none;
  transition: opacity .2s var(--ease);
}
.slice__icon { pointer-events: none; transition: opacity .2s var(--ease); }
.slice__brand-image {
  pointer-events: none;

  filter:
    drop-shadow(0 0 1px rgba(255, 255, 255, .85))
    drop-shadow(0 1px 1.5px rgba(0, 0, 0, .75));
}
.pie__caption {
  margin-top: 16px;
  color: var(--muted); font-size: 13px; font-weight: 550;
  text-align: center;
}

/* ── Parts ───────────────────────────────────────────────────────────────── */

.parts__head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 14px;
}
.parts__title { font-size: 17px; }
.pctbadge {
  padding: 5px 12px; border-radius: 999px;
  background: var(--surface-3); color: var(--ink-2);
  font-size: 13px; font-weight: 700;
  font-variant-numeric: tabular-nums;
  transition: background .2s var(--ease), color .2s var(--ease);
}
.pctbadge.is-ok { background: color-mix(in oklab, var(--good) 18%, transparent); color: var(--good); }
.pctbadge.is-over { background: color-mix(in oklab, var(--crit) 18%, transparent); color: var(--crit); }

.parts { display: flex; flex-direction: column; gap: 6px; }
.part {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 84px minmax(84px, auto) 32px;
  align-items: center; gap: 10px;
  padding: 8px 10px;
  border-radius: var(--r-sm);
  transition: background .18s var(--ease);
  animation: pop .35s var(--ease) calc(var(--i, 0) * 35ms) both;
}
@keyframes pop { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.part:hover, .part.is-hot { background: var(--surface-3); }
/* The tile carries the asset's logo; the ring around it carries the slice
   colour, so the row and the pie stay tied together. */
.part__logo {
  width: 44px; height: 44px; padding: 0;
  display: grid; place-items: center;
  border: 0; border-radius: 15px;
  background: transparent;
  cursor: pointer;
  box-shadow: inset 0 0 0 2px var(--slice, transparent);
  transition: transform .18s var(--ease), box-shadow .18s var(--ease);
}
.part__logo:hover { transform: scale(1.06); }
.part__ident { display: flex; flex-direction: column; min-width: 0; }
.part__sub {
  color: var(--muted); font-size: 11.5px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  margin-top: -2px;
}

/* ── Logo tiles ──────────────────────────────────────────────────────────── */

.tile {
  display: inline-grid; place-items: center; flex: none;
  border-radius: 11px;
  background: color-mix(in oklab, var(--brand) 18%, var(--surface));
  color: var(--brand);
}

.tile svg {
  width: 58%;
  height: 58%;
  display: block;
}

.tile__logo {
  width: 70%;
  height: 70%;
  object-fit: contain;
  display: block;
  pointer-events: none;

   filter:
    drop-shadow(0 0 .6px rgba(255, 255, 255, .45))
    drop-shadow(0 1px 1px rgba(0, 0, 0, .35));
}

.tile__mono {
  font-size: .4em;
  font-weight: 700;
  letter-spacing: -.02em;
}

.tile--md {
  width: 34px;
  height: 34px;
  font-size: 34px;
}

.tile--lg {
  width: 42px;
  height: 42px;
  border-radius: 13px;
  font-size: 42px;
}

/* Keep near-black and near-white brand colours legible on both surfaces. */
@supports (color: oklch(from red l c h)) {
  .tile { color: oklch(from var(--brand) min(l, 0.68) c h); }
  :root:not([data-theme="light"]) .tile { color: oklch(from var(--brand) max(l, 0.72) c h); }
}
.part__name {
  border: 0; background: transparent; padding: 4px 0;
  font-size: 15px; font-weight: 600; letter-spacing: -0.015em;
  min-width: 0;
}
.part__name:focus { outline: none; }
.part__name::placeholder { color: var(--muted); font-weight: 500; }
.part__pct {
  display: inline-flex; align-items: center; gap: 2px;
  padding: 6px 10px;
  border: 1px solid var(--line); border-radius: 11px;
  background: var(--surface-2);
  color: var(--muted); font-size: 13px;
  transition: border-color .16s var(--ease);
}
.part__pct:focus-within { border-color: var(--accent); }
.part__pct input {
  width: 44px; border: 0; background: transparent; padding: 0;
  text-align: right; font-weight: 700; font-size: 14px;
  font-variant-numeric: tabular-nums; color: var(--ink);
}
.part__pct input:focus { outline: none; }
.part__amount {
  text-align: right; font-weight: 650; font-size: 14px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.part__x {
  width: 30px; height: 30px;
  display: grid; place-items: center;
  border: 0; border-radius: 9px;
  background: transparent; color: var(--muted);
  cursor: pointer; opacity: 0;
  transition: opacity .16s var(--ease), background .16s var(--ease), color .16s var(--ease);
}
.part__x svg { width: 15px; height: 15px; }
.part:hover .part__x, .part__x:focus-visible { opacity: 1; }
.part__x:hover { background: color-mix(in oklab, var(--crit) 16%, transparent); color: var(--crit); }
.parts__empty { color: var(--muted); font-size: 14px; padding: 22px 10px; text-align: center; }

.parts__actions {
  display: flex; gap: 8px; flex-wrap: wrap;
  margin-top: 16px; padding-top: 16px;
  border-top: 1px solid var(--line);
}
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 10px 16px;
  border: 1px solid var(--line); border-radius: 13px;
  background: var(--surface-2); color: var(--ink-2);
  font-weight: 650; font-size: 14px;
  cursor: pointer;
  transition: transform .16s var(--ease), background .2s var(--ease), color .2s var(--ease), border-color .2s var(--ease);
}
.btn svg { width: 16px; height: 16px; }
.btn:hover { background: var(--surface-3); color: var(--ink); border-color: var(--line-strong); }
.btn:active { transform: translateY(1px); }
.btn--main {
  background: var(--accent); border-color: var(--accent); color: var(--accent-ink);
}
.btn--main:hover {
  background: color-mix(in oklab, var(--accent) 86%, var(--ink));
  color: var(--accent-ink);
  transform: translateY(-1px);
}

/* ── Tooltip ─────────────────────────────────────────────────────────────── */

.tip {
  position: fixed; top: 0; left: 0; z-index: 60;
  display: flex; flex-direction: column;
  padding: 10px 13px;
  border: 1px solid var(--line-strong); border-radius: 13px;
  background: var(--surface-2);
  box-shadow: var(--shadow-lg);
  pointer-events: none; opacity: 0;
  transition: opacity .12s var(--ease);
  white-space: nowrap;
}
.tip.on { opacity: 1; }
.tip__title { font-size: 11.5px; font-weight: 650; color: var(--muted); text-transform: uppercase; letter-spacing: .07em; }
.tip strong { font-size: 17px; font-weight: 750; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.tip__sub { font-size: 12.5px; color: var(--ink-2); font-variant-numeric: tabular-nums; }

/* ── Settings sheet ──────────────────────────────────────────────────────── */

.sheet { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; padding: 20px; }
.sheet[hidden] { display: none; }
.sheet__scrim {
  position: absolute; inset: 0;
  background: color-mix(in oklab, var(--page) 70%, transparent);
  backdrop-filter: blur(6px);
  opacity: 0; transition: opacity .2s var(--ease);
}
.sheet.on .sheet__scrim { opacity: 1; }
.sheet__panel {
  position: relative;
  width: min(440px, 100%);
  max-height: 88vh; overflow-y: auto;
  padding: 22px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow-lg);
  opacity: 0; transform: translateY(16px) scale(.97);
  transition: opacity .24s var(--ease), transform .24s var(--ease);
}
.sheet.on .sheet__panel { opacity: 1; transform: none; }
.sheet__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.sheet__head h2 { font-size: 20px; letter-spacing: -0.03em; }
.sheet__group + .sheet__group { margin-top: 22px; padding-top: 20px; border-top: 1px solid var(--line); }
.sheet__group h3 {
  font-size: 11.5px; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: .12em; margin-bottom: 10px;
}
.sheet__note { color: var(--muted); font-size: 12px; margin-top: 10px; line-height: 1.45; }

.ccyopts { display: grid; gap: 8px; }
.ccyopt {
  display: flex; align-items: center; gap: 13px;
  padding: 13px 14px;
  border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--surface-2);
  cursor: pointer; text-align: left;
  transition: border-color .18s var(--ease), background .18s var(--ease), transform .18s var(--ease);
}
.ccyopt:hover { transform: translateY(-1px); border-color: var(--line-strong); }
.ccyopt.is-on { border-color: var(--accent); background: var(--accent-soft); }
.ccyopt__flag { width: 34px; height: 23px; flex: none; }
.ccyopt__text { display: flex; flex-direction: column; flex: 1; line-height: 1.25; }
.ccyopt__text strong { font-size: 15px; font-weight: 750; letter-spacing: -0.02em; }
.ccyopt__text small { color: var(--muted); font-size: 12px; }
.ccyopt__check {
  width: 22px; height: 22px; flex: none;
  display: grid; place-items: center;
  border-radius: 50%;
  color: var(--accent-ink); background: var(--accent);
  opacity: 0; transform: scale(.7);
  transition: opacity .18s var(--ease), transform .18s var(--ease);
}
.ccyopt__check svg { width: 13px; height: 13px; }
.ccyopt.is-on .ccyopt__check { opacity: 1; transform: none; }

.rowbtn {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%; padding: 13px 14px;
  border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--surface-2); color: var(--ink);
  font-weight: 600; cursor: pointer;
  transition: background .18s var(--ease), border-color .18s var(--ease);
}
.rowbtn:hover { background: var(--surface-3); border-color: var(--line-strong); }
.rowbtn--danger { color: var(--crit); border-color: color-mix(in oklab, var(--crit) 30%, transparent); }
.rowbtn__icon { width: 20px; height: 20px; position: relative; color: var(--muted); }
.rowbtn__icon svg { width: 20px; height: 20px; position: absolute; inset: 0; transition: opacity .2s var(--ease), transform .3s var(--ease); }
.i-sun { opacity: 0; transform: rotate(-40deg) scale(.7); }
:root[data-theme="light"] .i-sun { opacity: 1; transform: none; }
:root[data-theme="light"] .i-moon { opacity: 0; transform: rotate(40deg) scale(.7); }

/* ── Responsive ──────────────────────────────────────────────────────────── */

@media (max-width: 880px) {
  .board { grid-template-columns: minmax(0, 1fr); }
  .panel--chart { order: 2; }
  .panel--parts { order: 1; }
}

@media (max-width: 520px) {
  .part { grid-template-columns: 40px minmax(0, 1fr) 74px 30px; row-gap: 2px; }
  .part__logo { width: 40px; height: 40px; border-radius: 13px; }
  .part__amount {
    grid-column: 2 / 4;
    text-align: left; font-size: 12.5px; color: var(--muted);
  }
  .part__x { opacity: 1; }
  .parts__actions .btn { flex: 1; justify-content: center; }
  .hero__field { gap: 8px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    transition-duration: .001ms !important;
  }
}


/* ── Export bar ──────────────────────────────────────────────────────────── */

.export {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap;
  padding: 18px clamp(18px, 3vw, 26px);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow);
}
.export__text { display: flex; flex-direction: column; gap: 2px; }
.export__text strong { font-size: 15px; }
.export__text span { color: var(--muted); font-size: 13px; }
.export__actions { display: flex; gap: 8px; }

/* ── Asset picker ────────────────────────────────────────────────────────── */

.sheet__panel--picker {
  width: min(520px, 100%);
  display: flex; flex-direction: column;
  max-height: 86vh; padding: 22px 0 0;
}
.sheet__panel--picker .sheet__head { padding: 0 22px; }
.pickbar {
  display: flex; align-items: center; gap: 9px;
  margin: 0 22px;
  padding: 11px 14px;
  border: 1px solid var(--line); border-radius: 13px;
  background: var(--surface-2);
}
.pickbar:focus-within { border-color: var(--accent); }
.pickbar svg { width: 17px; height: 17px; color: var(--muted); flex: none; }
.pickbar input { flex: 1; min-width: 0; border: 0; background: transparent; }
.pickbar input:focus { outline: none; }

.pickchips { display: flex; gap: 6px; flex-wrap: wrap; padding: 12px 22px 4px; }
.pickchip {
  padding: 6px 12px; border-radius: 999px;
  border: 1px solid var(--line); background: transparent;
  color: var(--ink-2); font-size: 12.5px; font-weight: 600;
  cursor: pointer;
  transition: background .16s var(--ease), color .16s var(--ease), border-color .16s var(--ease);
}
.pickchip:hover { background: var(--surface-3); color: var(--ink); }
.pickchip.is-on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

.picklist { flex: 1; overflow-y: auto; padding: 8px 14px 12px; }
.picklist__group {
  padding: 12px 8px 6px;
  color: var(--muted); font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .1em;
}
.pickrow {
  display: flex; align-items: center; gap: 12px;
  width: 100%; padding: 9px 10px;
  border: 0; border-radius: 13px;
  background: transparent; color: var(--ink);
  text-align: left; cursor: pointer;
  transition: background .15s var(--ease);
}
.pickrow:hover { background: var(--surface-3); }
.pickrow.is-taken { opacity: .5; }
.pickrow__text { display: flex; flex-direction: column; flex: 1; min-width: 0; line-height: 1.25; }
.pickrow__text strong { font-size: 14.5px; font-weight: 700; }
.pickrow__text small { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pickrow__tag {
  padding: 3px 9px; border-radius: 999px;
  background: var(--surface-3); color: var(--muted);
  font-size: 10.5px; font-weight: 650; white-space: nowrap;
}
.pickfoot { padding: 14px 22px 20px; border-top: 1px solid var(--line); background: var(--surface-2); }
.pickfoot .btn { width: 100%; justify-content: center; }

@media (max-width: 520px) {
  .export { flex-direction: column; align-items: stretch; }
  .export__actions .btn { flex: 1; justify-content: center; }
}
