/* Mobile-first: bottom tab bar */
.tab-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-around;
  align-items: center;
  background: color-mix(in srgb, var(--bg-primary) 80%, transparent);
  backdrop-filter: blur(16px) saturate(1.5);
  -webkit-backdrop-filter: blur(16px) saturate(1.5);
  border-top: 1px solid var(--border-light);
  padding: var(--space-2) 0;
  padding-bottom: max(var(--space-2), env(safe-area-inset-bottom));
  z-index: 100;
}

.tab {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-decoration: none;
  color: var(--text-tertiary);
  font-size: 0.7rem;
  min-width: 44px;
  min-height: 44px;
  justify-content: center;
  padding: var(--space-1) var(--space-3);
  transition: color 0.2s;
}

.tab::after {
  content: '';
  position: absolute;
  bottom: 2px;
  left: 50%;
  transform: translateX(-50%);
  width: 20px;
  height: 2px;
  background: var(--primary);
  border-radius: var(--radius-full);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.tab.active {
  color: var(--primary);
}

.tab.active::after {
  opacity: 1;
}

.theme-toggle {
  background: none;
  border: none;
  cursor: pointer;
  padding: var(--space-1) var(--space-3);
}

.tab-icon {
  font-size: 1.25rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
}

.tab-icon svg {
  width: 20px;
  height: 20px;
}

.tab-label {
  margin-top: 2px;
  font-size: 10px;
  font-weight: 600;
  font-family: var(--font-body);
  letter-spacing: 0.02em;
}

/* Theme icon toggle — CSS-driven */
.icon-sun { display: none; }
[data-theme="dark"] .icon-sun { display: block; }
[data-theme="dark"] .icon-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .icon-sun { display: block; }
  :root:not([data-theme="light"]) .icon-moon { display: none; }
}

/* Prevent content from hiding behind tab bar */
body {
  padding-bottom: 5rem;
}

/* Touch-friendly tap targets (mobile only) */
@media (hover: none) {
  button, [role="button"], input[type="submit"] {
    min-height: 44px;
  }
}

/* Loading indicator for HTMX */
.htmx-indicator {
  display: none;
}
.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
  display: inline-block;
}

.pill-delete {
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
  padding: 0;
  font-size: 12px;
  line-height: 1;
  min-height: auto;
  opacity: 0.6;
}

.pill-delete:hover {
  opacity: 1;
}

/* Desktop: nav moves to top as horizontal text tabs */
@media (min-width: 768px) {
  body {
    padding-bottom: 0;
  }

  .breadcrumb {
    max-width: 720px;
    margin: 0 auto;
    border-bottom: none;
    padding-top: var(--space-3);
    padding-bottom: var(--space-1);
  }

  .tab-bar {
    position: static;
    max-width: 720px;
    margin: 0 auto;
    border-top: none;
    border-bottom: 1px solid var(--border-light);
    background: transparent;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    justify-content: flex-start;
    gap: 0;
    padding: 0;
  }

  .tab {
    flex-direction: row;
    padding: var(--space-3) var(--space-5);
    font-size: 0.875rem;
    min-height: auto;
    min-width: auto;
  }

  .tab:hover {
    color: var(--text-primary);
  }

  .tab.active {
    color: var(--text-primary);
  }

  .tab-icon {
    display: none;
  }

  .tab-label {
    margin-top: 0;
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
  }

  .tab::after {
    bottom: 0;
    left: 0;
    width: 100%;
    height: 2px;
    transform: none;
    opacity: 0;
    transition: opacity 0.2s ease;
  }

  .tab.active::after {
    opacity: 1;
  }
}

/* Editable name — pencil icon inline rename */
.editable-name {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}

.editable-name-text {
  margin: 0;
}

.edit-name-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: var(--space-1);
  color: var(--text-tertiary);
  line-height: 1;
  min-height: auto;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  transition: all 0.15s;
}

.edit-name-btn:hover {
  color: var(--text-primary);
  background: var(--bg-secondary);
}

.edit-name-btn.save {
  color: var(--mastered);
}

.edit-name-btn.save:hover {
  background: color-mix(in srgb, var(--mastered) 12%, transparent);
}

.edit-name-btn.cancel {
  color: var(--text-tertiary);
}

.edit-name-input {
  font-size: inherit;
  font-weight: inherit;
  font-family: inherit;
  padding: 0.15em 0.35em;
  margin: 0;
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-sm);
  background: var(--bg-primary);
  color: var(--text-primary);
  min-width: 0;
  width: 100%;
  max-width: 100%;
  height: auto;
  min-height: 0;
}
.edit-name-input:focus {
  box-shadow: 0 0 0 3px rgba(184, 110, 58, 0.1);
  border-color: var(--primary);
}

/* In unit rows, constrain edit to available space */
.card-title-row .editable-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
}
.card-title-row .editable-name.editing {
  flex: 1;
  min-width: 0;
}
.card-title-row .edit-name-input {
  width: 100%;
}
