:root {
  color-scheme: light;
  --bg: #ffffff;
  --text: #111111;
  --muted: #5e5e5e;
  --line: #d8d8d8;
  --card: #ffffff;
  --green-bg: #e7f6ec;
  --green-line: #0c7a3e;
  --control: #ffffff;
}

:root:not([data-theme="light"]) {
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    color-scheme: dark;
    --bg: #000000;
    --text: #f4f4f4;
    --muted: #a6a6a6;
    --line: #2c2c2c;
    --card: #000000;
    --green-bg: #102216;
    --green-line: #3ddc84;
    --control: #000000;
  }
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #000000;
  --text: #f4f4f4;
  --muted: #a6a6a6;
  --line: #2c2c2c;
  --card: #000000;
  --green-bg: #102216;
  --green-line: #3ddc84;
  --control: #000000;
}

[data-theme="light"] {
  color-scheme: light;
  --bg: #ffffff;
  --text: #111111;
  --muted: #5e5e5e;
  --line: #d8d8d8;
  --card: #ffffff;
  --green-bg: #e7f6ec;
  --green-line: #0c7a3e;
  --control: #ffffff;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.45;
}

button,
input {
  font-family: inherit;
}

.top,
main {
  width: min(1120px, calc(100% - 32px));
  margin-inline: auto;
}

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 28px 0 8px;
}

.identity {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.monogram {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 1px solid currentColor;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.01em;
  flex: none;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 22px;
  font-weight: 600;
  line-height: 1.2;
}

h2 {
  font-size: 16px;
  font-weight: 600;
  line-height: 1.3;
}

.theme-toggle,
.dice,
.thumb {
  background: var(--control);
  color: var(--text);
  border: 1px solid var(--line);
  cursor: pointer;
}

.dice,
.thumb {
  position: relative;
}

.dice:hover::after,
.dice:focus-visible::after,
.thumb:hover::after,
.thumb:focus-visible::after {
  content: attr(title);
  position: absolute;
  z-index: 3;
  width: max-content;
  max-width: 220px;
  padding: 6px 8px;
  background: var(--text);
  color: var(--bg);
  font-size: 12px;
  font-weight: 400;
  line-height: 1.35;
  text-align: left;
  white-space: normal;
  pointer-events: none;
}

.dice:hover::after,
.dice:focus-visible::after {
  top: calc(100% + 6px);
  right: 0;
}

.thumb:hover::after,
.thumb:focus-visible::after {
  top: calc(100% + 6px);
  right: 0;
}

.theme-toggle {
  padding: 6px 10px;
  font-size: 14px;
}

.theme-toggle:focus-visible,
.dice:focus-visible,
.thumb:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 2px;
}

.balance {
  padding-top: 28px;
}

.balance-label {
  margin-bottom: 12px;
}

.balance-chart {
  display: grid;
  place-items: center;
  width: 100%;
  height: 168px;
  border: 1px solid var(--line);
}

.ei {
  padding-top: 28px;
}

.ei-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.ei-tools {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: none;
}

.countdown {
  color: var(--muted);
  font-size: 14px;
}

.dice {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
}

.dice svg {
  width: 18px;
  height: 18px;
  display: block;
}

.ei-row {
  display: flex;
  gap: 12px;
}

.ei-card {
  flex: 1 1 0;
  min-width: 340px;
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) auto auto;
  grid-template-areas: "illus action alif thumbs";
  column-gap: 12px;
  align-items: center;
  padding: 14px;
  background: var(--card);
  border: 1px solid var(--line);
  color: var(--text);
}

.ei-card.is-highlight {
  background: var(--green-bg);
  border: 2px solid var(--green-line);
}

.illus {
  grid-area: illus;
  width: 40px;
  height: 40px;
}

.illus svg {
  width: 40px;
  height: 40px;
  display: block;
}

.action {
  grid-area: action;
  font-size: 15px;
  line-height: 1.35;
}

.alif {
  grid-area: alif;
  justify-self: start;
  font-size: 11px;
  letter-spacing: 0.04em;
  line-height: 1;
  color: var(--muted);
}

.thumbs {
  grid-area: thumbs;
  display: flex;
  gap: 6px;
  justify-self: end;
}

.thumb {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
}

.thumb svg {
  width: 16px;
  height: 16px;
  display: block;
}

.thumb[aria-pressed="true"] {
  background: var(--text);
  color: var(--bg);
  border-color: var(--text);
}

.ei-card.is-highlight .thumb[aria-pressed="true"] {
  background: var(--text);
  color: var(--green-bg);
}

.loops {
  padding: 36px 0 48px;
}

.loops section + section {
  margin-top: 28px;
}

.owner {
  margin-top: 10px;
  font-weight: 600;
}

.owner-k {
  font-weight: 400;
  color: var(--muted);
  margin-right: 8px;
}

.loop p + p,
.empty {
  margin-top: 6px;
}

.empty {
  color: var(--muted);
}

@media (max-width: 720px) {
  .top,
  main {
    width: min(1120px, calc(100% - 24px));
  }

  h1 {
    font-size: 20px;
  }

  .ei-row {
    overflow-x: auto;
    padding-bottom: 4px;
  }

  .ei-card {
    min-width: 300px;
  }
}
