.icon-button {
  display: grid;
  place-items: center;
  width: var(--touch);
  height: var(--touch);
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
}

.icon-button svg {
  width: 22px;
  height: 22px;
}

@media (hover: hover) {
  .icon-button:hover {
    background: var(--hover);
    color: var(--text);
  }
}

/* Sync status */

.sync {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.sync-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ok);
  transition: background-color var(--duration) var(--ease);
}

.sync[data-state="syncing"] .sync-dot {
  background: var(--busy);
  animation: sync-pulse 1s ease-in-out infinite alternate;
}

.sync[data-state="offline"] .sync-dot {
  background: var(--muted);
}

@keyframes sync-pulse {
  to {
    opacity: 0.35;
  }
}

/* Confirmation dialog */

.dialog {
  width: min(320px, calc(100vw - 32px));
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
}

.dialog[open] {
  animation: dialog-in var(--duration) var(--ease);
}

.dialog::backdrop {
  background: var(--backdrop);
  animation: fade-in var(--duration) var(--ease);
}

.dialog-title {
  margin: 0 0 6px;
  font-size: 18px;
}

.dialog-task {
  margin: 0 0 18px;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.dialog-actions {
  display: flex;
  gap: 10px;
}

.dialog-actions .button {
  flex: 1;
}

@keyframes dialog-in {
  from {
    opacity: 0;
    transform: scale(0.96);
  }
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
}

/* Context menu */

.menu {
  position: fixed;
  z-index: 15;
  min-width: 200px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow-lift);
  transform-origin: top left;
  animation: menu-in 150ms var(--ease);
}

@keyframes menu-in {
  from {
    opacity: 0;
    transform: scale(0.96);
  }
}

.menu-heading {
  padding: 6px 12px 2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: var(--touch);
  padding: 0 12px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  text-align: left;
}

.menu-item:focus-visible {
  outline-offset: -2px;
}

@media (hover: hover) {
  .menu-item:hover {
    background: var(--hover);
  }
}

.menu-item[aria-checked="true"]::after {
  content: "\2713";
  margin-left: auto;
  color: var(--accent);
  font-weight: 700;
}

.menu-delete {
  color: var(--danger);
  font-weight: 600;
}

.menu-separator {
  height: 1px;
  margin: 4px 6px;
  border: 0;
  background: var(--line);
}

.swatch {
  width: 18px;
  height: 18px;
  border: 1px solid var(--muted);
  border-radius: 50%;
}

.swatch-none {
  background: var(--surface);
}

.swatch-1 {
  background: var(--highlight-1);
}

.swatch-2 {
  background: var(--highlight-2);
}

/* Keyboard shortcuts overlay */

.dialog-wide {
  width: min(400px, calc(100vw - 32px));
}

.shortcuts {
  display: grid;
  gap: 2px;
  margin: 8px 0 18px;
}

.shortcuts > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 32px;
}

.shortcuts dt {
  display: flex;
  gap: 4px;
  flex: none;
}

.shortcuts dd {
  margin: 0;
  color: var(--muted);
  text-align: right;
}

kbd {
  min-width: 26px;
  padding: 2px 7px;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 6px;
  background: var(--bg);
  font: 600 13px/1.4 var(--font);
  text-align: center;
}

/* Keyboard help is pointless on a touch-only device. */
@media (hover: none) and (pointer: coarse) {
  .help-button {
    display: none;
  }
}

/* Toast */

.toast {
  position: fixed;
  left: 50%;
  bottom: max(20px, env(safe-area-inset-bottom));
  z-index: 20;
  max-width: calc(100vw - 32px);
  padding: 12px 16px;
  border-radius: 12px;
  background: var(--text);
  color: var(--bg);
  box-shadow: var(--shadow);
  font-size: 15px;
  transform: translateX(-50%);
  animation: toast-in var(--duration) var(--ease);
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translate(-50%, 8px);
  }
}
