:root {
  color-scheme: dark;
  --bg: #0c0f14;
  --bar: #12161e;
  --card: #171c26;
  --line: #2a3142;
  --text: #f3f5f8;
  --muted: #8e98ab;
  --gold: #d7b36a;
  --gw: #ed1c24;
  --amber: #e6b450;
  --green: #3dce8e;
  --chip: #232938;
  --dim: #6d768a;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", system-ui, sans-serif;
}

body {
  margin: 0;
  padding: 0 0 calc(0.8rem + env(safe-area-inset-bottom));
}

.bar {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--bar);
  margin: 0;
  padding: 0.45rem clamp(0.75rem, 1.5vw, 1.75rem) 0.4rem;
  padding-top: calc(0.45rem + env(safe-area-inset-top));
  border-bottom: 1px solid var(--line);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.28);
}

.top {
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 0.5rem;
}

.brand {
  position: relative;
  grid-column: 2;
  justify-self: center;
  min-width: 0;
}

.logo-line {
  display: flex;
  justify-content: center;
}

.logo {
  position: absolute;
  top: 0;
  right: calc(100% + 0.5rem);
  height: 100%;
  width: auto;
  object-fit: contain;
  display: block;
}

h1 {
  margin: 0;
  font-size: 2.3rem;
  letter-spacing: -0.02em;
  color: var(--gw);
  line-height: 1.1;
}

#clock {
  margin: 0.1rem 0 0;
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1.2;
  text-align: center;
}

@media (max-width: 720px) {
  h1 { font-size: clamp(1.35rem, 5.4vw, 2.3rem); }
}

.tools {
  grid-column: 3;
  justify-self: end;
  align-self: center;
  display: flex;
  flex-wrap: nowrap;
  justify-content: flex-end;
  align-items: center;
  gap: 0.35rem;
}

.tool, .chip, .icon, .copy {
  border: 0;
  font: inherit;
  cursor: pointer;
}

.tool {
  min-height: 2rem;
  padding: 0 0.7rem;
  border-radius: 999px;
  background: var(--chip);
  color: var(--text);
  font-size: 0.82rem;
  white-space: nowrap;
}

a.tool {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  text-decoration: none;
}

a.tool svg {
  width: 1rem;
  height: 1rem;
  fill: currentColor;
  flex: 0 0 auto;
}

.heart-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.heart-link svg {
  width: 1rem;
  height: 1rem;
  fill: #ea4aaa;
  flex: 0 0 auto;
}

.api-sync {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex: 0 0 auto;
  align-self: center;
}

