*,
*::before,
*::after {
  box-sizing: border-box;
}

:root {
  color-scheme: light;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: #f4f6fb;
  color: #1f2a3d;
}

body {
  margin: 0;
  min-height: 100vh;
}

.app-header {
  background: #1f2a3d;
  color: #fff;
  padding: 1.25rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  align-items: center;
}

.app-header h1 {
  margin: 0;
  font-size: 1.5rem;
  letter-spacing: 0.5px;
}

.controls {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 0.75rem 1rem;
  align-items: center;
  width: 100%;
}

.add-form {
  display: flex;
  gap: 0.5rem;
  width: 100%;
}

.search-block {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.search-container.hidden {
  display: none;
}

.search-container input {
  padding: 0.45rem 0.55rem;
  border: 1px solid #d5d8e0;
  border-radius: 6px;
  min-width: 180px;
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.45rem 0.55rem;
  border-radius: 6px;
  background: #e9ecf3;
  color: #1f2a3d;
  box-shadow: none;
  border: 1px solid #d5d8e0;
}

.icon-button.active {
  background: #d5d8e0;
}

input[type="text"] {
  padding: 0.55rem 0.75rem;
  border: 1px solid #d5d8e0;
  border-radius: 6px;
  min-width: 220px;
  font-size: 1rem;
}

button,
select {
  border: none;
  background: #f26b38;
  color: #fff;
  padding: 0.6rem 0.9rem;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.1);
}

select {
  background: #fff;
  color: #1f2a3d;
  border: 1px solid #d5d8e0;
  padding: 0.5rem 0.7rem;
  box-shadow: none;
}

button:hover {
  background: #d85d31;
}

.sort {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
  color: #e4e8f0;
}

main {
  max-width: 920px;
  margin: 1.5rem auto;
  padding: 0 1.5rem 3rem;
}

.section {
  margin-bottom: 1.5rem;
}

.section-header {
  display: grid;
  align-items: center;
  grid-template-columns: auto 1fr auto;
  gap: 0.5rem;
}

.section-header h2 {
  margin: 0.5rem 0;
}

.done-title {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.count {
  font-size: 0.9rem;
  color: #7a8292;
}

.status {
  min-height: 1.2rem;
  color: #d24c21;
  margin-bottom: 0.5rem;
}

.items {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.item {
  background: #fff;
  border-radius: 10px;
  padding: 0.85rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.05);
}

.item.done {
  opacity: 0.75;
  pointer-events: auto;
}

.item-text {
  flex: 1;
  font-size: 1rem;
}

.item-text.clickable {
  cursor: pointer;
}

.item.editing {
  outline: 1px dashed #f26b38;
}

.inline-edit {
  flex: 1;
  padding: 0.5rem 0.6rem;
  border: 1px solid #d5d8e0;
  border-radius: 6px;
  font-size: 1rem;
}

.item-text.done {
  text-decoration: line-through;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-weight: 600;
  color: #d85d31;
}

.item small {
  color: #7a8292;
}

.edit-group {
  display: flex;
  gap: 0.35rem;
}

.star-button {
  background: transparent;
  color: #f29f05;
  box-shadow: none;
  padding: 0.4rem 0.5rem;
  font-size: 1rem;
}

.star-button.inactive {
  color: #b6bcc9;
}

.star-button:disabled {
  cursor: not-allowed;
  color: #c6ccd8;
}

.small {
  padding: 0.35rem 0.65rem;
  font-size: 0.9rem;
}

.ghost-button {
  background: #e9ecf3;
  color: #1f2a3d;
  box-shadow: none;
}

.ghost-button:hover {
  background: #d5d8e0;
}

.ghost-button:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

.done-list .item {
  background: #f2f3f7;
}

#done-container.collapsed {
  display: none;
}

@media (max-width: 768px) {
  .app-header {
    align-items: flex-start;
    padding: 1rem 1.25rem;
    gap: 0.75rem;
  }

  .app-header h1 {
    font-size: 1.35rem;
  }

  .controls {
    grid-template-columns: 1fr;
    gap: 0.6rem;
  }

  .add-form {
    flex-wrap: wrap;
    gap: 0.4rem;
  }

  .add-form input[type="text"] {
    flex: 1 1 100%;
    width: 100%;
    min-width: 0;
  }

  .add-form button {
    width: 100%;
  }

  .search-block {
    width: 100%;
    justify-content: space-between;
  }

  .search-container {
    flex: 1;
  }

  .search-container input {
    width: 100%;
  }

  .sort {
    width: 100%;
    justify-content: space-between;
    color: #dfe4f0;
  }

  .sort select {
    min-width: 160px;
  }

  main {
    padding: 0 1rem 2.5rem;
  }

  .section {
    margin-bottom: 1.25rem;
  }

  .section-header h2 {
    margin: 0.25rem 0;
  }

  .item {
    flex-wrap: wrap;
    padding: 0.8rem 0.85rem;
    gap: 0.6rem;
  }

  .item-text {
    order: 3;
    width: 100%;
  }

  .edit-group {
    width: 100%;
    justify-content: flex-end;
  }
}