.api-sync.ok { background: #3ddc6e; }
.api-sync.busy { background: #4da3ff; animation: api-blink 0.9s steps(2, end) infinite; }
.api-sync.fail { background: #e23b3b; }
.api-sync.partial { background: #e2b33b; }

@keyframes api-blink {
  50% { opacity: 0.15; }
}

.tool[aria-pressed="true"] {
  background: #143528;
  color: var(--green);
}

.search {
  width: 100%;
  margin-top: 0.4rem;
  min-height: 2.15rem;
  border: 1px solid var(--line);
  border-radius: 0.65rem;
  background: #0d1118;
  color: var(--text);
  font: inherit;
  font-size: 0.92rem;
  padding: 0 0.7rem;
}

.search:focus {
  outline: 2px solid var(--gold);
  outline-offset: 1px;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.35rem;
}

.chip {
  flex: 0 0 auto;
  min-height: 1.9rem;
  padding: 0 0.7rem;
  border-radius: 999px;
  background: var(--chip);
  color: var(--text);
  font-size: 0.8rem;
  white-space: nowrap;
}

.chip[aria-pressed="true"] {
  background: var(--text);
  color: #141821;
}

.list {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.45rem 0.75rem;
  align-items: start;
  padding: 0.45rem clamp(0.75rem, 1.5vw, 1.75rem) 0;
}

.queue, .empty { grid-column: 1 / -1; }

@media (min-width: 1200px) {
  .list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (min-width: 1900px) {
  .list { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (min-width: 2560px) {
  .list { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (min-width: 3440px) {
  .list { grid-template-columns: repeat(5, minmax(0, 1fr)); }
}

@media (min-width: 3840px) {
  .list { grid-template-columns: repeat(6, minmax(0, 1fr)); }
}

.queue {
  margin: 0.25rem 0 0;
  color: var(--gold);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.queue.prep { color: #9cc7ff; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-left: 3px solid var(--line);
  border-radius: 0.65rem;
  padding: 0.4rem 0.55rem 0.4rem 0.6rem;
}

.card.soon { border-left-color: var(--amber); }
.card.prep { border-left-color: #7eb6ff; }
.card.now { border-left-color: var(--green); }
.card.fresh {
  background: #1c4634;
  border-color: var(--green);
}
.card.done { opacity: 0.7; }

.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.45rem;
}

.name {
  margin: 0;
  font-size: 0.98rem;
  line-height: 1.15;
  min-width: 0;
}

.map, .start {
  color: var(--muted);
  font-size: 0.75rem;
}

.map {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
}

.card.soon .status { color: var(--amber); }
.card.prep .status { color: #9cc7ff; }
.card.now .status { color: var(--green); font-weight: 700; }

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.28rem;
  margin-top: 0.32rem;
}

.tag {
  color: var(--gold);
  background: #2a2418;
  border: 1px solid #4a3d24;
  border-radius: 999px;
  padding: 0.04rem 0.42rem;
  font-size: 0.68rem;
  font-weight: 650;
  letter-spacing: 0.03em;
  line-height: 1.35;
}

.actions {
  margin-top: 0.28rem;
}

.chat {
  min-width: 0;
  color: var(--muted);
  font-size: 0.75rem;
  user-select: all;
}

.actions .icon, .copy {
  flex: 0 0 auto;
  min-width: 2.15rem;
  min-height: 1.85rem;
  border-radius: 0.5rem;
  background: #0d1118;
  color: var(--text);
  font-size: 0.78rem;
}

.icon { color: #e7ebf3; font-size: 1.05rem; }
.icon.star { font-size: 1.65rem; line-height: 1; }
.icon svg {
  width: 1.45rem;
  height: 1.45rem;
  display: block;
  fill: currentColor;
}
.icon.on, .icon.ring {
  color: #ffcc33;
  background: #3a3214;
}
.icon.check {
  min-width: 2.4rem;
  min-height: 2.15rem;
  color: #9aa3b5;
}
.icon.check svg {
  width: 1.7rem;
  height: 1.7rem;
  fill: none;
}
.icon.check.checked {
  color: var(--green);
  background: #143226;
}

.empty, .foot {
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.35;
}

.foot {
  margin: 0.6rem 0 0;
  padding: 0 clamp(0.75rem, 1.5vw, 1.75rem);
}

.foot.credit {
  margin-bottom: 0.15rem;
}

.pix-modal {
  width: min(22rem, calc(100vw - 1.5rem));
  margin: auto;
  border: 1px solid var(--line);
  border-radius: 1rem;
  background: var(--bar);
  color: var(--text);
  padding: 1rem 1rem 0.9rem;
  text-align: center;
}

.pix-modal::backdrop {
  background: rgba(0, 0, 0, 0.62);
}

.pix-modal h2 {
  margin: 0;
  font-size: 1.05rem;
}

.pix-modal p {
  margin: 0.35rem 0 0.75rem;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.35;
}

.pix-modal img {
  width: min(240px, 68vw);
  height: auto;
  background: #fff;
  border-radius: 0.7rem;
  padding: 0.45rem;
}

.pix-actions {
  display: flex;
  justify-content: center;
  gap: 0.4rem;
  margin-top: 0.85rem;
}

.toast {
  position: fixed;
  left: 0.7rem;
  right: 0.7rem;
  bottom: calc(0.6rem + env(safe-area-inset-bottom));
  max-width: 38rem;
  margin: 0 auto;
  background: #f3f5f8;
  color: #141821;
  border-radius: 0.7rem;
  padding: 0.65rem 0.8rem;
  font-size: 0.9rem;
  z-index: 6;
}

.toast code {
  display: block;
  margin-top: 0.2rem;
}

.tip {
  position: fixed;
  z-index: 40;
  max-width: 16rem;
  padding: 0.4rem 0.65rem;
  border-radius: 0.55rem;
  background: #f3f5f8;
  color: #141821;
  font-size: 0.82rem;
  line-height: 1.3;
  pointer-events: none;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35);
}

.tip[hidden] { display: none; }

@media (prefers-reduced-motion: no-preference) {
  .card.urgent { animation: pulse 1.6s ease-in-out infinite; }
}

@keyframes pulse {
  50% { border-left-color: #fff4d2; }
}

.alarm {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.85rem;
  width: 100%;
  margin: 0;
  padding: 1.6rem 1.2rem calc(2.4rem + env(safe-area-inset-bottom));
  border: 0;
  overflow-x: hidden;
  overflow-y: auto;
  scrollbar-width: none;
  font: inherit;
  background: #0e3a28;
  color: #f7faf8;
  cursor: pointer;
}

.alarm[hidden] { display: none; }
.alarm::-webkit-scrollbar { display: none; }

.alarm.on { animation: alarm-flash 1.2s ease-in-out infinite; }

.alarm-kind {
  margin: 0 0 0.35rem;
  max-width: 22rem;
  font-size: clamp(1.35rem, 4vw, 1.7rem);
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
}

.alarm-name {
  margin: 0;
  max-width: 18ch;
  font-size: clamp(2.4rem, 8vw, 3.6rem);
  font-weight: 700;
  line-height: 1.15;
  text-align: center;
  overflow-wrap: anywhere;
}

.alarm.crowd .alarm-name { font-size: clamp(1.8rem, 6vw, 2.6rem); }

.alarm-hint {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(0.8rem + env(safe-area-inset-bottom));
  margin: 0;
  color: rgba(247, 250, 248, 0.82);
  font-size: 0.85rem;
  text-align: center;
}

@keyframes alarm-flash {
  0%, 100% { background-color: #0e3a28; }
  50% { background-color: #1b6b45; }
}

@media (prefers-reduced-motion: reduce) {
  .alarm.on { animation: none; }
}

.mobile-only { display: none; }

.sound-pop { position: static; flex: 0 0 auto; }

.sound-panel {
  position: absolute;
  top: calc(100% + 0.35rem);
  right: 0;
  z-index: 8;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  width: 15.5rem;
  max-width: calc(100vw - 1.5rem);
  padding: 0.6rem;
  border: 1px solid var(--line);
  border-radius: 0.85rem;
  background: var(--bar);
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.4);
}

.sound-panel[hidden] { display: none; }

.sound-panel > .tool { width: 100%; }

.sound-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  color: var(--text);
  font-size: 0.82rem;
}

.sound-row .tool {
  min-width: 3.1rem;
  padding-right: 0.55rem;
  padding-left: 0.55rem;
  text-align: center;
}

.icon-btn {
  align-items: center;
  justify-content: center;
  width: 2.1rem;
  padding: 0;
}

.icon-btn svg {
  width: 1rem;
  height: 1rem;
  fill: currentColor;
}

.sheet {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 0.7rem;
  padding-top: calc(4.2rem + env(safe-area-inset-top));
  background: rgba(0, 0, 0, 0.55);
}

.sheet[hidden] { display: none; }

.sheet-card {
  width: min(26rem, 100%);
  max-height: calc(100dvh - 5.4rem);
  overflow: auto;
  padding: 0.75rem;
  border: 1px solid var(--line);
  border-radius: 1rem;
  background: var(--bar);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
}

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.65rem;
}

#sheet-body {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
}

.sheet .tool-shelf {
  flex: 1 0 100%;
  flex-direction: row;
  align-items: center;
  grid-column: auto;
  justify-self: start;
}

.sheet #filters { flex: 1 0 100%; }

@media (max-width: 900px) {
  .top {
    display: flex;
    align-items: center;
    gap: 0.45rem;
  }

  .brand {
    display: flex;
    flex: 1 1 auto;
    flex-wrap: wrap;
    align-items: center;
    align-content: flex-start;
    gap: 0 0.45rem;
    grid-column: auto;
    justify-self: auto;
    height: 2.15rem;
    min-width: 0;
    overflow: hidden;
  }

  .logo-line {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: flex-start;
    gap: 0.4rem;
    max-width: 100%;
    height: 2.15rem;
    min-width: 0;
  }

  .logo {
    position: static;
    flex: 0 0 auto;
    height: 2.15rem;
  }

  h1 {
    min-width: 0;
    overflow: hidden;
    font-size: clamp(0.82rem, 3.6vw, 1.15rem);
    line-height: 1.1;
    letter-spacing: -0.03em;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  #clock {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    height: 2.15rem;
    margin: 0 0 0 auto;
    text-align: right;
    white-space: nowrap;
  }

  .tools {
    flex: 0 0 auto;
    grid-column: auto;
    justify-self: auto;
  }

  .mobile-only { display: inline-flex; }

  #sound {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.1rem;
    padding: 0;
    font-size: 0;
  }

  #sound::before {
    content: "";
    width: 1rem;
    height: 1rem;
    background: currentColor;
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M7.7 2.4 4.2 5.2H1.8v5.6h2.4l3.5 2.8V2.4zm1.8 2.2a3.4 3.4 0 0 1 0 6.8' fill='black' stroke='black' stroke-width='1.2' stroke-linecap='round'/%3E%3C/svg%3E") center / contain no-repeat;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M7.7 2.4 4.2 5.2H1.8v5.6h2.4l3.5 2.8V2.4zm1.8 2.2a3.4 3.4 0 0 1 0 6.8' fill='black' stroke='black' stroke-width='1.2' stroke-linecap='round'/%3E%3C/svg%3E") center / contain no-repeat;
  }

  .bar:not(.search-open) .search { display: none; }

  #queues {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
  }

  #queues::-webkit-scrollbar { display: none; }
}
